@@ -20,4 +20,6 @@ |
||
20 | 20 | * |
21 | 21 | * As you get this only by an error in the code or during development, the message does not need to be translated |
22 | 22 | */ |
23 | -class InvalidName extends Exception\NoPermission { } |
|
23 | +class InvalidName extends Exception\NoPermission |
|
24 | +{ |
|
25 | +} |
@@ -20,4 +20,6 @@ |
||
20 | 20 | * |
21 | 21 | * As you get this only by an error in the code or during development, the message does not need to be translated |
22 | 22 | */ |
23 | -class Exception extends Api\Exception\WrongParameter { } |
|
23 | +class Exception extends Api\Exception\WrongParameter |
|
24 | +{ |
|
25 | +} |
@@ -123,7 +123,10 @@ discard block |
||
123 | 123 | function __construct($app, Api\CalDAV $caldav) |
124 | 124 | { |
125 | 125 | $this->app = $app; |
126 | - if (!is_null($caldav->debug)) $this->debug = $caldav->debug; |
|
126 | + if (!is_null($caldav->debug)) |
|
127 | + { |
|
128 | + $this->debug = $caldav->debug; |
|
129 | + } |
|
127 | 130 | $this->base_uri = $caldav->base_uri; |
128 | 131 | $this->caldav = $caldav; |
129 | 132 | |
@@ -282,11 +285,17 @@ discard block |
||
282 | 285 | */ |
283 | 286 | function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false) |
284 | 287 | { |
285 | - if (self::$path_extension) $id = basename($id,self::$path_extension); |
|
288 | + if (self::$path_extension) |
|
289 | + { |
|
290 | + $id = basename($id,self::$path_extension); |
|
291 | + } |
|
286 | 292 | |
287 | 293 | if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app]) |
288 | 294 | { |
289 | - if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'"); |
|
295 | + if ($this->debug) |
|
296 | + { |
|
297 | + error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'"); |
|
298 | + } |
|
290 | 299 | return '403 Forbidden'; // no app rights |
291 | 300 | } |
292 | 301 | $extra_acl = $this->method2acl[$method]; |
@@ -295,12 +304,18 @@ discard block |
||
295 | 304 | { |
296 | 305 | if ($return_no_access && !is_null($entry)) |
297 | 306 | { |
298 | - if ($this->debug) error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false"); |
|
307 | + if ($this->debug) |
|
308 | + { |
|
309 | + error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false"); |
|
310 | + } |
|
299 | 311 | $return_no_access = false; |
300 | 312 | } |
301 | 313 | else |
302 | 314 | { |
303 | - if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null')); |
|
315 | + if ($this->debug) |
|
316 | + { |
|
317 | + error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null')); |
|
318 | + } |
|
304 | 319 | return !is_null($entry) ? '403 Forbidden' : '404 Not Found'; |
305 | 320 | } |
306 | 321 | } |
@@ -313,11 +328,17 @@ discard block |
||
313 | 328 | { |
314 | 329 | $this->http_if_match = $_SERVER['HTTP_IF_MATCH']; |
315 | 330 | // strip of quotes around etag, if they exist, that way we allow etag with and without quotes |
316 | - if ($this->http_if_match[0] == '"') $this->http_if_match = substr($this->http_if_match, 1, -1); |
|
331 | + if ($this->http_if_match[0] == '"') |
|
332 | + { |
|
333 | + $this->http_if_match = substr($this->http_if_match, 1, -1); |
|
334 | + } |
|
317 | 335 | |
318 | 336 | if ($this->http_if_match !== $etag) |
319 | 337 | { |
320 | - if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry)); |
|
338 | + if ($this->debug) |
|
339 | + { |
|
340 | + error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry)); |
|
341 | + } |
|
321 | 342 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
322 | 343 | $this->check_return_representation($options, $id); |
323 | 344 | return '412 Precondition Failed'; |
@@ -327,17 +348,26 @@ discard block |
||
327 | 348 | { |
328 | 349 | $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH']; |
329 | 350 | // strip of quotes around etag, if they exist, that way we allow etag with and without quotes |
330 | - if ($if_none_match[0] == '"') $if_none_match = substr($if_none_match, 1, -1); |
|
351 | + if ($if_none_match[0] == '"') |
|
352 | + { |
|
353 | + $if_none_match = substr($if_none_match, 1, -1); |
|
354 | + } |
|
331 | 355 | |
332 | 356 | // if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date |
333 | 357 | if (in_array($method, array('GET','HEAD')) && $etag === $if_none_match) |
334 | 358 | { |
335 | - if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); |
|
359 | + if ($this->debug) |
|
360 | + { |
|
361 | + error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); |
|
362 | + } |
|
336 | 363 | return '304 Not Modified'; |
337 | 364 | } |
338 | 365 | if ($method == 'PUT' && ($if_none_match == '*' || $if_none_match == $etag)) |
339 | 366 | { |
340 | - if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed"); |
|
367 | + if ($this->debug) |
|
368 | + { |
|
369 | + error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed"); |
|
370 | + } |
|
341 | 371 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
342 | 372 | $this->check_return_representation($options, $id); |
343 | 373 | return '412 Precondition Failed'; |
@@ -376,7 +406,10 @@ discard block |
||
376 | 406 | |
377 | 407 | if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data'])) |
378 | 408 | { |
379 | - if (!$this->caldav->use_compression()) header('Content-Length: '.$this->caldav->bytes($options['data'])); |
|
409 | + if (!$this->caldav->use_compression()) |
|
410 | + { |
|
411 | + header('Content-Length: '.$this->caldav->bytes($options['data'])); |
|
412 | + } |
|
380 | 413 | header('Content-Type: '.$options['mimetype']); |
381 | 414 | echo $options['data']; |
382 | 415 | } |
@@ -412,7 +445,10 @@ discard block |
||
412 | 445 | if (!array_key_exists($app,$handler_cache)) |
413 | 446 | { |
414 | 447 | $class = $app.'_groupdav'; |
415 | - if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) return null; |
|
448 | + if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) |
|
449 | + { |
|
450 | + return null; |
|
451 | + } |
|
416 | 452 | |
417 | 453 | $handler_cache[$app] = new $class($app, $groupdav); |
418 | 454 | } |
@@ -474,7 +510,10 @@ discard block |
||
474 | 510 | $matches = null; |
475 | 511 | if (preg_match('/address%20book\/([0-9.]+)/', $user_agent, $matches)) |
476 | 512 | { |
477 | - if ((int)$matches[1] < 868) $agent .= '_old'; |
|
513 | + if ((int)$matches[1] < 868) |
|
514 | + { |
|
515 | + $agent .= '_old'; |
|
516 | + } |
|
478 | 517 | } |
479 | 518 | break; |
480 | 519 | case 'kde': |
@@ -575,7 +614,10 @@ discard block |
||
575 | 614 | // --> as all clients dislike not getting an ETag for a PUT, we sending it again even not storing byte-by-byte |
576 | 615 | //if (get_class($this) == 'addressbook_groupdav' && in_array(self::get_agent(),array('thunderbird','lightning'))) |
577 | 616 | { |
578 | - if (is_null($etag)) $etag = $this->get_etag($entry); |
|
617 | + if (is_null($etag)) |
|
618 | + { |
|
619 | + $etag = $this->get_etag($entry); |
|
620 | + } |
|
579 | 621 | header('ETag: "'.$etag.'"'); |
580 | 622 | } |
581 | 623 | |
@@ -741,7 +783,10 @@ discard block |
||
741 | 783 | */ |
742 | 784 | public function get_sync_token($path, $user, $token=null) |
743 | 785 | { |
744 | - if (!isset($token)) $token = $this->getctag($path, $user); |
|
786 | + if (!isset($token)) |
|
787 | + { |
|
788 | + $token = $this->getctag($path, $user); |
|
789 | + } |
|
745 | 790 | |
746 | 791 | // never return current time, as more modifications might happen due to second granularity --> return 1sec less |
747 | 792 | if ($token >= (int)$GLOBALS['egw_info']['flags']['page_start_time']) |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param string $path |
153 | 153 | * @param array $filter |
154 | - * @param array|boolean $start false=return all or array(start,num) |
|
154 | + * @param integer[] $start false=return all or array(start,num) |
|
155 | 155 | * @return array with "files" array with values for keys path and props |
156 | 156 | */ |
157 | 157 | function &propfind_callback($path, array $filter, $start) |
@@ -192,7 +192,6 @@ discard block |
||
192 | 192 | * Read an entry |
193 | 193 | * |
194 | 194 | * @param string|int $id |
195 | - * @param string $path =null implementation can use it, used in call from _common_get_put_delete |
|
196 | 195 | * @return array|boolean array with entry, false if no read rights, null if $id does not exist |
197 | 196 | */ |
198 | 197 | abstract function read($id /*,$path=null*/); |
@@ -237,7 +236,7 @@ discard block |
||
237 | 236 | * Get the etag for an entry, can be reimplemented for other algorithm or field names |
238 | 237 | * |
239 | 238 | * @param array|int $entry array with event or cal_id |
240 | - * @return string|boolean string with etag or false |
|
239 | + * @return false|string string with etag or false |
|
241 | 240 | */ |
242 | 241 | function get_etag($entry) |
243 | 242 | { |
@@ -422,7 +421,7 @@ discard block |
||
422 | 421 | /** |
423 | 422 | * Identify know GroupDAV agents by HTTP_USER_AGENT header |
424 | 423 | * |
425 | - * @return string|boolean agent name or false |
|
424 | + * @return string|false agent name or false |
|
426 | 425 | */ |
427 | 426 | static function get_agent() |
428 | 427 | { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param int $user account_id |
145 | 145 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
146 | 146 | */ |
147 | - abstract function propfind($path,&$options,&$files,$user); |
|
147 | + abstract function propfind($path, &$options, &$files, $user); |
|
148 | 148 | |
149 | 149 | /** |
150 | 150 | * Propfind callback, if interator is used |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | function &propfind_callback($path, array $filter, $start) |
158 | 158 | { |
159 | - unset($path, $filter, $start); // not used, but required by function signature |
|
159 | + unset($path, $filter, $start); // not used, but required by function signature |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param int $user =null account_id |
168 | 168 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
169 | 169 | */ |
170 | - abstract function get(&$options,$id,$user=null); |
|
170 | + abstract function get(&$options, $id, $user = null); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Handle get request for an applications entry |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param int $user =null account_id of owner, default null |
178 | 178 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
179 | 179 | */ |
180 | - abstract function put(&$options,$id,$user=null); |
|
180 | + abstract function put(&$options, $id, $user = null); |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Handle get request for an applications entry |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param int $user account_id of collection owner |
188 | 188 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
189 | 189 | */ |
190 | - abstract function delete(&$options,$id,$user); |
|
190 | + abstract function delete(&$options, $id, $user); |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Read an entry |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @param array|int $entry entry-array or id |
217 | 217 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
218 | 218 | */ |
219 | - abstract function check_access($acl,$entry); |
|
219 | + abstract function check_access($acl, $entry); |
|
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Add extra properties for collections |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * @param int $user =null account_id of owner of collection |
228 | 228 | * @return array |
229 | 229 | */ |
230 | - public function extra_properties(array $props, $displayname, $base_uri=null, $user=null) |
|
230 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null) |
|
231 | 231 | { |
232 | - unset($displayname, $base_uri, $user); // not used, but required by function signature |
|
232 | + unset($displayname, $base_uri, $user); // not used, but required by function signature |
|
233 | 233 | |
234 | 234 | return $props; |
235 | 235 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | static function etag2value($etag) |
264 | 264 | { |
265 | - list(,$val) = explode(':',$etag,2); |
|
265 | + list(,$val) = explode(':', $etag, 2); |
|
266 | 266 | |
267 | 267 | return $val; |
268 | 268 | } |
@@ -280,18 +280,18 @@ discard block |
||
280 | 280 | * @param boolean $ignore_if_match =false if true, ignore If-Match precondition |
281 | 281 | * @return array|string entry on success, string with http-error-code on failure, null for PUT on an unknown id |
282 | 282 | */ |
283 | - function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false) |
|
283 | + function _common_get_put_delete($method, &$options, &$id, &$return_no_access = false, $ignore_if_match = false) |
|
284 | 284 | { |
285 | - if (self::$path_extension) $id = basename($id,self::$path_extension); |
|
285 | + if (self::$path_extension) $id = basename($id, self::$path_extension); |
|
286 | 286 | |
287 | 287 | if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app]) |
288 | 288 | { |
289 | 289 | if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'"); |
290 | - return '403 Forbidden'; // no app rights |
|
290 | + return '403 Forbidden'; // no app rights |
|
291 | 291 | } |
292 | 292 | $extra_acl = $this->method2acl[$method]; |
293 | 293 | if ($id && !($entry = $this->read($id, $options['path'])) && ($method != 'PUT' || $entry === false) || |
294 | - ($extra_acl != Api\Acl::READ && $this->check_access($extra_acl,$entry) === false)) |
|
294 | + ($extra_acl != Api\Acl::READ && $this->check_access($extra_acl, $entry) === false)) |
|
295 | 295 | { |
296 | 296 | if ($return_no_access && !is_null($entry)) |
297 | 297 | { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } |
301 | 301 | else |
302 | 302 | { |
303 | - if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null')); |
|
303 | + if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry === false ? 'false' : 'null')); |
|
304 | 304 | return !is_null($entry) ? '403 Forbidden' : '404 Not Found'; |
305 | 305 | } |
306 | 306 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | if ($if_none_match[0] == '"') $if_none_match = substr($if_none_match, 1, -1); |
331 | 331 | |
332 | 332 | // if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date |
333 | - if (in_array($method, array('GET','HEAD')) && $etag === $if_none_match) |
|
333 | + if (in_array($method, array('GET', 'HEAD')) && $etag === $if_none_match) |
|
334 | 334 | { |
335 | 335 | if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); |
336 | 336 | return '304 Not Modified'; |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @param int $user =null account_id |
356 | 356 | * @return string|boolean http status of get or null if no representation was requested |
357 | 357 | */ |
358 | - public function check_return_representation($options, $id, $user=null) |
|
358 | + public function check_return_representation($options, $id, $user = null) |
|
359 | 359 | { |
360 | 360 | //error_log(__METHOD__."(, $id, $user) start ".function_backtrace()); |
361 | 361 | if (isset($_SERVER['HTTP_PREFER']) && in_array('return=representation', preg_split('/, ?/', $_SERVER['HTTP_PREFER']))) |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function update_tags($entry) |
396 | 396 | { |
397 | - unset($entry); // not used, but required by function signature |
|
397 | + unset($entry); // not used, but required by function signature |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | { |
410 | 410 | static $handler_cache = array(); |
411 | 411 | |
412 | - if (!array_key_exists($app,$handler_cache)) |
|
412 | + if (!array_key_exists($app, $handler_cache)) |
|
413 | 413 | { |
414 | 414 | $class = $app.'_groupdav'; |
415 | 415 | if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) return null; |
@@ -427,37 +427,37 @@ discard block |
||
427 | 427 | */ |
428 | 428 | static function get_agent() |
429 | 429 | { |
430 | - static $agent=null; |
|
430 | + static $agent = null; |
|
431 | 431 | |
432 | 432 | if (is_null($agent)) |
433 | 433 | { |
434 | 434 | $agent = false; |
435 | 435 | // identify the agent (GroupDAV client) from the HTTP_USER_AGENT header |
436 | 436 | $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); |
437 | - foreach(array( |
|
438 | - 'carddav-sync' => 'carddav-sync', // dmfs.org CardDAV client for Android: CardDAV-Sync (Android) (like iOS/5.0.1 (9A405) dataaccessd/1.0) gzip |
|
439 | - 'iphone' => 'iphone', // Apple iPhone iCal |
|
440 | - 'davkit' => 'davkit', // Apple iCal 10.6 |
|
441 | - 'coredav' => 'coredav', // Apple iCal 10.7 |
|
442 | - 'calendarstore' => 'calendarstore', // Apple iCal 5.0.1 under OS X 10.7.2 |
|
443 | - 'calendaragent/' => 'calendaragent', // Apple iCal OS X 10.8*: Mac OS X/10.8.2 (12C54) CalendarAgent/55 |
|
444 | - 'dataaccess' => 'dataaccess', // Apple addressbook iPhone |
|
445 | - 'cfnetwork' => 'cfnetwork', // Apple Addressbook 10.6/7 |
|
446 | - 'addressbook/' => 'cfnetwork', // Apple Addressbook OS X 10.8*: Mac OS X/10.8.2 (12C54) AddressBook/1167 |
|
447 | - 'bionicmessage.net' => 'funambol', // funambol GroupDAV connector from bionicmessage.net |
|
448 | - 'zideone' => 'zideone', // zideone outlook plugin |
|
449 | - 'lightning' => 'lightning', // Lighting (incl. SOGo connector for addressbook) |
|
450 | - 'webkit' => 'webkit', // Webkit Browser (also reports KHTML!) |
|
451 | - 'akonadi' => 'akonadi', // new KDE PIM framework (also reports KHTML!) |
|
452 | - 'khtml' => 'kde', // KDE clients |
|
437 | + foreach (array( |
|
438 | + 'carddav-sync' => 'carddav-sync', // dmfs.org CardDAV client for Android: CardDAV-Sync (Android) (like iOS/5.0.1 (9A405) dataaccessd/1.0) gzip |
|
439 | + 'iphone' => 'iphone', // Apple iPhone iCal |
|
440 | + 'davkit' => 'davkit', // Apple iCal 10.6 |
|
441 | + 'coredav' => 'coredav', // Apple iCal 10.7 |
|
442 | + 'calendarstore' => 'calendarstore', // Apple iCal 5.0.1 under OS X 10.7.2 |
|
443 | + 'calendaragent/' => 'calendaragent', // Apple iCal OS X 10.8*: Mac OS X/10.8.2 (12C54) CalendarAgent/55 |
|
444 | + 'dataaccess' => 'dataaccess', // Apple addressbook iPhone |
|
445 | + 'cfnetwork' => 'cfnetwork', // Apple Addressbook 10.6/7 |
|
446 | + 'addressbook/' => 'cfnetwork', // Apple Addressbook OS X 10.8*: Mac OS X/10.8.2 (12C54) AddressBook/1167 |
|
447 | + 'bionicmessage.net' => 'funambol', // funambol GroupDAV connector from bionicmessage.net |
|
448 | + 'zideone' => 'zideone', // zideone outlook plugin |
|
449 | + 'lightning' => 'lightning', // Lighting (incl. SOGo connector for addressbook) |
|
450 | + 'webkit' => 'webkit', // Webkit Browser (also reports KHTML!) |
|
451 | + 'akonadi' => 'akonadi', // new KDE PIM framework (also reports KHTML!) |
|
452 | + 'khtml' => 'kde', // KDE clients |
|
453 | 453 | 'neon' => 'neon', |
454 | - 'ical4ol' => 'ical4ol', // iCal4OL client |
|
455 | - 'evolution' => 'evolution', // Evolution |
|
456 | - 'thunderbird' => 'thunderbird', // SOGo connector for addressbook, no Lightning installed |
|
457 | - 'caldavsynchronizer'=> 'caldavsynchronizer', // Outlook CalDAV Synchroniser (https://caldavsynchronizer.org/) |
|
454 | + 'ical4ol' => 'ical4ol', // iCal4OL client |
|
455 | + 'evolution' => 'evolution', // Evolution |
|
456 | + 'thunderbird' => 'thunderbird', // SOGo connector for addressbook, no Lightning installed |
|
457 | + 'caldavsynchronizer'=> 'caldavsynchronizer', // Outlook CalDAV Synchroniser (https://caldavsynchronizer.org/) |
|
458 | 458 | ) as $pattern => $name) |
459 | 459 | { |
460 | - if (strpos($user_agent,$pattern) !== false) |
|
460 | + if (strpos($user_agent, $pattern) !== false) |
|
461 | 461 | { |
462 | 462 | $agent = $name; |
463 | 463 | break; |
@@ -513,35 +513,35 @@ discard block |
||
513 | 513 | * @param int $user =null owner of the collection, default current user |
514 | 514 | * @return array with privileges |
515 | 515 | */ |
516 | - public function current_user_privileges($path, $user=null) |
|
516 | + public function current_user_privileges($path, $user = null) |
|
517 | 517 | { |
518 | - unset($path); // not used, but required by function signature |
|
518 | + unset($path); // not used, but required by function signature |
|
519 | 519 | |
520 | - static $grants=null; |
|
520 | + static $grants = null; |
|
521 | 521 | if (is_null($grants)) |
522 | 522 | { |
523 | 523 | $grants = $this->get_grants(); |
524 | 524 | } |
525 | 525 | $priviledes = array('read-current-user-privilege-set' => 'read-current-user-privilege-set'); |
526 | 526 | |
527 | - if (is_null($user) || $grants[$user] & Api\Acl::READ) |
|
527 | + if (is_null($user) || $grants[$user]&Api\Acl::READ) |
|
528 | 528 | { |
529 | 529 | $priviledes['read'] = 'read'; |
530 | 530 | // allows on all calendars/addressbooks to write properties, as we store them on a per-user basis |
531 | 531 | // and only allow to modify explicit named properties in CalDAV, CardDAV or Calendarserver name-space |
532 | 532 | $priviledes['write-properties'] = 'write-properties'; |
533 | 533 | } |
534 | - if (is_null($user) || $grants[$user] & Api\Acl::ADD) |
|
534 | + if (is_null($user) || $grants[$user]&Api\Acl::ADD) |
|
535 | 535 | { |
536 | - $priviledes['bind'] = 'bind'; // PUT for new resources |
|
536 | + $priviledes['bind'] = 'bind'; // PUT for new resources |
|
537 | 537 | } |
538 | - if (is_null($user) || $grants[$user] & Api\Acl::EDIT) |
|
538 | + if (is_null($user) || $grants[$user]&Api\Acl::EDIT) |
|
539 | 539 | { |
540 | - $priviledes['write-content'] = 'write-content'; // otherwise iOS calendar does not allow to add events |
|
540 | + $priviledes['write-content'] = 'write-content'; // otherwise iOS calendar does not allow to add events |
|
541 | 541 | } |
542 | - if (is_null($user) || $grants[$user] & Api\Acl::DELETE) |
|
542 | + if (is_null($user) || $grants[$user]&Api\Acl::DELETE) |
|
543 | 543 | { |
544 | - $priviledes['unbind'] = 'unbind'; // DELETE |
|
544 | + $priviledes['unbind'] = 'unbind'; // DELETE |
|
545 | 545 | } |
546 | 546 | // copy/move of existing resources might require write-properties, thought we do not support an explicit PROPATCH |
547 | 547 | //error_log(__METHOD__."('$path', ".array2string($user).') returning '.array2string($priviledes).' '.function_backtrace()); |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header) |
569 | 569 | * @param string $etag =null etag, to not calculate it again (if != null) |
570 | 570 | */ |
571 | - function put_response_headers($entry, $path, $retval, $path_attr_is_name=true, $etag=null) |
|
571 | + function put_response_headers($entry, $path, $retval, $path_attr_is_name = true, $etag = null) |
|
572 | 572 | { |
573 | 573 | //error_log(__METHOD__."(".array2string($entry).", '$path', ".array2string($retval).", path_attr_is_name=$path_attr_is_name, etag=".array2string($etag).")"); |
574 | 574 | // we should not return an etag here, as EGroupware never stores ical/vcard byte-by-byte |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | */ |
612 | 612 | static function get_settings($hook_data) |
613 | 613 | { |
614 | - unset($hook_data); // not used, but required by function signature |
|
614 | + unset($hook_data); // not used, but required by function signature |
|
615 | 615 | |
616 | 616 | return array(); |
617 | 617 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | { |
632 | 632 | $props['getetag'] = $this->get_etag($entry); |
633 | 633 | } |
634 | - foreach(array( |
|
634 | + foreach (array( |
|
635 | 635 | 'getcontenttype' => 'text/calendar', |
636 | 636 | 'getlastmodified' => $entry['modified'], |
637 | 637 | 'displayname' => $entry['title'], |
@@ -669,17 +669,17 @@ discard block |
||
669 | 669 | * @param boolean $full_uri =true |
670 | 670 | * @return string eg. https://domain.com/egroupware/groupdav.php |
671 | 671 | */ |
672 | - public function base_uri($full_uri=true) |
|
672 | + public function base_uri($full_uri = true) |
|
673 | 673 | { |
674 | - static $uri=null; |
|
675 | - static $path=null; |
|
674 | + static $uri = null; |
|
675 | + static $path = null; |
|
676 | 676 | |
677 | 677 | if (!isset($uri)) |
678 | 678 | { |
679 | 679 | $uri = $path = $this->caldav->base_uri; |
680 | 680 | if ($uri[0] == '/') |
681 | 681 | { |
682 | - $uri = ($_SERVER["HTTPS"] === "on" ? "https:" : "http:") .'//' . $_SERVER['HTTP_HOST'] . $uri; |
|
682 | + $uri = ($_SERVER["HTTPS"] === "on" ? "https:" : "http:").'//'.$_SERVER['HTTP_HOST'].$uri; |
|
683 | 683 | } |
684 | 684 | else |
685 | 685 | { |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * @param int $user parameter necessary to call getctag, if no $token specified |
704 | 704 | * @return string |
705 | 705 | */ |
706 | - public function get_sync_collection_token($path, $user=null, $more_results=null) |
|
706 | + public function get_sync_collection_token($path, $user = null, $more_results = null) |
|
707 | 707 | { |
708 | 708 | //error_log(__METHOD__."('$path', $user, more_results=$more_results) this->sync_collection_token=".$this->sync_collection_token); |
709 | 709 | if ($more_results) |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | '; |
718 | 718 | if ($this->caldav->crrnd) |
719 | 719 | { |
720 | - $error = str_replace(array('<D:', '</D:'), array('<', '</'), $error); |
|
720 | + $error = str_replace(array('<D:', '</D:'), array('<', '</'), $error); |
|
721 | 721 | } |
722 | 722 | echo $error; |
723 | 723 | } |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | * @param int $token =null modification time, default call getctag($path, $user) to fetch it |
741 | 741 | * @return string |
742 | 742 | */ |
743 | - public function get_sync_token($path, $user, $token=null) |
|
743 | + public function get_sync_token($path, $user, $token = null) |
|
744 | 744 | { |
745 | 745 | if (!isset($token)) $token = $this->getctag($path, $user); |
746 | 746 |
@@ -47,7 +47,10 @@ discard block |
||
47 | 47 | { |
48 | 48 | static $func_overload = null; |
49 | 49 | |
50 | - if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
50 | + if (is_null($func_overload)) |
|
51 | + { |
|
52 | + $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str); |
53 | 56 | } |
@@ -64,7 +67,10 @@ discard block |
||
64 | 67 | { |
65 | 68 | static $func_overload = null; |
66 | 69 | |
67 | - if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
70 | + if (is_null($func_overload)) |
|
71 | + { |
|
72 | + $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
73 | + } |
|
68 | 74 | |
69 | 75 | if (is_null($len)) |
70 | 76 | { |
@@ -130,7 +136,10 @@ discard block |
||
130 | 136 | { |
131 | 137 | $personal = str_replace('\\', '', substr($personal, 1, -1)); |
132 | 138 | } |
133 | - if (empty($host)) $host = $default_host; |
|
139 | + if (empty($host)) |
|
140 | + { |
|
141 | + $host = $default_host; |
|
142 | + } |
|
134 | 143 | |
135 | 144 | $addresses[] = (object)array_diff(array( |
136 | 145 | 'mailbox' => $mailbox, |
@@ -153,13 +162,19 @@ discard block |
||
153 | 162 | */ |
154 | 163 | function imap_rfc822_write_address($mailbox, $host, $personal) |
155 | 164 | { |
156 | - if (is_array($personal)) $personal = implode(' ', $personal); |
|
165 | + if (is_array($personal)) |
|
166 | + { |
|
167 | + $personal = implode(' ', $personal); |
|
168 | + } |
|
157 | 169 | |
158 | 170 | //if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal)) // that's how I read the rfc(2)822 |
159 | - if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) // but quoting is never wrong, so quote more then necessary |
|
171 | + if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) |
|
172 | + { |
|
173 | + // but quoting is never wrong, so quote more then necessary |
|
160 | 174 | { |
161 | 175 | $personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"'; |
162 | 176 | } |
177 | + } |
|
163 | 178 | return ($personal ? $personal.' <' : '').$mailbox.($host ? '@'.$host : '').($personal ? '>' : ''); |
164 | 179 | } |
165 | 180 | } |
@@ -366,7 +381,9 @@ discard block |
||
366 | 381 | return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']); |
367 | 382 | } |
368 | 383 | |
369 | -if (!function_exists('lang') || defined('NO_LANG')) // setup declares an own version |
|
384 | +if (!function_exists('lang') || defined('NO_LANG')) |
|
385 | +{ |
|
386 | + // setup declares an own version |
|
370 | 387 | { |
371 | 388 | /** |
372 | 389 | * function to handle multilanguage support |
@@ -380,6 +397,7 @@ discard block |
||
380 | 397 | if(!is_array($vars)) |
381 | 398 | { |
382 | 399 | $vars = func_get_args(); |
400 | +} |
|
383 | 401 | array_shift($vars); // remove $key |
384 | 402 | } |
385 | 403 | return Api\Translation::translate($key,$vars); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | return stripslashes($var); |
31 | 31 | } |
32 | - foreach($var as $key => $val) |
|
32 | + foreach ($var as $key => $val) |
|
33 | 33 | { |
34 | 34 | $var[$key] = is_array($val) ? array_stripslashes($val) : stripslashes($val); |
35 | 35 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
51 | 51 | |
52 | - return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str); |
|
52 | + return $func_overload&2 ? mb_strlen($str, 'ascii') : strlen($str); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param int $len |
61 | 61 | * @return string |
62 | 62 | */ |
63 | -function cut_bytes(&$data,$offset,$len=null) |
|
63 | +function cut_bytes(&$data, $offset, $len = null) |
|
64 | 64 | { |
65 | 65 | static $func_overload = null; |
66 | 66 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | |
69 | 69 | if (is_null($len)) |
70 | 70 | { |
71 | - return $func_overload & 2 ? mb_substr($data,$offset,bytes($data),'ascii') : substr($data,$offset); |
|
71 | + return $func_overload&2 ? mb_substr($data, $offset, bytes($data), 'ascii') : substr($data, $offset); |
|
72 | 72 | } |
73 | - return $func_overload & 2 ? mb_substr($data,$offset,$len,'ascii') : substr($data,$offset,$len); |
|
73 | + return $func_overload&2 ? mb_substr($data, $offset, $len, 'ascii') : substr($data, $offset, $len); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | if (!function_exists('imap_rfc822_parse_adrlist')) |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | { |
103 | 103 | $addresses = array(); |
104 | 104 | $pending = ''; |
105 | - foreach(explode(',', $address) as $part) |
|
105 | + foreach (explode(',', $address) as $part) |
|
106 | 106 | { |
107 | 107 | $trimmed = trim(($pending ? $pending.',' : '').$part); |
108 | - if (($trimmed[0] == '"' && substr($trimmed, -1) != '>')||strpos($part, '@')===false) |
|
108 | + if (($trimmed[0] == '"' && substr($trimmed, -1) != '>') || strpos($part, '@') === false) |
|
109 | 109 | { |
110 | 110 | $pending .= ($pending ? $pending.',' : '').$part; |
111 | 111 | continue; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | //if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal)) // that's how I read the rfc(2)822 |
159 | 159 | if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) // but quoting is never wrong, so quote more then necessary |
160 | 160 | { |
161 | - $personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"'; |
|
161 | + $personal = '"'.str_replace(array('\\', '"'), array('\\\\', '\\"'), $personal).'"'; |
|
162 | 162 | } |
163 | 163 | return ($personal ? $personal.' <' : '').$mailbox.($host ? '@'.$host : '').($personal ? '>' : ''); |
164 | 164 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | { |
180 | 180 | return array((object)array( |
181 | 181 | 'text' => Horde_Mime::decode($text), |
182 | - 'charset' => Api\Translation::charset(), // is already in our internal encoding! |
|
182 | + 'charset' => Api\Translation::charset(), // is already in our internal encoding! |
|
183 | 183 | )); |
184 | 184 | } |
185 | 185 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param int $len |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - function mb_substr(&$data, $offset, $len=null) |
|
211 | + function mb_substr(&$data, $offset, $len = null) |
|
212 | 212 | { |
213 | 213 | return is_null($len) ? substr($data, $offset) : substr($data, $offset, $len); |
214 | 214 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | return 'NULL'; |
237 | 237 | case 'object': |
238 | 238 | case 'array': |
239 | - return str_replace(array("\n",' '/*,'Array'*/),'',print_r($var,true)); |
|
239 | + return str_replace(array("\n", ' '/*,'Array'*/), '', print_r($var, true)); |
|
240 | 240 | } |
241 | 241 | return 'UNKNOWN TYPE!'; |
242 | 242 | } |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | * @return boolean true if loaded now, false otherwise |
250 | 250 | * @throws Api\Exception\AssertionFailed |
251 | 251 | */ |
252 | -function check_load_extension($extension,$throw=false) |
|
252 | +function check_load_extension($extension, $throw = false) |
|
253 | 253 | { |
254 | 254 | if (!defined('PHP_SHLIB_PREFIX')) |
255 | 255 | { |
256 | - define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); |
|
256 | + define('PHP_SHLIB_PREFIX', PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); |
|
257 | 257 | } |
258 | 258 | // we check for the existens of 'dl', as multithreaded webservers dont have it and some hosters disable it !!! |
259 | - $loaded = extension_loaded($extension) || function_exists('dl') && @dl($dl=PHP_SHLIB_PREFIX.$extension.'.'.PHP_SHLIB_SUFFIX); |
|
259 | + $loaded = extension_loaded($extension) || function_exists('dl') && @dl($dl = PHP_SHLIB_PREFIX.$extension.'.'.PHP_SHLIB_SUFFIX); |
|
260 | 260 | |
261 | 261 | if (!$loaded && $throw) |
262 | 262 | { |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param int/string $default_id either a name or an id |
285 | 285 | * @return int account_id |
286 | 286 | */ |
287 | -function get_account_id($account_id = '',$default_id = '') |
|
287 | +function get_account_id($account_id = '', $default_id = '') |
|
288 | 288 | { |
289 | 289 | if (gettype($account_id) == 'integer') |
290 | 290 | { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | { |
295 | 295 | if ($default_id == '') |
296 | 296 | { |
297 | - return (isset($GLOBALS['egw_info']['user']['account_id'])?$GLOBALS['egw_info']['user']['account_id']:0); |
|
297 | + return (isset($GLOBALS['egw_info']['user']['account_id']) ? $GLOBALS['egw_info']['user']['account_id'] : 0); |
|
298 | 298 | } |
299 | 299 | elseif (is_string($default_id)) |
300 | 300 | { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | elseif (is_string($account_id)) |
306 | 306 | { |
307 | - if((int)$account_id && $GLOBALS['egw']->accounts->exists((int)$account_id) == True) |
|
307 | + if ((int)$account_id && $GLOBALS['egw']->accounts->exists((int)$account_id) == True) |
|
308 | 308 | { |
309 | 309 | return (int)$account_id; |
310 | 310 | } |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | * @param boolean $print =true print or return the content |
323 | 323 | * @return string if !$print |
324 | 324 | */ |
325 | -function _debug_array($array,$print=True) |
|
325 | +function _debug_array($array, $print = True) |
|
326 | 326 | { |
327 | - $output = '<pre>'.print_r($array,true)."</pre>\n"; |
|
327 | + $output = '<pre>'.print_r($array, true)."</pre>\n"; |
|
328 | 328 | |
329 | 329 | if ($print) |
330 | 330 | { |
@@ -343,28 +343,28 @@ discard block |
||
343 | 343 | * @param int $remove =0 number of levels to remove |
344 | 344 | * @return string function-names separated by slashes (beginning with the calling function not this one) |
345 | 345 | */ |
346 | -function function_backtrace($remove=0) |
|
346 | +function function_backtrace($remove = 0) |
|
347 | 347 | { |
348 | 348 | if (function_exists('debug_backtrace')) |
349 | 349 | { |
350 | 350 | $backtrace = debug_backtrace(); |
351 | 351 | //echo "function_backtrace($remove)<pre>".print_r($backtrace,True)."</pre>\n"; |
352 | - foreach($backtrace as $n => $level) |
|
352 | + foreach ($backtrace as $n => $level) |
|
353 | 353 | { |
354 | 354 | if ($remove-- < 0) |
355 | 355 | { |
356 | - $ret[] = (isset($level['class'])?$level['class'].$level['type']:'').$level['function']. |
|
357 | - ($n > 0 && isset($backtrace[$n-1]['line']) ? ':'.$backtrace[$n-1]['line'] : ''). // add line number of call |
|
356 | + $ret[] = (isset($level['class']) ? $level['class'].$level['type'] : '').$level['function']. |
|
357 | + ($n > 0 && isset($backtrace[$n - 1]['line']) ? ':'.$backtrace[$n - 1]['line'] : '').// add line number of call |
|
358 | 358 | (!$level['class'] && !is_object($level['args'][0]) && $level['function'] != 'unserialize' ? |
359 | - '('.substr(str_replace(EGW_SERVER_ROOT,'',(string)$level['args'][0]),0,64).')' : ''); |
|
359 | + '('.substr(str_replace(EGW_SERVER_ROOT, '', (string)$level['args'][0]), 0, 64).')' : ''); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | if (is_array($ret)) |
363 | 363 | { |
364 | - return implode(' / ',$ret); |
|
364 | + return implode(' / ', $ret); |
|
365 | 365 | } |
366 | 366 | } |
367 | - return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']); |
|
367 | + return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT, '', $_SERVER['SCRIPT_FILENAME']); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | if (!function_exists('lang') || defined('NO_LANG')) // setup declares an own version |
@@ -376,14 +376,14 @@ discard block |
||
376 | 376 | * @param string $vars =null multiple values to replace the placeholders |
377 | 377 | * @return string translated message with placeholders replaced |
378 | 378 | */ |
379 | - function lang($key,$vars=null) |
|
379 | + function lang($key, $vars = null) |
|
380 | 380 | { |
381 | - if(!is_array($vars)) |
|
381 | + if (!is_array($vars)) |
|
382 | 382 | { |
383 | 383 | $vars = func_get_args(); |
384 | - array_shift($vars); // remove $key |
|
384 | + array_shift($vars); // remove $key |
|
385 | 385 | } |
386 | - return Api\Translation::translate($key,$vars); |
|
386 | + return Api\Translation::translate($key, $vars); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @deprecated use $GLOBALS['egw']->framework->sidebox() |
415 | 415 | */ |
416 | - function display_sidebox($appname,$menu_title,$_file) |
|
416 | + function display_sidebox($appname, $menu_title, $_file) |
|
417 | 417 | { |
418 | 418 | $file = str_replace('preferences.uisettings.index', 'preferences.preferences_settings.index', $_file); |
419 | - $GLOBALS['egw']->framework->sidebox($appname,$menu_title,$file); |
|
419 | + $GLOBALS['egw']->framework->sidebox($appname, $menu_title, $file); |
|
420 | 420 | } |
421 | 421 | } |
@@ -24,7 +24,9 @@ discard block |
||
24 | 24 | { |
25 | 25 | static $preg=null; |
26 | 26 | //old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i'; |
27 | - if (!isset($preg)) $preg = |
|
27 | + if (!isset($preg)) |
|
28 | + { |
|
29 | + $preg = |
|
28 | 30 | // forbidden tags like iframe or script |
29 | 31 | '/(<(\s*\/)?\s*(iframe|script|object|embed|math|meta)[^a-z0-9]|'. |
30 | 32 | // on* attributes |
@@ -33,6 +35,7 @@ discard block |
||
33 | 35 | '<[^>]+(href|src|dynsrc|lowsrc|background|style|poster|action)\s*=\s*("|\')?[^"\']*javascript|'. |
34 | 36 | // benavior:url and expression in style attribute |
35 | 37 | '<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i'; |
38 | + } |
|
36 | 39 | if (is_array($var)) |
37 | 40 | { |
38 | 41 | foreach($var as $key => $val) |
@@ -41,7 +44,9 @@ discard block |
||
41 | 44 | { |
42 | 45 | _check_script_tag($var[$key],$name.'['.$key.']'); |
43 | 46 | } |
44 | - elseif(strpos($val, '<') !== false) // speedup: ignore everything without < |
|
47 | + elseif(strpos($val, '<') !== false) |
|
48 | + { |
|
49 | + // speedup: ignore everything without < |
|
45 | 50 | { |
46 | 51 | if (preg_match($preg,$val)) |
47 | 52 | { |
@@ -49,6 +54,7 @@ discard block |
||
49 | 54 | if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true))) |
50 | 55 | { |
51 | 56 | _check_script_tag($json_data, $name.'[json_data]'); |
57 | + } |
|
52 | 58 | $_REQUEST[$key] = $var[$key] = json_encode($json_data); |
53 | 59 | continue; |
54 | 60 | } |
@@ -20,6 +20,7 @@ |
||
20 | 20 | * @param array &$var reference of array to check |
21 | 21 | * @param string $name ='' name of the array |
22 | 22 | * @param boolean $log = true Log the results of checking to the error log |
23 | + * @param string[] $var |
|
23 | 24 | */ |
24 | 25 | function _check_script_tag(&$var,$name='',$log=true) |
25 | 26 | { |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * @param string $name ='' name of the array |
22 | 22 | * @param boolean $log = true Log the results of checking to the error log |
23 | 23 | */ |
24 | -function _check_script_tag(&$var,$name='',$log=true) |
|
24 | +function _check_script_tag(&$var, $name = '', $log = true) |
|
25 | 25 | { |
26 | - static $preg=null; |
|
26 | + static $preg = null; |
|
27 | 27 | //old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i'; |
28 | 28 | if (!isset($preg)) $preg = |
29 | 29 | // forbidden tags like iframe or script |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | '<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i'; |
41 | 41 | if (is_array($var)) |
42 | 42 | { |
43 | - foreach($var as $key => $val) |
|
43 | + foreach ($var as $key => $val) |
|
44 | 44 | { |
45 | 45 | if (is_array($val)) |
46 | 46 | { |
47 | - _check_script_tag($var[$key],$name.'['.$key.']'); |
|
47 | + _check_script_tag($var[$key], $name.'['.$key.']'); |
|
48 | 48 | } |
49 | - elseif(strpos($val, '<') !== false) // speedup: ignore everything without < |
|
49 | + elseif (strpos($val, '<') !== false) // speedup: ignore everything without < |
|
50 | 50 | { |
51 | - if (preg_match($preg,$val)) |
|
51 | + if (preg_match($preg, $val)) |
|
52 | 52 | { |
53 | 53 | // special handling for $_POST[json_data], to decend into it's decoded content, fixing json direct might break json syntax |
54 | 54 | if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true))) |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | // check if we succeeded, if not drop the var anyway, keep the egw_unset_var in any case |
65 | 65 | if (preg_match($preg, $var[$key])) |
66 | 66 | { |
67 | - if($log) |
|
67 | + if ($log) |
|
68 | 68 | { |
69 | 69 | error_log("*** _check_script_tag($name): unset(${name}[$key]) with value '$val'"); |
70 | 70 | } |
71 | 71 | unset($var[$key]); |
72 | 72 | } |
73 | - elseif($log) |
|
73 | + elseif ($log) |
|
74 | 74 | { |
75 | 75 | error_log("*** _check_script_tag($name): HtmlLawed::purify(${name}[$key]) succeeded '$val' --> '{$var[$key]}'"); |
76 | 76 | } |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -foreach(array('_COOKIE','_GET','_POST','_REQUEST','HTTP_GET_VARS','HTTP_POST_VARS') as $n => $where) |
|
85 | +foreach (array('_COOKIE', '_GET', '_POST', '_REQUEST', 'HTTP_GET_VARS', 'HTTP_POST_VARS') as $n => $where) |
|
86 | 86 | { |
87 | 87 | $pregs = array( |
88 | 88 | 'order' => '/^[a-zA-Z0-9_,]*$/', |
89 | 89 | 'sort' => '/^(ASC|DESC|asc|desc|0|1|2|3|4|5|6|7){0,1}$/', |
90 | 90 | ); |
91 | - foreach(array('order','sort') as $name) |
|
91 | + foreach (array('order', 'sort') as $name) |
|
92 | 92 | { |
93 | - if (isset($GLOBALS[$where][$name]) && !is_array($GLOBALS[$where][$name]) && !preg_match($pregs[$name],$GLOBALS[$where][$name])) |
|
93 | + if (isset($GLOBALS[$where][$name]) && !is_array($GLOBALS[$where][$name]) && !preg_match($pregs[$name], $GLOBALS[$where][$name])) |
|
94 | 94 | { |
95 | 95 | $GLOBALS[$where][$name] = ''; |
96 | 96 | } |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | // speeds up the execusion a bit |
100 | 100 | if (isset($GLOBALS[$where]) && is_array($GLOBALS[$where]) && ($n < 3 || isset($GLOBALS['egw_unset_vars']))) |
101 | 101 | { |
102 | - _check_script_tag($GLOBALS[$where],$where); |
|
102 | + _check_script_tag($GLOBALS[$where], $where); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | //if (is_array($GLOBALS['egw_unset_vars'])) { echo "egw_unset_vars=<pre>".htmlspecialchars(print_r($GLOBALS['egw_unset_vars'],true))."</pre>"; exit; } |
106 | 106 | |
107 | 107 | // $GLOBALS[egw_info][flags][currentapp] and die if it contains something nasty or unexpected |
108 | 108 | if (isset($GLOBALS['egw_info']) && isset($GLOBALS['egw_info']['flags']) && |
109 | - isset($GLOBALS['egw_info']['flags']['currentapp']) && !preg_match('/^[A-Za-z0-9_-]+$/',$GLOBALS['egw_info']['flags']['currentapp'])) |
|
109 | + isset($GLOBALS['egw_info']['flags']['currentapp']) && !preg_match('/^[A-Za-z0-9_-]+$/', $GLOBALS['egw_info']['flags']['currentapp'])) |
|
110 | 110 | { |
111 | 111 | error_log(__FILE__.': '.__LINE__.' Invalid $GLOBALS[egw_info][flags][currentapp]='.array2string($GLOBALS['egw_info']['flags']['currentapp']).', $_SERVER[REQUEST_URI]='.array2string($_SERVER['REQUEST_URI'])); |
112 | 112 | die('Invalid $GLOBALS[egw_info][flags][currentapp]!'); |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | die('GLOBALS overwrite detected!!!'); |
125 | 125 | } |
126 | 126 | // unregister all globals |
127 | - $noUnset = array('GLOBALS','_GET','_POST','_COOKIE','_SERVER','_ENV','_FILES','xajax'); |
|
128 | - foreach(array_unique(array_merge( |
|
129 | - array_keys($_GET),array_keys($_POST),array_keys($_COOKIE),array_keys($_SERVER),array_keys($_ENV),array_keys($_FILES), |
|
127 | + $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_SERVER', '_ENV', '_FILES', 'xajax'); |
|
128 | + foreach (array_unique(array_merge( |
|
129 | + array_keys($_GET), array_keys($_POST), array_keys($_COOKIE), array_keys($_SERVER), array_keys($_ENV), array_keys($_FILES), |
|
130 | 130 | isset($_SESSION) && is_array($_SESSION) ? array_keys($_SESSION) : array())) as $k) |
131 | 131 | { |
132 | - if (!in_array($k,$noUnset) && isset($GLOBALS[$k])) |
|
132 | + if (!in_array($k, $noUnset) && isset($GLOBALS[$k])) |
|
133 | 133 | { |
134 | 134 | unset($GLOBALS[$k]); |
135 | 135 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | preg_match('/(^|;|{)[OC]:\d+:"/', $str)) |
160 | 160 | { |
161 | 161 | error_log(__METHOD__."('$str') contains objects --> return NULL"); |
162 | - return null; // null, not false, to not trigger behavior of returning string itself to app code |
|
162 | + return null; // null, not false, to not trigger behavior of returning string itself to app code |
|
163 | 163 | } |
164 | 164 | return unserialize($str); |
165 | 165 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param boolean $allow_not_serialized =false true: return $str as is, if it is no serialized array |
174 | 174 | * @return array|str|false false if content can not be unserialized (not null like json_decode!) |
175 | 175 | */ |
176 | -function json_php_unserialize($str, $allow_not_serialized=false) |
|
176 | +function json_php_unserialize($str, $allow_not_serialized = false) |
|
177 | 177 | { |
178 | 178 | if ((in_array($str[0], array('a', 'i', 's', 'b', 'O', 'C')) && $str[1] == ':' || $str === 'N;') && |
179 | 179 | ($arr = php_safe_unserialize($str)) !== false || $str === 'b:0;') |
@@ -19,4 +19,6 @@ |
||
19 | 19 | * User lacks a record level permission, eg. he's not the owner and has no grant from the owner |
20 | 20 | * |
21 | 21 | */ |
22 | -class Record extends Exception\NoPermission { } |
|
22 | +class Record extends Exception\NoPermission |
|
23 | +{ |
|
24 | +} |
@@ -17,4 +17,6 @@ |
||
17 | 17 | * Wrong or missing required user input: message should be translated so it can be shown directly to the user |
18 | 18 | * |
19 | 19 | */ |
20 | -class WrongUserinput extends AssertionFailed { } |
|
20 | +class WrongUserinput extends AssertionFailed |
|
21 | +{ |
|
22 | +} |
@@ -18,4 +18,6 @@ |
||
18 | 18 | * |
19 | 19 | * As you get this only by an error in the code or during development, the message does not need to be translated |
20 | 20 | */ |
21 | -class WrongParameter extends AssertionFailed { } |
|
21 | +class WrongParameter extends AssertionFailed |
|
22 | +{ |
|
23 | +} |
@@ -20,4 +20,6 @@ |
||
20 | 20 | * |
21 | 21 | * As you get this only by an error in the code or during development, the message does not need to be translated |
22 | 22 | */ |
23 | -class AssertionFailed extends Api\Exception { } |
|
23 | +class AssertionFailed extends Api\Exception |
|
24 | +{ |
|
25 | +} |