@@ -36,81 +36,81 @@ discard block |
||
36 | 36 | *************************************************/ |
37 | 37 | |
38 | 38 | class Snoopy { |
39 | - /**** Public variables ****/ |
|
39 | + /**** Public variables ****/ |
|
40 | 40 | |
41 | - /* user definable vars */ |
|
42 | - |
|
43 | - public $host = "www.php.net"; // host name we are connecting to |
|
44 | - public $port = 80; // port we are connecting to |
|
45 | - public $proxy_host = ""; // proxy host to use |
|
46 | - public $proxy_port = ""; // proxy port to use |
|
47 | - public $agent = "Snoopy v1.0"; // agent we masquerade as |
|
48 | - public $referer = ""; // referer info to pass |
|
49 | - public $cookies = array(); // array of cookies to pass |
|
50 | - // $cookies["username"]="joe"; |
|
51 | - public $rawheaders = array(); // array of raw headers to send |
|
52 | - // $rawheaders["Content-type"]="text/html"; |
|
53 | - |
|
54 | - public $maxredirs = 5; // http redirection depth maximum. 0 = disallow |
|
55 | - public $lastredirectaddr = ""; // contains address of last redirected address |
|
56 | - public $offsiteok = true; // allows redirection off-site |
|
57 | - public $maxframes = 0; // frame content depth maximum. 0 = disallow |
|
58 | - public $expandlinks = true; // expand links to fully qualified URLs. |
|
59 | - // this only applies to fetchlinks() |
|
60 | - // or submitlinks() |
|
61 | - public $passcookies = true; // pass set cookies back through redirects |
|
62 | - // NOTE: this currently does not respect |
|
63 | - // dates, domains or paths. |
|
41 | + /* user definable vars */ |
|
42 | + |
|
43 | + public $host = "www.php.net"; // host name we are connecting to |
|
44 | + public $port = 80; // port we are connecting to |
|
45 | + public $proxy_host = ""; // proxy host to use |
|
46 | + public $proxy_port = ""; // proxy port to use |
|
47 | + public $agent = "Snoopy v1.0"; // agent we masquerade as |
|
48 | + public $referer = ""; // referer info to pass |
|
49 | + public $cookies = array(); // array of cookies to pass |
|
50 | + // $cookies["username"]="joe"; |
|
51 | + public $rawheaders = array(); // array of raw headers to send |
|
52 | + // $rawheaders["Content-type"]="text/html"; |
|
53 | + |
|
54 | + public $maxredirs = 5; // http redirection depth maximum. 0 = disallow |
|
55 | + public $lastredirectaddr = ""; // contains address of last redirected address |
|
56 | + public $offsiteok = true; // allows redirection off-site |
|
57 | + public $maxframes = 0; // frame content depth maximum. 0 = disallow |
|
58 | + public $expandlinks = true; // expand links to fully qualified URLs. |
|
59 | + // this only applies to fetchlinks() |
|
60 | + // or submitlinks() |
|
61 | + public $passcookies = true; // pass set cookies back through redirects |
|
62 | + // NOTE: this currently does not respect |
|
63 | + // dates, domains or paths. |
|
64 | 64 | |
65 | - public $user = ""; // user for http authentication |
|
66 | - public $pass = ""; // password for http authentication |
|
65 | + public $user = ""; // user for http authentication |
|
66 | + public $pass = ""; // password for http authentication |
|
67 | 67 | |
68 | - // http accept types |
|
69 | - public $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
|
68 | + // http accept types |
|
69 | + public $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
|
70 | 70 | |
71 | - public $results = ""; // where the content is put |
|
71 | + public $results = ""; // where the content is put |
|
72 | 72 | |
73 | - public $error = ""; // error messages sent here |
|
74 | - public $response_code = ""; // response code returned from server |
|
75 | - public $headers = array(); // headers returned from server sent here |
|
76 | - public $maxlength = 500000; // max return data length (body) |
|
77 | - public $read_timeout = 0; // timeout on read operations, in seconds |
|
78 | - // supported only since PHP 4 Beta 4 |
|
79 | - // set to 0 to disallow timeouts |
|
80 | - public $timed_out = false; // if a read operation timed out |
|
81 | - public $status = 0; // http request status |
|
73 | + public $error = ""; // error messages sent here |
|
74 | + public $response_code = ""; // response code returned from server |
|
75 | + public $headers = array(); // headers returned from server sent here |
|
76 | + public $maxlength = 500000; // max return data length (body) |
|
77 | + public $read_timeout = 0; // timeout on read operations, in seconds |
|
78 | + // supported only since PHP 4 Beta 4 |
|
79 | + // set to 0 to disallow timeouts |
|
80 | + public $timed_out = false; // if a read operation timed out |
|
81 | + public $status = 0; // http request status |
|
82 | 82 | |
83 | - public $curl_path = "/usr/bin/curl"; |
|
84 | - // Snoopy will use cURL for fetching |
|
85 | - // SSL content if a full system path to |
|
86 | - // the cURL binary is supplied here. |
|
87 | - // set to false if you do not have |
|
88 | - // cURL installed. See http://curl.haxx.se |
|
89 | - // for details on installing cURL. |
|
90 | - // Snoopy does *not* use the cURL |
|
91 | - // library functions built into php, |
|
92 | - // as these functions are not stable |
|
93 | - // as of this Snoopy release. |
|
83 | + public $curl_path = "/usr/bin/curl"; |
|
84 | + // Snoopy will use cURL for fetching |
|
85 | + // SSL content if a full system path to |
|
86 | + // the cURL binary is supplied here. |
|
87 | + // set to false if you do not have |
|
88 | + // cURL installed. See http://curl.haxx.se |
|
89 | + // for details on installing cURL. |
|
90 | + // Snoopy does *not* use the cURL |
|
91 | + // library functions built into php, |
|
92 | + // as these functions are not stable |
|
93 | + // as of this Snoopy release. |
|
94 | 94 | |
95 | - // send Accept-encoding: gzip? |
|
96 | - public $use_gzip = true; |
|
95 | + // send Accept-encoding: gzip? |
|
96 | + public $use_gzip = true; |
|
97 | 97 | |
98 | - /**** Private variables ****/ |
|
98 | + /**** Private variables ****/ |
|
99 | 99 | |
100 | - private $_maxlinelen = 4096; // max line length (headers) |
|
100 | + private $_maxlinelen = 4096; // max line length (headers) |
|
101 | 101 | |
102 | - private $_httpmethod = "GET"; // default http request method |
|
103 | - private $_httpversion = "HTTP/1.0"; // default http request version |
|
104 | - private $_submit_method = "POST"; // default submit method |
|
105 | - private $_submit_type = "application/x-www-form-urlencoded"; // default submit type |
|
106 | - private $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type |
|
107 | - private $_redirectaddr = false; // will be set if page fetched is a redirect |
|
108 | - private $_redirectdepth = 0; // increments on an http redirect |
|
109 | - private $_frameurls = array(); // frame src urls |
|
110 | - private $_framedepth = 0; // increments on frame depth |
|
102 | + private $_httpmethod = "GET"; // default http request method |
|
103 | + private $_httpversion = "HTTP/1.0"; // default http request version |
|
104 | + private $_submit_method = "POST"; // default submit method |
|
105 | + private $_submit_type = "application/x-www-form-urlencoded"; // default submit type |
|
106 | + private $_mime_boundary = ""; // MIME boundary for multipart/form-data submit type |
|
107 | + private $_redirectaddr = false; // will be set if page fetched is a redirect |
|
108 | + private $_redirectdepth = 0; // increments on an http redirect |
|
109 | + private $_frameurls = array(); // frame src urls |
|
110 | + private $_framedepth = 0; // increments on frame depth |
|
111 | 111 | |
112 | - private $_isproxy = false; // set if using a proxy server |
|
113 | - private $_fp_timeout = 30; // timeout for socket connection |
|
112 | + private $_isproxy = false; // set if using a proxy server |
|
113 | + private $_fp_timeout = 30; // timeout for socket connection |
|
114 | 114 | |
115 | 115 | /*======================================================================*\ |
116 | 116 | Function: fetch |
@@ -121,136 +121,136 @@ discard block |
||
121 | 121 | Output: $this->results the output text from the fetch |
122 | 122 | \*======================================================================*/ |
123 | 123 | |
124 | - public function fetch($URI) { |
|
125 | - //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); |
|
126 | - $URI_PARTS = parse_url($URI); |
|
127 | - if (!empty($URI_PARTS["user"])) |
|
128 | - $this->user = $URI_PARTS["user"]; |
|
129 | - if (!empty($URI_PARTS["pass"])) |
|
130 | - $this->pass = $URI_PARTS["pass"]; |
|
131 | - if (!isset($fp)) { $fp = false; } |
|
132 | - switch ($URI_PARTS["scheme"]) { |
|
133 | - case "http": |
|
134 | - $this->host = $URI_PARTS["host"]; |
|
135 | - if(!empty($URI_PARTS["port"])) |
|
136 | - $this->port = $URI_PARTS["port"]; |
|
137 | - if($this->_connect($fp)) |
|
138 | - { |
|
139 | - if($this->_isproxy) |
|
140 | - { |
|
141 | - // using proxy, send entire URI |
|
142 | - $this->_httprequest($URI,$fp,$URI,$this->_httpmethod); |
|
143 | - } |
|
144 | - else |
|
145 | - { |
|
146 | - $path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : ""); |
|
147 | - // no proxy, send only the path |
|
148 | - $this->_httprequest($path, $fp, $URI, $this->_httpmethod); |
|
149 | - } |
|
124 | + public function fetch($URI) { |
|
125 | + //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); |
|
126 | + $URI_PARTS = parse_url($URI); |
|
127 | + if (!empty($URI_PARTS["user"])) |
|
128 | + $this->user = $URI_PARTS["user"]; |
|
129 | + if (!empty($URI_PARTS["pass"])) |
|
130 | + $this->pass = $URI_PARTS["pass"]; |
|
131 | + if (!isset($fp)) { $fp = false; } |
|
132 | + switch ($URI_PARTS["scheme"]) { |
|
133 | + case "http": |
|
134 | + $this->host = $URI_PARTS["host"]; |
|
135 | + if(!empty($URI_PARTS["port"])) |
|
136 | + $this->port = $URI_PARTS["port"]; |
|
137 | + if($this->_connect($fp)) |
|
138 | + { |
|
139 | + if($this->_isproxy) |
|
140 | + { |
|
141 | + // using proxy, send entire URI |
|
142 | + $this->_httprequest($URI,$fp,$URI,$this->_httpmethod); |
|
143 | + } |
|
144 | + else |
|
145 | + { |
|
146 | + $path = $URI_PARTS["path"].(isset($URI_PARTS["query"]) ? "?".$URI_PARTS["query"] : ""); |
|
147 | + // no proxy, send only the path |
|
148 | + $this->_httprequest($path, $fp, $URI, $this->_httpmethod); |
|
149 | + } |
|
150 | 150 | |
151 | - $this->_disconnect($fp); |
|
152 | - |
|
153 | - if($this->_redirectaddr) |
|
154 | - { |
|
155 | - /* url was redirected, check if we've hit the max depth */ |
|
156 | - if($this->maxredirs > $this->_redirectdepth) |
|
157 | - { |
|
158 | - // only follow redirect if it's on this site, or offsiteok is true |
|
159 | - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
160 | - { |
|
161 | - /* follow the redirect */ |
|
162 | - $this->_redirectdepth++; |
|
163 | - $this->lastredirectaddr=$this->_redirectaddr; |
|
164 | - $this->fetch($this->_redirectaddr); |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
168 | - |
|
169 | - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
170 | - { |
|
171 | - $frameurls = $this->_frameurls; |
|
172 | - $this->_frameurls = array(); |
|
151 | + $this->_disconnect($fp); |
|
152 | + |
|
153 | + if($this->_redirectaddr) |
|
154 | + { |
|
155 | + /* url was redirected, check if we've hit the max depth */ |
|
156 | + if($this->maxredirs > $this->_redirectdepth) |
|
157 | + { |
|
158 | + // only follow redirect if it's on this site, or offsiteok is true |
|
159 | + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
160 | + { |
|
161 | + /* follow the redirect */ |
|
162 | + $this->_redirectdepth++; |
|
163 | + $this->lastredirectaddr=$this->_redirectaddr; |
|
164 | + $this->fetch($this->_redirectaddr); |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | + |
|
169 | + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
170 | + { |
|
171 | + $frameurls = $this->_frameurls; |
|
172 | + $this->_frameurls = array(); |
|
173 | 173 | |
174 | - while(list(,$frameurl) = each($frameurls)) |
|
175 | - { |
|
176 | - if($this->_framedepth < $this->maxframes) |
|
177 | - { |
|
178 | - $this->fetch($frameurl); |
|
179 | - $this->_framedepth++; |
|
180 | - } |
|
181 | - else |
|
182 | - break; |
|
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - else |
|
187 | - { |
|
188 | - return false; |
|
189 | - } |
|
190 | - return true; |
|
191 | - break; |
|
192 | - case "https": |
|
193 | - if(!$this->curl_path || (!is_executable($this->curl_path))) { |
|
194 | - $this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n"; |
|
195 | - return false; |
|
196 | - } |
|
197 | - $this->host = $URI_PARTS["host"]; |
|
198 | - if(!empty($URI_PARTS["port"])) |
|
199 | - $this->port = $URI_PARTS["port"]; |
|
200 | - if($this->_isproxy) |
|
201 | - { |
|
202 | - // using proxy, send entire URI |
|
203 | - $this->_httpsrequest($URI,$URI,$this->_httpmethod); |
|
204 | - } |
|
205 | - else |
|
206 | - { |
|
207 | - $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); |
|
208 | - // no proxy, send only the path |
|
209 | - $this->_httpsrequest($path, $URI, $this->_httpmethod); |
|
210 | - } |
|
211 | - |
|
212 | - if($this->_redirectaddr) |
|
213 | - { |
|
214 | - /* url was redirected, check if we've hit the max depth */ |
|
215 | - if($this->maxredirs > $this->_redirectdepth) |
|
216 | - { |
|
217 | - // only follow redirect if it's on this site, or offsiteok is true |
|
218 | - if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
219 | - { |
|
220 | - /* follow the redirect */ |
|
221 | - $this->_redirectdepth++; |
|
222 | - $this->lastredirectaddr=$this->_redirectaddr; |
|
223 | - $this->fetch($this->_redirectaddr); |
|
224 | - } |
|
225 | - } |
|
226 | - } |
|
227 | - |
|
228 | - if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
229 | - { |
|
230 | - $frameurls = $this->_frameurls; |
|
231 | - $this->_frameurls = array(); |
|
232 | - |
|
233 | - while(list(,$frameurl) = each($frameurls)) |
|
234 | - { |
|
235 | - if($this->_framedepth < $this->maxframes) |
|
236 | - { |
|
237 | - $this->fetch($frameurl); |
|
238 | - $this->_framedepth++; |
|
239 | - } |
|
240 | - else |
|
241 | - break; |
|
242 | - } |
|
243 | - } |
|
244 | - return true; |
|
245 | - break; |
|
246 | - default: |
|
247 | - // not a valid protocol |
|
248 | - $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
249 | - return false; |
|
250 | - break; |
|
251 | - } |
|
252 | - return true; |
|
253 | - } |
|
174 | + while(list(,$frameurl) = each($frameurls)) |
|
175 | + { |
|
176 | + if($this->_framedepth < $this->maxframes) |
|
177 | + { |
|
178 | + $this->fetch($frameurl); |
|
179 | + $this->_framedepth++; |
|
180 | + } |
|
181 | + else |
|
182 | + break; |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + else |
|
187 | + { |
|
188 | + return false; |
|
189 | + } |
|
190 | + return true; |
|
191 | + break; |
|
192 | + case "https": |
|
193 | + if(!$this->curl_path || (!is_executable($this->curl_path))) { |
|
194 | + $this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n"; |
|
195 | + return false; |
|
196 | + } |
|
197 | + $this->host = $URI_PARTS["host"]; |
|
198 | + if(!empty($URI_PARTS["port"])) |
|
199 | + $this->port = $URI_PARTS["port"]; |
|
200 | + if($this->_isproxy) |
|
201 | + { |
|
202 | + // using proxy, send entire URI |
|
203 | + $this->_httpsrequest($URI,$URI,$this->_httpmethod); |
|
204 | + } |
|
205 | + else |
|
206 | + { |
|
207 | + $path = $URI_PARTS["path"].($URI_PARTS["query"] ? "?".$URI_PARTS["query"] : ""); |
|
208 | + // no proxy, send only the path |
|
209 | + $this->_httpsrequest($path, $URI, $this->_httpmethod); |
|
210 | + } |
|
211 | + |
|
212 | + if($this->_redirectaddr) |
|
213 | + { |
|
214 | + /* url was redirected, check if we've hit the max depth */ |
|
215 | + if($this->maxredirs > $this->_redirectdepth) |
|
216 | + { |
|
217 | + // only follow redirect if it's on this site, or offsiteok is true |
|
218 | + if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) |
|
219 | + { |
|
220 | + /* follow the redirect */ |
|
221 | + $this->_redirectdepth++; |
|
222 | + $this->lastredirectaddr=$this->_redirectaddr; |
|
223 | + $this->fetch($this->_redirectaddr); |
|
224 | + } |
|
225 | + } |
|
226 | + } |
|
227 | + |
|
228 | + if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0) |
|
229 | + { |
|
230 | + $frameurls = $this->_frameurls; |
|
231 | + $this->_frameurls = array(); |
|
232 | + |
|
233 | + while(list(,$frameurl) = each($frameurls)) |
|
234 | + { |
|
235 | + if($this->_framedepth < $this->maxframes) |
|
236 | + { |
|
237 | + $this->fetch($frameurl); |
|
238 | + $this->_framedepth++; |
|
239 | + } |
|
240 | + else |
|
241 | + break; |
|
242 | + } |
|
243 | + } |
|
244 | + return true; |
|
245 | + break; |
|
246 | + default: |
|
247 | + // not a valid protocol |
|
248 | + $this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n'; |
|
249 | + return false; |
|
250 | + break; |
|
251 | + } |
|
252 | + return true; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | |
256 | 256 | |
@@ -266,32 +266,32 @@ discard block |
||
266 | 266 | Output: $match an array of the links |
267 | 267 | \*======================================================================*/ |
268 | 268 | |
269 | - private function _striplinks($document) |
|
270 | - { |
|
271 | - preg_match_all("'<\s*a\s+.*href\s*=\s* # find <a href= |
|
269 | + private function _striplinks($document) |
|
270 | + { |
|
271 | + preg_match_all("'<\s*a\s+.*href\s*=\s* # find <a href= |
|
272 | 272 | ([\"\'])? # find single or double quote |
273 | 273 | (?(1) (.*?)\\1 | ([^\s\>]+)) # if quote found, match up to next matching |
274 | 274 | # quote, otherwise match up to next space |
275 | 275 | 'isx",$document,$links); |
276 | 276 | |
277 | 277 | |
278 | - // catenate the non-empty matches from the conditional subpattern |
|
278 | + // catenate the non-empty matches from the conditional subpattern |
|
279 | 279 | |
280 | - while(list($key,$val) = each($links[2])) |
|
281 | - { |
|
282 | - if(!empty($val)) |
|
283 | - $match[] = $val; |
|
284 | - } |
|
280 | + while(list($key,$val) = each($links[2])) |
|
281 | + { |
|
282 | + if(!empty($val)) |
|
283 | + $match[] = $val; |
|
284 | + } |
|
285 | 285 | |
286 | - while(list($key,$val) = each($links[3])) |
|
287 | - { |
|
288 | - if(!empty($val)) |
|
289 | - $match[] = $val; |
|
290 | - } |
|
286 | + while(list($key,$val) = each($links[3])) |
|
287 | + { |
|
288 | + if(!empty($val)) |
|
289 | + $match[] = $val; |
|
290 | + } |
|
291 | 291 | |
292 | - // return the links |
|
293 | - return $match; |
|
294 | - } |
|
292 | + // return the links |
|
293 | + return $match; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | /*======================================================================*\ |
297 | 297 | Function: _stripform |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | Output: $match an array of the links |
301 | 301 | \*======================================================================*/ |
302 | 302 | |
303 | - private function _stripform($document) |
|
304 | - { |
|
305 | - preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); |
|
303 | + private function _stripform($document) |
|
304 | + { |
|
305 | + preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); |
|
306 | 306 | |
307 | - // catenate the matches |
|
308 | - $match = implode("\r\n",$elements[0]); |
|
307 | + // catenate the matches |
|
308 | + $match = implode("\r\n",$elements[0]); |
|
309 | 309 | |
310 | - // return the links |
|
311 | - return $match; |
|
312 | - } |
|
310 | + // return the links |
|
311 | + return $match; |
|
312 | + } |
|
313 | 313 | |
314 | 314 | |
315 | 315 | |
@@ -320,43 +320,43 @@ discard block |
||
320 | 320 | Output: $text the resulting text |
321 | 321 | \*======================================================================*/ |
322 | 322 | |
323 | - private function _striptext($document) |
|
324 | - { |
|
323 | + private function _striptext($document) |
|
324 | + { |
|
325 | 325 | |
326 | - // I didn't use preg eval (//e) since that is only available in PHP 4.0. |
|
327 | - // so, list your entities one by one here. I included some of the |
|
328 | - // more common ones. |
|
326 | + // I didn't use preg eval (//e) since that is only available in PHP 4.0. |
|
327 | + // so, list your entities one by one here. I included some of the |
|
328 | + // more common ones. |
|
329 | 329 | |
330 | - $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript |
|
331 | - "'<[\/\!]*?[^<>]*?>'si", // strip out html tags |
|
332 | - "'([\r\n])[\s]+'", // strip out white space |
|
333 | - "'&(quote|#34);'i", // replace html entities |
|
334 | - "'&(amp|#38);'i", |
|
335 | - "'&(lt|#60);'i", |
|
336 | - "'&(gt|#62);'i", |
|
337 | - "'&(nbsp|#160);'i", |
|
338 | - "'&(iexcl|#161);'i", |
|
339 | - "'&(cent|#162);'i", |
|
340 | - "'&(pound|#163);'i", |
|
341 | - "'&(copy|#169);'i" |
|
342 | - ); |
|
343 | - $replace = array( "", |
|
344 | - "", |
|
345 | - "\\1", |
|
346 | - "\"", |
|
347 | - "&", |
|
348 | - "<", |
|
349 | - ">", |
|
350 | - " ", |
|
351 | - chr(161), |
|
352 | - chr(162), |
|
353 | - chr(163), |
|
354 | - chr(169)); |
|
330 | + $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript |
|
331 | + "'<[\/\!]*?[^<>]*?>'si", // strip out html tags |
|
332 | + "'([\r\n])[\s]+'", // strip out white space |
|
333 | + "'&(quote|#34);'i", // replace html entities |
|
334 | + "'&(amp|#38);'i", |
|
335 | + "'&(lt|#60);'i", |
|
336 | + "'&(gt|#62);'i", |
|
337 | + "'&(nbsp|#160);'i", |
|
338 | + "'&(iexcl|#161);'i", |
|
339 | + "'&(cent|#162);'i", |
|
340 | + "'&(pound|#163);'i", |
|
341 | + "'&(copy|#169);'i" |
|
342 | + ); |
|
343 | + $replace = array( "", |
|
344 | + "", |
|
345 | + "\\1", |
|
346 | + "\"", |
|
347 | + "&", |
|
348 | + "<", |
|
349 | + ">", |
|
350 | + " ", |
|
351 | + chr(161), |
|
352 | + chr(162), |
|
353 | + chr(163), |
|
354 | + chr(169)); |
|
355 | 355 | |
356 | - $text = preg_replace($search,$replace,$document); |
|
356 | + $text = preg_replace($search,$replace,$document); |
|
357 | 357 | |
358 | - return $text; |
|
359 | - } |
|
358 | + return $text; |
|
359 | + } |
|
360 | 360 | |
361 | 361 | /*======================================================================*\ |
362 | 362 | Function: _expandlinks |
@@ -366,29 +366,29 @@ discard block |
||
366 | 366 | Output: $expandedLinks the expanded links |
367 | 367 | \*======================================================================*/ |
368 | 368 | |
369 | - private function _expandlinks($links,$URI) |
|
370 | - { |
|
369 | + private function _expandlinks($links,$URI) |
|
370 | + { |
|
371 | 371 | |
372 | - preg_match("/^[^\?]+/",$URI,$match); |
|
372 | + preg_match("/^[^\?]+/",$URI,$match); |
|
373 | 373 | |
374 | - $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); |
|
374 | + $match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]); |
|
375 | 375 | |
376 | - $search = array( "|^http://".preg_quote($this->host)."|i", |
|
377 | - "|^(?!http://)(\/)?(?!mailto:)|i", |
|
378 | - "|/\./|", |
|
379 | - "|/[^\/]+/\.\./|" |
|
380 | - ); |
|
376 | + $search = array( "|^http://".preg_quote($this->host)."|i", |
|
377 | + "|^(?!http://)(\/)?(?!mailto:)|i", |
|
378 | + "|/\./|", |
|
379 | + "|/[^\/]+/\.\./|" |
|
380 | + ); |
|
381 | 381 | |
382 | - $replace = array( "", |
|
383 | - $match."/", |
|
384 | - "/", |
|
385 | - "/" |
|
386 | - ); |
|
382 | + $replace = array( "", |
|
383 | + $match."/", |
|
384 | + "/", |
|
385 | + "/" |
|
386 | + ); |
|
387 | 387 | |
388 | - $expandedLinks = preg_replace($search,$replace,$links); |
|
388 | + $expandedLinks = preg_replace($search,$replace,$links); |
|
389 | 389 | |
390 | - return $expandedLinks; |
|
391 | - } |
|
390 | + return $expandedLinks; |
|
391 | + } |
|
392 | 392 | |
393 | 393 | /*======================================================================*\ |
394 | 394 | Function: _httprequest |
@@ -400,179 +400,179 @@ discard block |
||
400 | 400 | Output: |
401 | 401 | \*======================================================================*/ |
402 | 402 | |
403 | - private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") |
|
404 | - { |
|
405 | - if($this->passcookies && $this->_redirectaddr) |
|
406 | - $this->setcookies(); |
|
403 | + private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") |
|
404 | + { |
|
405 | + if($this->passcookies && $this->_redirectaddr) |
|
406 | + $this->setcookies(); |
|
407 | 407 | |
408 | - $URI_PARTS = parse_url($URI); |
|
409 | - if(empty($url)) |
|
410 | - $url = "/"; |
|
411 | - $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; |
|
412 | - if(!empty($this->agent)) |
|
413 | - $headers .= "User-Agent: ".$this->agent."\r\n"; |
|
414 | - if(!empty($this->host) && !isset($this->rawheaders['Host'])) |
|
415 | - $headers .= "Host: ".$this->host."\r\n"; |
|
416 | - if(!empty($this->accept)) |
|
417 | - $headers .= "Accept: ".$this->accept."\r\n"; |
|
408 | + $URI_PARTS = parse_url($URI); |
|
409 | + if(empty($url)) |
|
410 | + $url = "/"; |
|
411 | + $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; |
|
412 | + if(!empty($this->agent)) |
|
413 | + $headers .= "User-Agent: ".$this->agent."\r\n"; |
|
414 | + if(!empty($this->host) && !isset($this->rawheaders['Host'])) |
|
415 | + $headers .= "Host: ".$this->host."\r\n"; |
|
416 | + if(!empty($this->accept)) |
|
417 | + $headers .= "Accept: ".$this->accept."\r\n"; |
|
418 | 418 | |
419 | - if($this->use_gzip) { |
|
420 | - // make sure PHP was built with --with-zlib |
|
421 | - // and we can handle gzipp'ed data |
|
422 | - if ( function_exists(gzinflate) ) { |
|
423 | - $headers .= "Accept-encoding: gzip\r\n"; |
|
424 | - } |
|
425 | - else { |
|
426 | - trigger_error( |
|
427 | - "use_gzip is on, but PHP was built without zlib support.". |
|
428 | - " Requesting file(s) without gzip encoding.", |
|
429 | - E_USER_NOTICE); |
|
430 | - } |
|
431 | - } |
|
419 | + if($this->use_gzip) { |
|
420 | + // make sure PHP was built with --with-zlib |
|
421 | + // and we can handle gzipp'ed data |
|
422 | + if ( function_exists(gzinflate) ) { |
|
423 | + $headers .= "Accept-encoding: gzip\r\n"; |
|
424 | + } |
|
425 | + else { |
|
426 | + trigger_error( |
|
427 | + "use_gzip is on, but PHP was built without zlib support.". |
|
428 | + " Requesting file(s) without gzip encoding.", |
|
429 | + E_USER_NOTICE); |
|
430 | + } |
|
431 | + } |
|
432 | 432 | |
433 | - if(!empty($this->referer)) |
|
434 | - $headers .= "Referer: ".$this->referer."\r\n"; |
|
435 | - if(!empty($this->cookies)) |
|
436 | - { |
|
437 | - if(!is_array($this->cookies)) |
|
438 | - $this->cookies = (array)$this->cookies; |
|
433 | + if(!empty($this->referer)) |
|
434 | + $headers .= "Referer: ".$this->referer."\r\n"; |
|
435 | + if(!empty($this->cookies)) |
|
436 | + { |
|
437 | + if(!is_array($this->cookies)) |
|
438 | + $this->cookies = (array)$this->cookies; |
|
439 | 439 | |
440 | - reset($this->cookies); |
|
441 | - if ( count($this->cookies) > 0 ) { |
|
442 | - $cookie_headers .= 'Cookie: '; |
|
443 | - foreach ( $this->cookies as $cookieKey => $cookieVal ) { |
|
444 | - $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; |
|
445 | - } |
|
446 | - $headers .= substr($cookie_headers,0,-2) . "\r\n"; |
|
447 | - } |
|
448 | - } |
|
449 | - if(!empty($this->rawheaders)) |
|
450 | - { |
|
451 | - if(!is_array($this->rawheaders)) |
|
452 | - $this->rawheaders = (array)$this->rawheaders; |
|
453 | - while(list($headerKey,$headerVal) = each($this->rawheaders)) |
|
454 | - $headers .= $headerKey.": ".$headerVal."\r\n"; |
|
455 | - } |
|
456 | - if(!empty($content_type)) { |
|
457 | - $headers .= "Content-type: $content_type"; |
|
458 | - if ($content_type == "multipart/form-data") |
|
459 | - $headers .= "; boundary=".$this->_mime_boundary; |
|
460 | - $headers .= "\r\n"; |
|
461 | - } |
|
462 | - if(!empty($body)) |
|
463 | - $headers .= "Content-length: ".strlen($body)."\r\n"; |
|
464 | - if(!empty($this->user) || !empty($this->pass)) |
|
465 | - $headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n"; |
|
466 | - |
|
467 | - $headers .= "\r\n"; |
|
440 | + reset($this->cookies); |
|
441 | + if ( count($this->cookies) > 0 ) { |
|
442 | + $cookie_headers .= 'Cookie: '; |
|
443 | + foreach ( $this->cookies as $cookieKey => $cookieVal ) { |
|
444 | + $cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; "; |
|
445 | + } |
|
446 | + $headers .= substr($cookie_headers,0,-2) . "\r\n"; |
|
447 | + } |
|
448 | + } |
|
449 | + if(!empty($this->rawheaders)) |
|
450 | + { |
|
451 | + if(!is_array($this->rawheaders)) |
|
452 | + $this->rawheaders = (array)$this->rawheaders; |
|
453 | + while(list($headerKey,$headerVal) = each($this->rawheaders)) |
|
454 | + $headers .= $headerKey.": ".$headerVal."\r\n"; |
|
455 | + } |
|
456 | + if(!empty($content_type)) { |
|
457 | + $headers .= "Content-type: $content_type"; |
|
458 | + if ($content_type == "multipart/form-data") |
|
459 | + $headers .= "; boundary=".$this->_mime_boundary; |
|
460 | + $headers .= "\r\n"; |
|
461 | + } |
|
462 | + if(!empty($body)) |
|
463 | + $headers .= "Content-length: ".strlen($body)."\r\n"; |
|
464 | + if(!empty($this->user) || !empty($this->pass)) |
|
465 | + $headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n"; |
|
466 | + |
|
467 | + $headers .= "\r\n"; |
|
468 | 468 | |
469 | - // set the read timeout if needed |
|
470 | - if ($this->read_timeout > 0) |
|
471 | - socket_set_timeout($fp, $this->read_timeout); |
|
472 | - $this->timed_out = false; |
|
469 | + // set the read timeout if needed |
|
470 | + if ($this->read_timeout > 0) |
|
471 | + socket_set_timeout($fp, $this->read_timeout); |
|
472 | + $this->timed_out = false; |
|
473 | 473 | |
474 | - fwrite($fp,$headers.$body,strlen($headers.$body)); |
|
474 | + fwrite($fp,$headers.$body,strlen($headers.$body)); |
|
475 | 475 | |
476 | - $this->_redirectaddr = false; |
|
477 | - unset($this->headers); |
|
476 | + $this->_redirectaddr = false; |
|
477 | + unset($this->headers); |
|
478 | 478 | |
479 | - // content was returned gzip encoded? |
|
480 | - $is_gzipped = false; |
|
479 | + // content was returned gzip encoded? |
|
480 | + $is_gzipped = false; |
|
481 | 481 | |
482 | - while($currentHeader = fgets($fp,$this->_maxlinelen)) |
|
483 | - { |
|
484 | - if ($this->read_timeout > 0 && $this->_check_timeout($fp)) |
|
485 | - { |
|
486 | - $this->status=-100; |
|
487 | - return false; |
|
488 | - } |
|
482 | + while($currentHeader = fgets($fp,$this->_maxlinelen)) |
|
483 | + { |
|
484 | + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) |
|
485 | + { |
|
486 | + $this->status=-100; |
|
487 | + return false; |
|
488 | + } |
|
489 | 489 | |
490 | - // if($currentHeader == "\r\n") |
|
491 | - if(preg_match("/^\r?\n$/", $currentHeader) ) |
|
492 | - break; |
|
490 | + // if($currentHeader == "\r\n") |
|
491 | + if(preg_match("/^\r?\n$/", $currentHeader) ) |
|
492 | + break; |
|
493 | 493 | |
494 | - // if a header begins with Location: or URI:, set the redirect |
|
495 | - if(preg_match("/^(Location:|URI:)/i",$currentHeader)) |
|
496 | - { |
|
497 | - // get URL portion of the redirect |
|
498 | - preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches); |
|
499 | - // look for :// in the Location header to see if hostname is included |
|
500 | - if(!preg_match("|\:\/\/|",$matches[2])) |
|
501 | - { |
|
502 | - // no host in the path, so prepend |
|
503 | - $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
|
504 | - // eliminate double slash |
|
505 | - if(!preg_match("|^/|",$matches[2])) |
|
506 | - $this->_redirectaddr .= "/".$matches[2]; |
|
507 | - else |
|
508 | - $this->_redirectaddr .= $matches[2]; |
|
509 | - } |
|
510 | - else |
|
511 | - $this->_redirectaddr = $matches[2]; |
|
512 | - } |
|
494 | + // if a header begins with Location: or URI:, set the redirect |
|
495 | + if(preg_match("/^(Location:|URI:)/i",$currentHeader)) |
|
496 | + { |
|
497 | + // get URL portion of the redirect |
|
498 | + preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches); |
|
499 | + // look for :// in the Location header to see if hostname is included |
|
500 | + if(!preg_match("|\:\/\/|",$matches[2])) |
|
501 | + { |
|
502 | + // no host in the path, so prepend |
|
503 | + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
|
504 | + // eliminate double slash |
|
505 | + if(!preg_match("|^/|",$matches[2])) |
|
506 | + $this->_redirectaddr .= "/".$matches[2]; |
|
507 | + else |
|
508 | + $this->_redirectaddr .= $matches[2]; |
|
509 | + } |
|
510 | + else |
|
511 | + $this->_redirectaddr = $matches[2]; |
|
512 | + } |
|
513 | 513 | |
514 | - if(preg_match("|^HTTP/|",$currentHeader)) |
|
515 | - { |
|
514 | + if(preg_match("|^HTTP/|",$currentHeader)) |
|
515 | + { |
|
516 | 516 | if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status)) |
517 | - { |
|
518 | - $this->status= $status[1]; |
|
517 | + { |
|
518 | + $this->status= $status[1]; |
|
519 | 519 | } |
520 | - $this->response_code = $currentHeader; |
|
521 | - } |
|
520 | + $this->response_code = $currentHeader; |
|
521 | + } |
|
522 | 522 | |
523 | - if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) { |
|
524 | - $is_gzipped = true; |
|
525 | - } |
|
523 | + if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) { |
|
524 | + $is_gzipped = true; |
|
525 | + } |
|
526 | 526 | |
527 | - $this->headers[] = $currentHeader; |
|
528 | - } |
|
529 | - |
|
530 | - # $results = fread($fp, $this->maxlength); |
|
531 | - $results = ""; |
|
532 | - while ( $data = fread($fp, $this->maxlength) ) { |
|
533 | - $results .= $data; |
|
534 | - if ( |
|
535 | - strlen($results) > $this->maxlength ) { |
|
536 | - break; |
|
537 | - } |
|
538 | - } |
|
527 | + $this->headers[] = $currentHeader; |
|
528 | + } |
|
529 | + |
|
530 | + # $results = fread($fp, $this->maxlength); |
|
531 | + $results = ""; |
|
532 | + while ( $data = fread($fp, $this->maxlength) ) { |
|
533 | + $results .= $data; |
|
534 | + if ( |
|
535 | + strlen($results) > $this->maxlength ) { |
|
536 | + break; |
|
537 | + } |
|
538 | + } |
|
539 | 539 | |
540 | - // gunzip |
|
541 | - if ( $is_gzipped ) { |
|
542 | - // per http://www.php.net/manual/en/function.gzencode.php |
|
543 | - $results = substr($results, 10); |
|
544 | - $results = gzinflate($results); |
|
545 | - } |
|
540 | + // gunzip |
|
541 | + if ( $is_gzipped ) { |
|
542 | + // per http://www.php.net/manual/en/function.gzencode.php |
|
543 | + $results = substr($results, 10); |
|
544 | + $results = gzinflate($results); |
|
545 | + } |
|
546 | 546 | |
547 | - if ($this->read_timeout > 0 && $this->_check_timeout($fp)) |
|
548 | - { |
|
549 | - $this->status=-100; |
|
550 | - return false; |
|
551 | - } |
|
547 | + if ($this->read_timeout > 0 && $this->_check_timeout($fp)) |
|
548 | + { |
|
549 | + $this->status=-100; |
|
550 | + return false; |
|
551 | + } |
|
552 | 552 | |
553 | - // check if there is a a redirect meta tag |
|
553 | + // check if there is a a redirect meta tag |
|
554 | 554 | |
555 | - if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
|
556 | - { |
|
557 | - $this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
|
558 | - } |
|
559 | - |
|
560 | - // have we hit our frame depth and is there frame src to fetch? |
|
561 | - if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) |
|
562 | - { |
|
563 | - $this->results[] = $results; |
|
564 | - for($x=0; $x<count($match[1]); $x++) |
|
565 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); |
|
566 | - } |
|
567 | - // have we already fetched framed content? |
|
568 | - elseif(is_array($this->results)) |
|
569 | - $this->results[] = $results; |
|
570 | - // no framed content |
|
571 | - else |
|
572 | - $this->results = $results; |
|
555 | + if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
|
556 | + { |
|
557 | + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
|
558 | + } |
|
559 | + |
|
560 | + // have we hit our frame depth and is there frame src to fetch? |
|
561 | + if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) |
|
562 | + { |
|
563 | + $this->results[] = $results; |
|
564 | + for($x=0; $x<count($match[1]); $x++) |
|
565 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); |
|
566 | + } |
|
567 | + // have we already fetched framed content? |
|
568 | + elseif(is_array($this->results)) |
|
569 | + $this->results[] = $results; |
|
570 | + // no framed content |
|
571 | + else |
|
572 | + $this->results = $results; |
|
573 | 573 | |
574 | - return true; |
|
575 | - } |
|
574 | + return true; |
|
575 | + } |
|
576 | 576 | |
577 | 577 | /*======================================================================*\ |
578 | 578 | Function: _httpsrequest |
@@ -583,163 +583,163 @@ discard block |
||
583 | 583 | Output: |
584 | 584 | \*======================================================================*/ |
585 | 585 | |
586 | - private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") |
|
587 | - { |
|
588 | - if($this->passcookies && $this->_redirectaddr) |
|
589 | - $this->setcookies(); |
|
586 | + private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") |
|
587 | + { |
|
588 | + if($this->passcookies && $this->_redirectaddr) |
|
589 | + $this->setcookies(); |
|
590 | 590 | |
591 | - $headers = array(); |
|
591 | + $headers = array(); |
|
592 | 592 | |
593 | - $URI_PARTS = parse_url($URI); |
|
594 | - if(empty($url)) |
|
595 | - $url = "/"; |
|
596 | - // GET ... header not needed for curl |
|
597 | - //$headers[] = $http_method." ".$url." ".$this->_httpversion; |
|
598 | - if(!empty($this->agent)) |
|
599 | - $headers[] = "User-Agent: ".$this->agent; |
|
600 | - if(!empty($this->host)) |
|
601 | - $headers[] = "Host: ".$this->host; |
|
602 | - if(!empty($this->accept)) |
|
603 | - $headers[] = "Accept: ".$this->accept; |
|
604 | - if(!empty($this->referer)) |
|
605 | - $headers[] = "Referer: ".$this->referer; |
|
606 | - if(!empty($this->cookies)) |
|
607 | - { |
|
608 | - if(!is_array($this->cookies)) |
|
609 | - $this->cookies = (array)$this->cookies; |
|
593 | + $URI_PARTS = parse_url($URI); |
|
594 | + if(empty($url)) |
|
595 | + $url = "/"; |
|
596 | + // GET ... header not needed for curl |
|
597 | + //$headers[] = $http_method." ".$url." ".$this->_httpversion; |
|
598 | + if(!empty($this->agent)) |
|
599 | + $headers[] = "User-Agent: ".$this->agent; |
|
600 | + if(!empty($this->host)) |
|
601 | + $headers[] = "Host: ".$this->host; |
|
602 | + if(!empty($this->accept)) |
|
603 | + $headers[] = "Accept: ".$this->accept; |
|
604 | + if(!empty($this->referer)) |
|
605 | + $headers[] = "Referer: ".$this->referer; |
|
606 | + if(!empty($this->cookies)) |
|
607 | + { |
|
608 | + if(!is_array($this->cookies)) |
|
609 | + $this->cookies = (array)$this->cookies; |
|
610 | 610 | |
611 | - reset($this->cookies); |
|
612 | - if ( count($this->cookies) > 0 ) { |
|
613 | - $cookie_str = 'Cookie: '; |
|
614 | - foreach ( $this->cookies as $cookieKey => $cookieVal ) { |
|
615 | - $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; |
|
616 | - } |
|
617 | - $headers[] = substr($cookie_str,0,-2); |
|
618 | - } |
|
619 | - } |
|
620 | - if(!empty($this->rawheaders)) |
|
621 | - { |
|
622 | - if(!is_array($this->rawheaders)) |
|
623 | - $this->rawheaders = (array)$this->rawheaders; |
|
624 | - while(list($headerKey,$headerVal) = each($this->rawheaders)) |
|
625 | - $headers[] = $headerKey.": ".$headerVal; |
|
626 | - } |
|
627 | - if(!empty($content_type)) { |
|
628 | - if ($content_type == "multipart/form-data") |
|
629 | - $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; |
|
630 | - else |
|
631 | - $headers[] = "Content-type: $content_type"; |
|
632 | - } |
|
633 | - if(!empty($body)) |
|
634 | - $headers[] = "Content-length: ".strlen($body); |
|
635 | - if(!empty($this->user) || !empty($this->pass)) |
|
636 | - $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); |
|
611 | + reset($this->cookies); |
|
612 | + if ( count($this->cookies) > 0 ) { |
|
613 | + $cookie_str = 'Cookie: '; |
|
614 | + foreach ( $this->cookies as $cookieKey => $cookieVal ) { |
|
615 | + $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; |
|
616 | + } |
|
617 | + $headers[] = substr($cookie_str,0,-2); |
|
618 | + } |
|
619 | + } |
|
620 | + if(!empty($this->rawheaders)) |
|
621 | + { |
|
622 | + if(!is_array($this->rawheaders)) |
|
623 | + $this->rawheaders = (array)$this->rawheaders; |
|
624 | + while(list($headerKey,$headerVal) = each($this->rawheaders)) |
|
625 | + $headers[] = $headerKey.": ".$headerVal; |
|
626 | + } |
|
627 | + if(!empty($content_type)) { |
|
628 | + if ($content_type == "multipart/form-data") |
|
629 | + $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; |
|
630 | + else |
|
631 | + $headers[] = "Content-type: $content_type"; |
|
632 | + } |
|
633 | + if(!empty($body)) |
|
634 | + $headers[] = "Content-length: ".strlen($body); |
|
635 | + if(!empty($this->user) || !empty($this->pass)) |
|
636 | + $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); |
|
637 | 637 | |
638 | - for($curr_header = 0; $curr_header < count($headers); $curr_header++) { |
|
639 | - $cmdline_params .= " -H \"".$headers[$curr_header]."\""; |
|
640 | - } |
|
638 | + for($curr_header = 0; $curr_header < count($headers); $curr_header++) { |
|
639 | + $cmdline_params .= " -H \"".$headers[$curr_header]."\""; |
|
640 | + } |
|
641 | 641 | |
642 | - if(!empty($body)) |
|
643 | - $cmdline_params .= " -d \"$body\""; |
|
642 | + if(!empty($body)) |
|
643 | + $cmdline_params .= " -d \"$body\""; |
|
644 | 644 | |
645 | - if($this->read_timeout > 0) |
|
646 | - $cmdline_params .= " -m ".$this->read_timeout; |
|
645 | + if($this->read_timeout > 0) |
|
646 | + $cmdline_params .= " -m ".$this->read_timeout; |
|
647 | 647 | |
648 | - $headerfile = uniqid(time()); |
|
648 | + $headerfile = uniqid(time()); |
|
649 | 649 | |
650 | - # accept self-signed certs |
|
651 | - $cmdline_params .= " -k"; |
|
650 | + # accept self-signed certs |
|
651 | + $cmdline_params .= " -k"; |
|
652 | 652 | $results = array(); |
653 | 653 | $return = 0; |
654 | - exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return); |
|
654 | + exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return); |
|
655 | 655 | |
656 | - if($return) |
|
657 | - { |
|
658 | - $this->error = "Error: cURL could not retrieve the document, error $return."; |
|
659 | - return false; |
|
660 | - } |
|
656 | + if($return) |
|
657 | + { |
|
658 | + $this->error = "Error: cURL could not retrieve the document, error $return."; |
|
659 | + return false; |
|
660 | + } |
|
661 | 661 | |
662 | 662 | |
663 | - $results = implode("\r\n",$results); |
|
663 | + $results = implode("\r\n",$results); |
|
664 | 664 | |
665 | - $result_headers = file("/tmp/$headerfile"); |
|
665 | + $result_headers = file("/tmp/$headerfile"); |
|
666 | 666 | |
667 | - $this->_redirectaddr = false; |
|
668 | - unset($this->headers); |
|
667 | + $this->_redirectaddr = false; |
|
668 | + unset($this->headers); |
|
669 | 669 | |
670 | - for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) |
|
671 | - { |
|
670 | + for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) |
|
671 | + { |
|
672 | 672 | |
673 | - // if a header begins with Location: or URI:, set the redirect |
|
674 | - if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) |
|
675 | - { |
|
676 | - // get URL portion of the redirect |
|
677 | - preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches); |
|
678 | - // look for :// in the Location header to see if hostname is included |
|
679 | - if(!preg_match("|\:\/\/|",$matches[2])) |
|
680 | - { |
|
681 | - // no host in the path, so prepend |
|
682 | - $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
|
683 | - // eliminate double slash |
|
684 | - if(!preg_match("|^/|",$matches[2])) |
|
685 | - $this->_redirectaddr .= "/".$matches[2]; |
|
686 | - else |
|
687 | - $this->_redirectaddr .= $matches[2]; |
|
688 | - } |
|
689 | - else |
|
690 | - $this->_redirectaddr = $matches[2]; |
|
691 | - } |
|
673 | + // if a header begins with Location: or URI:, set the redirect |
|
674 | + if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) |
|
675 | + { |
|
676 | + // get URL portion of the redirect |
|
677 | + preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches); |
|
678 | + // look for :// in the Location header to see if hostname is included |
|
679 | + if(!preg_match("|\:\/\/|",$matches[2])) |
|
680 | + { |
|
681 | + // no host in the path, so prepend |
|
682 | + $this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port; |
|
683 | + // eliminate double slash |
|
684 | + if(!preg_match("|^/|",$matches[2])) |
|
685 | + $this->_redirectaddr .= "/".$matches[2]; |
|
686 | + else |
|
687 | + $this->_redirectaddr .= $matches[2]; |
|
688 | + } |
|
689 | + else |
|
690 | + $this->_redirectaddr = $matches[2]; |
|
691 | + } |
|
692 | 692 | |
693 | - if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) |
|
694 | - { |
|
695 | - $this->response_code = $result_headers[$currentHeader]; |
|
696 | - if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match)) |
|
697 | - { |
|
698 | - $this->status= $match[1]; |
|
699 | - } |
|
700 | - } |
|
701 | - $this->headers[] = $result_headers[$currentHeader]; |
|
702 | - } |
|
703 | - |
|
704 | - // check if there is a a redirect meta tag |
|
693 | + if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) |
|
694 | + { |
|
695 | + $this->response_code = $result_headers[$currentHeader]; |
|
696 | + if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match)) |
|
697 | + { |
|
698 | + $this->status= $match[1]; |
|
699 | + } |
|
700 | + } |
|
701 | + $this->headers[] = $result_headers[$currentHeader]; |
|
702 | + } |
|
703 | + |
|
704 | + // check if there is a a redirect meta tag |
|
705 | 705 | |
706 | - if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
|
707 | - { |
|
708 | - $this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
|
709 | - } |
|
710 | - |
|
711 | - // have we hit our frame depth and is there frame src to fetch? |
|
712 | - if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) |
|
713 | - { |
|
714 | - $this->results[] = $results; |
|
715 | - for($x=0; $x<count($match[1]); $x++) |
|
716 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); |
|
717 | - } |
|
718 | - // have we already fetched framed content? |
|
719 | - elseif(is_array($this->results)) |
|
720 | - $this->results[] = $results; |
|
721 | - // no framed content |
|
722 | - else |
|
723 | - $this->results = $results; |
|
724 | - |
|
725 | - unlink("/tmp/$headerfile"); |
|
706 | + if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) |
|
707 | + { |
|
708 | + $this->_redirectaddr = $this->_expandlinks($match[1],$URI); |
|
709 | + } |
|
710 | + |
|
711 | + // have we hit our frame depth and is there frame src to fetch? |
|
712 | + if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match)) |
|
713 | + { |
|
714 | + $this->results[] = $results; |
|
715 | + for($x=0; $x<count($match[1]); $x++) |
|
716 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host); |
|
717 | + } |
|
718 | + // have we already fetched framed content? |
|
719 | + elseif(is_array($this->results)) |
|
720 | + $this->results[] = $results; |
|
721 | + // no framed content |
|
722 | + else |
|
723 | + $this->results = $results; |
|
724 | + |
|
725 | + unlink("/tmp/$headerfile"); |
|
726 | 726 | |
727 | - return true; |
|
728 | - } |
|
727 | + return true; |
|
728 | + } |
|
729 | 729 | |
730 | 730 | /*======================================================================*\ |
731 | 731 | Function: setcookies() |
732 | 732 | Purpose: set cookies for a redirection |
733 | 733 | \*======================================================================*/ |
734 | 734 | |
735 | - public function setcookies() |
|
736 | - { |
|
737 | - for($x=0; $x<count($this->headers); $x++) |
|
738 | - { |
|
739 | - if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match)) |
|
740 | - $this->cookies[$match[1]] = $match[2]; |
|
741 | - } |
|
742 | - } |
|
735 | + public function setcookies() |
|
736 | + { |
|
737 | + for($x=0; $x<count($this->headers); $x++) |
|
738 | + { |
|
739 | + if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match)) |
|
740 | + $this->cookies[$match[1]] = $match[2]; |
|
741 | + } |
|
742 | + } |
|
743 | 743 | |
744 | 744 | |
745 | 745 | /*======================================================================*\ |
@@ -748,17 +748,17 @@ discard block |
||
748 | 748 | Input: $fp file pointer |
749 | 749 | \*======================================================================*/ |
750 | 750 | |
751 | - private function _check_timeout($fp) |
|
752 | - { |
|
753 | - if ($this->read_timeout > 0) { |
|
754 | - $fp_status = socket_get_status($fp); |
|
755 | - if ($fp_status["timed_out"]) { |
|
756 | - $this->timed_out = true; |
|
757 | - return true; |
|
758 | - } |
|
759 | - } |
|
760 | - return false; |
|
761 | - } |
|
751 | + private function _check_timeout($fp) |
|
752 | + { |
|
753 | + if ($this->read_timeout > 0) { |
|
754 | + $fp_status = socket_get_status($fp); |
|
755 | + if ($fp_status["timed_out"]) { |
|
756 | + $this->timed_out = true; |
|
757 | + return true; |
|
758 | + } |
|
759 | + } |
|
760 | + return false; |
|
761 | + } |
|
762 | 762 | |
763 | 763 | /*======================================================================*\ |
764 | 764 | Function: _connect |
@@ -766,62 +766,62 @@ discard block |
||
766 | 766 | Input: $fp file pointer |
767 | 767 | \*======================================================================*/ |
768 | 768 | |
769 | - private function _connect(&$fp) |
|
770 | - { |
|
771 | - if(!empty($this->proxy_host) && !empty($this->proxy_port)) |
|
772 | - { |
|
773 | - $this->_isproxy = true; |
|
774 | - $host = $this->proxy_host; |
|
775 | - $port = $this->proxy_port; |
|
776 | - } |
|
777 | - else |
|
778 | - { |
|
779 | - $host = $this->host; |
|
780 | - $port = $this->port; |
|
781 | - } |
|
769 | + private function _connect(&$fp) |
|
770 | + { |
|
771 | + if(!empty($this->proxy_host) && !empty($this->proxy_port)) |
|
772 | + { |
|
773 | + $this->_isproxy = true; |
|
774 | + $host = $this->proxy_host; |
|
775 | + $port = $this->proxy_port; |
|
776 | + } |
|
777 | + else |
|
778 | + { |
|
779 | + $host = $this->host; |
|
780 | + $port = $this->port; |
|
781 | + } |
|
782 | 782 | |
783 | - $this->status = 0; |
|
783 | + $this->status = 0; |
|
784 | 784 | |
785 | - if($fp = fsockopen( |
|
786 | - $host, |
|
787 | - $port, |
|
788 | - $errno, |
|
789 | - $errstr, |
|
790 | - $this->_fp_timeout |
|
791 | - )) |
|
792 | - { |
|
793 | - // socket connection succeeded |
|
794 | - |
|
795 | - return true; |
|
796 | - } |
|
797 | - else |
|
798 | - { |
|
799 | - // socket connection failed |
|
800 | - $this->status = $errno; |
|
801 | - switch($errno) |
|
802 | - { |
|
803 | - case -3: |
|
804 | - $this->error="socket creation failed (-3)"; |
|
805 | - case -4: |
|
806 | - $this->error="dns lookup failure (-4)"; |
|
807 | - case -5: |
|
808 | - $this->error="connection refused or timed out (-5)"; |
|
809 | - default: |
|
810 | - $this->error="connection failed (".$errno.")"; |
|
811 | - } |
|
812 | - return false; |
|
813 | - } |
|
814 | - } |
|
785 | + if($fp = fsockopen( |
|
786 | + $host, |
|
787 | + $port, |
|
788 | + $errno, |
|
789 | + $errstr, |
|
790 | + $this->_fp_timeout |
|
791 | + )) |
|
792 | + { |
|
793 | + // socket connection succeeded |
|
794 | + |
|
795 | + return true; |
|
796 | + } |
|
797 | + else |
|
798 | + { |
|
799 | + // socket connection failed |
|
800 | + $this->status = $errno; |
|
801 | + switch($errno) |
|
802 | + { |
|
803 | + case -3: |
|
804 | + $this->error="socket creation failed (-3)"; |
|
805 | + case -4: |
|
806 | + $this->error="dns lookup failure (-4)"; |
|
807 | + case -5: |
|
808 | + $this->error="connection refused or timed out (-5)"; |
|
809 | + default: |
|
810 | + $this->error="connection failed (".$errno.")"; |
|
811 | + } |
|
812 | + return false; |
|
813 | + } |
|
814 | + } |
|
815 | 815 | /*======================================================================*\ |
816 | 816 | Function: _disconnect |
817 | 817 | Purpose: disconnect a socket connection |
818 | 818 | Input: $fp file pointer |
819 | 819 | \*======================================================================*/ |
820 | 820 | |
821 | - private function _disconnect($fp) |
|
822 | - { |
|
823 | - return(fclose($fp)); |
|
824 | - } |
|
821 | + private function _disconnect($fp) |
|
822 | + { |
|
823 | + return(fclose($fp)); |
|
824 | + } |
|
825 | 825 | |
826 | 826 | |
827 | 827 | /*======================================================================*\ |
@@ -832,65 +832,65 @@ discard block |
||
832 | 832 | Output: post body |
833 | 833 | \*======================================================================*/ |
834 | 834 | |
835 | - private function _prepare_post_body($formvars, $formfiles) |
|
836 | - { |
|
837 | - settype($formvars, "array"); |
|
838 | - settype($formfiles, "array"); |
|
835 | + private function _prepare_post_body($formvars, $formfiles) |
|
836 | + { |
|
837 | + settype($formvars, "array"); |
|
838 | + settype($formfiles, "array"); |
|
839 | 839 | |
840 | - if (count($formvars) == 0 && count($formfiles) == 0) |
|
841 | - return; |
|
840 | + if (count($formvars) == 0 && count($formfiles) == 0) |
|
841 | + return; |
|
842 | 842 | |
843 | - switch ($this->_submit_type) { |
|
844 | - case "application/x-www-form-urlencoded": |
|
845 | - reset($formvars); |
|
846 | - while(list($key,$val) = each($formvars)) { |
|
847 | - if (is_array($val) || is_object($val)) { |
|
848 | - while (list($cur_key, $cur_val) = each($val)) { |
|
849 | - $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; |
|
850 | - } |
|
851 | - } else |
|
852 | - $postdata .= urlencode($key)."=".urlencode($val)."&"; |
|
853 | - } |
|
854 | - break; |
|
855 | - |
|
856 | - case "multipart/form-data": |
|
857 | - $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); |
|
843 | + switch ($this->_submit_type) { |
|
844 | + case "application/x-www-form-urlencoded": |
|
845 | + reset($formvars); |
|
846 | + while(list($key,$val) = each($formvars)) { |
|
847 | + if (is_array($val) || is_object($val)) { |
|
848 | + while (list($cur_key, $cur_val) = each($val)) { |
|
849 | + $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&"; |
|
850 | + } |
|
851 | + } else |
|
852 | + $postdata .= urlencode($key)."=".urlencode($val)."&"; |
|
853 | + } |
|
854 | + break; |
|
855 | + |
|
856 | + case "multipart/form-data": |
|
857 | + $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); |
|
858 | 858 | |
859 | - reset($formvars); |
|
860 | - while(list($key,$val) = each($formvars)) { |
|
861 | - if (is_array($val) || is_object($val)) { |
|
862 | - while (list($cur_key, $cur_val) = each($val)) { |
|
863 | - $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
864 | - $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; |
|
865 | - $postdata .= "$cur_val\r\n"; |
|
866 | - } |
|
867 | - } else { |
|
868 | - $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
869 | - $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; |
|
870 | - $postdata .= "$val\r\n"; |
|
871 | - } |
|
872 | - } |
|
859 | + reset($formvars); |
|
860 | + while(list($key,$val) = each($formvars)) { |
|
861 | + if (is_array($val) || is_object($val)) { |
|
862 | + while (list($cur_key, $cur_val) = each($val)) { |
|
863 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
864 | + $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n"; |
|
865 | + $postdata .= "$cur_val\r\n"; |
|
866 | + } |
|
867 | + } else { |
|
868 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
869 | + $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n"; |
|
870 | + $postdata .= "$val\r\n"; |
|
871 | + } |
|
872 | + } |
|
873 | 873 | |
874 | - reset($formfiles); |
|
875 | - while (list($field_name, $file_names) = each($formfiles)) { |
|
876 | - settype($file_names, "array"); |
|
877 | - while (list(, $file_name) = each($file_names)) { |
|
878 | - if (!is_readable($file_name)) continue; |
|
879 | - |
|
880 | - $fp = fopen($file_name, "r"); |
|
881 | - $file_content = fread($fp, filesize($file_name)); |
|
882 | - fclose($fp); |
|
883 | - $base_name = basename($file_name); |
|
884 | - |
|
885 | - $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
886 | - $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; |
|
887 | - $postdata .= "$file_content\r\n"; |
|
888 | - } |
|
889 | - } |
|
890 | - $postdata .= "--".$this->_mime_boundary."--\r\n"; |
|
891 | - break; |
|
892 | - } |
|
893 | - |
|
894 | - return $postdata; |
|
895 | - } |
|
874 | + reset($formfiles); |
|
875 | + while (list($field_name, $file_names) = each($formfiles)) { |
|
876 | + settype($file_names, "array"); |
|
877 | + while (list(, $file_name) = each($file_names)) { |
|
878 | + if (!is_readable($file_name)) continue; |
|
879 | + |
|
880 | + $fp = fopen($file_name, "r"); |
|
881 | + $file_content = fread($fp, filesize($file_name)); |
|
882 | + fclose($fp); |
|
883 | + $base_name = basename($file_name); |
|
884 | + |
|
885 | + $postdata .= "--".$this->_mime_boundary."\r\n"; |
|
886 | + $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$base_name\"\r\n\r\n"; |
|
887 | + $postdata .= "$file_content\r\n"; |
|
888 | + } |
|
889 | + } |
|
890 | + $postdata .= "--".$this->_mime_boundary."--\r\n"; |
|
891 | + break; |
|
892 | + } |
|
893 | + |
|
894 | + return $postdata; |
|
895 | + } |
|
896 | 896 | } |
897 | 897 | \ No newline at end of file |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Project: MagpieRSS: a simple RSS integration tool |
|
4 | - * File: rss_parse.inc - parse an RSS or Atom feed |
|
5 | - * return as a simple object. |
|
6 | - * |
|
7 | - * Handles RSS 0.9x, RSS 2.0, RSS 1.0, and Atom 0.3 |
|
8 | - * |
|
9 | - * The lastest version of MagpieRSS can be obtained from: |
|
10 | - * http://magpierss.sourceforge.net |
|
11 | - * |
|
12 | - * For questions, help, comments, discussion, etc., please join the |
|
13 | - * Magpie mailing list: |
|
14 | - * [email protected] |
|
15 | - * |
|
16 | - * @author Kellan Elliott-McCrea <[email protected]> |
|
17 | - * @version 0.7a |
|
18 | - * @license GPL |
|
19 | - * @package chamilo.include.rss |
|
20 | - */ |
|
3 | + * Project: MagpieRSS: a simple RSS integration tool |
|
4 | + * File: rss_parse.inc - parse an RSS or Atom feed |
|
5 | + * return as a simple object. |
|
6 | + * |
|
7 | + * Handles RSS 0.9x, RSS 2.0, RSS 1.0, and Atom 0.3 |
|
8 | + * |
|
9 | + * The lastest version of MagpieRSS can be obtained from: |
|
10 | + * http://magpierss.sourceforge.net |
|
11 | + * |
|
12 | + * For questions, help, comments, discussion, etc., please join the |
|
13 | + * Magpie mailing list: |
|
14 | + * [email protected] |
|
15 | + * |
|
16 | + * @author Kellan Elliott-McCrea <[email protected]> |
|
17 | + * @version 0.7a |
|
18 | + * @license GPL |
|
19 | + * @package chamilo.include.rss |
|
20 | + */ |
|
21 | 21 | /** |
22 | - * Code |
|
23 | - */ |
|
22 | + * Code |
|
23 | + */ |
|
24 | 24 | define('RSS', 'RSS'); |
25 | 25 | define('ATOM', 'Atom'); |
26 | 26 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | # |
101 | 101 | if (!function_exists('xml_parser_create')) { |
102 | 102 | $this->error( "Failed to load PHP's XML Extension. " . |
103 | - "http://www.php.net/manual/en/ref.xml.php", |
|
104 | - E_USER_ERROR ); |
|
103 | + "http://www.php.net/manual/en/ref.xml.php", |
|
104 | + E_USER_ERROR ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | list($parser, $source) = $this->create_parser($source, |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | |
111 | 111 | if (!is_resource($parser)) { |
112 | 112 | $this->error( "Failed to create an instance of PHP's XML parser. " . |
113 | - "http://www.php.net/manual/en/ref.xml.php", |
|
114 | - E_USER_ERROR ); |
|
113 | + "http://www.php.net/manual/en/ref.xml.php", |
|
114 | + E_USER_ERROR ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | - * return XML parser, and possibly re-encoded source |
|
451 | - * |
|
452 | - */ |
|
450 | + * return XML parser, and possibly re-encoded source |
|
451 | + * |
|
452 | + */ |
|
453 | 453 | public function create_parser($source, $out_enc, $in_enc, $detect) { |
454 | 454 | if ( substr(phpversion(),0,1) == 5) { |
455 | 455 | $parser = $this->php5_create_parser($in_enc, $detect); |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
469 | - * Instantiate an XML parser under PHP5 |
|
470 | - * |
|
471 | - * PHP5 will do a fine job of detecting input encoding |
|
472 | - * if passed an empty string as the encoding. |
|
473 | - * |
|
474 | - * All hail libxml2! |
|
475 | - * |
|
476 | - */ |
|
469 | + * Instantiate an XML parser under PHP5 |
|
470 | + * |
|
471 | + * PHP5 will do a fine job of detecting input encoding |
|
472 | + * if passed an empty string as the encoding. |
|
473 | + * |
|
474 | + * All hail libxml2! |
|
475 | + * |
|
476 | + */ |
|
477 | 477 | public function php5_create_parser($in_enc, $detect) { |
478 | 478 | // by default php5 does a fine job of detecting input encodings |
479 | 479 | if(!$detect && $in_enc) { |
@@ -485,20 +485,20 @@ discard block |
||
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
488 | - * Instaniate an XML parser under PHP4 |
|
489 | - * |
|
490 | - * Unfortunately PHP4's support for character encodings |
|
491 | - * and especially XML and character encodings sucks. As |
|
492 | - * long as the documents you parse only contain characters |
|
493 | - * from the ISO-8859-1 character set (a superset of ASCII, |
|
494 | - * and a subset of UTF-8) you're fine. However once you |
|
495 | - * step out of that comfy little world things get mad, bad, |
|
496 | - * and dangerous to know. |
|
497 | - * |
|
498 | - * The following code is based on SJM's work with FoF |
|
499 | - * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
500 | - * |
|
501 | - */ |
|
488 | + * Instaniate an XML parser under PHP4 |
|
489 | + * |
|
490 | + * Unfortunately PHP4's support for character encodings |
|
491 | + * and especially XML and character encodings sucks. As |
|
492 | + * long as the documents you parse only contain characters |
|
493 | + * from the ISO-8859-1 character set (a superset of ASCII, |
|
494 | + * and a subset of UTF-8) you're fine. However once you |
|
495 | + * step out of that comfy little world things get mad, bad, |
|
496 | + * and dangerous to know. |
|
497 | + * |
|
498 | + * The following code is based on SJM's work with FoF |
|
499 | + * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
500 | + * |
|
501 | + */ |
|
502 | 502 | public function php4_create_parser($source, $in_enc, $detect) { |
503 | 503 | if ( !$detect ) { |
504 | 504 | return array(xml_parser_create($in_enc), $source); |
@@ -542,8 +542,8 @@ discard block |
||
542 | 542 | |
543 | 543 | // else |
544 | 544 | $this->error("Feed is in an unsupported character encoding. ($in_enc) " . |
545 | - "You may see strange artifacts, and mangled characters.", |
|
546 | - E_USER_NOTICE); |
|
545 | + "You may see strange artifacts, and mangled characters.", |
|
546 | + E_USER_NOTICE); |
|
547 | 547 | |
548 | 548 | return array(xml_parser_create(), $source); |
549 | 549 | } |
@@ -589,17 +589,17 @@ discard block |
||
589 | 589 | // courtesy, Ryan Currie, [email protected] |
590 | 590 | |
591 | 591 | if (!function_exists('array_change_key_case')) { |
592 | - define("CASE_UPPER",1); |
|
593 | - define("CASE_LOWER",0); |
|
592 | + define("CASE_UPPER",1); |
|
593 | + define("CASE_LOWER",0); |
|
594 | 594 | |
595 | 595 | |
596 | - function array_change_key_case($array,$case=CASE_LOWER) { |
|
597 | - if ($case=CASE_LOWER) $cmd=strtolower; |
|
598 | - elseif ($case=CASE_UPPER) $cmd=strtoupper; |
|
599 | - foreach($array as $key=>$value) { |
|
600 | - $output[$cmd($key)]=$value; |
|
601 | - } |
|
602 | - return $output; |
|
603 | - } |
|
596 | + function array_change_key_case($array,$case=CASE_LOWER) { |
|
597 | + if ($case=CASE_LOWER) $cmd=strtolower; |
|
598 | + elseif ($case=CASE_UPPER) $cmd=strtoupper; |
|
599 | + foreach($array as $key=>$value) { |
|
600 | + $output[$cmd($key)]=$value; |
|
601 | + } |
|
602 | + return $output; |
|
603 | + } |
|
604 | 604 | |
605 | 605 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if ($height >= $max_size_for_picture) { |
48 | 48 | // scale width |
49 | 49 | $new_width = round($width * ($max_size_for_picture / $height)); |
50 | - $this->image_wrapper->resize($new_width, $max_size_for_picture, 0); |
|
50 | + $this->image_wrapper->resize($new_width, $max_size_for_picture, 0); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | public function __construct($path) |
151 | 151 | { |
152 | - parent::__construct($path); |
|
152 | + parent::__construct($path); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | public function set_image_wrapper() |
@@ -184,19 +184,19 @@ discard block |
||
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - public function get_image_size() |
|
187 | + public function get_image_size() |
|
188 | 188 | { |
189 | - $imagesize = array('width'=>0,'height'=>0); |
|
190 | - if ($this->image_validated) { |
|
189 | + $imagesize = array('width'=>0,'height'=>0); |
|
190 | + if ($this->image_validated) { |
|
191 | 191 | $imagesize = $this->image->getImageGeometry(); |
192 | - } |
|
193 | - return $imagesize; |
|
194 | - } |
|
192 | + } |
|
193 | + return $imagesize; |
|
194 | + } |
|
195 | 195 | |
196 | - //@todo implement border logic case for Imagick |
|
197 | - public function resize($thumbw, $thumbh, $border, $specific_size = false) |
|
196 | + //@todo implement border logic case for Imagick |
|
197 | + public function resize($thumbw, $thumbh, $border, $specific_size = false) |
|
198 | 198 | { |
199 | - if (!$this->image_validated) return false; |
|
199 | + if (!$this->image_validated) return false; |
|
200 | 200 | |
201 | 201 | if ($specific_size) { |
202 | 202 | $width = $thumbw; |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | $width = (int)($this->width * $scale); |
207 | 207 | $height = (int)($this->height * $scale); |
208 | 208 | } |
209 | - $result = $this->image->resizeImage($width, $height, $this->filter, 1); |
|
210 | - $this->width = $thumbw; |
|
211 | - $this->height = $thumbh; |
|
212 | - } |
|
209 | + $result = $this->image->resizeImage($width, $height, $this->filter, 1); |
|
210 | + $this->width = $thumbw; |
|
211 | + $this->height = $thumbh; |
|
212 | + } |
|
213 | 213 | |
214 | 214 | /** |
215 | 215 | * @author José Loguercio <[email protected]> |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | public function crop($x, $y, $width, $height, $src_width, $src_height) { |
225 | 225 | if (!$this->image_validated) return false; |
226 | 226 | $this->image->cropimage($width, $height, $x, $y); |
227 | - $this->width = $width; |
|
228 | - $this->height = $height; |
|
227 | + $this->width = $width; |
|
228 | + $this->height = $height; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | public function send_image($file = '', $compress = -1, $convert_file_to = null) |
@@ -235,35 +235,35 @@ discard block |
||
235 | 235 | if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) { |
236 | 236 | $type = $convert_file_to; |
237 | 237 | } |
238 | - switch ($type) { |
|
239 | - case 'jpeg': |
|
240 | - case 'jpg': |
|
241 | - if (!$file) header("Content-type: image/jpeg"); |
|
242 | - break; |
|
243 | - case 'png': |
|
244 | - if (!$file) header("Content-type: image/png"); |
|
245 | - break; |
|
246 | - case 'gif': |
|
247 | - if (!$file) header("Content-type: image/gif"); |
|
248 | - break; |
|
249 | - } |
|
250 | - $result = false; |
|
251 | - try { |
|
252 | - $result = $this->image->writeImage($file); |
|
253 | - } catch(ImagickException $e) { |
|
238 | + switch ($type) { |
|
239 | + case 'jpeg': |
|
240 | + case 'jpg': |
|
241 | + if (!$file) header("Content-type: image/jpeg"); |
|
242 | + break; |
|
243 | + case 'png': |
|
244 | + if (!$file) header("Content-type: image/png"); |
|
245 | + break; |
|
246 | + case 'gif': |
|
247 | + if (!$file) header("Content-type: image/gif"); |
|
248 | + break; |
|
249 | + } |
|
250 | + $result = false; |
|
251 | + try { |
|
252 | + $result = $this->image->writeImage($file); |
|
253 | + } catch(ImagickException $e) { |
|
254 | 254 | if ($this->debug) error_log($e->getMessage()); |
255 | 255 | } |
256 | 256 | |
257 | - if (!$file) { |
|
258 | - echo $this->image; |
|
259 | - $this->image->clear(); |
|
257 | + if (!$file) { |
|
258 | + echo $this->image; |
|
259 | + $this->image->clear(); |
|
260 | 260 | $this->image->destroy(); |
261 | - } else { |
|
262 | - $this->image->clear(); |
|
261 | + } else { |
|
262 | + $this->image->clear(); |
|
263 | 263 | $this->image->destroy(); |
264 | - return $result; |
|
265 | - } |
|
266 | - } |
|
264 | + return $result; |
|
265 | + } |
|
266 | + } |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
@@ -285,21 +285,21 @@ discard block |
||
285 | 285 | $this->fill_image_info(); |
286 | 286 | |
287 | 287 | switch ($this->type) { |
288 | - case 0: |
|
289 | - $handler = false; |
|
290 | - break; |
|
291 | - case 1 : |
|
288 | + case 0: |
|
289 | + $handler = false; |
|
290 | + break; |
|
291 | + case 1 : |
|
292 | 292 | $handler = @imagecreatefromgif($this->path); |
293 | 293 | $this->type = 'gif'; |
294 | 294 | break; |
295 | - case 2 : |
|
295 | + case 2 : |
|
296 | 296 | $handler = @imagecreatefromjpeg($this->path); |
297 | 297 | $this->type = 'jpg'; |
298 | 298 | break; |
299 | - case 3 : |
|
300 | - $handler = @imagecreatefrompng($this->path); |
|
301 | - $this->type = 'png'; |
|
302 | - break; |
|
299 | + case 3 : |
|
300 | + $handler = @imagecreatefrompng($this->path); |
|
301 | + $this->type = 'png'; |
|
302 | + break; |
|
303 | 303 | } |
304 | 304 | if ($handler) { |
305 | 305 | $this->image_validated = true; |
@@ -313,29 +313,29 @@ discard block |
||
313 | 313 | { |
314 | 314 | $return_array = array('width'=>0,'height'=>0); |
315 | 315 | if ($this->image_validated) { |
316 | - $return_array = array('width'=>$this->width,'height'=>$this->height); |
|
316 | + $return_array = array('width'=>$this->width,'height'=>$this->height); |
|
317 | 317 | } |
318 | 318 | return $return_array; |
319 | - } |
|
319 | + } |
|
320 | 320 | |
321 | 321 | public function fill_image_info() |
322 | 322 | { |
323 | - if (file_exists($this->path)) { |
|
324 | - $image_info = getimagesize($this->path); |
|
325 | - $this->width = $image_info[0]; |
|
326 | - $this->height = $image_info[1]; |
|
327 | - $this->type = $image_info[2]; |
|
328 | - } else { |
|
329 | - $this->width = 0; |
|
330 | - $this->height = 0; |
|
331 | - $this->type = 0; |
|
332 | - } |
|
323 | + if (file_exists($this->path)) { |
|
324 | + $image_info = getimagesize($this->path); |
|
325 | + $this->width = $image_info[0]; |
|
326 | + $this->height = $image_info[1]; |
|
327 | + $this->type = $image_info[2]; |
|
328 | + } else { |
|
329 | + $this->width = 0; |
|
330 | + $this->height = 0; |
|
331 | + $this->type = 0; |
|
332 | + } |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | public function resize($thumbw, $thumbh, $border, $specific_size = false) |
336 | 336 | { |
337 | 337 | if (!$this->image_validated) return false; |
338 | - if ($border == 1) { |
|
338 | + if ($border == 1) { |
|
339 | 339 | if ($specific_size) { |
340 | 340 | $width = $thumbw; |
341 | 341 | $height = $thumbh; |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | $width = (int)($this->width * $scale); |
345 | 345 | $height = (int)($this->height * $scale); |
346 | 346 | } |
347 | - $deltaw = (int)(($thumbw - $width) / 2); |
|
348 | - $deltah = (int)(($thumbh - $height) / 2); |
|
349 | - $dst_img = @ImageCreateTrueColor($thumbw, $thumbh); |
|
350 | - @imagealphablending($dst_img, false); |
|
351 | - @imagesavealpha($dst_img, true); |
|
352 | - if (!empty($this->color)) { |
|
353 | - @imagefill($dst_img, 0, 0, $this->color); |
|
354 | - } |
|
355 | - $this->width = $thumbw; |
|
356 | - $this->height = $thumbh; |
|
357 | - } elseif ($border == 0) { |
|
347 | + $deltaw = (int)(($thumbw - $width) / 2); |
|
348 | + $deltah = (int)(($thumbh - $height) / 2); |
|
349 | + $dst_img = @ImageCreateTrueColor($thumbw, $thumbh); |
|
350 | + @imagealphablending($dst_img, false); |
|
351 | + @imagesavealpha($dst_img, true); |
|
352 | + if (!empty($this->color)) { |
|
353 | + @imagefill($dst_img, 0, 0, $this->color); |
|
354 | + } |
|
355 | + $this->width = $thumbw; |
|
356 | + $this->height = $thumbh; |
|
357 | + } elseif ($border == 0) { |
|
358 | 358 | if ($specific_size) { |
359 | 359 | $width = $thumbw; |
360 | 360 | $height = $thumbh; |
@@ -363,19 +363,19 @@ discard block |
||
363 | 363 | $width = (int)($this->width * $scale); |
364 | 364 | $height = (int)($this->height * $scale); |
365 | 365 | } |
366 | - $deltaw = 0; |
|
367 | - $deltah = 0; |
|
368 | - $dst_img = @ImageCreateTrueColor($width, $height); |
|
369 | - @imagealphablending($dst_img, false); |
|
370 | - @imagesavealpha($dst_img, true); |
|
371 | - $this->width = $width; |
|
372 | - $this->height = $height; |
|
373 | - } |
|
374 | - $src_img = $this->bg; |
|
375 | - @ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img), ImageSY($src_img)); |
|
376 | - $this->bg = $dst_img; |
|
377 | - @imagedestroy($src_img); |
|
378 | - } |
|
366 | + $deltaw = 0; |
|
367 | + $deltah = 0; |
|
368 | + $dst_img = @ImageCreateTrueColor($width, $height); |
|
369 | + @imagealphablending($dst_img, false); |
|
370 | + @imagesavealpha($dst_img, true); |
|
371 | + $this->width = $width; |
|
372 | + $this->height = $height; |
|
373 | + } |
|
374 | + $src_img = $this->bg; |
|
375 | + @ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img), ImageSY($src_img)); |
|
376 | + $this->bg = $dst_img; |
|
377 | + @imagedestroy($src_img); |
|
378 | + } |
|
379 | 379 | |
380 | 380 | /** |
381 | 381 | * @author José Loguercio <[email protected]> |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | public function crop($x, $y, $width, $height, $src_width, $src_height) { |
390 | 390 | if (!$this->image_validated) return false; |
391 | 391 | $this->width = $width; |
392 | - $this->height = $height; |
|
392 | + $this->height = $height; |
|
393 | 393 | $src = null; |
394 | 394 | $dest = @imagecreatetruecolor($width, $height); |
395 | 395 | $type = $this->type; |
@@ -400,56 +400,56 @@ discard block |
||
400 | 400 | @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height); |
401 | 401 | @imagejpeg($dest, $this->path); |
402 | 402 | break; |
403 | - case 'png' : |
|
403 | + case 'png' : |
|
404 | 404 | $src = @imagecreatefrompng($this->path); |
405 | 405 | @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height); |
406 | 406 | @imagepng($dest, $this->path); |
407 | 407 | break; |
408 | - case 'gif' : |
|
409 | - $src = @imagecreatefromgif($this->path); |
|
408 | + case 'gif' : |
|
409 | + $src = @imagecreatefromgif($this->path); |
|
410 | 410 | @imagecopy($dest, $src, 0, 0, $x, $y, $src_width, $src_height); |
411 | 411 | @imagegif($dest, $this->path); |
412 | - break; |
|
412 | + break; |
|
413 | 413 | default: return 0; |
414 | 414 | } |
415 | 415 | @imagedestroy($dest); |
416 | 416 | @imagedestroy($src); |
417 | 417 | } |
418 | 418 | |
419 | - public function send_image($file = '', $compress = -1, $convert_file_to = null) |
|
419 | + public function send_image($file = '', $compress = -1, $convert_file_to = null) |
|
420 | 420 | { |
421 | - if (!$this->image_validated) return false; |
|
421 | + if (!$this->image_validated) return false; |
|
422 | 422 | $compress = (int)$compress; |
423 | 423 | $type = $this->type; |
424 | 424 | if (!empty($convert_file_to) && in_array($convert_file_to, $this->allowed_extensions)) { |
425 | 425 | $type = $convert_file_to; |
426 | 426 | } |
427 | - switch ($type) { |
|
428 | - case 'jpeg': |
|
429 | - case 'jpg': |
|
430 | - if (!$file) header("Content-type: image/jpeg"); |
|
431 | - if ($compress == -1) $compress = 100; |
|
432 | - return imagejpeg($this->bg, $file, $compress); |
|
433 | - break; |
|
434 | - case 'png': |
|
435 | - if (!$file) header("Content-type: image/png"); |
|
436 | - if ($compress != -1) { |
|
437 | - @imagetruecolortopalette($this->bg, true, $compress); |
|
438 | - } |
|
439 | - return imagepng($this->bg, $file, $compress); |
|
440 | - break; |
|
441 | - case 'gif': |
|
442 | - if (!$file) header("Content-type: image/gif"); |
|
443 | - if ($compress != -1) { |
|
444 | - @imagetruecolortopalette($this->bg, true, $compress); |
|
445 | - } |
|
446 | - return imagegif($this->bg, $file, $compress); |
|
447 | - break; |
|
448 | - default: return 0; |
|
449 | - } |
|
450 | - // TODO: Occupied memory is not released, because the following fragment of code is actually dead. |
|
451 | - @imagedestroy($this->bg); |
|
452 | - } |
|
427 | + switch ($type) { |
|
428 | + case 'jpeg': |
|
429 | + case 'jpg': |
|
430 | + if (!$file) header("Content-type: image/jpeg"); |
|
431 | + if ($compress == -1) $compress = 100; |
|
432 | + return imagejpeg($this->bg, $file, $compress); |
|
433 | + break; |
|
434 | + case 'png': |
|
435 | + if (!$file) header("Content-type: image/png"); |
|
436 | + if ($compress != -1) { |
|
437 | + @imagetruecolortopalette($this->bg, true, $compress); |
|
438 | + } |
|
439 | + return imagepng($this->bg, $file, $compress); |
|
440 | + break; |
|
441 | + case 'gif': |
|
442 | + if (!$file) header("Content-type: image/gif"); |
|
443 | + if ($compress != -1) { |
|
444 | + @imagetruecolortopalette($this->bg, true, $compress); |
|
445 | + } |
|
446 | + return imagegif($this->bg, $file, $compress); |
|
447 | + break; |
|
448 | + default: return 0; |
|
449 | + } |
|
450 | + // TODO: Occupied memory is not released, because the following fragment of code is actually dead. |
|
451 | + @imagedestroy($this->bg); |
|
452 | + } |
|
453 | 453 | |
454 | 454 | /** |
455 | 455 | * Convert image to black & white |
@@ -838,18 +838,18 @@ |
||
838 | 838 | $email = false; |
839 | 839 | } |
840 | 840 | |
841 | - if ($email) { |
|
842 | - $condition = "LOWER(email) = '".Database::escape_string($username)."' "; |
|
843 | - } else { |
|
841 | + if ($email) { |
|
842 | + $condition = "LOWER(email) = '".Database::escape_string($username)."' "; |
|
843 | + } else { |
|
844 | 844 | $condition = "LOWER(username) = '".Database::escape_string($username)."'"; |
845 | 845 | } |
846 | 846 | |
847 | - $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
848 | - $query = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email, |
|
847 | + $tbl_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
848 | + $query = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email, |
|
849 | 849 | status AS status, official_code, phone, picture_uri, creator_id |
850 | 850 | FROM $tbl_user |
851 | 851 | WHERE ( $condition AND active = 1) "; |
852 | - $result = Database::query($query); |
|
852 | + $result = Database::query($query); |
|
853 | 853 | $num_rows = Database::num_rows($result); |
854 | 854 | if ($result && $num_rows > 0) { |
855 | 855 | return Database::fetch_assoc($result); |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | ); |
26 | 26 | public $is_course_model = true; |
27 | 27 | |
28 | - public function __construct() |
|
28 | + public function __construct() |
|
29 | 29 | { |
30 | 30 | $this->table = Database::get_course_table(TABLE_TIMELINE); |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Get the count of elements |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * Displays the title + grid |
54 | 54 | */ |
55 | - public function listing() |
|
55 | + public function listing() |
|
56 | 56 | { |
57 | - // action links |
|
58 | - $html = '<div class="actions">'; |
|
57 | + // action links |
|
58 | + $html = '<div class="actions">'; |
|
59 | 59 | //$html .= '<a href="career_dashboard.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>'; |
60 | - $html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>'; |
|
61 | - $html .= '</div>'; |
|
60 | + $html .= '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'),'','32').'</a>'; |
|
61 | + $html .= '</div>'; |
|
62 | 62 | $html .= Display::grid_html('timelines'); |
63 | 63 | return $html; |
64 | - } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public function get_status_list() |
67 | 67 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $form->addElement('text', 'headline', get_lang('Name'), array('size' => '70')); |
91 | 91 | //$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'Careers','Width' => '100%', 'Height' => '250')); |
92 | - $status_list = $this->get_status_list(); |
|
92 | + $status_list = $this->get_status_list(); |
|
93 | 93 | $form->addElement('select', 'status', get_lang('Status'), $status_list); |
94 | 94 | if ($action == 'edit') { |
95 | 95 | //$form->addElement('text', 'created_at', get_lang('CreatedAt')); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | // Setting the rules |
175 | 175 | $form->addRule('headline', get_lang('ThisFieldIsRequired'), 'required'); |
176 | - return $form; |
|
176 | + return $form; |
|
177 | 177 | |
178 | 178 | } |
179 | 179 | |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | public function save_item($params) |
185 | 185 | { |
186 | 186 | $params['c_id'] = api_get_course_int_id(); |
187 | - $id = parent::save($params); |
|
188 | - if (!empty($id)) { |
|
189 | - //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
190 | - } |
|
191 | - return $id; |
|
187 | + $id = parent::save($params); |
|
188 | + if (!empty($id)) { |
|
189 | + //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
190 | + } |
|
191 | + return $id; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | $params['c_id'] = api_get_course_int_id(); |
200 | 200 | $params['parent_id'] = '0'; |
201 | 201 | $params['type'] = 'default'; |
202 | - $id = parent::save($params); |
|
203 | - if (!empty($id)) { |
|
204 | - //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
205 | - } |
|
206 | - return $id; |
|
202 | + $id = parent::save($params); |
|
203 | + if (!empty($id)) { |
|
204 | + //event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
205 | + } |
|
206 | + return $id; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | public function delete($id) { |
210 | - parent::delete($id); |
|
211 | - //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
210 | + parent::delete($id); |
|
211 | + //event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id()); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | public function get_url($id) { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $item['asset'] = array( 'media' => $item['media'], |
248 | 248 | 'credit' => $item['media_credit'], |
249 | 249 | 'caption' => $item['media_caption'], |
250 | - ); |
|
250 | + ); |
|
251 | 251 | |
252 | 252 | //Cleaning items |
253 | 253 | unset($item['id']); |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | class UrlManager |
12 | 12 | { |
13 | 13 | /** |
14 | - * Creates a new url access |
|
15 | - * |
|
16 | - * @author Julio Montoya <[email protected]>, |
|
17 | - * |
|
18 | - * @param string $url The URL of the site |
|
19 | - * @param string $description The description of the site |
|
20 | - * @param int $active is active or not |
|
21 | - * @return boolean if success |
|
22 | - */ |
|
14 | + * Creates a new url access |
|
15 | + * |
|
16 | + * @author Julio Montoya <[email protected]>, |
|
17 | + * |
|
18 | + * @param string $url The URL of the site |
|
19 | + * @param string $description The description of the site |
|
20 | + * @param int $active is active or not |
|
21 | + * @return boolean if success |
|
22 | + */ |
|
23 | 23 | public static function add($url, $description, $active) |
24 | 24 | { |
25 | 25 | $tms = time(); |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * Updates an URL access |
|
40 | - * @author Julio Montoya <[email protected]>, |
|
41 | - * |
|
42 | - * @param int $url_id The url id |
|
43 | - * @param string $url |
|
44 | - * @param string $description The description of the site |
|
45 | - * @param int $active is active or not |
|
46 | - * @return boolean if success |
|
47 | - */ |
|
39 | + * Updates an URL access |
|
40 | + * @author Julio Montoya <[email protected]>, |
|
41 | + * |
|
42 | + * @param int $url_id The url id |
|
43 | + * @param string $url |
|
44 | + * @param string $description The description of the site |
|
45 | + * @param int $active is active or not |
|
46 | + * @return boolean if success |
|
47 | + */ |
|
48 | 48 | public static function update($url_id, $url, $description, $active) |
49 | 49 | { |
50 | 50 | $url_id = intval($url_id); |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Deletes an url |
|
67 | - * @author Julio Montoya |
|
68 | - * @param int $id url id |
|
66 | + * Deletes an url |
|
67 | + * @author Julio Montoya |
|
68 | + * @param int $id url id |
|
69 | 69 | * |
70 | - * @return boolean true if success |
|
71 | - * */ |
|
70 | + * @return boolean true if success |
|
71 | + * */ |
|
72 | 72 | public static function delete($id) |
73 | 73 | { |
74 | 74 | $id = intval($id); |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
203 | - * Gets the inner join of access_url and the course table |
|
204 | - * |
|
205 | - * @author Julio Montoya |
|
206 | - * @param int access url id |
|
207 | - * @return array Database::store_result of the result |
|
208 | - **/ |
|
203 | + * Gets the inner join of access_url and the course table |
|
204 | + * |
|
205 | + * @author Julio Montoya |
|
206 | + * @param int access url id |
|
207 | + * @return array Database::store_result of the result |
|
208 | + **/ |
|
209 | 209 | public static function get_url_rel_course_data($access_url_id = null) |
210 | 210 | { |
211 | 211 | $where = ''; |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
365 | - * Checks the relationship between an URL and a User (return the num_rows) |
|
366 | - * @author Julio Montoya |
|
367 | - * @param int user id |
|
368 | - * @param int url id |
|
369 | - * @return boolean true if success |
|
370 | - * */ |
|
365 | + * Checks the relationship between an URL and a User (return the num_rows) |
|
366 | + * @author Julio Montoya |
|
367 | + * @param int user id |
|
368 | + * @param int url id |
|
369 | + * @return boolean true if success |
|
370 | + * */ |
|
371 | 371 | public static function relation_url_user_exist($user_id, $url_id) |
372 | 372 | { |
373 | 373 | $table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | $num = Database::num_rows($result); |
378 | 378 | |
379 | 379 | return $num; |
380 | - } |
|
380 | + } |
|
381 | 381 | |
382 | 382 | /** |
383 | - * Checks the relationship between an URL and a Course (return the num_rows) |
|
384 | - * @author Julio Montoya |
|
385 | - * @param int $courseId |
|
386 | - * @param int $urlId |
|
387 | - * @return boolean true if success |
|
388 | - * */ |
|
383 | + * Checks the relationship between an URL and a Course (return the num_rows) |
|
384 | + * @author Julio Montoya |
|
385 | + * @param int $courseId |
|
386 | + * @param int $urlId |
|
387 | + * @return boolean true if success |
|
388 | + * */ |
|
389 | 389 | public static function relation_url_course_exist($courseId, $urlId) |
390 | 390 | { |
391 | 391 | $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
@@ -420,12 +420,12 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
423 | - * Checks the relationship between an URL and a Session (return the num_rows) |
|
424 | - * @author Julio Montoya |
|
425 | - * @param int user id |
|
426 | - * @param int url id |
|
427 | - * @return boolean true if success |
|
428 | - * */ |
|
423 | + * Checks the relationship between an URL and a Session (return the num_rows) |
|
424 | + * @author Julio Montoya |
|
425 | + * @param int user id |
|
426 | + * @param int url id |
|
427 | + * @return boolean true if success |
|
428 | + * */ |
|
429 | 429 | public static function relation_url_session_exist($session_id, $url_id) |
430 | 430 | { |
431 | 431 | $table_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
@@ -737,13 +737,13 @@ discard block |
||
737 | 737 | } |
738 | 738 | |
739 | 739 | /** |
740 | - * Deletes an url and user relationship |
|
741 | - * @author Julio Montoya |
|
742 | - * @param int user id |
|
743 | - * @param int url id |
|
740 | + * Deletes an url and user relationship |
|
741 | + * @author Julio Montoya |
|
742 | + * @param int user id |
|
743 | + * @param int url id |
|
744 | 744 | * |
745 | - * @return boolean true if success |
|
746 | - * */ |
|
745 | + * @return boolean true if success |
|
746 | + * */ |
|
747 | 747 | public static function delete_url_rel_user($user_id, $url_id) |
748 | 748 | { |
749 | 749 | $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
761 | - * Deletes an url and course relationship |
|
762 | - * @author Julio Montoya |
|
763 | - * @param int $courseId |
|
764 | - * @param int $urlId |
|
761 | + * Deletes an url and course relationship |
|
762 | + * @author Julio Montoya |
|
763 | + * @param int $courseId |
|
764 | + * @param int $urlId |
|
765 | 765 | * |
766 | - * @return boolean true if success |
|
767 | - * */ |
|
766 | + * @return boolean true if success |
|
767 | + * */ |
|
768 | 768 | public static function delete_url_rel_course($courseId, $urlId) |
769 | 769 | { |
770 | 770 | $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
817 | - * Deletes an url and session relationship |
|
818 | - * @author Julio Montoya |
|
819 | - * @param char course code |
|
820 | - * @param int url id |
|
817 | + * Deletes an url and session relationship |
|
818 | + * @author Julio Montoya |
|
819 | + * @param char course code |
|
820 | + * @param int url id |
|
821 | 821 | * |
822 | - * @return boolean true if success |
|
823 | - * */ |
|
822 | + * @return boolean true if success |
|
823 | + * */ |
|
824 | 824 | public static function delete_url_rel_session($session_id, $url_id) |
825 | 825 | { |
826 | 826 | $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | $extend_link = ''; |
312 | 312 | if (!empty($inter_num)) { |
313 | 313 | $extend_link = Display::url( |
314 | - Display::return_icon('visible.gif', get_lang('HideAttemptView')), |
|
315 | - api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix |
|
314 | + Display::return_icon('visible.gif', get_lang('HideAttemptView')), |
|
315 | + api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix |
|
316 | 316 | ); |
317 | 317 | } |
318 | 318 | $title = $row['mytitle']; |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | case 'last_30_days': |
1320 | 1320 | $new_date = date('Y-m-d H:i:s', strtotime('-30 day')); |
1321 | 1321 | $condition_time = ' AND (login_date >= "'.$new_date.'" AND logout_date <= "'.$today.'") '; |
1322 | - break; |
|
1322 | + break; |
|
1323 | 1323 | case 'custom': |
1324 | 1324 | if (!empty($start_date) && !empty($end_date)) { |
1325 | 1325 | $start_date = Database::escape_string($start_date); |
@@ -1329,10 +1329,10 @@ discard block |
||
1329 | 1329 | break; |
1330 | 1330 | } |
1331 | 1331 | |
1332 | - $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff |
|
1332 | + $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff |
|
1333 | 1333 | FROM '.$tbl_track_login.' |
1334 | 1334 | WHERE '.$userCondition.$condition_time; |
1335 | - $rs = Database::query($sql); |
|
1335 | + $rs = Database::query($sql); |
|
1336 | 1336 | $row = Database::fetch_array($rs, 'ASSOC'); |
1337 | 1337 | $diff = $row['diff']; |
1338 | 1338 | |
@@ -1354,18 +1354,18 @@ discard block |
||
1354 | 1354 | public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0) |
1355 | 1355 | { |
1356 | 1356 | $courseId = intval($courseId); |
1357 | - $session_id = intval($session_id); |
|
1358 | - |
|
1359 | - $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1360 | - if (is_array($user_id)) { |
|
1361 | - $user_id = array_map('intval', $user_id); |
|
1362 | - $condition_user = " AND user_id IN (".implode(',',$user_id).") "; |
|
1363 | - } else { |
|
1364 | - $user_id = intval($user_id); |
|
1365 | - $condition_user = " AND user_id = $user_id "; |
|
1366 | - } |
|
1367 | - |
|
1368 | - $sql = "SELECT |
|
1357 | + $session_id = intval($session_id); |
|
1358 | + |
|
1359 | + $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1360 | + if (is_array($user_id)) { |
|
1361 | + $user_id = array_map('intval', $user_id); |
|
1362 | + $condition_user = " AND user_id IN (".implode(',',$user_id).") "; |
|
1363 | + } else { |
|
1364 | + $user_id = intval($user_id); |
|
1365 | + $condition_user = " AND user_id = $user_id "; |
|
1366 | + } |
|
1367 | + |
|
1368 | + $sql = "SELECT |
|
1369 | 1369 | SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds |
1370 | 1370 | FROM $tbl_track_course |
1371 | 1371 | WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) "; |
@@ -1381,9 +1381,9 @@ discard block |
||
1381 | 1381 | $sql .= $condition_user; |
1382 | 1382 | |
1383 | 1383 | $rs = Database::query($sql); |
1384 | - $row = Database::fetch_array($rs); |
|
1384 | + $row = Database::fetch_array($rs); |
|
1385 | 1385 | |
1386 | - return $row['nb_seconds']; |
|
1386 | + return $row['nb_seconds']; |
|
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | /** |
@@ -1394,25 +1394,25 @@ discard block |
||
1394 | 1394 | */ |
1395 | 1395 | public static function get_first_connection_date($student_id) |
1396 | 1396 | { |
1397 | - $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1398 | - $sql = 'SELECT login_date |
|
1397 | + $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1398 | + $sql = 'SELECT login_date |
|
1399 | 1399 | FROM ' . $tbl_track_login . ' |
1400 | 1400 | WHERE login_user_id = ' . intval($student_id) . ' |
1401 | 1401 | ORDER BY login_date ASC |
1402 | 1402 | LIMIT 0,1'; |
1403 | 1403 | |
1404 | - $rs = Database::query($sql); |
|
1405 | - if (Database::num_rows($rs)>0) { |
|
1406 | - if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1404 | + $rs = Database::query($sql); |
|
1405 | + if (Database::num_rows($rs)>0) { |
|
1406 | + if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1407 | 1407 | return api_convert_and_format_date( |
1408 | 1408 | $first_login_date, |
1409 | 1409 | DATE_FORMAT_SHORT, |
1410 | 1410 | date_default_timezone_get() |
1411 | 1411 | ); |
1412 | - } |
|
1413 | - } |
|
1412 | + } |
|
1413 | + } |
|
1414 | 1414 | |
1415 | - return false; |
|
1415 | + return false; |
|
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | /** |
@@ -1425,38 +1425,38 @@ discard block |
||
1425 | 1425 | */ |
1426 | 1426 | public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false) |
1427 | 1427 | { |
1428 | - $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1429 | - $sql = 'SELECT login_date |
|
1428 | + $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
1429 | + $sql = 'SELECT login_date |
|
1430 | 1430 | FROM ' . $table . ' |
1431 | 1431 | WHERE login_user_id = ' . intval($student_id) . ' |
1432 | 1432 | ORDER BY login_date |
1433 | 1433 | DESC LIMIT 0,1'; |
1434 | 1434 | |
1435 | - $rs = Database::query($sql); |
|
1436 | - if (Database::num_rows($rs) > 0) { |
|
1437 | - if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1438 | - $last_login_date = api_get_local_time($last_login_date); |
|
1439 | - if ($return_timestamp) { |
|
1440 | - return api_strtotime($last_login_date,'UTC'); |
|
1441 | - } else { |
|
1442 | - if (!$warning_message) { |
|
1443 | - return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1444 | - } else { |
|
1445 | - $timestamp = api_strtotime($last_login_date,'UTC'); |
|
1446 | - $currentTimestamp = time(); |
|
1447 | - |
|
1448 | - //If the last connection is > than 7 days, the text is red |
|
1449 | - //345600 = 7 days in seconds |
|
1450 | - if ($currentTimestamp - $timestamp > 604800) { |
|
1451 | - return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>'; |
|
1452 | - } else { |
|
1453 | - return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1454 | - } |
|
1455 | - } |
|
1456 | - } |
|
1457 | - } |
|
1458 | - } |
|
1459 | - return false; |
|
1435 | + $rs = Database::query($sql); |
|
1436 | + if (Database::num_rows($rs) > 0) { |
|
1437 | + if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1438 | + $last_login_date = api_get_local_time($last_login_date); |
|
1439 | + if ($return_timestamp) { |
|
1440 | + return api_strtotime($last_login_date,'UTC'); |
|
1441 | + } else { |
|
1442 | + if (!$warning_message) { |
|
1443 | + return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1444 | + } else { |
|
1445 | + $timestamp = api_strtotime($last_login_date,'UTC'); |
|
1446 | + $currentTimestamp = time(); |
|
1447 | + |
|
1448 | + //If the last connection is > than 7 days, the text is red |
|
1449 | + //345600 = 7 days in seconds |
|
1450 | + if ($currentTimestamp - $timestamp > 604800) { |
|
1451 | + return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>'; |
|
1452 | + } else { |
|
1453 | + return api_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1454 | + } |
|
1455 | + } |
|
1456 | + } |
|
1457 | + } |
|
1458 | + } |
|
1459 | + return false; |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | /** |
@@ -1510,30 +1510,30 @@ discard block |
||
1510 | 1510 | $session_id = 0, |
1511 | 1511 | $convert_date = true |
1512 | 1512 | ) { |
1513 | - $student_id = intval($student_id); |
|
1513 | + $student_id = intval($student_id); |
|
1514 | 1514 | $courseId = intval($courseId); |
1515 | - $session_id = intval($session_id); |
|
1515 | + $session_id = intval($session_id); |
|
1516 | 1516 | |
1517 | - $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1518 | - $sql = 'SELECT login_course_date |
|
1517 | + $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1518 | + $sql = 'SELECT login_course_date |
|
1519 | 1519 | FROM '.$tbl_track_login.' |
1520 | 1520 | WHERE |
1521 | 1521 | user_id = '.$student_id.' AND |
1522 | 1522 | c_id = '.$courseId.' AND |
1523 | 1523 | session_id = '.$session_id.' |
1524 | 1524 | ORDER BY login_course_date ASC LIMIT 0,1'; |
1525 | - $rs = Database::query($sql); |
|
1526 | - if (Database::num_rows($rs) > 0) { |
|
1527 | - if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1528 | - if ($convert_date) { |
|
1529 | - return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT); |
|
1530 | - } else { |
|
1531 | - return $first_login_date; |
|
1532 | - } |
|
1533 | - } |
|
1534 | - } |
|
1535 | - |
|
1536 | - return false; |
|
1525 | + $rs = Database::query($sql); |
|
1526 | + if (Database::num_rows($rs) > 0) { |
|
1527 | + if ($first_login_date = Database::result($rs, 0, 0)) { |
|
1528 | + if ($convert_date) { |
|
1529 | + return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT); |
|
1530 | + } else { |
|
1531 | + return $first_login_date; |
|
1532 | + } |
|
1533 | + } |
|
1534 | + } |
|
1535 | + |
|
1536 | + return false; |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | /** |
@@ -1549,13 +1549,13 @@ discard block |
||
1549 | 1549 | $session_id = 0, |
1550 | 1550 | $convert_date = true |
1551 | 1551 | ) { |
1552 | - // protect data |
|
1553 | - $student_id = intval($student_id); |
|
1552 | + // protect data |
|
1553 | + $student_id = intval($student_id); |
|
1554 | 1554 | $courseId = $courseInfo['real_id']; |
1555 | - $session_id = intval($session_id); |
|
1555 | + $session_id = intval($session_id); |
|
1556 | 1556 | |
1557 | - $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
1558 | - $sql = 'SELECT access_date |
|
1557 | + $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
1558 | + $sql = 'SELECT access_date |
|
1559 | 1559 | FROM '.$tbl_track_e_access.' |
1560 | 1560 | WHERE access_user_id = '.$student_id.' AND |
1561 | 1561 | c_id = "'.$courseId.'" AND |
@@ -1563,38 +1563,38 @@ discard block |
||
1563 | 1563 | ORDER BY access_date DESC |
1564 | 1564 | LIMIT 0,1'; |
1565 | 1565 | |
1566 | - $rs = Database::query($sql); |
|
1567 | - if (Database::num_rows($rs) > 0) { |
|
1568 | - if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1566 | + $rs = Database::query($sql); |
|
1567 | + if (Database::num_rows($rs) > 0) { |
|
1568 | + if ($last_login_date = Database::result($rs, 0, 0)) { |
|
1569 | 1569 | if (empty($last_login_date) || $last_login_date == '0000-00-00 00:00:00') { |
1570 | 1570 | return false; |
1571 | 1571 | } |
1572 | 1572 | //see #5736 |
1573 | 1573 | $last_login_date_timestamp = api_strtotime($last_login_date); |
1574 | - $now = time(); |
|
1575 | - //If the last connection is > than 7 days, the text is red |
|
1576 | - //345600 = 7 days in seconds |
|
1577 | - if ($now - $last_login_date_timestamp > 604800) { |
|
1578 | - if ($convert_date) { |
|
1574 | + $now = time(); |
|
1575 | + //If the last connection is > than 7 days, the text is red |
|
1576 | + //345600 = 7 days in seconds |
|
1577 | + if ($now - $last_login_date_timestamp > 604800) { |
|
1578 | + if ($convert_date) { |
|
1579 | 1579 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT); |
1580 | 1580 | $icon = api_is_allowed_to_edit() ? |
1581 | 1581 | '<a href="'.api_get_path(REL_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'"> |
1582 | 1582 | <img src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" /> </a>' |
1583 | 1583 | : null; |
1584 | - return $icon. Display::label($last_login_date, 'warning'); |
|
1585 | - } else { |
|
1586 | - return $last_login_date; |
|
1587 | - } |
|
1588 | - } else { |
|
1589 | - if ($convert_date) { |
|
1590 | - return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1591 | - } else { |
|
1592 | - return $last_login_date; |
|
1593 | - } |
|
1594 | - } |
|
1595 | - } |
|
1596 | - } |
|
1597 | - return false; |
|
1584 | + return $icon. Display::label($last_login_date, 'warning'); |
|
1585 | + } else { |
|
1586 | + return $last_login_date; |
|
1587 | + } |
|
1588 | + } else { |
|
1589 | + if ($convert_date) { |
|
1590 | + return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT); |
|
1591 | + } else { |
|
1592 | + return $last_login_date; |
|
1593 | + } |
|
1594 | + } |
|
1595 | + } |
|
1596 | + } |
|
1597 | + return false; |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | /** |
@@ -1607,36 +1607,36 @@ discard block |
||
1607 | 1607 | */ |
1608 | 1608 | public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null) |
1609 | 1609 | { |
1610 | - if ($start < 0) { |
|
1611 | - $start = 0; |
|
1612 | - } |
|
1613 | - if (!isset($stop) or ($stop < 0)) { |
|
1614 | - $stop = api_get_utc_datetime(); |
|
1615 | - } |
|
1610 | + if ($start < 0) { |
|
1611 | + $start = 0; |
|
1612 | + } |
|
1613 | + if (!isset($stop) or ($stop < 0)) { |
|
1614 | + $stop = api_get_utc_datetime(); |
|
1615 | + } |
|
1616 | 1616 | |
1617 | 1617 | $start = Database::escape_string($start); |
1618 | 1618 | $stop = Database::escape_string($stop); |
1619 | 1619 | |
1620 | - $month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' "; |
|
1620 | + $month_filter = " AND login_course_date > '$start' AND login_course_date < '$stop' "; |
|
1621 | 1621 | |
1622 | 1622 | $courseId = intval($courseId); |
1623 | - $session_id = intval($session_id); |
|
1624 | - $count = 0; |
|
1623 | + $session_id = intval($session_id); |
|
1624 | + $count = 0; |
|
1625 | 1625 | |
1626 | - $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1627 | - $sql = "SELECT count(*) as count_connections |
|
1626 | + $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
1627 | + $sql = "SELECT count(*) as count_connections |
|
1628 | 1628 | FROM $tbl_track_e_course_access |
1629 | 1629 | WHERE |
1630 | 1630 | c_id = $courseId AND |
1631 | 1631 | session_id = $session_id |
1632 | 1632 | $month_filter"; |
1633 | - $rs = Database::query($sql); |
|
1634 | - if (Database::num_rows($rs)>0) { |
|
1635 | - $row = Database::fetch_object($rs); |
|
1636 | - $count = $row->count_connections; |
|
1637 | - } |
|
1633 | + $rs = Database::query($sql); |
|
1634 | + if (Database::num_rows($rs)>0) { |
|
1635 | + $row = Database::fetch_object($rs); |
|
1636 | + $count = $row->count_connections; |
|
1637 | + } |
|
1638 | 1638 | |
1639 | - return $count; |
|
1639 | + return $count; |
|
1640 | 1640 | } |
1641 | 1641 | |
1642 | 1642 | /** |
@@ -1647,25 +1647,25 @@ discard block |
||
1647 | 1647 | */ |
1648 | 1648 | public static function count_course_per_student($user_id, $include_sessions = true) |
1649 | 1649 | { |
1650 | - $user_id = intval($user_id); |
|
1651 | - $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
1652 | - $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
1650 | + $user_id = intval($user_id); |
|
1651 | + $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); |
|
1652 | + $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
|
1653 | 1653 | |
1654 | - $sql = 'SELECT DISTINCT c_id |
|
1654 | + $sql = 'SELECT DISTINCT c_id |
|
1655 | 1655 | FROM ' . $tbl_course_rel_user . ' |
1656 | 1656 | WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH; |
1657 | - $rs = Database::query($sql); |
|
1658 | - $nb_courses = Database::num_rows($rs); |
|
1657 | + $rs = Database::query($sql); |
|
1658 | + $nb_courses = Database::num_rows($rs); |
|
1659 | 1659 | |
1660 | - if ($include_sessions) { |
|
1661 | - $sql = 'SELECT DISTINCT c_id |
|
1660 | + if ($include_sessions) { |
|
1661 | + $sql = 'SELECT DISTINCT c_id |
|
1662 | 1662 | FROM ' . $tbl_session_course_rel_user . ' |
1663 | 1663 | WHERE user_id = ' . $user_id; |
1664 | - $rs = Database::query($sql); |
|
1665 | - $nb_courses += Database::num_rows($rs); |
|
1666 | - } |
|
1664 | + $rs = Database::query($sql); |
|
1665 | + $nb_courses += Database::num_rows($rs); |
|
1666 | + } |
|
1667 | 1667 | |
1668 | - return $nb_courses; |
|
1668 | + return $nb_courses; |
|
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | /** |
@@ -1696,25 +1696,25 @@ discard block |
||
1696 | 1696 | $into_lp = 0 |
1697 | 1697 | ) { |
1698 | 1698 | $course_code = Database::escape_string($course_code); |
1699 | - $course_info = api_get_course_info($course_code); |
|
1700 | - if (!empty($course_info)) { |
|
1701 | - // table definition |
|
1702 | - $tbl_course_quiz = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1703 | - $tbl_stats_exercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1704 | - |
|
1705 | - // Compose a filter based on optional exercise given |
|
1706 | - $condition_quiz = ""; |
|
1707 | - if (!empty($exercise_id)) { |
|
1708 | - $exercise_id = intval($exercise_id); |
|
1709 | - $condition_quiz =" AND id = $exercise_id "; |
|
1710 | - } |
|
1711 | - |
|
1712 | - // Compose a filter based on optional session id given |
|
1713 | - $condition_session = ""; |
|
1714 | - if (isset($session_id)) { |
|
1715 | - $session_id = intval($session_id); |
|
1716 | - $condition_session = " AND session_id = $session_id "; |
|
1717 | - } |
|
1699 | + $course_info = api_get_course_info($course_code); |
|
1700 | + if (!empty($course_info)) { |
|
1701 | + // table definition |
|
1702 | + $tbl_course_quiz = Database::get_course_table(TABLE_QUIZ_TEST); |
|
1703 | + $tbl_stats_exercise = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1704 | + |
|
1705 | + // Compose a filter based on optional exercise given |
|
1706 | + $condition_quiz = ""; |
|
1707 | + if (!empty($exercise_id)) { |
|
1708 | + $exercise_id = intval($exercise_id); |
|
1709 | + $condition_quiz =" AND id = $exercise_id "; |
|
1710 | + } |
|
1711 | + |
|
1712 | + // Compose a filter based on optional session id given |
|
1713 | + $condition_session = ""; |
|
1714 | + if (isset($session_id)) { |
|
1715 | + $session_id = intval($session_id); |
|
1716 | + $condition_session = " AND session_id = $session_id "; |
|
1717 | + } |
|
1718 | 1718 | if ($active_filter == 1) { |
1719 | 1719 | $condition_active = 'AND active <> -1'; |
1720 | 1720 | } elseif ($active_filter == 0) { |
@@ -1730,25 +1730,25 @@ discard block |
||
1730 | 1730 | $select_lp_id = ', orig_lp_id as lp_id '; |
1731 | 1731 | } |
1732 | 1732 | |
1733 | - $sql = "SELECT count(id) FROM $tbl_course_quiz |
|
1733 | + $sql = "SELECT count(id) FROM $tbl_course_quiz |
|
1734 | 1734 | WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz "; |
1735 | - $count_quiz = Database::fetch_row(Database::query($sql)); |
|
1735 | + $count_quiz = Database::fetch_row(Database::query($sql)); |
|
1736 | 1736 | |
1737 | - if (!empty($count_quiz[0]) && !empty($student_id)) { |
|
1738 | - if (is_array($student_id)) { |
|
1737 | + if (!empty($count_quiz[0]) && !empty($student_id)) { |
|
1738 | + if (is_array($student_id)) { |
|
1739 | 1739 | $student_id = array_map('intval', $student_id); |
1740 | - $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") "; |
|
1741 | - } else { |
|
1740 | + $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") "; |
|
1741 | + } else { |
|
1742 | 1742 | $student_id = intval($student_id); |
1743 | - $condition_user = " AND exe_user_id = '$student_id' "; |
|
1744 | - } |
|
1743 | + $condition_user = " AND exe_user_id = '$student_id' "; |
|
1744 | + } |
|
1745 | 1745 | |
1746 | - if (empty($exercise_id)) { |
|
1747 | - $sql = "SELECT id FROM $tbl_course_quiz |
|
1746 | + if (empty($exercise_id)) { |
|
1747 | + $sql = "SELECT id FROM $tbl_course_quiz |
|
1748 | 1748 | WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz"; |
1749 | 1749 | $result = Database::query($sql); |
1750 | 1750 | $exercise_list = array(); |
1751 | - $exercise_id = null; |
|
1751 | + $exercise_id = null; |
|
1752 | 1752 | if (Database::num_rows($result)) { |
1753 | 1753 | while ($row = Database::fetch_array($result)) { |
1754 | 1754 | $exercise_list[] = $row['id']; |
@@ -1757,11 +1757,11 @@ discard block |
||
1757 | 1757 | if (!empty($exercise_list)) { |
1758 | 1758 | $exercise_id = implode("','",$exercise_list); |
1759 | 1759 | } |
1760 | - } |
|
1760 | + } |
|
1761 | 1761 | |
1762 | - $count_quiz = Database::fetch_row(Database::query($sql)); |
|
1762 | + $count_quiz = Database::fetch_row(Database::query($sql)); |
|
1763 | 1763 | |
1764 | - $sql = "SELECT |
|
1764 | + $sql = "SELECT |
|
1765 | 1765 | SUM(exe_result/exe_weighting*100) as avg_score, |
1766 | 1766 | COUNT(*) as num_attempts |
1767 | 1767 | $select_lp_id |
@@ -1775,20 +1775,20 @@ discard block |
||
1775 | 1775 | $condition_into_lp |
1776 | 1776 | ORDER BY exe_date DESC"; |
1777 | 1777 | |
1778 | - $res = Database::query($sql); |
|
1779 | - $row = Database::fetch_array($res); |
|
1780 | - $quiz_avg_score = null; |
|
1778 | + $res = Database::query($sql); |
|
1779 | + $row = Database::fetch_array($res); |
|
1780 | + $quiz_avg_score = null; |
|
1781 | 1781 | |
1782 | - if (!empty($row['avg_score'])) { |
|
1783 | - $quiz_avg_score = round($row['avg_score'],2); |
|
1784 | - } |
|
1782 | + if (!empty($row['avg_score'])) { |
|
1783 | + $quiz_avg_score = round($row['avg_score'],2); |
|
1784 | + } |
|
1785 | 1785 | |
1786 | - if(!empty($row['num_attempts'])) { |
|
1787 | - $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2); |
|
1788 | - } |
|
1789 | - if (is_array($student_id)) { |
|
1790 | - $quiz_avg_score = round($quiz_avg_score / count($student_id), 2); |
|
1791 | - } |
|
1786 | + if(!empty($row['num_attempts'])) { |
|
1787 | + $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2); |
|
1788 | + } |
|
1789 | + if (is_array($student_id)) { |
|
1790 | + $quiz_avg_score = round($quiz_avg_score / count($student_id), 2); |
|
1791 | + } |
|
1792 | 1792 | if ($into_lp == 0) { |
1793 | 1793 | return $quiz_avg_score; |
1794 | 1794 | } else { |
@@ -1811,9 +1811,9 @@ discard block |
||
1811 | 1811 | return array($quiz_avg_score, null); |
1812 | 1812 | } |
1813 | 1813 | } |
1814 | - } |
|
1815 | - } |
|
1816 | - return null; |
|
1814 | + } |
|
1815 | + } |
|
1816 | + return null; |
|
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | /** |
@@ -1846,15 +1846,15 @@ discard block |
||
1846 | 1846 | $find_all_lp = 0 |
1847 | 1847 | ) { |
1848 | 1848 | $courseId = intval($courseId); |
1849 | - $student_id = intval($student_id); |
|
1850 | - $exercise_id = intval($exercise_id); |
|
1851 | - $session_id = intval($session_id); |
|
1849 | + $student_id = intval($student_id); |
|
1850 | + $exercise_id = intval($exercise_id); |
|
1851 | + $session_id = intval($session_id); |
|
1852 | 1852 | |
1853 | - $lp_id = intval($lp_id); |
|
1853 | + $lp_id = intval($lp_id); |
|
1854 | 1854 | $lp_item_id = intval($lp_item_id); |
1855 | - $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1855 | + $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); |
|
1856 | 1856 | |
1857 | - $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex |
|
1857 | + $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex |
|
1858 | 1858 | WHERE ex.c_id = $courseId |
1859 | 1859 | AND ex.exe_exo_id = $exercise_id |
1860 | 1860 | AND status = '' |
@@ -1869,11 +1869,11 @@ discard block |
||
1869 | 1869 | AND orig_lp_item_id = $lp_item_id"; |
1870 | 1870 | } |
1871 | 1871 | |
1872 | - $rs = Database::query($sql); |
|
1873 | - $row = Database::fetch_row($rs); |
|
1874 | - $count_attempts = $row[0]; |
|
1872 | + $rs = Database::query($sql); |
|
1873 | + $row = Database::fetch_row($rs); |
|
1874 | + $count_attempts = $row[0]; |
|
1875 | 1875 | |
1876 | - return $count_attempts; |
|
1876 | + return $count_attempts; |
|
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | /** |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | * @param int $user_id |
1884 | 1884 | * @param int $courseId |
1885 | 1885 | * @param int $session_id |
1886 | - */ |
|
1886 | + */ |
|
1887 | 1887 | public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id) |
1888 | 1888 | { |
1889 | 1889 | $courseId = intval($courseId); |
@@ -3499,8 +3499,8 @@ discard block |
||
3499 | 3499 | |
3500 | 3500 | $condition_session = ''; |
3501 | 3501 | if (isset($session_id)) { |
3502 | - $session_id = intval($session_id); |
|
3503 | - $condition_session = ' AND f.session_id = '. $session_id; |
|
3502 | + $session_id = intval($session_id); |
|
3503 | + $condition_session = ' AND f.session_id = '. $session_id; |
|
3504 | 3504 | } |
3505 | 3505 | |
3506 | 3506 | $groupId = intval($groupId); |
@@ -5399,9 +5399,9 @@ discard block |
||
5399 | 5399 | } |
5400 | 5400 | |
5401 | 5401 | /** |
5402 | - * @param FormValidator $form |
|
5403 | - * @return mixed |
|
5404 | - */ |
|
5402 | + * @param FormValidator $form |
|
5403 | + * @return mixed |
|
5404 | + */ |
|
5405 | 5405 | public static function setUserSearchForm($form) |
5406 | 5406 | { |
5407 | 5407 | global $_configuration; |
@@ -5680,26 +5680,26 @@ discard block |
||
5680 | 5680 | $session_id = api_get_session_id(); |
5681 | 5681 | $course_id = api_get_course_int_id(); |
5682 | 5682 | |
5683 | - $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
5684 | - $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
5683 | + $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
5684 | + $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
5685 | 5685 | |
5686 | - $sql = "SELECT count(tool) AS total_number_of_items |
|
5686 | + $sql = "SELECT count(tool) AS total_number_of_items |
|
5687 | 5687 | FROM $table_item_property track_resource, $table_user user |
5688 | 5688 | WHERE |
5689 | 5689 | track_resource.c_id = $course_id AND |
5690 | 5690 | track_resource.insert_user_id = user.user_id AND |
5691 | 5691 | session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id "); |
5692 | 5692 | |
5693 | - if (isset($_GET['keyword'])) { |
|
5694 | - $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
5695 | - $sql .= " AND ( |
|
5693 | + if (isset($_GET['keyword'])) { |
|
5694 | + $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
5695 | + $sql .= " AND ( |
|
5696 | 5696 | user.username LIKE '%".$keyword."%' OR |
5697 | 5697 | lastedit_type LIKE '%".$keyword."%' OR |
5698 | 5698 | tool LIKE '%".$keyword."%' |
5699 | 5699 | )"; |
5700 | - } |
|
5700 | + } |
|
5701 | 5701 | |
5702 | - $sql .= " AND tool IN ( |
|
5702 | + $sql .= " AND tool IN ( |
|
5703 | 5703 | 'document', |
5704 | 5704 | 'learnpath', |
5705 | 5705 | 'quiz', |
@@ -5711,10 +5711,10 @@ discard block |
||
5711 | 5711 | 'thematic_advance', |
5712 | 5712 | 'thematic_plan' |
5713 | 5713 | )"; |
5714 | - $res = Database::query($sql); |
|
5715 | - $obj = Database::fetch_object($res); |
|
5714 | + $res = Database::query($sql); |
|
5715 | + $obj = Database::fetch_object($res); |
|
5716 | 5716 | |
5717 | - return $obj->total_number_of_items; |
|
5717 | + return $obj->total_number_of_items; |
|
5718 | 5718 | } |
5719 | 5719 | |
5720 | 5720 | /** |
@@ -5729,12 +5729,12 @@ discard block |
||
5729 | 5729 | $session_id = api_get_session_id(); |
5730 | 5730 | $course_id = api_get_course_int_id(); |
5731 | 5731 | |
5732 | - $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
5733 | - $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
5734 | - $table_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
|
5735 | - $session_id = intval($session_id); |
|
5732 | + $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
5733 | + $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
5734 | + $table_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
|
5735 | + $session_id = intval($session_id); |
|
5736 | 5736 | |
5737 | - $sql = "SELECT |
|
5737 | + $sql = "SELECT |
|
5738 | 5738 | tool as col0, |
5739 | 5739 | lastedit_type as col1, |
5740 | 5740 | ref as ref, |
@@ -5748,16 +5748,16 @@ discard block |
||
5748 | 5748 | track_resource.insert_user_id = user.user_id AND |
5749 | 5749 | session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id "); |
5750 | 5750 | |
5751 | - if (isset($_GET['keyword'])) { |
|
5752 | - $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
5753 | - $sql .= " AND ( |
|
5751 | + if (isset($_GET['keyword'])) { |
|
5752 | + $keyword = Database::escape_string(trim($_GET['keyword'])); |
|
5753 | + $sql .= " AND ( |
|
5754 | 5754 | user.username LIKE '%".$keyword."%' OR |
5755 | 5755 | lastedit_type LIKE '%".$keyword."%' OR |
5756 | 5756 | tool LIKE '%".$keyword."%' |
5757 | 5757 | ) "; |
5758 | - } |
|
5758 | + } |
|
5759 | 5759 | |
5760 | - $sql .= " AND tool IN ( |
|
5760 | + $sql .= " AND tool IN ( |
|
5761 | 5761 | 'document', |
5762 | 5762 | 'learnpath', |
5763 | 5763 | 'quiz', |
@@ -5770,41 +5770,41 @@ discard block |
||
5770 | 5770 | 'thematic_plan' |
5771 | 5771 | )"; |
5772 | 5772 | |
5773 | - if ($column == 0) { |
|
5774 | - $column = '0'; |
|
5775 | - } |
|
5776 | - if ($column != '' && $direction != '') { |
|
5777 | - if ($column != 2 && $column != 4) { |
|
5778 | - $sql .= " ORDER BY col$column $direction"; |
|
5779 | - } |
|
5780 | - } else { |
|
5781 | - $sql .= " ORDER BY col5 DESC "; |
|
5782 | - } |
|
5773 | + if ($column == 0) { |
|
5774 | + $column = '0'; |
|
5775 | + } |
|
5776 | + if ($column != '' && $direction != '') { |
|
5777 | + if ($column != 2 && $column != 4) { |
|
5778 | + $sql .= " ORDER BY col$column $direction"; |
|
5779 | + } |
|
5780 | + } else { |
|
5781 | + $sql .= " ORDER BY col5 DESC "; |
|
5782 | + } |
|
5783 | 5783 | |
5784 | 5784 | $from = intval($from); |
5785 | 5785 | $number_of_items = intval($number_of_items); |
5786 | 5786 | |
5787 | - $sql .= " LIMIT $from, $number_of_items "; |
|
5788 | - |
|
5789 | - $res = Database::query($sql); |
|
5790 | - $resources = array(); |
|
5791 | - $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan'); |
|
5792 | - while ($row = Database::fetch_array($res)) { |
|
5793 | - $ref = $row['ref']; |
|
5794 | - $table_name = TrackingCourseLog::get_tool_name_table($row['col0']); |
|
5795 | - $table_tool = Database :: get_course_table($table_name['table_name']); |
|
5796 | - |
|
5797 | - $id = $table_name['id_tool']; |
|
5798 | - $recorset = false; |
|
5787 | + $sql .= " LIMIT $from, $number_of_items "; |
|
5799 | 5788 | |
5800 | - if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) { |
|
5801 | - $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC); |
|
5802 | - $sql = "SELECT thematic_id FROM $table_tool |
|
5789 | + $res = Database::query($sql); |
|
5790 | + $resources = array(); |
|
5791 | + $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan'); |
|
5792 | + while ($row = Database::fetch_array($res)) { |
|
5793 | + $ref = $row['ref']; |
|
5794 | + $table_name = TrackingCourseLog::get_tool_name_table($row['col0']); |
|
5795 | + $table_tool = Database :: get_course_table($table_name['table_name']); |
|
5796 | + |
|
5797 | + $id = $table_name['id_tool']; |
|
5798 | + $recorset = false; |
|
5799 | + |
|
5800 | + if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) { |
|
5801 | + $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC); |
|
5802 | + $sql = "SELECT thematic_id FROM $table_tool |
|
5803 | 5803 | WHERE c_id = $course_id AND id = $ref"; |
5804 | - $rs_thematic = Database::query($sql); |
|
5805 | - if (Database::num_rows($rs_thematic)) { |
|
5806 | - $row_thematic = Database::fetch_array($rs_thematic); |
|
5807 | - $thematic_id = $row_thematic['thematic_id']; |
|
5804 | + $rs_thematic = Database::query($sql); |
|
5805 | + if (Database::num_rows($rs_thematic)) { |
|
5806 | + $row_thematic = Database::fetch_array($rs_thematic); |
|
5807 | + $thematic_id = $row_thematic['thematic_id']; |
|
5808 | 5808 | |
5809 | 5809 | $sql = "SELECT session.id, session.name, user.username |
5810 | 5810 | FROM $tbl_thematic t, $table_session session, $table_user user |
@@ -5813,9 +5813,9 @@ discard block |
||
5813 | 5813 | t.session_id = session.id AND |
5814 | 5814 | session.id_coach = user.user_id AND |
5815 | 5815 | t.id = $thematic_id"; |
5816 | - $recorset = Database::query($sql); |
|
5817 | - } |
|
5818 | - } else { |
|
5816 | + $recorset = Database::query($sql); |
|
5817 | + } |
|
5818 | + } else { |
|
5819 | 5819 | $sql = "SELECT session.id, session.name, user.username |
5820 | 5820 | FROM $table_tool tool, $table_session session, $table_user user |
5821 | 5821 | WHERE |
@@ -5823,127 +5823,127 @@ discard block |
||
5823 | 5823 | tool.session_id = session.id AND |
5824 | 5824 | session.id_coach = user.user_id AND |
5825 | 5825 | tool.$id = $ref"; |
5826 | - $recorset = Database::query($sql); |
|
5827 | - } |
|
5828 | - |
|
5829 | - if (!empty($recorset)) { |
|
5830 | - $obj = Database::fetch_object($recorset); |
|
5831 | - |
|
5832 | - $name_session = ''; |
|
5833 | - $coach_name = ''; |
|
5834 | - if (!empty($obj)) { |
|
5835 | - $name_session = $obj->name; |
|
5836 | - $coach_name = $obj->username; |
|
5837 | - } |
|
5838 | - |
|
5839 | - $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool']; |
|
5840 | - $row[0] = ''; |
|
5841 | - if ($row['col6'] != 2) { |
|
5842 | - if (in_array($row['col0'], $thematic_tools)) { |
|
5843 | - |
|
5844 | - $exp_thematic_tool = explode('_', $row['col0']); |
|
5845 | - $thematic_tool_title = ''; |
|
5846 | - if (is_array($exp_thematic_tool)) { |
|
5847 | - foreach ($exp_thematic_tool as $exp) { |
|
5848 | - $thematic_tool_title .= api_ucfirst($exp); |
|
5849 | - } |
|
5850 | - } else { |
|
5851 | - $thematic_tool_title = api_ucfirst($row['col0']); |
|
5852 | - } |
|
5853 | - |
|
5854 | - $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>'; |
|
5855 | - } else { |
|
5856 | - $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>'; |
|
5857 | - } |
|
5858 | - } else { |
|
5859 | - $row[0] = api_ucfirst($row['col0']); |
|
5860 | - } |
|
5861 | - $row[1] = get_lang($row[1]); |
|
5862 | - $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get()); |
|
5863 | - $row[5] = ''; |
|
5864 | - //@todo Improve this code please |
|
5865 | - switch ($table_name['table_name']) { |
|
5866 | - case 'document' : |
|
5867 | - $sql = "SELECT tool.title as title FROM $table_tool tool |
|
5826 | + $recorset = Database::query($sql); |
|
5827 | + } |
|
5828 | + |
|
5829 | + if (!empty($recorset)) { |
|
5830 | + $obj = Database::fetch_object($recorset); |
|
5831 | + |
|
5832 | + $name_session = ''; |
|
5833 | + $coach_name = ''; |
|
5834 | + if (!empty($obj)) { |
|
5835 | + $name_session = $obj->name; |
|
5836 | + $coach_name = $obj->username; |
|
5837 | + } |
|
5838 | + |
|
5839 | + $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool']; |
|
5840 | + $row[0] = ''; |
|
5841 | + if ($row['col6'] != 2) { |
|
5842 | + if (in_array($row['col0'], $thematic_tools)) { |
|
5843 | + |
|
5844 | + $exp_thematic_tool = explode('_', $row['col0']); |
|
5845 | + $thematic_tool_title = ''; |
|
5846 | + if (is_array($exp_thematic_tool)) { |
|
5847 | + foreach ($exp_thematic_tool as $exp) { |
|
5848 | + $thematic_tool_title .= api_ucfirst($exp); |
|
5849 | + } |
|
5850 | + } else { |
|
5851 | + $thematic_tool_title = api_ucfirst($row['col0']); |
|
5852 | + } |
|
5853 | + |
|
5854 | + $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>'; |
|
5855 | + } else { |
|
5856 | + $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>'; |
|
5857 | + } |
|
5858 | + } else { |
|
5859 | + $row[0] = api_ucfirst($row['col0']); |
|
5860 | + } |
|
5861 | + $row[1] = get_lang($row[1]); |
|
5862 | + $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get()); |
|
5863 | + $row[5] = ''; |
|
5864 | + //@todo Improve this code please |
|
5865 | + switch ($table_name['table_name']) { |
|
5866 | + case 'document' : |
|
5867 | + $sql = "SELECT tool.title as title FROM $table_tool tool |
|
5868 | 5868 | WHERE c_id = $course_id AND id = $ref"; |
5869 | - $rs_document = Database::query($sql); |
|
5870 | - $obj_document = Database::fetch_object($rs_document); |
|
5871 | - $row[5] = $obj_document->title; |
|
5869 | + $rs_document = Database::query($sql); |
|
5870 | + $obj_document = Database::fetch_object($rs_document); |
|
5871 | + $row[5] = $obj_document->title; |
|
5872 | 5872 | |
5873 | - break; |
|
5874 | - case 'announcement': |
|
5873 | + break; |
|
5874 | + case 'announcement': |
|
5875 | 5875 | $sql = "SELECT title FROM $table_tool |
5876 | 5876 | WHERE c_id = $course_id AND id = $ref"; |
5877 | - $rs_document = Database::query($sql); |
|
5878 | - $obj_document = Database::fetch_object($rs_document); |
|
5877 | + $rs_document = Database::query($sql); |
|
5878 | + $obj_document = Database::fetch_object($rs_document); |
|
5879 | 5879 | if ($obj_document) { |
5880 | 5880 | $row[5] = $obj_document->title; |
5881 | 5881 | } |
5882 | - break; |
|
5883 | - case 'glossary': |
|
5882 | + break; |
|
5883 | + case 'glossary': |
|
5884 | 5884 | $sql = "SELECT name FROM $table_tool |
5885 | 5885 | WHERE c_id = $course_id AND glossary_id = $ref"; |
5886 | - $rs_document = Database::query($sql); |
|
5887 | - $obj_document = Database::fetch_object($rs_document); |
|
5886 | + $rs_document = Database::query($sql); |
|
5887 | + $obj_document = Database::fetch_object($rs_document); |
|
5888 | 5888 | if ($obj_document) { |
5889 | 5889 | $row[5] = $obj_document->name; |
5890 | 5890 | } |
5891 | - break; |
|
5892 | - case 'lp': |
|
5891 | + break; |
|
5892 | + case 'lp': |
|
5893 | 5893 | $sql = "SELECT name |
5894 | 5894 | FROM $table_tool WHERE c_id = $course_id AND id = $ref"; |
5895 | - $rs_document = Database::query($sql); |
|
5896 | - $obj_document = Database::fetch_object($rs_document); |
|
5897 | - $row[5] = $obj_document->name; |
|
5898 | - break; |
|
5899 | - case 'quiz': |
|
5895 | + $rs_document = Database::query($sql); |
|
5896 | + $obj_document = Database::fetch_object($rs_document); |
|
5897 | + $row[5] = $obj_document->name; |
|
5898 | + break; |
|
5899 | + case 'quiz': |
|
5900 | 5900 | $sql = "SELECT title FROM $table_tool |
5901 | 5901 | WHERE c_id = $course_id AND id = $ref"; |
5902 | - $rs_document = Database::query($sql); |
|
5903 | - $obj_document = Database::fetch_object($rs_document); |
|
5902 | + $rs_document = Database::query($sql); |
|
5903 | + $obj_document = Database::fetch_object($rs_document); |
|
5904 | 5904 | if ($obj_document) { |
5905 | 5905 | $row[5] = $obj_document->title; |
5906 | 5906 | } |
5907 | - break; |
|
5908 | - case 'course_description': |
|
5907 | + break; |
|
5908 | + case 'course_description': |
|
5909 | 5909 | $sql = "SELECT title FROM $table_tool |
5910 | 5910 | WHERE c_id = $course_id AND id = $ref"; |
5911 | - $rs_document = Database::query($sql); |
|
5912 | - $obj_document = Database::fetch_object($rs_document); |
|
5911 | + $rs_document = Database::query($sql); |
|
5912 | + $obj_document = Database::fetch_object($rs_document); |
|
5913 | 5913 | if ($obj_document) { |
5914 | 5914 | $row[5] = $obj_document->title; |
5915 | 5915 | } |
5916 | - break; |
|
5917 | - case 'thematic': |
|
5918 | - $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
5919 | - if (Database::num_rows($rs) > 0) { |
|
5920 | - $obj = Database::fetch_object($rs); |
|
5921 | - $row[5] = $obj->title; |
|
5922 | - } |
|
5923 | - break; |
|
5924 | - case 'thematic_advance': |
|
5925 | - $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
5926 | - if (Database::num_rows($rs) > 0) { |
|
5927 | - $obj = Database::fetch_object($rs); |
|
5928 | - $row[5] = $obj->content; |
|
5929 | - } |
|
5930 | - break; |
|
5931 | - case 'thematic_plan': |
|
5932 | - $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
5933 | - if (Database::num_rows($rs) > 0) { |
|
5934 | - $obj = Database::fetch_object($rs); |
|
5935 | - $row[5] = $obj->title; |
|
5936 | - } |
|
5937 | - break; |
|
5938 | - default: |
|
5939 | - break; |
|
5940 | - } |
|
5941 | - |
|
5942 | - $row2 = $name_session; |
|
5943 | - if (!empty($coach_name)) { |
|
5944 | - $row2 .= '<br />'.get_lang('Coach').': '.$coach_name; |
|
5945 | - } |
|
5946 | - $row[2] = $row2; |
|
5916 | + break; |
|
5917 | + case 'thematic': |
|
5918 | + $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
5919 | + if (Database::num_rows($rs) > 0) { |
|
5920 | + $obj = Database::fetch_object($rs); |
|
5921 | + $row[5] = $obj->title; |
|
5922 | + } |
|
5923 | + break; |
|
5924 | + case 'thematic_advance': |
|
5925 | + $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
5926 | + if (Database::num_rows($rs) > 0) { |
|
5927 | + $obj = Database::fetch_object($rs); |
|
5928 | + $row[5] = $obj->content; |
|
5929 | + } |
|
5930 | + break; |
|
5931 | + case 'thematic_plan': |
|
5932 | + $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref"); |
|
5933 | + if (Database::num_rows($rs) > 0) { |
|
5934 | + $obj = Database::fetch_object($rs); |
|
5935 | + $row[5] = $obj->title; |
|
5936 | + } |
|
5937 | + break; |
|
5938 | + default: |
|
5939 | + break; |
|
5940 | + } |
|
5941 | + |
|
5942 | + $row2 = $name_session; |
|
5943 | + if (!empty($coach_name)) { |
|
5944 | + $row2 .= '<br />'.get_lang('Coach').': '.$coach_name; |
|
5945 | + } |
|
5946 | + $row[2] = $row2; |
|
5947 | 5947 | if (!empty($row['col3'])) { |
5948 | 5948 | $userInfo = api_get_user_info($row['user_id']); |
5949 | 5949 | |
@@ -5960,11 +5960,11 @@ discard block |
||
5960 | 5960 | $row[4] = $ip; |
5961 | 5961 | } |
5962 | 5962 | |
5963 | - $resources[] = $row; |
|
5964 | - } |
|
5965 | - } |
|
5963 | + $resources[] = $row; |
|
5964 | + } |
|
5965 | + } |
|
5966 | 5966 | |
5967 | - return $resources; |
|
5967 | + return $resources; |
|
5968 | 5968 | } |
5969 | 5969 | |
5970 | 5970 | /** |
@@ -5974,63 +5974,63 @@ discard block |
||
5974 | 5974 | */ |
5975 | 5975 | public static function get_tool_name_table($tool) |
5976 | 5976 | { |
5977 | - switch ($tool) { |
|
5978 | - case 'document': |
|
5979 | - $table_name = TABLE_DOCUMENT; |
|
5980 | - $link_tool = 'document/document.php'; |
|
5981 | - $id_tool = 'id'; |
|
5982 | - break; |
|
5983 | - case 'learnpath': |
|
5984 | - $table_name = TABLE_LP_MAIN; |
|
5985 | - $link_tool = 'newscorm/lp_controller.php'; |
|
5986 | - $id_tool = 'id'; |
|
5987 | - break; |
|
5988 | - case 'quiz': |
|
5989 | - $table_name = TABLE_QUIZ_TEST; |
|
5990 | - $link_tool = 'exercice/exercice.php'; |
|
5991 | - $id_tool = 'id'; |
|
5992 | - break; |
|
5993 | - case 'glossary': |
|
5994 | - $table_name = TABLE_GLOSSARY; |
|
5995 | - $link_tool = 'glossary/index.php'; |
|
5996 | - $id_tool = 'glossary_id'; |
|
5997 | - break; |
|
5998 | - case 'link': |
|
5999 | - $table_name = TABLE_LINK; |
|
6000 | - $link_tool = 'link/link.php'; |
|
6001 | - $id_tool = 'id'; |
|
6002 | - break; |
|
6003 | - case 'course_description': |
|
6004 | - $table_name = TABLE_COURSE_DESCRIPTION; |
|
6005 | - $link_tool = 'course_description/'; |
|
6006 | - $id_tool = 'id'; |
|
6007 | - break; |
|
6008 | - case 'announcement': |
|
6009 | - $table_name = TABLE_ANNOUNCEMENT; |
|
6010 | - $link_tool = 'announcements/announcements.php'; |
|
6011 | - $id_tool = 'id'; |
|
6012 | - break; |
|
6013 | - case 'thematic': |
|
6014 | - $table_name = TABLE_THEMATIC; |
|
6015 | - $link_tool = 'course_progress/index.php'; |
|
6016 | - $id_tool = 'id'; |
|
6017 | - break; |
|
6018 | - case 'thematic_advance': |
|
6019 | - $table_name = TABLE_THEMATIC_ADVANCE; |
|
6020 | - $link_tool = 'course_progress/index.php'; |
|
6021 | - $id_tool = 'id'; |
|
6022 | - break; |
|
6023 | - case 'thematic_plan': |
|
6024 | - $table_name = TABLE_THEMATIC_PLAN; |
|
6025 | - $link_tool = 'course_progress/index.php'; |
|
6026 | - $id_tool = 'id'; |
|
6027 | - break; |
|
6028 | - default: |
|
6029 | - $table_name = $tool; |
|
6030 | - break; |
|
6031 | - } |
|
6032 | - |
|
6033 | - return array( |
|
5977 | + switch ($tool) { |
|
5978 | + case 'document': |
|
5979 | + $table_name = TABLE_DOCUMENT; |
|
5980 | + $link_tool = 'document/document.php'; |
|
5981 | + $id_tool = 'id'; |
|
5982 | + break; |
|
5983 | + case 'learnpath': |
|
5984 | + $table_name = TABLE_LP_MAIN; |
|
5985 | + $link_tool = 'newscorm/lp_controller.php'; |
|
5986 | + $id_tool = 'id'; |
|
5987 | + break; |
|
5988 | + case 'quiz': |
|
5989 | + $table_name = TABLE_QUIZ_TEST; |
|
5990 | + $link_tool = 'exercice/exercice.php'; |
|
5991 | + $id_tool = 'id'; |
|
5992 | + break; |
|
5993 | + case 'glossary': |
|
5994 | + $table_name = TABLE_GLOSSARY; |
|
5995 | + $link_tool = 'glossary/index.php'; |
|
5996 | + $id_tool = 'glossary_id'; |
|
5997 | + break; |
|
5998 | + case 'link': |
|
5999 | + $table_name = TABLE_LINK; |
|
6000 | + $link_tool = 'link/link.php'; |
|
6001 | + $id_tool = 'id'; |
|
6002 | + break; |
|
6003 | + case 'course_description': |
|
6004 | + $table_name = TABLE_COURSE_DESCRIPTION; |
|
6005 | + $link_tool = 'course_description/'; |
|
6006 | + $id_tool = 'id'; |
|
6007 | + break; |
|
6008 | + case 'announcement': |
|
6009 | + $table_name = TABLE_ANNOUNCEMENT; |
|
6010 | + $link_tool = 'announcements/announcements.php'; |
|
6011 | + $id_tool = 'id'; |
|
6012 | + break; |
|
6013 | + case 'thematic': |
|
6014 | + $table_name = TABLE_THEMATIC; |
|
6015 | + $link_tool = 'course_progress/index.php'; |
|
6016 | + $id_tool = 'id'; |
|
6017 | + break; |
|
6018 | + case 'thematic_advance': |
|
6019 | + $table_name = TABLE_THEMATIC_ADVANCE; |
|
6020 | + $link_tool = 'course_progress/index.php'; |
|
6021 | + $id_tool = 'id'; |
|
6022 | + break; |
|
6023 | + case 'thematic_plan': |
|
6024 | + $table_name = TABLE_THEMATIC_PLAN; |
|
6025 | + $link_tool = 'course_progress/index.php'; |
|
6026 | + $id_tool = 'id'; |
|
6027 | + break; |
|
6028 | + default: |
|
6029 | + $table_name = $tool; |
|
6030 | + break; |
|
6031 | + } |
|
6032 | + |
|
6033 | + return array( |
|
6034 | 6034 | 'table_name' => $table_name, |
6035 | 6035 | 'link_tool' => $link_tool, |
6036 | 6036 | 'id_tool' => $id_tool |
@@ -6039,45 +6039,45 @@ discard block |
||
6039 | 6039 | |
6040 | 6040 | public static function display_additional_profile_fields() |
6041 | 6041 | { |
6042 | - // getting all the extra profile fields that are defined by the platform administrator |
|
6043 | - $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC'); |
|
6044 | - |
|
6045 | - // creating the form |
|
6046 | - $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">'; |
|
6047 | - |
|
6048 | - // the select field with the additional user profile fields (= this is where we select the field of which we want to see |
|
6049 | - // the information the users have entered or selected. |
|
6050 | - $return .= '<select name="additional_profile_field">'; |
|
6051 | - $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>'; |
|
6052 | - $extra_fields_to_show = 0; |
|
6053 | - foreach ($extra_fields as $key=>$field) { |
|
6054 | - // show only extra fields that are visible + and can be filtered, added by J.Montoya |
|
6055 | - if ($field[6]==1 && $field[8] == 1) { |
|
6056 | - if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) { |
|
6057 | - $selected = 'selected="selected"'; |
|
6058 | - } else { |
|
6059 | - $selected = ''; |
|
6060 | - } |
|
6061 | - $extra_fields_to_show++; |
|
6062 | - $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>'; |
|
6063 | - } |
|
6064 | - } |
|
6065 | - $return .= '</select>'; |
|
6066 | - |
|
6067 | - // the form elements for the $_GET parameters (because the form is passed through GET |
|
6068 | - foreach ($_GET as $key=>$value){ |
|
6069 | - if ($key <> 'additional_profile_field') { |
|
6070 | - $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />'; |
|
6071 | - } |
|
6072 | - } |
|
6073 | - // the submit button |
|
6074 | - $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>'; |
|
6075 | - $return .= '</form>'; |
|
6076 | - if ($extra_fields_to_show > 0) { |
|
6077 | - return $return; |
|
6078 | - } else { |
|
6079 | - return ''; |
|
6080 | - } |
|
6042 | + // getting all the extra profile fields that are defined by the platform administrator |
|
6043 | + $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC'); |
|
6044 | + |
|
6045 | + // creating the form |
|
6046 | + $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">'; |
|
6047 | + |
|
6048 | + // the select field with the additional user profile fields (= this is where we select the field of which we want to see |
|
6049 | + // the information the users have entered or selected. |
|
6050 | + $return .= '<select name="additional_profile_field">'; |
|
6051 | + $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>'; |
|
6052 | + $extra_fields_to_show = 0; |
|
6053 | + foreach ($extra_fields as $key=>$field) { |
|
6054 | + // show only extra fields that are visible + and can be filtered, added by J.Montoya |
|
6055 | + if ($field[6]==1 && $field[8] == 1) { |
|
6056 | + if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) { |
|
6057 | + $selected = 'selected="selected"'; |
|
6058 | + } else { |
|
6059 | + $selected = ''; |
|
6060 | + } |
|
6061 | + $extra_fields_to_show++; |
|
6062 | + $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>'; |
|
6063 | + } |
|
6064 | + } |
|
6065 | + $return .= '</select>'; |
|
6066 | + |
|
6067 | + // the form elements for the $_GET parameters (because the form is passed through GET |
|
6068 | + foreach ($_GET as $key=>$value){ |
|
6069 | + if ($key <> 'additional_profile_field') { |
|
6070 | + $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />'; |
|
6071 | + } |
|
6072 | + } |
|
6073 | + // the submit button |
|
6074 | + $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>'; |
|
6075 | + $return .= '</form>'; |
|
6076 | + if ($extra_fields_to_show > 0) { |
|
6077 | + return $return; |
|
6078 | + } else { |
|
6079 | + return ''; |
|
6080 | + } |
|
6081 | 6081 | } |
6082 | 6082 | |
6083 | 6083 | /** |
@@ -6096,31 +6096,31 @@ discard block |
||
6096 | 6096 | */ |
6097 | 6097 | public static function get_addtional_profile_information_of_field_by_user($field_id, $users) |
6098 | 6098 | { |
6099 | - // Database table definition |
|
6100 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6101 | - $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
6099 | + // Database table definition |
|
6100 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6101 | + $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
6102 | 6102 | $extraField = Database::get_main_table(TABLE_EXTRA_FIELD); |
6103 | - $result_extra_field = UserManager::get_extra_field_information($field_id); |
|
6104 | - |
|
6105 | - if (!empty($users)) { |
|
6106 | - if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) { |
|
6107 | - foreach($users as $user_id) { |
|
6108 | - $user_result = UserManager::get_user_tags($user_id, $field_id); |
|
6109 | - $tag_list = array(); |
|
6110 | - foreach($user_result as $item) { |
|
6111 | - $tag_list[] = $item['tag']; |
|
6112 | - } |
|
6113 | - $return[$user_id][] = implode(', ',$tag_list); |
|
6114 | - } |
|
6115 | - } else { |
|
6116 | - $new_user_array = array(); |
|
6117 | - foreach ($users as $user_id) { |
|
6118 | - $new_user_array[]= "'".$user_id."'"; |
|
6119 | - } |
|
6120 | - $users = implode(',',$new_user_array); |
|
6103 | + $result_extra_field = UserManager::get_extra_field_information($field_id); |
|
6104 | + |
|
6105 | + if (!empty($users)) { |
|
6106 | + if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) { |
|
6107 | + foreach($users as $user_id) { |
|
6108 | + $user_result = UserManager::get_user_tags($user_id, $field_id); |
|
6109 | + $tag_list = array(); |
|
6110 | + foreach($user_result as $item) { |
|
6111 | + $tag_list[] = $item['tag']; |
|
6112 | + } |
|
6113 | + $return[$user_id][] = implode(', ',$tag_list); |
|
6114 | + } |
|
6115 | + } else { |
|
6116 | + $new_user_array = array(); |
|
6117 | + foreach ($users as $user_id) { |
|
6118 | + $new_user_array[]= "'".$user_id."'"; |
|
6119 | + } |
|
6120 | + $users = implode(',',$new_user_array); |
|
6121 | 6121 | $extraFieldType = EntityExtraField::USER_FIELD_TYPE; |
6122 | - // Selecting only the necessary information NOT ALL the user list |
|
6123 | - $sql = "SELECT user.user_id, v.value |
|
6122 | + // Selecting only the necessary information NOT ALL the user list |
|
6123 | + $sql = "SELECT user.user_id, v.value |
|
6124 | 6124 | FROM $table_user user |
6125 | 6125 | INNER JOIN $table_user_field_values v |
6126 | 6126 | ON (user.user_id = v.item_id) |
@@ -6131,27 +6131,27 @@ discard block |
||
6131 | 6131 | v.field_id=".intval($field_id)." AND |
6132 | 6132 | user.user_id IN ($users)"; |
6133 | 6133 | |
6134 | - $result = Database::query($sql); |
|
6135 | - while($row = Database::fetch_array($result)) { |
|
6136 | - // get option value for field type double select by id |
|
6137 | - if (!empty($row['value'])) { |
|
6138 | - if ($result_extra_field['field_type'] == |
|
6134 | + $result = Database::query($sql); |
|
6135 | + while($row = Database::fetch_array($result)) { |
|
6136 | + // get option value for field type double select by id |
|
6137 | + if (!empty($row['value'])) { |
|
6138 | + if ($result_extra_field['field_type'] == |
|
6139 | 6139 | ExtraField::FIELD_TYPE_DOUBLE_SELECT |
6140 | 6140 | ) { |
6141 | - $id_double_select = explode(';', $row['value']); |
|
6142 | - if (is_array($id_double_select)) { |
|
6143 | - $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value']; |
|
6144 | - $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value']; |
|
6145 | - $row['value'] = ($value1.';'.$value2); |
|
6146 | - } |
|
6147 | - } |
|
6148 | - } |
|
6149 | - // get other value from extra field |
|
6150 | - $return[$row['user_id']][] = $row['value']; |
|
6151 | - } |
|
6152 | - } |
|
6153 | - } |
|
6154 | - return $return; |
|
6141 | + $id_double_select = explode(';', $row['value']); |
|
6142 | + if (is_array($id_double_select)) { |
|
6143 | + $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value']; |
|
6144 | + $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value']; |
|
6145 | + $row['value'] = ($value1.';'.$value2); |
|
6146 | + } |
|
6147 | + } |
|
6148 | + } |
|
6149 | + // get other value from extra field |
|
6150 | + $return[$row['user_id']][] = $row['value']; |
|
6151 | + } |
|
6152 | + } |
|
6153 | + } |
|
6154 | + return $return; |
|
6155 | 6155 | } |
6156 | 6156 | |
6157 | 6157 | /** |
@@ -6160,18 +6160,18 @@ discard block |
||
6160 | 6160 | */ |
6161 | 6161 | public function count_student_in_course() |
6162 | 6162 | { |
6163 | - global $nbStudents; |
|
6164 | - return $nbStudents; |
|
6163 | + global $nbStudents; |
|
6164 | + return $nbStudents; |
|
6165 | 6165 | } |
6166 | 6166 | |
6167 | 6167 | public function sort_users($a, $b) |
6168 | 6168 | { |
6169 | - return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']]))); |
|
6169 | + return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']]))); |
|
6170 | 6170 | } |
6171 | 6171 | |
6172 | 6172 | public function sort_users_desc($a, $b) |
6173 | 6173 | { |
6174 | - return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']]))); |
|
6174 | + return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']]))); |
|
6175 | 6175 | } |
6176 | 6176 | |
6177 | 6177 | /** |
@@ -6180,8 +6180,8 @@ discard block |
||
6180 | 6180 | */ |
6181 | 6181 | public static function get_number_of_users() |
6182 | 6182 | { |
6183 | - global $user_ids; |
|
6184 | - return count($user_ids); |
|
6183 | + global $user_ids; |
|
6184 | + return count($user_ids); |
|
6185 | 6185 | } |
6186 | 6186 | |
6187 | 6187 | /** |
@@ -6197,37 +6197,37 @@ discard block |
||
6197 | 6197 | { |
6198 | 6198 | global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id; |
6199 | 6199 | |
6200 | - $course_code = Database::escape_string($course_code); |
|
6201 | - $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6202 | - $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
6200 | + $course_code = Database::escape_string($course_code); |
|
6201 | + $tbl_user = Database::get_main_table(TABLE_MAIN_USER); |
|
6202 | + $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
6203 | 6203 | |
6204 | - $access_url_id = api_get_current_access_url_id(); |
|
6204 | + $access_url_id = api_get_current_access_url_id(); |
|
6205 | 6205 | |
6206 | - // get all users data from a course for sortable with limit |
|
6207 | - if (is_array($user_ids)) { |
|
6208 | - $user_ids = array_map('intval', $user_ids); |
|
6209 | - $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") "; |
|
6210 | - } else { |
|
6211 | - $user_ids = intval($user_ids); |
|
6212 | - $condition_user = " WHERE user.user_id = $user_ids "; |
|
6213 | - } |
|
6206 | + // get all users data from a course for sortable with limit |
|
6207 | + if (is_array($user_ids)) { |
|
6208 | + $user_ids = array_map('intval', $user_ids); |
|
6209 | + $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") "; |
|
6210 | + } else { |
|
6211 | + $user_ids = intval($user_ids); |
|
6212 | + $condition_user = " WHERE user.user_id = $user_ids "; |
|
6213 | + } |
|
6214 | 6214 | |
6215 | - if (!empty($_GET['user_keyword'])) { |
|
6216 | - $keyword = trim(Database::escape_string($_GET['user_keyword'])); |
|
6217 | - $condition_user .= " AND ( |
|
6215 | + if (!empty($_GET['user_keyword'])) { |
|
6216 | + $keyword = trim(Database::escape_string($_GET['user_keyword'])); |
|
6217 | + $condition_user .= " AND ( |
|
6218 | 6218 | user.firstname LIKE '%".$keyword."%' OR |
6219 | 6219 | user.lastname LIKE '%".$keyword."%' OR |
6220 | 6220 | user.username LIKE '%".$keyword."%' OR |
6221 | 6221 | user.email LIKE '%".$keyword."%' |
6222 | 6222 | ) "; |
6223 | - } |
|
6223 | + } |
|
6224 | 6224 | |
6225 | 6225 | $url_table = null; |
6226 | 6226 | $url_condition = null; |
6227 | - if (api_is_multiple_url_enabled()) { |
|
6228 | - $url_table = ", ".$tbl_url_rel_user." as url_users"; |
|
6229 | - $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'"; |
|
6230 | - } |
|
6227 | + if (api_is_multiple_url_enabled()) { |
|
6228 | + $url_table = ", ".$tbl_url_rel_user." as url_users"; |
|
6229 | + $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'"; |
|
6230 | + } |
|
6231 | 6231 | |
6232 | 6232 | $invitedUsersCondition = ''; |
6233 | 6233 | |
@@ -6235,7 +6235,7 @@ discard block |
||
6235 | 6235 | $invitedUsersCondition = " AND user.status != " . INVITEE; |
6236 | 6236 | } |
6237 | 6237 | |
6238 | - $sql = "SELECT user.user_id as user_id, |
|
6238 | + $sql = "SELECT user.user_id as user_id, |
|
6239 | 6239 | user.official_code as col0, |
6240 | 6240 | user.lastname as col1, |
6241 | 6241 | user.firstname as col2, |
@@ -6243,17 +6243,17 @@ discard block |
||
6243 | 6243 | FROM $tbl_user as user $url_table |
6244 | 6244 | $condition_user $url_condition $invitedUsersCondition"; |
6245 | 6245 | |
6246 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
6247 | - $direction = 'ASC'; |
|
6248 | - } |
|
6246 | + if (!in_array($direction, array('ASC','DESC'))) { |
|
6247 | + $direction = 'ASC'; |
|
6248 | + } |
|
6249 | 6249 | |
6250 | - $column = intval($column); |
|
6250 | + $column = intval($column); |
|
6251 | 6251 | |
6252 | - $from = intval($from); |
|
6253 | - $number_of_items = intval($number_of_items); |
|
6252 | + $from = intval($from); |
|
6253 | + $number_of_items = intval($number_of_items); |
|
6254 | 6254 | |
6255 | - $sql .= " ORDER BY col$column $direction "; |
|
6256 | - $sql .= " LIMIT $from,$number_of_items"; |
|
6255 | + $sql .= " ORDER BY col$column $direction "; |
|
6256 | + $sql .= " LIMIT $from,$number_of_items"; |
|
6257 | 6257 | |
6258 | 6258 | $res = Database::query($sql); |
6259 | 6259 | $users = array(); |
@@ -6287,7 +6287,7 @@ discard block |
||
6287 | 6287 | } |
6288 | 6288 | } |
6289 | 6289 | |
6290 | - while ($user = Database::fetch_array($res, 'ASSOC')) { |
|
6290 | + while ($user = Database::fetch_array($res, 'ASSOC')) { |
|
6291 | 6291 | $courseInfo = api_get_course_info($course_code); |
6292 | 6292 | $courseId = $courseInfo['real_id']; |
6293 | 6293 | |
@@ -6318,10 +6318,10 @@ discard block |
||
6318 | 6318 | $session_id |
6319 | 6319 | ); |
6320 | 6320 | |
6321 | - if (empty($avg_student_progress)) { |
|
6321 | + if (empty($avg_student_progress)) { |
|
6322 | 6322 | $avg_student_progress = 0; |
6323 | - } |
|
6324 | - $user['average_progress'] = $avg_student_progress.'%'; |
|
6323 | + } |
|
6324 | + $user['average_progress'] = $avg_student_progress.'%'; |
|
6325 | 6325 | |
6326 | 6326 | $total_user_exercise = Tracking::get_exercise_student_progress( |
6327 | 6327 | $total_exercises, |
@@ -6341,11 +6341,11 @@ discard block |
||
6341 | 6341 | |
6342 | 6342 | $user['exercise_average_best_attempt'] = $total_user_exercise; |
6343 | 6343 | |
6344 | - if (is_numeric($avg_student_score)) { |
|
6345 | - $user['student_score'] = $avg_student_score.'%'; |
|
6346 | - } else { |
|
6347 | - $user['student_score'] = $avg_student_score; |
|
6348 | - } |
|
6344 | + if (is_numeric($avg_student_score)) { |
|
6345 | + $user['student_score'] = $avg_student_score.'%'; |
|
6346 | + } else { |
|
6347 | + $user['student_score'] = $avg_student_score; |
|
6348 | + } |
|
6349 | 6349 | |
6350 | 6350 | $user['count_assignments'] = Tracking::count_student_assignments( |
6351 | 6351 | $user['user_id'], |
@@ -6368,26 +6368,26 @@ discard block |
||
6368 | 6368 | $session_id |
6369 | 6369 | ); |
6370 | 6370 | |
6371 | - // we need to display an additional profile field |
|
6372 | - $user['additional'] = ''; |
|
6371 | + // we need to display an additional profile field |
|
6372 | + $user['additional'] = ''; |
|
6373 | 6373 | |
6374 | - if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) { |
|
6375 | - if (isset($additional_user_profile_info[$user['user_id']]) && |
|
6374 | + if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) { |
|
6375 | + if (isset($additional_user_profile_info[$user['user_id']]) && |
|
6376 | 6376 | is_array($additional_user_profile_info[$user['user_id']]) |
6377 | 6377 | ) { |
6378 | - $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]); |
|
6379 | - } |
|
6380 | - } |
|
6378 | + $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]); |
|
6379 | + } |
|
6380 | + } |
|
6381 | 6381 | |
6382 | 6382 | if (empty($session_id)) { |
6383 | 6383 | $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys; |
6384 | 6384 | } |
6385 | 6385 | |
6386 | - $user['link'] = '<center><a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'icons/22/2rightarrow.png" border="0" /></a></center>'; |
|
6386 | + $user['link'] = '<center><a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'icons/22/2rightarrow.png" border="0" /></a></center>'; |
|
6387 | 6387 | |
6388 | - // store columns in array $users |
|
6388 | + // store columns in array $users |
|
6389 | 6389 | |
6390 | - $is_western_name_order = api_is_western_name_order(); |
|
6390 | + $is_western_name_order = api_is_western_name_order(); |
|
6391 | 6391 | $user_row = array(); |
6392 | 6392 | |
6393 | 6393 | $user_row[]= $user['official_code']; //0 |
@@ -6422,21 +6422,21 @@ discard block |
||
6422 | 6422 | |
6423 | 6423 | $users[] = $user_row; |
6424 | 6424 | |
6425 | - if ($export_csv) { |
|
6426 | - if (empty($session_id)) { |
|
6425 | + if ($export_csv) { |
|
6426 | + if (empty($session_id)) { |
|
6427 | 6427 | $user_row = array_map('strip_tags', $user_row); |
6428 | - unset($user_row[14]); |
|
6429 | - unset($user_row[15]); |
|
6428 | + unset($user_row[14]); |
|
6429 | + unset($user_row[15]); |
|
6430 | 6430 | } else { |
6431 | 6431 | $user_row = array_map('strip_tags', $user_row); |
6432 | 6432 | unset($user_row[13]); |
6433 | 6433 | unset($user_row[14]); |
6434 | 6434 | } |
6435 | 6435 | |
6436 | - $csv_content[] = $user_row; |
|
6437 | - } |
|
6438 | - } |
|
6439 | - return $users; |
|
6436 | + $csv_content[] = $user_row; |
|
6437 | + } |
|
6438 | + } |
|
6439 | + return $users; |
|
6440 | 6440 | } |
6441 | 6441 | } |
6442 | 6442 | |
@@ -6454,18 +6454,18 @@ discard block |
||
6454 | 6454 | */ |
6455 | 6455 | public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0) |
6456 | 6456 | { |
6457 | - $MonthsLong = $GLOBALS['MonthsLong']; |
|
6458 | - |
|
6459 | - // protected data |
|
6460 | - $user_id = intval($user_id); |
|
6461 | - $session_id = intval($session_id); |
|
6462 | - $course_id = Database::escape_string($course_id); |
|
6463 | - |
|
6464 | - $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
6465 | - $tempView = $view; |
|
6466 | - if(substr($view,0,1) == '1') { |
|
6467 | - $new_view = substr_replace($view,'0',0,1); |
|
6468 | - echo " |
|
6457 | + $MonthsLong = $GLOBALS['MonthsLong']; |
|
6458 | + |
|
6459 | + // protected data |
|
6460 | + $user_id = intval($user_id); |
|
6461 | + $session_id = intval($session_id); |
|
6462 | + $course_id = Database::escape_string($course_id); |
|
6463 | + |
|
6464 | + $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
6465 | + $tempView = $view; |
|
6466 | + if(substr($view,0,1) == '1') { |
|
6467 | + $new_view = substr_replace($view,'0',0,1); |
|
6468 | + echo " |
|
6469 | 6469 | <tr> |
6470 | 6470 | <td valign='top'> |
6471 | 6471 | <font color='#0000FF'>- </font>" . |
@@ -6473,9 +6473,9 @@ discard block |
||
6473 | 6473 | </td> |
6474 | 6474 | </tr> |
6475 | 6475 | "; |
6476 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>"; |
|
6476 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>"; |
|
6477 | 6477 | |
6478 | - $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
6478 | + $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
6479 | 6479 | FROM $track_access_table |
6480 | 6480 | WHERE access_user_id = $user_id |
6481 | 6481 | AND c_id = $course_id |
@@ -6483,11 +6483,11 @@ discard block |
||
6483 | 6483 | GROUP BY YEAR(access_date),MONTH(access_date) |
6484 | 6484 | ORDER BY YEAR(access_date),MONTH(access_date) ASC"; |
6485 | 6485 | |
6486 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6487 | - $results = getManyResults3Col($sql); |
|
6486 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6487 | + $results = getManyResults3Col($sql); |
|
6488 | 6488 | |
6489 | - echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6490 | - echo "<tr> |
|
6489 | + echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6490 | + echo "<tr> |
|
6491 | 6491 | <td class='secLine'> |
6492 | 6492 | ".get_lang('LoginsTitleMonthColumn')." |
6493 | 6493 | </td> |
@@ -6495,36 +6495,36 @@ discard block |
||
6495 | 6495 | ".get_lang('LoginsTitleCountColumn')." |
6496 | 6496 | </td> |
6497 | 6497 | </tr>"; |
6498 | - $total = 0; |
|
6499 | - if (is_array($results)) { |
|
6500 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
6501 | - echo "<tr>"; |
|
6502 | - echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>"; |
|
6503 | - echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>"; |
|
6504 | - echo"</tr>"; |
|
6505 | - $total = $total + $results[$j][1]; |
|
6506 | - } |
|
6507 | - echo "<tr>"; |
|
6508 | - echo "<td>".get_lang('Total')."</td>"; |
|
6509 | - echo "<td align='right' class='content'>".$total."</td>"; |
|
6510 | - echo"</tr>"; |
|
6511 | - } else { |
|
6512 | - echo "<tr>"; |
|
6513 | - echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>"; |
|
6514 | - echo"</tr>"; |
|
6515 | - } |
|
6516 | - echo "</table>"; |
|
6517 | - echo "</td></tr>"; |
|
6518 | - } else { |
|
6519 | - $new_view = substr_replace($view,'1',0,1); |
|
6520 | - echo " |
|
6498 | + $total = 0; |
|
6499 | + if (is_array($results)) { |
|
6500 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
6501 | + echo "<tr>"; |
|
6502 | + echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>"; |
|
6503 | + echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>"; |
|
6504 | + echo"</tr>"; |
|
6505 | + $total = $total + $results[$j][1]; |
|
6506 | + } |
|
6507 | + echo "<tr>"; |
|
6508 | + echo "<td>".get_lang('Total')."</td>"; |
|
6509 | + echo "<td align='right' class='content'>".$total."</td>"; |
|
6510 | + echo"</tr>"; |
|
6511 | + } else { |
|
6512 | + echo "<tr>"; |
|
6513 | + echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>"; |
|
6514 | + echo"</tr>"; |
|
6515 | + } |
|
6516 | + echo "</table>"; |
|
6517 | + echo "</td></tr>"; |
|
6518 | + } else { |
|
6519 | + $new_view = substr_replace($view,'1',0,1); |
|
6520 | + echo " |
|
6521 | 6521 | <tr> |
6522 | 6522 | <td valign='top'> |
6523 | 6523 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a> |
6524 | 6524 | </td> |
6525 | 6525 | </tr> |
6526 | 6526 | "; |
6527 | - } |
|
6527 | + } |
|
6528 | 6528 | } |
6529 | 6529 | |
6530 | 6530 | /** |
@@ -6537,38 +6537,38 @@ discard block |
||
6537 | 6537 | */ |
6538 | 6538 | public function display_exercise_tracking_info($view, $user_id, $courseCode) |
6539 | 6539 | { |
6540 | - global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong; |
|
6540 | + global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong; |
|
6541 | 6541 | $courseId = api_get_course_int_id($courseCode); |
6542 | - if(substr($view,1,1) == '1') { |
|
6543 | - $new_view = substr_replace($view,'0',1,1); |
|
6544 | - echo "<tr> |
|
6542 | + if(substr($view,1,1) == '1') { |
|
6543 | + $new_view = substr_replace($view,'0',1,1); |
|
6544 | + echo "<tr> |
|
6545 | 6545 | <td valign='top'> |
6546 | 6546 | <font color='#0000FF'>- </font><b>".get_lang('ExercicesResults')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>] |
6547 | 6547 | </td> |
6548 | 6548 | </tr>"; |
6549 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />"; |
|
6549 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />"; |
|
6550 | 6550 | |
6551 | - $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6551 | + $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6552 | 6552 | FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te |
6553 | 6553 | WHERE te.c_id = $courseId |
6554 | 6554 | AND te.exe_user_id = ".intval($user_id)." |
6555 | 6555 | AND te.exe_exo_id = ce.id |
6556 | 6556 | ORDER BY ce.title ASC, te.exe_date ASC"; |
6557 | 6557 | |
6558 | - $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6558 | + $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6559 | 6559 | FROM $TBL_TRACK_HOTPOTATOES AS te |
6560 | 6560 | WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId |
6561 | 6561 | ORDER BY te.c_id ASC, te.exe_date ASC"; |
6562 | 6562 | |
6563 | - $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
6563 | + $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
6564 | 6564 | |
6565 | - $NoTestRes = 0; |
|
6566 | - $NoHPTestRes = 0; |
|
6565 | + $NoTestRes = 0; |
|
6566 | + $NoHPTestRes = 0; |
|
6567 | 6567 | |
6568 | - echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n"; |
|
6569 | - $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
6570 | - echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n"; |
|
6571 | - echo " |
|
6568 | + echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n"; |
|
6569 | + $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
6570 | + echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n"; |
|
6571 | + echo " |
|
6572 | 6572 | <tr bgcolor='#E6E6E6'> |
6573 | 6573 | <td> |
6574 | 6574 | ".get_lang('ExercicesTitleExerciceColumn')." |
@@ -6581,28 +6581,28 @@ discard block |
||
6581 | 6581 | </td> |
6582 | 6582 | </tr>"; |
6583 | 6583 | |
6584 | - if (is_array($results)) { |
|
6585 | - for($i = 0; $i < sizeof($results); $i++) { |
|
6586 | - $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
6587 | - echo "<tr>\n"; |
|
6588 | - echo "<td class='content'>".$results[$i][0]."</td>\n"; |
|
6589 | - echo "<td class='content'>".$display_date."</td>\n"; |
|
6590 | - echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n"; |
|
6591 | - echo "</tr>\n"; |
|
6592 | - } |
|
6593 | - } else { |
|
6594 | - // istvan begin |
|
6595 | - $NoTestRes = 1; |
|
6596 | - } |
|
6597 | - |
|
6598 | - // The Result of Tests |
|
6599 | - if (is_array($hpresults)) { |
|
6600 | - for($i = 0; $i < sizeof($hpresults); $i++) { |
|
6601 | - $title = GetQuizName($hpresults[$i][0],''); |
|
6602 | - if ($title == '') |
|
6603 | - $title = basename($hpresults[$i][0]); |
|
6604 | - $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
6605 | - ?> |
|
6584 | + if (is_array($results)) { |
|
6585 | + for($i = 0; $i < sizeof($results); $i++) { |
|
6586 | + $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
6587 | + echo "<tr>\n"; |
|
6588 | + echo "<td class='content'>".$results[$i][0]."</td>\n"; |
|
6589 | + echo "<td class='content'>".$display_date."</td>\n"; |
|
6590 | + echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n"; |
|
6591 | + echo "</tr>\n"; |
|
6592 | + } |
|
6593 | + } else { |
|
6594 | + // istvan begin |
|
6595 | + $NoTestRes = 1; |
|
6596 | + } |
|
6597 | + |
|
6598 | + // The Result of Tests |
|
6599 | + if (is_array($hpresults)) { |
|
6600 | + for($i = 0; $i < sizeof($hpresults); $i++) { |
|
6601 | + $title = GetQuizName($hpresults[$i][0],''); |
|
6602 | + if ($title == '') |
|
6603 | + $title = basename($hpresults[$i][0]); |
|
6604 | + $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
6605 | + ?> |
|
6606 | 6606 | <tr> |
6607 | 6607 | <td class="content"><?php echo $title; ?></td> |
6608 | 6608 | <td class="content" align="center"><?php echo $display_date; ?></td> |
@@ -6612,26 +6612,26 @@ discard block |
||
6612 | 6612 | |
6613 | 6613 | <?php |
6614 | 6614 | } |
6615 | - } else { |
|
6616 | - $NoHPTestRes = 1; |
|
6617 | - } |
|
6618 | - |
|
6619 | - if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
6620 | - echo "<tr>\n"; |
|
6621 | - echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n"; |
|
6622 | - echo "</tr>\n"; |
|
6623 | - } |
|
6624 | - echo "</table>"; |
|
6625 | - echo "</td>\n</tr>\n"; |
|
6626 | - } else { |
|
6627 | - $new_view = substr_replace($view,'1',1,1); |
|
6628 | - echo " |
|
6615 | + } else { |
|
6616 | + $NoHPTestRes = 1; |
|
6617 | + } |
|
6618 | + |
|
6619 | + if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
6620 | + echo "<tr>\n"; |
|
6621 | + echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n"; |
|
6622 | + echo "</tr>\n"; |
|
6623 | + } |
|
6624 | + echo "</table>"; |
|
6625 | + echo "</td>\n</tr>\n"; |
|
6626 | + } else { |
|
6627 | + $new_view = substr_replace($view,'1',1,1); |
|
6628 | + echo " |
|
6629 | 6629 | <tr> |
6630 | 6630 | <td valign='top'> |
6631 | 6631 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a> |
6632 | 6632 | </td> |
6633 | 6633 | </tr>"; |
6634 | - } |
|
6634 | + } |
|
6635 | 6635 | } |
6636 | 6636 | |
6637 | 6637 | /** |
@@ -6640,27 +6640,27 @@ discard block |
||
6640 | 6640 | */ |
6641 | 6641 | public function display_student_publications_tracking_info($view, $user_id, $course_id) |
6642 | 6642 | { |
6643 | - global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
6643 | + global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
6644 | 6644 | $_course = api_get_course_info_by_id($course_id); |
6645 | 6645 | |
6646 | - if (substr($view,2,1) == '1') { |
|
6647 | - $new_view = substr_replace($view,'0',2,1); |
|
6648 | - echo "<tr> |
|
6646 | + if (substr($view,2,1) == '1') { |
|
6647 | + $new_view = substr_replace($view,'0',2,1); |
|
6648 | + echo "<tr> |
|
6649 | 6649 | <td valign='top'> |
6650 | 6650 | <font color='#0000FF'>- </font><b>".get_lang('WorkUploads')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>] |
6651 | 6651 | </td> |
6652 | 6652 | </tr>"; |
6653 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>"; |
|
6654 | - $sql = "SELECT u.upload_date, w.title, w.author,w.url |
|
6653 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>"; |
|
6654 | + $sql = "SELECT u.upload_date, w.title, w.author,w.url |
|
6655 | 6655 | FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w |
6656 | 6656 | WHERE u.upload_work_id = w.id |
6657 | 6657 | AND u.upload_user_id = '".intval($user_id)."' |
6658 | 6658 | AND u.c_id = '".intval($course_id)."' |
6659 | 6659 | ORDER BY u.upload_date DESC"; |
6660 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6661 | - $results = StatsUtils::getManyResultsXCol($sql,4); |
|
6662 | - echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6663 | - echo "<tr> |
|
6660 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6661 | + $results = StatsUtils::getManyResultsXCol($sql,4); |
|
6662 | + echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6663 | + echo "<tr> |
|
6664 | 6664 | <td class='secLine' width='40%'> |
6665 | 6665 | ".get_lang('WorkTitle')." |
6666 | 6666 | </td> |
@@ -6671,35 +6671,35 @@ discard block |
||
6671 | 6671 | ".get_lang('Date')." |
6672 | 6672 | </td> |
6673 | 6673 | </tr>"; |
6674 | - if (is_array($results)) { |
|
6675 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
6676 | - $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
6677 | - $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
6678 | - echo "<tr>"; |
|
6679 | - echo "<td class='content'>" |
|
6680 | - ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>" |
|
6681 | - ."</td>"; |
|
6682 | - echo "<td class='content'>".$results[$j][2]."</td>"; |
|
6683 | - echo "<td class='content'>".$beautifulDate."</td>"; |
|
6684 | - echo"</tr>"; |
|
6685 | - } |
|
6686 | - } else { |
|
6687 | - echo "<tr>"; |
|
6688 | - echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>"; |
|
6689 | - echo"</tr>"; |
|
6690 | - } |
|
6691 | - echo "</table>"; |
|
6692 | - echo "</td></tr>"; |
|
6693 | - } else { |
|
6694 | - $new_view = substr_replace($view,'1',2,1); |
|
6695 | - echo " |
|
6674 | + if (is_array($results)) { |
|
6675 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
6676 | + $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
6677 | + $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
6678 | + echo "<tr>"; |
|
6679 | + echo "<td class='content'>" |
|
6680 | + ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>" |
|
6681 | + ."</td>"; |
|
6682 | + echo "<td class='content'>".$results[$j][2]."</td>"; |
|
6683 | + echo "<td class='content'>".$beautifulDate."</td>"; |
|
6684 | + echo"</tr>"; |
|
6685 | + } |
|
6686 | + } else { |
|
6687 | + echo "<tr>"; |
|
6688 | + echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>"; |
|
6689 | + echo"</tr>"; |
|
6690 | + } |
|
6691 | + echo "</table>"; |
|
6692 | + echo "</td></tr>"; |
|
6693 | + } else { |
|
6694 | + $new_view = substr_replace($view,'1',2,1); |
|
6695 | + echo " |
|
6696 | 6696 | <tr> |
6697 | 6697 | <td valign='top'> |
6698 | 6698 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a> |
6699 | 6699 | </td> |
6700 | 6700 | </tr> |
6701 | 6701 | "; |
6702 | - } |
|
6702 | + } |
|
6703 | 6703 | } |
6704 | 6704 | |
6705 | 6705 | /** |
@@ -6708,55 +6708,55 @@ discard block |
||
6708 | 6708 | */ |
6709 | 6709 | public function display_links_tracking_info($view, $user_id, $courseCode) |
6710 | 6710 | { |
6711 | - global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
6711 | + global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
6712 | 6712 | $courseId = api_get_course_int_id($courseCode); |
6713 | - if (substr($view,3,1) == '1') { |
|
6714 | - $new_view = substr_replace($view,'0',3,1); |
|
6715 | - echo " |
|
6713 | + if (substr($view,3,1) == '1') { |
|
6714 | + $new_view = substr_replace($view,'0',3,1); |
|
6715 | + echo " |
|
6716 | 6716 | <tr> |
6717 | 6717 | <td valign='top'> |
6718 | 6718 | <font color='#0000FF'>- </font><b>".get_lang('LinksAccess')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>] |
6719 | 6719 | </td> |
6720 | 6720 | </tr> |
6721 | 6721 | "; |
6722 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>"; |
|
6723 | - $sql = "SELECT cl.title, cl.url |
|
6722 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>"; |
|
6723 | + $sql = "SELECT cl.title, cl.url |
|
6724 | 6724 | FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl |
6725 | 6725 | WHERE sl.links_link_id = cl.id |
6726 | 6726 | AND sl.c_id = $courseId |
6727 | 6727 | AND sl.links_user_id = ".intval($user_id)." |
6728 | 6728 | GROUP BY cl.title, cl.url"; |
6729 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6730 | - $results = StatsUtils::getManyResults2Col($sql); |
|
6731 | - echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6732 | - echo "<tr> |
|
6729 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6730 | + $results = StatsUtils::getManyResults2Col($sql); |
|
6731 | + echo "<table cellpadding='2' cellspacing='1' border='0' align=center>"; |
|
6732 | + echo "<tr> |
|
6733 | 6733 | <td class='secLine'> |
6734 | 6734 | ".get_lang('LinksTitleLinkColumn')." |
6735 | 6735 | </td> |
6736 | 6736 | </tr>"; |
6737 | - if (is_array($results)) { |
|
6738 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
6739 | - echo "<tr>"; |
|
6740 | - echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>"; |
|
6741 | - echo"</tr>"; |
|
6742 | - } |
|
6743 | - } else { |
|
6744 | - echo "<tr>"; |
|
6745 | - echo "<td ><center>".get_lang('NoResult')."</center></td>"; |
|
6746 | - echo"</tr>"; |
|
6747 | - } |
|
6748 | - echo "</table>"; |
|
6749 | - echo "</td></tr>"; |
|
6750 | - } else { |
|
6751 | - $new_view = substr_replace($view,'1',3,1); |
|
6752 | - echo " |
|
6737 | + if (is_array($results)) { |
|
6738 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
6739 | + echo "<tr>"; |
|
6740 | + echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>"; |
|
6741 | + echo"</tr>"; |
|
6742 | + } |
|
6743 | + } else { |
|
6744 | + echo "<tr>"; |
|
6745 | + echo "<td ><center>".get_lang('NoResult')."</center></td>"; |
|
6746 | + echo"</tr>"; |
|
6747 | + } |
|
6748 | + echo "</table>"; |
|
6749 | + echo "</td></tr>"; |
|
6750 | + } else { |
|
6751 | + $new_view = substr_replace($view,'1',3,1); |
|
6752 | + echo " |
|
6753 | 6753 | <tr> |
6754 | 6754 | <td valign='top'> |
6755 | 6755 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a> |
6756 | 6756 | </td> |
6757 | 6757 | </tr> |
6758 | 6758 | "; |
6759 | - } |
|
6759 | + } |
|
6760 | 6760 | } |
6761 | 6761 | |
6762 | 6762 | /** |
@@ -6769,61 +6769,61 @@ discard block |
||
6769 | 6769 | */ |
6770 | 6770 | public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0) |
6771 | 6771 | { |
6772 | - // protect data |
|
6772 | + // protect data |
|
6773 | 6773 | $user_id = intval($user_id); |
6774 | 6774 | $courseId = api_get_course_int_id($course_code); |
6775 | - $session_id = intval($session_id); |
|
6775 | + $session_id = intval($session_id); |
|
6776 | 6776 | |
6777 | - $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
6778 | - if(substr($view,4,1) == '1') { |
|
6779 | - $new_view = substr_replace($view,'0',4,1); |
|
6780 | - echo " |
|
6777 | + $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
6778 | + if(substr($view,4,1) == '1') { |
|
6779 | + $new_view = substr_replace($view,'0',4,1); |
|
6780 | + echo " |
|
6781 | 6781 | <tr> |
6782 | 6782 | <td valign='top'> |
6783 | 6783 | <font color='#0000FF'>- </font><b>".get_lang('DocumentsAccess')."</b> [<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>] [<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>] |
6784 | 6784 | </td> |
6785 | 6785 | </tr> |
6786 | 6786 | "; |
6787 | - echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>"; |
|
6787 | + echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>"; |
|
6788 | 6788 | |
6789 | - $sql = "SELECT down_doc_path |
|
6789 | + $sql = "SELECT down_doc_path |
|
6790 | 6790 | FROM $downloads_table |
6791 | 6791 | WHERE c_id = $courseId |
6792 | 6792 | AND down_user_id = $user_id |
6793 | 6793 | AND down_session_id = $session_id |
6794 | 6794 | GROUP BY down_doc_path"; |
6795 | 6795 | |
6796 | - echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6797 | - $results = StatsUtils::getManyResults1Col($sql); |
|
6798 | - echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>"; |
|
6799 | - echo "<tr> |
|
6796 | + echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>"; |
|
6797 | + $results = StatsUtils::getManyResults1Col($sql); |
|
6798 | + echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>"; |
|
6799 | + echo "<tr> |
|
6800 | 6800 | <td class='secLine'> |
6801 | 6801 | ".get_lang('DocumentsTitleDocumentColumn')." |
6802 | 6802 | </td> |
6803 | 6803 | </tr>"; |
6804 | - if (is_array($results)) { |
|
6805 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
6806 | - echo "<tr>"; |
|
6807 | - echo "<td class='content'>".$results[$j]."</td>"; |
|
6808 | - echo"</tr>"; |
|
6809 | - } |
|
6810 | - } else { |
|
6811 | - echo "<tr>"; |
|
6812 | - echo "<td><center>".get_lang('NoResult')."</center></td>"; |
|
6813 | - echo"</tr>"; |
|
6814 | - } |
|
6815 | - echo "</table>"; |
|
6816 | - echo "</td></tr>"; |
|
6817 | - } else { |
|
6818 | - $new_view = substr_replace($view,'1',4,1); |
|
6819 | - echo " |
|
6804 | + if (is_array($results)) { |
|
6805 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
6806 | + echo "<tr>"; |
|
6807 | + echo "<td class='content'>".$results[$j]."</td>"; |
|
6808 | + echo"</tr>"; |
|
6809 | + } |
|
6810 | + } else { |
|
6811 | + echo "<tr>"; |
|
6812 | + echo "<td><center>".get_lang('NoResult')."</center></td>"; |
|
6813 | + echo"</tr>"; |
|
6814 | + } |
|
6815 | + echo "</table>"; |
|
6816 | + echo "</td></tr>"; |
|
6817 | + } else { |
|
6818 | + $new_view = substr_replace($view,'1',4,1); |
|
6819 | + echo " |
|
6820 | 6820 | <tr> |
6821 | 6821 | <td valign='top'> |
6822 | 6822 | +<font color='#0000FF'> </font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a> |
6823 | 6823 | </td> |
6824 | 6824 | </tr> |
6825 | 6825 | "; |
6826 | - } |
|
6826 | + } |
|
6827 | 6827 | } |
6828 | 6828 | |
6829 | 6829 | /** |
@@ -6880,43 +6880,43 @@ discard block |
||
6880 | 6880 | */ |
6881 | 6881 | public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0) |
6882 | 6882 | { |
6883 | - $MonthsLong = $GLOBALS['MonthsLong']; |
|
6884 | - $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
6885 | - |
|
6886 | - // protected data |
|
6887 | - $user_id = intval($user_id); |
|
6888 | - $session_id = intval($session_id); |
|
6889 | - $course_id = intval($course_id); |
|
6890 | - |
|
6891 | - $tempView = $view; |
|
6892 | - if (substr($view,0,1) == '1') { |
|
6893 | - $new_view = substr_replace($view,'0',0,1); |
|
6894 | - $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails'); |
|
6895 | - $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
6883 | + $MonthsLong = $GLOBALS['MonthsLong']; |
|
6884 | + $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS); |
|
6885 | + |
|
6886 | + // protected data |
|
6887 | + $user_id = intval($user_id); |
|
6888 | + $session_id = intval($session_id); |
|
6889 | + $course_id = intval($course_id); |
|
6890 | + |
|
6891 | + $tempView = $view; |
|
6892 | + if (substr($view,0,1) == '1') { |
|
6893 | + $new_view = substr_replace($view,'0',0,1); |
|
6894 | + $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails'); |
|
6895 | + $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date) |
|
6896 | 6896 | FROM $track_access_table |
6897 | 6897 | WHERE access_user_id = $user_id |
6898 | 6898 | AND c_id = $course_id |
6899 | 6899 | AND access_session_id = $session_id |
6900 | 6900 | GROUP BY YEAR(access_date),MONTH(access_date) |
6901 | 6901 | ORDER BY YEAR(access_date),MONTH(access_date) ASC"; |
6902 | - //$results = getManyResults2Col($sql); |
|
6903 | - $results = getManyResults3Col($sql); |
|
6904 | - $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n"; |
|
6905 | - $line=''; |
|
6906 | - $total = 0; |
|
6907 | - if (is_array($results)) { |
|
6908 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
6909 | - $line .= $results[$j][0].';'.$results[$j][1]."\n"; |
|
6910 | - $total = $total + $results[$j][1]; |
|
6911 | - } |
|
6912 | - $line .= get_lang('Total').";".$total."\n"; |
|
6913 | - } else { |
|
6914 | - $line= get_lang('NoResult')."</center></td>"; |
|
6915 | - } |
|
6916 | - } else { |
|
6917 | - $new_view = substr_replace($view,'1',0,1); |
|
6918 | - } |
|
6919 | - return array($title_line, $line); |
|
6902 | + //$results = getManyResults2Col($sql); |
|
6903 | + $results = getManyResults3Col($sql); |
|
6904 | + $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n"; |
|
6905 | + $line=''; |
|
6906 | + $total = 0; |
|
6907 | + if (is_array($results)) { |
|
6908 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
6909 | + $line .= $results[$j][0].';'.$results[$j][1]."\n"; |
|
6910 | + $total = $total + $results[$j][1]; |
|
6911 | + } |
|
6912 | + $line .= get_lang('Total').";".$total."\n"; |
|
6913 | + } else { |
|
6914 | + $line= get_lang('NoResult')."</center></td>"; |
|
6915 | + } |
|
6916 | + } else { |
|
6917 | + $new_view = substr_replace($view,'1',0,1); |
|
6918 | + } |
|
6919 | + return array($title_line, $line); |
|
6920 | 6920 | } |
6921 | 6921 | |
6922 | 6922 | /** |
@@ -6929,67 +6929,67 @@ discard block |
||
6929 | 6929 | */ |
6930 | 6930 | public function display_exercise_tracking_info($view, $userId, $courseCode) |
6931 | 6931 | { |
6932 | - global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong; |
|
6932 | + global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong; |
|
6933 | 6933 | $courseId = api_get_course_int_id($courseCode); |
6934 | 6934 | $userId = intval($userId); |
6935 | - if (substr($view,1,1) == '1') { |
|
6936 | - $new_view = substr_replace($view,'0',1,1); |
|
6937 | - $title[1] = get_lang('ExercicesDetails'); |
|
6938 | - $line = ''; |
|
6939 | - $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6935 | + if (substr($view,1,1) == '1') { |
|
6936 | + $new_view = substr_replace($view,'0',1,1); |
|
6937 | + $title[1] = get_lang('ExercicesDetails'); |
|
6938 | + $line = ''; |
|
6939 | + $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6940 | 6940 | FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te |
6941 | 6941 | WHERE te.c_id = $courseId |
6942 | 6942 | AND te.exe_user_id = $userId |
6943 | 6943 | AND te.exe_exo_id = ce.id |
6944 | 6944 | ORDER BY ce.title ASC, te.exe_date ASC"; |
6945 | 6945 | |
6946 | - $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6946 | + $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date) |
|
6947 | 6947 | FROM $TABLETRACK_HOTPOTATOES AS te |
6948 | 6948 | WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId |
6949 | 6949 | ORDER BY te.c_id ASC, te.exe_date ASC"; |
6950 | 6950 | |
6951 | - $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
6951 | + $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4); |
|
6952 | 6952 | |
6953 | - $NoTestRes = 0; |
|
6954 | - $NoHPTestRes = 0; |
|
6953 | + $NoTestRes = 0; |
|
6954 | + $NoHPTestRes = 0; |
|
6955 | 6955 | |
6956 | - $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
6957 | - $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n"; |
|
6956 | + $results = StatsUtils::getManyResultsXCol($sql, 4); |
|
6957 | + $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n"; |
|
6958 | 6958 | |
6959 | - if (is_array($results)) { |
|
6960 | - for($i = 0; $i < sizeof($results); $i++) |
|
6961 | - { |
|
6962 | - $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
6963 | - $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n"; |
|
6964 | - } |
|
6965 | - } else { |
|
6959 | + if (is_array($results)) { |
|
6960 | + for($i = 0; $i < sizeof($results); $i++) |
|
6961 | + { |
|
6962 | + $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get()); |
|
6963 | + $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n"; |
|
6964 | + } |
|
6965 | + } else { |
|
6966 | 6966 | // istvan begin |
6967 | - $NoTestRes = 1; |
|
6968 | - } |
|
6969 | - |
|
6970 | - // The Result of Tests |
|
6971 | - if (is_array($hpresults)) { |
|
6972 | - for($i = 0; $i < sizeof($hpresults); $i++) { |
|
6973 | - $title = GetQuizName($hpresults[$i][0],''); |
|
6974 | - |
|
6975 | - if ($title == '') |
|
6976 | - $title = basename($hpresults[$i][0]); |
|
6977 | - |
|
6978 | - $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
6979 | - |
|
6980 | - $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n"; |
|
6981 | - } |
|
6982 | - } else { |
|
6983 | - $NoHPTestRes = 1; |
|
6984 | - } |
|
6985 | - |
|
6986 | - if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
6987 | - $line=get_lang('NoResult'); |
|
6988 | - } |
|
6989 | - } else { |
|
6990 | - $new_view = substr_replace($view,'1',1,1); |
|
6991 | - } |
|
6992 | - return array($title_line, $line); |
|
6967 | + $NoTestRes = 1; |
|
6968 | + } |
|
6969 | + |
|
6970 | + // The Result of Tests |
|
6971 | + if (is_array($hpresults)) { |
|
6972 | + for($i = 0; $i < sizeof($hpresults); $i++) { |
|
6973 | + $title = GetQuizName($hpresults[$i][0],''); |
|
6974 | + |
|
6975 | + if ($title == '') |
|
6976 | + $title = basename($hpresults[$i][0]); |
|
6977 | + |
|
6978 | + $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get()); |
|
6979 | + |
|
6980 | + $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n"; |
|
6981 | + } |
|
6982 | + } else { |
|
6983 | + $NoHPTestRes = 1; |
|
6984 | + } |
|
6985 | + |
|
6986 | + if ($NoTestRes == 1 && $NoHPTestRes == 1) { |
|
6987 | + $line=get_lang('NoResult'); |
|
6988 | + } |
|
6989 | + } else { |
|
6990 | + $new_view = substr_replace($view,'1',1,1); |
|
6991 | + } |
|
6992 | + return array($title_line, $line); |
|
6993 | 6993 | } |
6994 | 6994 | |
6995 | 6995 | /** |
@@ -6998,37 +6998,37 @@ discard block |
||
6998 | 6998 | */ |
6999 | 6999 | public function display_student_publications_tracking_info($view, $user_id, $course_id) |
7000 | 7000 | { |
7001 | - global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
7001 | + global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK; |
|
7002 | 7002 | $_course = api_get_course_info(); |
7003 | 7003 | $user_id = intval($user_id); |
7004 | 7004 | $course_id = intval($course_id); |
7005 | 7005 | |
7006 | - if (substr($view,2,1) == '1') { |
|
7007 | - $sql = "SELECT u.upload_date, w.title, w.author, w.url |
|
7006 | + if (substr($view,2,1) == '1') { |
|
7007 | + $sql = "SELECT u.upload_date, w.title, w.author, w.url |
|
7008 | 7008 | FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w |
7009 | 7009 | WHERE |
7010 | 7010 | u.upload_work_id = w.id AND |
7011 | 7011 | u.upload_user_id = '$user_id' AND |
7012 | 7012 | u.c_id = '$course_id' |
7013 | 7013 | ORDER BY u.upload_date DESC"; |
7014 | - $results = StatsUtils::getManyResultsXCol($sql,4); |
|
7015 | - |
|
7016 | - $title[1]=get_lang('WorksDetails'); |
|
7017 | - $line=''; |
|
7018 | - $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n"; |
|
7019 | - |
|
7020 | - if (is_array($results)) { |
|
7021 | - for($j = 0 ; $j < count($results) ; $j++) { |
|
7022 | - $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
7023 | - $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
7024 | - $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n"; |
|
7025 | - } |
|
7026 | - |
|
7027 | - } else { |
|
7028 | - $line= get_lang('NoResult'); |
|
7029 | - } |
|
7030 | - } |
|
7031 | - return array($title_line, $line); |
|
7014 | + $results = StatsUtils::getManyResultsXCol($sql,4); |
|
7015 | + |
|
7016 | + $title[1]=get_lang('WorksDetails'); |
|
7017 | + $line=''; |
|
7018 | + $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n"; |
|
7019 | + |
|
7020 | + if (is_array($results)) { |
|
7021 | + for($j = 0 ; $j < count($results) ; $j++) { |
|
7022 | + $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3]; |
|
7023 | + $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get()); |
|
7024 | + $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n"; |
|
7025 | + } |
|
7026 | + |
|
7027 | + } else { |
|
7028 | + $line= get_lang('NoResult'); |
|
7029 | + } |
|
7030 | + } |
|
7031 | + return array($title_line, $line); |
|
7032 | 7032 | } |
7033 | 7033 | |
7034 | 7034 | /** |
@@ -7037,32 +7037,32 @@ discard block |
||
7037 | 7037 | */ |
7038 | 7038 | public function display_links_tracking_info($view, $userId, $courseCode) |
7039 | 7039 | { |
7040 | - global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
7040 | + global $TABLETRACK_LINKS, $TABLECOURSE_LINKS; |
|
7041 | 7041 | $courseId = api_get_course_int_id($courseCode); |
7042 | 7042 | $userId = intval($userId); |
7043 | 7043 | $line = null; |
7044 | - if (substr($view,3,1) == '1') { |
|
7045 | - $new_view = substr_replace($view,'0',3,1); |
|
7046 | - $title[1]=get_lang('LinksDetails'); |
|
7047 | - $sql = "SELECT cl.title, cl.url |
|
7044 | + if (substr($view,3,1) == '1') { |
|
7045 | + $new_view = substr_replace($view,'0',3,1); |
|
7046 | + $title[1]=get_lang('LinksDetails'); |
|
7047 | + $sql = "SELECT cl.title, cl.url |
|
7048 | 7048 | FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl |
7049 | 7049 | WHERE sl.links_link_id = cl.id |
7050 | 7050 | AND sl.c_id = $courseId |
7051 | 7051 | AND sl.links_user_id = $userId |
7052 | 7052 | GROUP BY cl.title, cl.url"; |
7053 | - $results = StatsUtils::getManyResults2Col($sql); |
|
7054 | - $title_line= get_lang('LinksTitleLinkColumn')."\n"; |
|
7055 | - if (is_array($results)) { |
|
7056 | - for ($j = 0 ; $j < count($results) ; $j++) { |
|
7057 | - $line .= $results[$j][0]."\n"; |
|
7058 | - } |
|
7059 | - } else { |
|
7060 | - $line=get_lang('NoResult'); |
|
7061 | - } |
|
7062 | - } else { |
|
7063 | - $new_view = substr_replace($view,'1',3,1); |
|
7064 | - } |
|
7065 | - return array($title_line, $line); |
|
7053 | + $results = StatsUtils::getManyResults2Col($sql); |
|
7054 | + $title_line= get_lang('LinksTitleLinkColumn')."\n"; |
|
7055 | + if (is_array($results)) { |
|
7056 | + for ($j = 0 ; $j < count($results) ; $j++) { |
|
7057 | + $line .= $results[$j][0]."\n"; |
|
7058 | + } |
|
7059 | + } else { |
|
7060 | + $line=get_lang('NoResult'); |
|
7061 | + } |
|
7062 | + } else { |
|
7063 | + $new_view = substr_replace($view,'1',3,1); |
|
7064 | + } |
|
7065 | + return array($title_line, $line); |
|
7066 | 7066 | } |
7067 | 7067 | |
7068 | 7068 | /** |
@@ -7075,38 +7075,38 @@ discard block |
||
7075 | 7075 | */ |
7076 | 7076 | public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0) |
7077 | 7077 | { |
7078 | - // protect data |
|
7079 | - $user_id = intval($user_id); |
|
7078 | + // protect data |
|
7079 | + $user_id = intval($user_id); |
|
7080 | 7080 | $courseId = api_get_course_int_id($courseCode); |
7081 | - $session_id = intval($session_id); |
|
7081 | + $session_id = intval($session_id); |
|
7082 | 7082 | |
7083 | - $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
7083 | + $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS); |
|
7084 | 7084 | |
7085 | - if (substr($view,4,1) == '1') { |
|
7086 | - $new_view = substr_replace($view,'0',4,1); |
|
7087 | - $title[1]= get_lang('DocumentsDetails'); |
|
7085 | + if (substr($view,4,1) == '1') { |
|
7086 | + $new_view = substr_replace($view,'0',4,1); |
|
7087 | + $title[1]= get_lang('DocumentsDetails'); |
|
7088 | 7088 | |
7089 | - $sql = "SELECT down_doc_path |
|
7089 | + $sql = "SELECT down_doc_path |
|
7090 | 7090 | FROM $downloads_table |
7091 | 7091 | WHERE c_id = $courseId |
7092 | 7092 | AND down_user_id = $user_id |
7093 | 7093 | AND down_session_id = $session_id |
7094 | 7094 | GROUP BY down_doc_path"; |
7095 | 7095 | |
7096 | - $results = StatsUtils::getManyResults1Col($sql); |
|
7097 | - $title_line = get_lang('DocumentsTitleDocumentColumn')."\n"; |
|
7096 | + $results = StatsUtils::getManyResults1Col($sql); |
|
7097 | + $title_line = get_lang('DocumentsTitleDocumentColumn')."\n"; |
|
7098 | 7098 | $line = null; |
7099 | - if (is_array($results)) { |
|
7100 | - for ($j = 0 ; $j < count($results) ; $j++) { |
|
7101 | - $line .= $results[$j]."\n"; |
|
7102 | - } |
|
7103 | - } else { |
|
7104 | - $line = get_lang('NoResult'); |
|
7105 | - } |
|
7106 | - } else { |
|
7107 | - $new_view = substr_replace($view,'1',4,1); |
|
7108 | - } |
|
7109 | - return array($title_line, $line); |
|
7099 | + if (is_array($results)) { |
|
7100 | + for ($j = 0 ; $j < count($results) ; $j++) { |
|
7101 | + $line .= $results[$j]."\n"; |
|
7102 | + } |
|
7103 | + } else { |
|
7104 | + $line = get_lang('NoResult'); |
|
7105 | + } |
|
7106 | + } else { |
|
7107 | + $new_view = substr_replace($view,'1',4,1); |
|
7108 | + } |
|
7109 | + return array($title_line, $line); |
|
7110 | 7110 | } |
7111 | 7111 | |
7112 | 7112 | /** |
@@ -6,47 +6,47 @@ discard block |
||
6 | 6 | */ |
7 | 7 | class AddCourseToSession |
8 | 8 | { |
9 | - /** |
|
10 | - * Searches a course, given a search string and a type of search box |
|
11 | - * @param string $needle Search string |
|
12 | - * @param string $type Type of search box ('single' or anything else) |
|
13 | - * @return string XajaxResponse |
|
14 | - * @assert ('abc', 'single') !== null |
|
15 | - * @assert ('abc', 'multiple') !== null |
|
16 | - */ |
|
17 | - public static function search_courses($needle, $type) |
|
18 | - { |
|
19 | - global $tbl_session_rel_course, $id_session; |
|
9 | + /** |
|
10 | + * Searches a course, given a search string and a type of search box |
|
11 | + * @param string $needle Search string |
|
12 | + * @param string $type Type of search box ('single' or anything else) |
|
13 | + * @return string XajaxResponse |
|
14 | + * @assert ('abc', 'single') !== null |
|
15 | + * @assert ('abc', 'multiple') !== null |
|
16 | + */ |
|
17 | + public static function search_courses($needle, $type) |
|
18 | + { |
|
19 | + global $tbl_session_rel_course, $id_session; |
|
20 | 20 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
21 | - $course_title = null; |
|
22 | - $xajax_response = new xajaxResponse(); |
|
23 | - $return = ''; |
|
24 | - if(!empty($needle) && !empty($type)) { |
|
25 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
26 | - $charset = api_get_system_encoding(); |
|
27 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
21 | + $course_title = null; |
|
22 | + $xajax_response = new xajaxResponse(); |
|
23 | + $return = ''; |
|
24 | + if(!empty($needle) && !empty($type)) { |
|
25 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
26 | + $charset = api_get_system_encoding(); |
|
27 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
28 | 28 | |
29 | - $cond_course_code = ''; |
|
30 | - if (!empty($id_session)) { |
|
31 | - $id_session = intval($id_session); |
|
32 | - // check course_code from session_rel_course table |
|
33 | - $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.' |
|
29 | + $cond_course_code = ''; |
|
30 | + if (!empty($id_session)) { |
|
31 | + $id_session = intval($id_session); |
|
32 | + // check course_code from session_rel_course table |
|
33 | + $sql = 'SELECT c_id FROM '.$tbl_session_rel_course.' |
|
34 | 34 | WHERE session_id = '.$id_session; |
35 | - $res = Database::query($sql); |
|
36 | - $course_codes = ''; |
|
37 | - if (Database::num_rows($res) > 0) { |
|
38 | - while ($row = Database::fetch_row($res)) { |
|
39 | - $course_codes .= '\''.$row[0].'\','; |
|
40 | - } |
|
41 | - $course_codes = substr($course_codes,0,(strlen($course_codes)-1)); |
|
35 | + $res = Database::query($sql); |
|
36 | + $course_codes = ''; |
|
37 | + if (Database::num_rows($res) > 0) { |
|
38 | + while ($row = Database::fetch_row($res)) { |
|
39 | + $course_codes .= '\''.$row[0].'\','; |
|
40 | + } |
|
41 | + $course_codes = substr($course_codes,0,(strlen($course_codes)-1)); |
|
42 | 42 | |
43 | - $cond_course_code = ' AND course.id NOT IN('.$course_codes.') '; |
|
44 | - } |
|
45 | - } |
|
43 | + $cond_course_code = ' AND course.id NOT IN('.$course_codes.') '; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - if ($type=='single') { |
|
48 | - // search users where username or firstname or lastname begins likes $needle |
|
49 | - $sql = 'SELECT |
|
47 | + if ($type=='single') { |
|
48 | + // search users where username or firstname or lastname begins likes $needle |
|
49 | + $sql = 'SELECT |
|
50 | 50 | course.code, |
51 | 51 | course.visual_code, |
52 | 52 | course.title, |
@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | WHERE |
59 | 59 | course.visual_code LIKE "'.$needle.'%" OR |
60 | 60 | course.title LIKE "'.$needle.'%"'; |
61 | - } else { |
|
62 | - $sql = 'SELECT course.code, course.visual_code, course.title |
|
61 | + } else { |
|
62 | + $sql = 'SELECT course.code, course.visual_code, course.title |
|
63 | 63 | FROM '.$tbl_course.' course |
64 | 64 | WHERE |
65 | 65 | course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' |
66 | 66 | ORDER BY course.code '; |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - if (api_is_multiple_url_enabled()) { |
|
70 | - $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
71 | - $access_url_id = api_get_current_access_url_id(); |
|
72 | - if ($access_url_id != -1){ |
|
69 | + if (api_is_multiple_url_enabled()) { |
|
70 | + $tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
71 | + $access_url_id = api_get_current_access_url_id(); |
|
72 | + if ($access_url_id != -1){ |
|
73 | 73 | |
74 | - if ($type=='single') { |
|
75 | - $sql = 'SELECT |
|
74 | + if ($type=='single') { |
|
75 | + $sql = 'SELECT |
|
76 | 76 | course.code, |
77 | 77 | course.visual_code, |
78 | 78 | course.title, |
@@ -87,42 +87,42 @@ discard block |
||
87 | 87 | access_url_id = '.$access_url_id.' AND |
88 | 88 | (course.visual_code LIKE "'.$needle.'%" OR |
89 | 89 | course.title LIKE "'.$needle.'%" )'; |
90 | - } else { |
|
91 | - $sql = 'SELECT course.code, course.visual_code, course.title |
|
90 | + } else { |
|
91 | + $sql = 'SELECT course.code, course.visual_code, course.title |
|
92 | 92 | FROM '.$tbl_course.' course, '.$tbl_course_rel_access_url.' url_course |
93 | 93 | WHERE |
94 | 94 | url_course.c_id = course.id AND |
95 | 95 | access_url_id = '.$access_url_id.' AND |
96 | 96 | course.visual_code LIKE "'.$needle.'%" '.$cond_course_code.' |
97 | 97 | ORDER BY course.code '; |
98 | - } |
|
99 | - } |
|
100 | - } |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - $rs = Database::query($sql); |
|
103 | - $course_list = array(); |
|
104 | - if ($type=='single') { |
|
102 | + $rs = Database::query($sql); |
|
103 | + $course_list = array(); |
|
104 | + if ($type=='single') { |
|
105 | 105 | |
106 | - while($course = Database :: fetch_array($rs)) { |
|
107 | - $course_list[] = $course['code']; |
|
108 | - $course_title=str_replace("'","\'",$course_title); |
|
109 | - $return .= '<a href="javascript: void(0);" onclick="javascript: add_course_to_session(\''.$course['code'].'\',\''.$course_title.' ('.$course['visual_code'].')'.'\')">'.$course['title'].' ('.$course['visual_code'].')</a><br />'; |
|
110 | - } |
|
111 | - $xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return)); |
|
112 | - } else { |
|
113 | - $return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
114 | - while($course = Database :: fetch_array($rs)) { |
|
115 | - $course_list[] = $course['code']; |
|
116 | - $course_title=str_replace("'","\'",$course_title); |
|
117 | - $return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>'; |
|
118 | - } |
|
119 | - $return .= '</select>'; |
|
106 | + while($course = Database :: fetch_array($rs)) { |
|
107 | + $course_list[] = $course['code']; |
|
108 | + $course_title=str_replace("'","\'",$course_title); |
|
109 | + $return .= '<a href="javascript: void(0);" onclick="javascript: add_course_to_session(\''.$course['code'].'\',\''.$course_title.' ('.$course['visual_code'].')'.'\')">'.$course['title'].' ('.$course['visual_code'].')</a><br />'; |
|
110 | + } |
|
111 | + $xajax_response -> addAssign('ajax_list_courses_single','innerHTML',api_utf8_encode($return)); |
|
112 | + } else { |
|
113 | + $return .= '<select id="origin" name="NoSessionCoursesList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
114 | + while($course = Database :: fetch_array($rs)) { |
|
115 | + $course_list[] = $course['code']; |
|
116 | + $course_title=str_replace("'","\'",$course_title); |
|
117 | + $return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>'; |
|
118 | + } |
|
119 | + $return .= '</select>'; |
|
120 | 120 | |
121 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
122 | - } |
|
123 | - } |
|
124 | - $_SESSION['course_list'] = $course_list; |
|
121 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
122 | + } |
|
123 | + } |
|
124 | + $_SESSION['course_list'] = $course_list; |
|
125 | 125 | |
126 | - return $xajax_response; |
|
127 | - } |
|
126 | + return $xajax_response; |
|
127 | + } |
|
128 | 128 | } |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | |
32 | 32 | |
33 | 33 | function kses($string, $allowed_html, $allowed_protocols = |
34 | - array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', |
|
35 | - 'gopher', 'mailto')) |
|
34 | + array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', |
|
35 | + 'gopher', 'mailto')) |
|
36 | 36 | ############################################################################### |
37 | 37 | # This function makes sure that only the allowed HTML element names, attribute |
38 | 38 | # names and attribute values plus only sane HTML entities will occur in |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | # call this function. |
41 | 41 | ############################################################################### |
42 | 42 | { |
43 | - $string = kses_no_null($string); |
|
44 | - $string = kses_js_entities($string); |
|
45 | - $string = kses_normalize_entities($string); |
|
46 | - $string = kses_hook($string); |
|
47 | - $allowed_html_fixed = kses_array_lc($allowed_html); |
|
48 | - return kses_split($string, $allowed_html_fixed, $allowed_protocols); |
|
43 | + $string = kses_no_null($string); |
|
44 | + $string = kses_js_entities($string); |
|
45 | + $string = kses_normalize_entities($string); |
|
46 | + $string = kses_hook($string); |
|
47 | + $allowed_html_fixed = kses_array_lc($allowed_html); |
|
48 | + return kses_split($string, $allowed_html_fixed, $allowed_protocols); |
|
49 | 49 | } # function kses |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | # You add any kses hooks here. |
55 | 55 | ############################################################################### |
56 | 56 | { |
57 | - return $string; |
|
57 | + return $string; |
|
58 | 58 | } # function kses_hook |
59 | 59 | |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | # This function returns kses' version number. |
64 | 64 | ############################################################################### |
65 | 65 | { |
66 | - return '0.2.2'; |
|
66 | + return '0.2.2'; |
|
67 | 67 | } # function kses_version |
68 | 68 | |
69 | 69 | |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | # matches stray ">" characters. |
74 | 74 | ############################################################################### |
75 | 75 | { |
76 | - return preg_replace('%(<'. # EITHER: < |
|
77 | - '[^>]*'. # things that aren't > |
|
78 | - '(>|$)'. # > or end of string |
|
79 | - '|>)%e', # OR: just a > |
|
80 | - "kses_split2('\\1', \$allowed_html, ". |
|
81 | - '$allowed_protocols)', |
|
82 | - $string); |
|
76 | + return preg_replace('%(<'. # EITHER: < |
|
77 | + '[^>]*'. # things that aren't > |
|
78 | + '(>|$)'. # > or end of string |
|
79 | + '|>)%e', # OR: just a > |
|
80 | + "kses_split2('\\1', \$allowed_html, ". |
|
81 | + '$allowed_protocols)', |
|
82 | + $string); |
|
83 | 83 | } # function kses_split |
84 | 84 | |
85 | 85 | |
@@ -91,30 +91,30 @@ discard block |
||
91 | 91 | # attribute list. |
92 | 92 | ############################################################################### |
93 | 93 | { |
94 | - $string = kses_stripslashes($string); |
|
94 | + $string = kses_stripslashes($string); |
|
95 | 95 | |
96 | - if (substr($string, 0, 1) != '<') |
|
96 | + if (substr($string, 0, 1) != '<') |
|
97 | 97 | return '>'; |
98 | 98 | # It matched a ">" character |
99 | 99 | |
100 | - if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) |
|
100 | + if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) |
|
101 | 101 | return ''; |
102 | 102 | # It's seriously malformed |
103 | 103 | |
104 | - $slash = trim($matches[1]); |
|
105 | - $elem = $matches[2]; |
|
106 | - $attrlist = $matches[3]; |
|
104 | + $slash = trim($matches[1]); |
|
105 | + $elem = $matches[2]; |
|
106 | + $attrlist = $matches[3]; |
|
107 | 107 | |
108 | - if (!@isset($allowed_html[strtolower($elem)])) |
|
108 | + if (!@isset($allowed_html[strtolower($elem)])) |
|
109 | 109 | return ''; |
110 | 110 | # They are using a not allowed HTML element |
111 | 111 | |
112 | - if ($slash != '') |
|
112 | + if ($slash != '') |
|
113 | 113 | return "<$slash$elem>"; |
114 | - # No attributes are allowed for closing elements |
|
114 | + # No attributes are allowed for closing elements |
|
115 | 115 | |
116 | - return kses_attr("$slash$elem", $attrlist, $allowed_html, |
|
117 | - $allowed_protocols); |
|
116 | + return kses_attr("$slash$elem", $attrlist, $allowed_html, |
|
117 | + $allowed_protocols); |
|
118 | 118 | } # function kses_split2 |
119 | 119 | |
120 | 120 | |
@@ -130,56 +130,56 @@ discard block |
||
130 | 130 | { |
131 | 131 | # Is there a closing XHTML slash at the end of the attributes? |
132 | 132 | |
133 | - $xhtml_slash = ''; |
|
134 | - if (preg_match('%\s/\s*$%', $attr)) |
|
133 | + $xhtml_slash = ''; |
|
134 | + if (preg_match('%\s/\s*$%', $attr)) |
|
135 | 135 | $xhtml_slash = ' /'; |
136 | 136 | |
137 | 137 | # Are any attributes allowed at all for this element? |
138 | 138 | |
139 | - if (@count($allowed_html[strtolower($element)]) == 0) |
|
139 | + if (@count($allowed_html[strtolower($element)]) == 0) |
|
140 | 140 | return "<$element$xhtml_slash>"; |
141 | 141 | |
142 | 142 | # Split it |
143 | 143 | |
144 | - $attrarr = kses_hair($attr, $allowed_protocols); |
|
144 | + $attrarr = kses_hair($attr, $allowed_protocols); |
|
145 | 145 | |
146 | 146 | # Go through $attrarr, and save the allowed attributes for this element |
147 | 147 | # in $attr2 |
148 | 148 | |
149 | - $attr2 = ''; |
|
149 | + $attr2 = ''; |
|
150 | 150 | |
151 | - foreach ($attrarr as $arreach) |
|
152 | - { |
|
151 | + foreach ($attrarr as $arreach) |
|
152 | + { |
|
153 | 153 | if (!@isset($allowed_html[strtolower($element)] |
154 | 154 | [strtolower($arreach['name'])])) |
155 | - continue; # the attribute is not allowed |
|
155 | + continue; # the attribute is not allowed |
|
156 | 156 | |
157 | 157 | $current = $allowed_html[strtolower($element)] |
158 | 158 | [strtolower($arreach['name'])]; |
159 | 159 | |
160 | 160 | if (!is_array($current)) |
161 | - $attr2 .= ' '.$arreach['whole']; |
|
161 | + $attr2 .= ' '.$arreach['whole']; |
|
162 | 162 | # there are no checks |
163 | 163 | |
164 | 164 | else |
165 | 165 | { |
166 | 166 | # there are some checks |
167 | - $ok = true; |
|
168 | - foreach ($current as $currkey => $currval) |
|
167 | + $ok = true; |
|
168 | + foreach ($current as $currkey => $currval) |
|
169 | 169 | if (!kses_check_attr_val($arreach['value'], $arreach['vless'], |
170 | - $currkey, $currval)) |
|
170 | + $currkey, $currval)) |
|
171 | 171 | { $ok = false; break; } |
172 | 172 | |
173 | - if ($ok) |
|
173 | + if ($ok) |
|
174 | 174 | $attr2 .= ' '.$arreach['whole']; # it passed them |
175 | 175 | } # if !is_array($current) |
176 | - } # foreach |
|
176 | + } # foreach |
|
177 | 177 | |
178 | 178 | # Remove any "<" or ">" characters |
179 | 179 | |
180 | - $attr2 = preg_replace('/[<>]/', '', $attr2); |
|
180 | + $attr2 = preg_replace('/[<>]/', '', $attr2); |
|
181 | 181 | |
182 | - return "<$element$attr2$xhtml_slash>"; |
|
182 | + return "<$element$attr2$xhtml_slash>"; |
|
183 | 183 | } # function kses_attr |
184 | 184 | |
185 | 185 | |
@@ -193,96 +193,96 @@ discard block |
||
193 | 193 | # from attribute values. |
194 | 194 | ############################################################################### |
195 | 195 | { |
196 | - $attrarr = array(); |
|
197 | - $mode = 0; |
|
198 | - $attrname = ''; |
|
196 | + $attrarr = array(); |
|
197 | + $mode = 0; |
|
198 | + $attrname = ''; |
|
199 | 199 | |
200 | 200 | # Loop through the whole attribute list |
201 | 201 | |
202 | - while (strlen($attr) != 0) |
|
203 | - { |
|
202 | + while (strlen($attr) != 0) |
|
203 | + { |
|
204 | 204 | $working = 0; # Was the last operation successful? |
205 | 205 | |
206 | 206 | switch ($mode) |
207 | 207 | { |
208 | - case 0: # attribute name, href for instance |
|
208 | + case 0: # attribute name, href for instance |
|
209 | 209 | |
210 | 210 | if (preg_match('/^([-a-zA-Z]+)/', $attr, $match)) |
211 | 211 | { |
212 | - $attrname = $match[1]; |
|
213 | - $working = $mode = 1; |
|
214 | - $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr); |
|
212 | + $attrname = $match[1]; |
|
213 | + $working = $mode = 1; |
|
214 | + $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | break; |
218 | 218 | |
219 | - case 1: # equals sign or valueless ("selected") |
|
219 | + case 1: # equals sign or valueless ("selected") |
|
220 | 220 | |
221 | 221 | if (preg_match('/^\s*=\s*/', $attr)) # equals sign |
222 | 222 | { |
223 | - $working = 1; $mode = 2; |
|
224 | - $attr = preg_replace('/^\s*=\s*/', '', $attr); |
|
225 | - break; |
|
223 | + $working = 1; $mode = 2; |
|
224 | + $attr = preg_replace('/^\s*=\s*/', '', $attr); |
|
225 | + break; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | if (preg_match('/^\s+/', $attr)) # valueless |
229 | 229 | { |
230 | - $working = 1; $mode = 0; |
|
231 | - $attrarr[] = array |
|
230 | + $working = 1; $mode = 0; |
|
231 | + $attrarr[] = array |
|
232 | 232 | ('name' => $attrname, |
233 | - 'value' => '', |
|
234 | - 'whole' => $attrname, |
|
235 | - 'vless' => 'y'); |
|
236 | - $attr = preg_replace('/^\s+/', '', $attr); |
|
233 | + 'value' => '', |
|
234 | + 'whole' => $attrname, |
|
235 | + 'vless' => 'y'); |
|
236 | + $attr = preg_replace('/^\s+/', '', $attr); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | break; |
240 | 240 | |
241 | - case 2: # attribute value, a URL after href= for instance |
|
241 | + case 2: # attribute value, a URL after href= for instance |
|
242 | 242 | |
243 | 243 | if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match)) |
244 | - # "value" |
|
244 | + # "value" |
|
245 | 245 | { |
246 | - $thisval = kses_bad_protocol($match[1], $allowed_protocols); |
|
246 | + $thisval = kses_bad_protocol($match[1], $allowed_protocols); |
|
247 | 247 | |
248 | - $attrarr[] = array |
|
248 | + $attrarr[] = array |
|
249 | 249 | ('name' => $attrname, |
250 | - 'value' => $thisval, |
|
251 | - 'whole' => "$attrname=\"$thisval\"", |
|
252 | - 'vless' => 'n'); |
|
253 | - $working = 1; $mode = 0; |
|
254 | - $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr); |
|
255 | - break; |
|
250 | + 'value' => $thisval, |
|
251 | + 'whole' => "$attrname=\"$thisval\"", |
|
252 | + 'vless' => 'n'); |
|
253 | + $working = 1; $mode = 0; |
|
254 | + $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr); |
|
255 | + break; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match)) |
259 | - # 'value' |
|
259 | + # 'value' |
|
260 | 260 | { |
261 | - $thisval = kses_bad_protocol($match[1], $allowed_protocols); |
|
261 | + $thisval = kses_bad_protocol($match[1], $allowed_protocols); |
|
262 | 262 | |
263 | - $attrarr[] = array |
|
263 | + $attrarr[] = array |
|
264 | 264 | ('name' => $attrname, |
265 | - 'value' => $thisval, |
|
266 | - 'whole' => "$attrname='$thisval'", |
|
267 | - 'vless' => 'n'); |
|
268 | - $working = 1; $mode = 0; |
|
269 | - $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr); |
|
270 | - break; |
|
265 | + 'value' => $thisval, |
|
266 | + 'whole' => "$attrname='$thisval'", |
|
267 | + 'vless' => 'n'); |
|
268 | + $working = 1; $mode = 0; |
|
269 | + $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr); |
|
270 | + break; |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match)) |
274 | - # value |
|
274 | + # value |
|
275 | 275 | { |
276 | - $thisval = kses_bad_protocol($match[1], $allowed_protocols); |
|
276 | + $thisval = kses_bad_protocol($match[1], $allowed_protocols); |
|
277 | 277 | |
278 | - $attrarr[] = array |
|
278 | + $attrarr[] = array |
|
279 | 279 | ('name' => $attrname, |
280 | - 'value' => $thisval, |
|
281 | - 'whole' => "$attrname=\"$thisval\"", |
|
282 | - 'vless' => 'n'); |
|
283 | - # We add quotes to conform to W3C's HTML spec. |
|
284 | - $working = 1; $mode = 0; |
|
285 | - $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr); |
|
280 | + 'value' => $thisval, |
|
281 | + 'whole' => "$attrname=\"$thisval\"", |
|
282 | + 'vless' => 'n'); |
|
283 | + # We add quotes to conform to W3C's HTML spec. |
|
284 | + $working = 1; $mode = 0; |
|
285 | + $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | break; |
@@ -290,21 +290,21 @@ discard block |
||
290 | 290 | |
291 | 291 | if ($working == 0) # not well formed, remove and try again |
292 | 292 | { |
293 | - $attr = kses_html_error($attr); |
|
294 | - $mode = 0; |
|
293 | + $attr = kses_html_error($attr); |
|
294 | + $mode = 0; |
|
295 | 295 | } |
296 | - } # while |
|
296 | + } # while |
|
297 | 297 | |
298 | - if ($mode == 1) |
|
299 | - # special case, for when the attribute list ends with a valueless |
|
300 | - # attribute like "selected" |
|
298 | + if ($mode == 1) |
|
299 | + # special case, for when the attribute list ends with a valueless |
|
300 | + # attribute like "selected" |
|
301 | 301 | $attrarr[] = array |
302 | - ('name' => $attrname, |
|
303 | - 'value' => '', |
|
304 | - 'whole' => $attrname, |
|
305 | - 'vless' => 'y'); |
|
302 | + ('name' => $attrname, |
|
303 | + 'value' => '', |
|
304 | + 'whole' => $attrname, |
|
305 | + 'vless' => 'y'); |
|
306 | 306 | |
307 | - return $attrarr; |
|
307 | + return $attrarr; |
|
308 | 308 | } # function kses_hair |
309 | 309 | |
310 | 310 | |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | # with even more checks to come soon. |
316 | 316 | ############################################################################### |
317 | 317 | { |
318 | - $ok = true; |
|
318 | + $ok = true; |
|
319 | 319 | |
320 | - switch (strtolower($checkname)) |
|
321 | - { |
|
320 | + switch (strtolower($checkname)) |
|
321 | + { |
|
322 | 322 | case 'maxlen': |
323 | 323 | # The maxlen check makes sure that the attribute value has a length not |
324 | 324 | # greater than the given value. This can be used to avoid Buffer Overflows |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | if (strlen($value) > $checkvalue) |
328 | 328 | $ok = false; |
329 | - break; |
|
329 | + break; |
|
330 | 330 | |
331 | 331 | case 'minlen': |
332 | 332 | # The minlen check makes sure that the attribute value has a length not |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | if (strlen($value) < $checkvalue) |
336 | 336 | $ok = false; |
337 | - break; |
|
337 | + break; |
|
338 | 338 | |
339 | 339 | case 'maxval': |
340 | 340 | # The maxval check does two things: it checks that the attribute value is |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | |
346 | 346 | if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
347 | 347 | $ok = false; |
348 | - if ($value > $checkvalue) |
|
348 | + if ($value > $checkvalue) |
|
349 | 349 | $ok = false; |
350 | - break; |
|
350 | + break; |
|
351 | 351 | |
352 | 352 | case 'minval': |
353 | 353 | # The minval check checks that the attribute value is a positive integer, |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | |
356 | 356 | if (!preg_match('/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value)) |
357 | 357 | $ok = false; |
358 | - if ($value < $checkvalue) |
|
358 | + if ($value < $checkvalue) |
|
359 | 359 | $ok = false; |
360 | - break; |
|
360 | + break; |
|
361 | 361 | |
362 | 362 | case 'valueless': |
363 | 363 | # The valueless check checks if the attribute has a value |
@@ -367,10 +367,10 @@ discard block |
||
367 | 367 | |
368 | 368 | if (strtolower($checkvalue) != $vless) |
369 | 369 | $ok = false; |
370 | - break; |
|
371 | - } # switch |
|
370 | + break; |
|
371 | + } # switch |
|
372 | 372 | |
373 | - return $ok; |
|
373 | + return $ok; |
|
374 | 374 | } # function kses_check_attr_val |
375 | 375 | |
376 | 376 | |
@@ -382,17 +382,17 @@ discard block |
||
382 | 382 | # fooled by a string like "javascript:javascript:alert(57)". |
383 | 383 | ############################################################################### |
384 | 384 | { |
385 | - $string = kses_no_null($string); |
|
386 | - $string = preg_replace('/\xad+/', '', $string); # deals with Opera "feature" |
|
387 | - $string2 = $string.'a'; |
|
385 | + $string = kses_no_null($string); |
|
386 | + $string = preg_replace('/\xad+/', '', $string); # deals with Opera "feature" |
|
387 | + $string2 = $string.'a'; |
|
388 | 388 | |
389 | - while ($string != $string2) |
|
390 | - { |
|
389 | + while ($string != $string2) |
|
390 | + { |
|
391 | 391 | $string2 = $string; |
392 | 392 | $string = kses_bad_protocol_once($string, $allowed_protocols); |
393 | - } # while |
|
393 | + } # while |
|
394 | 394 | |
395 | - return $string; |
|
395 | + return $string; |
|
396 | 396 | } # function kses_bad_protocol |
397 | 397 | |
398 | 398 | |
@@ -401,10 +401,10 @@ discard block |
||
401 | 401 | # This function removes any NULL characters in $string. |
402 | 402 | ############################################################################### |
403 | 403 | { |
404 | - $string = preg_replace('/\0+/', '', $string); |
|
405 | - $string = preg_replace('/(\\\\0)+/', '', $string); |
|
404 | + $string = preg_replace('/\0+/', '', $string); |
|
405 | + $string = preg_replace('/(\\\\0)+/', '', $string); |
|
406 | 406 | |
407 | - return $string; |
|
407 | + return $string; |
|
408 | 408 | } # function kses_no_null |
409 | 409 | |
410 | 410 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | # preg_replace(//e) seems to require this. |
416 | 416 | ############################################################################### |
417 | 417 | { |
418 | - return preg_replace('%\\\\"%', '"', $string); |
|
418 | + return preg_replace('%\\\\"%', '"', $string); |
|
419 | 419 | } # function kses_stripslashes |
420 | 420 | |
421 | 421 | |
@@ -424,21 +424,21 @@ discard block |
||
424 | 424 | # This function goes through an array, and changes the keys to all lower case. |
425 | 425 | ############################################################################### |
426 | 426 | { |
427 | - $outarray = array(); |
|
427 | + $outarray = array(); |
|
428 | 428 | |
429 | - foreach ($inarray as $inkey => $inval) |
|
430 | - { |
|
429 | + foreach ($inarray as $inkey => $inval) |
|
430 | + { |
|
431 | 431 | $outkey = strtolower($inkey); |
432 | 432 | $outarray[$outkey] = array(); |
433 | 433 | |
434 | 434 | foreach ($inval as $inkey2 => $inval2) |
435 | 435 | { |
436 | - $outkey2 = strtolower($inkey2); |
|
437 | - $outarray[$outkey][$outkey2] = $inval2; |
|
436 | + $outkey2 = strtolower($inkey2); |
|
437 | + $outarray[$outkey][$outkey2] = $inval2; |
|
438 | 438 | } # foreach $inval |
439 | - } # foreach $inarray |
|
439 | + } # foreach $inarray |
|
440 | 440 | |
441 | - return $outarray; |
|
441 | + return $outarray; |
|
442 | 442 | } # function kses_array_lc |
443 | 443 | |
444 | 444 | |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | # Netscape 4. |
449 | 449 | ############################################################################### |
450 | 450 | { |
451 | - return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string); |
|
451 | + return preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string); |
|
452 | 452 | } # function kses_js_entities |
453 | 453 | |
454 | 454 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | # quotes and apostrophes as well. |
460 | 460 | ############################################################################### |
461 | 461 | { |
462 | - return preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string); |
|
462 | + return preg_replace('/^("[^"]*("|$)|\'[^\']*(\'|$)|\S)*\s*/', '', $string); |
|
463 | 463 | } # function kses_html_error |
464 | 464 | |
465 | 465 | |
@@ -469,12 +469,12 @@ discard block |
||
469 | 469 | # handling whitespace and HTML entities. |
470 | 470 | ############################################################################### |
471 | 471 | { |
472 | - $string2 = preg_split('/:|:|:/i', $string, 2); |
|
473 | - if(isset($string2[1]) && !preg_match('%/\?%',$string2[0])) |
|
474 | - { |
|
475 | - $string = kses_bad_protocol_once2($string2[0],$allowed_protocols).trim($string2[1]); |
|
476 | - } |
|
477 | - return $string; |
|
472 | + $string2 = preg_split('/:|:|:/i', $string, 2); |
|
473 | + if(isset($string2[1]) && !preg_match('%/\?%',$string2[0])) |
|
474 | + { |
|
475 | + $string = kses_bad_protocol_once2($string2[0],$allowed_protocols).trim($string2[1]); |
|
476 | + } |
|
477 | + return $string; |
|
478 | 478 | } # function kses_bad_protocol_once |
479 | 479 | |
480 | 480 | |
@@ -484,24 +484,24 @@ discard block |
||
484 | 484 | # list or not, and returns different data depending on the answer. |
485 | 485 | ############################################################################### |
486 | 486 | { |
487 | - $string2 = kses_decode_entities($string); |
|
488 | - $string2 = preg_replace('/\s/', '', $string2); |
|
489 | - $string2 = kses_no_null($string2); |
|
490 | - $string2 = preg_replace('/\xad+/', '', $string2); |
|
491 | - # deals with Opera "feature" |
|
492 | - $string2 = strtolower($string2); |
|
493 | - |
|
494 | - $allowed = false; |
|
495 | - foreach ($allowed_protocols as $one_protocol) |
|
487 | + $string2 = kses_decode_entities($string); |
|
488 | + $string2 = preg_replace('/\s/', '', $string2); |
|
489 | + $string2 = kses_no_null($string2); |
|
490 | + $string2 = preg_replace('/\xad+/', '', $string2); |
|
491 | + # deals with Opera "feature" |
|
492 | + $string2 = strtolower($string2); |
|
493 | + |
|
494 | + $allowed = false; |
|
495 | + foreach ($allowed_protocols as $one_protocol) |
|
496 | 496 | if (strtolower($one_protocol) == $string2) |
497 | 497 | { |
498 | - $allowed = true; |
|
499 | - break; |
|
498 | + $allowed = true; |
|
499 | + break; |
|
500 | 500 | } |
501 | 501 | |
502 | - if ($allowed) |
|
502 | + if ($allowed) |
|
503 | 503 | return "$string2:"; |
504 | - else |
|
504 | + else |
|
505 | 505 | return ''; |
506 | 506 | } # function kses_bad_protocol_once2 |
507 | 507 | |
@@ -514,18 +514,18 @@ discard block |
||
514 | 514 | { |
515 | 515 | # Disarm all entities by converting & to & |
516 | 516 | |
517 | - $string = str_replace('&', '&', $string); |
|
517 | + $string = str_replace('&', '&', $string); |
|
518 | 518 | |
519 | 519 | # Change back the allowed entities in our entity whitelist |
520 | 520 | |
521 | - $string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', |
|
522 | - '&\\1;', $string); |
|
523 | - $string = preg_replace('/&#0*([0-9]{1,5});/e', |
|
524 | - 'kses_normalize_entities2("\\1")', $string); |
|
525 | - $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', |
|
526 | - '&#\\1\\2;', $string); |
|
521 | + $string = preg_replace('/&([A-Za-z][A-Za-z0-9]{0,19});/', |
|
522 | + '&\\1;', $string); |
|
523 | + $string = preg_replace('/&#0*([0-9]{1,5});/e', |
|
524 | + 'kses_normalize_entities2("\\1")', $string); |
|
525 | + $string = preg_replace('/&#([Xx])0*(([0-9A-Fa-f]{2}){1,2});/', |
|
526 | + '&#\\1\\2;', $string); |
|
527 | 527 | |
528 | - return $string; |
|
528 | + return $string; |
|
529 | 529 | } # function kses_normalize_entities |
530 | 530 | |
531 | 531 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | # and nothing more for &#number; entities. |
536 | 536 | ############################################################################### |
537 | 537 | { |
538 | - return (($i > 65535) ? "&#$i;" : "&#$i;"); |
|
538 | + return (($i > 65535) ? "&#$i;" : "&#$i;"); |
|
539 | 539 | } # function kses_normalize_entities2 |
540 | 540 | |
541 | 541 | |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | # URL protocol whitelisting system anyway. |
547 | 547 | ############################################################################### |
548 | 548 | { |
549 | - $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string); |
|
550 | - $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))', |
|
551 | - $string); |
|
549 | + $string = preg_replace('/&#([0-9]+);/e', 'chr("\\1")', $string); |
|
550 | + $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+);/e', 'chr(hexdec("\\1"))', |
|
551 | + $string); |
|
552 | 552 | |
553 | - return $string; |
|
553 | + return $string; |
|
554 | 554 | } # function kses_decode_entities |
555 | 555 | |
556 | 556 | ?> |