@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Mime type of directories, the old vfs used 'Directory', while eg. WebDAV uses 'httpd/unix-directory' |
53 | 53 | */ |
54 | - const DIR_MIME_TYPE = Vfs::DIR_MIME_TYPE ; |
|
54 | + const DIR_MIME_TYPE = Vfs::DIR_MIME_TYPE; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * mode-bits, which have to be set for files |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * mode-bits, which have to be set for directories |
62 | 62 | */ |
63 | - const MODE_DIR = 040000; |
|
63 | + const MODE_DIR = 040000; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * optional context param when opening the stream, null if no context passed |
@@ -123,50 +123,50 @@ discard block |
||
123 | 123 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
124 | 124 | * @return boolean true if the ressource was opened successful, otherwise false |
125 | 125 | */ |
126 | - function stream_open ( $url, $mode, $options, &$opened_path ) |
|
126 | + function stream_open($url, $mode, $options, &$opened_path) |
|
127 | 127 | { |
128 | - unset($opened_path); // not used, but required by interface |
|
128 | + unset($opened_path); // not used, but required by interface |
|
129 | 129 | |
130 | 130 | $this->opened_stream = $this->opened_stream_url = null; |
131 | - $read_only = str_replace('b','',$mode) == 'r'; |
|
131 | + $read_only = str_replace('b', '', $mode) == 'r'; |
|
132 | 132 | |
133 | 133 | // check access rights, based on the eGW mount perms |
134 | - if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
134 | + if (!($stat = self::url_stat($url, 0)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
135 | 135 | { |
136 | 136 | $dir = Vfs::dirname($url); |
137 | - if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
138 | - $mode[0] == 'x' || // or file should not exist, but does |
|
139 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) // or we are not allowed to create it |
|
137 | + if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
138 | + $mode[0] == 'x' || // or file should not exist, but does |
|
139 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = self::url_stat($dir, 0))) // or we are not allowed to create it |
|
140 | 140 | { |
141 | 141 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
142 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
142 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
143 | 143 | { |
144 | - trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
|
144 | + trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!", E_USER_WARNING); |
|
145 | 145 | } |
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | } |
149 | - elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // we are not allowed to edit it |
|
149 | + elseif (!$read_only && !Vfs::check_access($url, Vfs::WRITABLE, $stat)) // we are not allowed to edit it |
|
150 | 150 | { |
151 | 151 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be edited!"); |
152 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
152 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
153 | 153 | { |
154 | - trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!",E_USER_WARNING); |
|
154 | + trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!", E_USER_WARNING); |
|
155 | 155 | } |
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | if (!$read_only && self::deny_script($url)) |
159 | 159 | { |
160 | 160 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!"); |
161 | - if (!($options & STREAM_URL_STAT_QUIET)) |
|
161 | + if (!($options&STREAM_URL_STAT_QUIET)) |
|
162 | 162 | { |
163 | - trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!",E_USER_WARNING); |
|
163 | + trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!", E_USER_WARNING); |
|
164 | 164 | } |
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // open the "real" file |
169 | - if (!($this->opened_stream = fopen($path=Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)),$mode,$options))) |
|
169 | + if (!($this->opened_stream = fopen($path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)), $mode, $options))) |
|
170 | 170 | { |
171 | 171 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!"); |
172 | 172 | return false; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * You must release any resources that were locked or allocated by the stream. |
183 | 183 | */ |
184 | - function stream_close ( ) |
|
184 | + function stream_close( ) |
|
185 | 185 | { |
186 | 186 | $ret = fclose($this->opened_stream); |
187 | 187 | |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | * @param int $count |
202 | 202 | * @return string/false up to count bytes read or false on EOF |
203 | 203 | */ |
204 | - function stream_read ( $count ) |
|
204 | + function stream_read($count) |
|
205 | 205 | { |
206 | - return fread($this->opened_stream,$count); |
|
206 | + return fread($this->opened_stream, $count); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param string $data |
218 | 218 | * @return integer |
219 | 219 | */ |
220 | - function stream_write ( $data ) |
|
220 | + function stream_write($data) |
|
221 | 221 | { |
222 | - return fwrite($this->opened_stream,$data); |
|
222 | + return fwrite($this->opened_stream, $data); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
236 | 236 | */ |
237 | - function stream_eof ( ) |
|
237 | + function stream_eof( ) |
|
238 | 238 | { |
239 | 239 | return feof($this->opened_stream); |
240 | 240 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return integer current read/write position of the stream |
246 | 246 | */ |
247 | - function stream_tell ( ) |
|
247 | + function stream_tell( ) |
|
248 | 248 | { |
249 | 249 | return ftell($this->opened_stream); |
250 | 250 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | * SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
262 | 262 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
263 | 263 | */ |
264 | - function stream_seek ( $offset, $whence ) |
|
264 | + function stream_seek($offset, $whence) |
|
265 | 265 | { |
266 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
266 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
275 | 275 | */ |
276 | - function stream_flush ( ) |
|
276 | + function stream_flush( ) |
|
277 | 277 | { |
278 | 278 | return fflush($this->opened_stream); |
279 | 279 | } |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return array containing the same values as appropriate for the stream. |
294 | 294 | */ |
295 | - function stream_stat ( ) |
|
295 | + function stream_stat( ) |
|
296 | 296 | { |
297 | - return self::url_stat($this->opened_stream_url,0); |
|
297 | + return self::url_stat($this->opened_stream_url, 0); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | * @param string $url |
307 | 307 | * @return boolean TRUE on success or FALSE on failure |
308 | 308 | */ |
309 | - static function unlink ( $url ) |
|
309 | + static function unlink($url) |
|
310 | 310 | { |
311 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
311 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
312 | 312 | |
313 | 313 | // check access rights (file need to exist and directory need to be writable |
314 | - if (!file_exists($path) || is_dir($path) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
|
314 | + if (!file_exists($path) || is_dir($path) || !Vfs::check_access(Vfs::dirname($url), Vfs::WRITABLE)) |
|
315 | 315 | { |
316 | 316 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
317 | - return false; // no permission or file does not exist |
|
317 | + return false; // no permission or file does not exist |
|
318 | 318 | } |
319 | 319 | return unlink($path); |
320 | 320 | } |
@@ -331,22 +331,22 @@ discard block |
||
331 | 331 | * @param string $url_to |
332 | 332 | * @return boolean TRUE on success or FALSE on failure |
333 | 333 | */ |
334 | - static function rename ( $url_from, $url_to ) |
|
334 | + static function rename($url_from, $url_to) |
|
335 | 335 | { |
336 | 336 | $from = Vfs::parse_url($url_from); |
337 | 337 | $to = Vfs::parse_url($url_to); |
338 | 338 | |
339 | 339 | // check access rights |
340 | - if (!($from_stat = self::url_stat($url_from,0)) || !Vfs::check_access(Vfs::dirname($url_from),Vfs::WRITABLE)) |
|
340 | + if (!($from_stat = self::url_stat($url_from, 0)) || !Vfs::check_access(Vfs::dirname($url_from), Vfs::WRITABLE)) |
|
341 | 341 | { |
342 | 342 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); |
343 | - return false; // no permission or file does not exist |
|
343 | + return false; // no permission or file does not exist |
|
344 | 344 | } |
345 | 345 | $to_dir = Vfs::dirname($url_to); |
346 | - if (!Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = self::url_stat($to_dir,0))) |
|
346 | + if (!Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = self::url_stat($to_dir, 0))) |
|
347 | 347 | { |
348 | 348 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); |
349 | - return false; // no permission or parent-dir does not exist |
|
349 | + return false; // no permission or parent-dir does not exist |
|
350 | 350 | } |
351 | 351 | if (self::deny_script($url_to)) |
352 | 352 | { |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | } |
356 | 356 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
357 | 357 | // for our vfs too, we abort here with an error, like the filesystem one does |
358 | - if (($to_stat = self::url_stat($to['path'],0)) && |
|
358 | + if (($to_stat = self::url_stat($to['path'], 0)) && |
|
359 | 359 | ($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE)) |
360 | 360 | { |
361 | 361 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
362 | 362 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!"); |
363 | - return false; // no permission or file does not exist |
|
363 | + return false; // no permission or file does not exist |
|
364 | 364 | } |
365 | 365 | // if destination file already exists, delete it |
366 | 366 | if ($to_stat && !self::unlink($url_to)) |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
369 | 369 | return false; |
370 | 370 | } |
371 | - return rename(Vfs::decodePath($from['path']),Vfs::decodePath($to['path'])); |
|
371 | + return rename(Vfs::decodePath($from['path']), Vfs::decodePath($to['path'])); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
383 | 383 | * @return boolean TRUE on success or FALSE on failure |
384 | 384 | */ |
385 | - static function mkdir ( $url, $mode, $options ) |
|
385 | + static function mkdir($url, $mode, $options) |
|
386 | 386 | { |
387 | - unset($mode); // not used, but required by interface |
|
387 | + unset($mode); // not used, but required by interface |
|
388 | 388 | |
389 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
390 | - $recursive = (bool)($options & STREAM_MKDIR_RECURSIVE); |
|
389 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
390 | + $recursive = (bool)($options&STREAM_MKDIR_RECURSIVE); |
|
391 | 391 | |
392 | 392 | // find the real parent (might be more then one level if $recursive!) |
393 | 393 | do { |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | //echo __METHOD__."($url,$mode,$options) path=$path, recursive=$recursive, parent=$parent, Vfs::check_access(parent_url=$parent_url,Vfs::WRITABLE)=".(int)Vfs::check_access($parent_url,Vfs::WRITABLE)."\n"; |
399 | 399 | |
400 | 400 | // check access rights (in real filesystem AND by mount perms) |
401 | - if (file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url,Vfs::WRITABLE)) |
|
401 | + if (file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url, Vfs::WRITABLE)) |
|
402 | 402 | { |
403 | 403 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
404 | 404 | return false; |
405 | 405 | } |
406 | - return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
|
406 | + return mkdir($path, 0700, $recursive); // setting mode 0700 allows (only) apache to write into the dir |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -416,15 +416,15 @@ discard block |
||
416 | 416 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
417 | 417 | * @return boolean TRUE on success or FALSE on failure. |
418 | 418 | */ |
419 | - static function rmdir ( $url, $options ) |
|
419 | + static function rmdir($url, $options) |
|
420 | 420 | { |
421 | - unset($options); // not used, but required by interface |
|
421 | + unset($options); // not used, but required by interface |
|
422 | 422 | |
423 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
423 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
424 | 424 | $parent = dirname($path); |
425 | 425 | |
426 | 426 | // check access rights (in real filesystem AND by mount perms) |
427 | - if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
|
427 | + if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url), Vfs::WRITABLE)) |
|
428 | 428 | { |
429 | 429 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
430 | 430 | return false; |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
441 | 441 | * @return boolean true on success, false otherwise |
442 | 442 | */ |
443 | - static function touch($url,$time=null,$atime=null) |
|
443 | + static function touch($url, $time = null, $atime = null) |
|
444 | 444 | { |
445 | - $path = Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)); |
|
445 | + $path = Vfs::decodePath(Vfs::parse_url($url, PHP_URL_PATH)); |
|
446 | 446 | $parent = dirname($path); |
447 | 447 | |
448 | 448 | // check access rights (in real filesystem AND by mount perms) |
449 | - if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE)) |
|
449 | + if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url), Vfs::WRITABLE)) |
|
450 | 450 | { |
451 | 451 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
452 | 452 | return false; |
453 | 453 | } |
454 | - return touch($path,$time,$atime); |
|
454 | + return touch($path, $time, $atime); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | * @param string $mode mode string see Vfs::mode2int |
464 | 464 | * @return boolean true on success, false otherwise |
465 | 465 | */ |
466 | - static function chmod($path,$mode) |
|
466 | + static function chmod($path, $mode) |
|
467 | 467 | { |
468 | - unset($path, $mode); // not used, but required by interface |
|
468 | + unset($path, $mode); // not used, but required by interface |
|
469 | 469 | |
470 | 470 | return false; |
471 | 471 | } |
@@ -479,9 +479,9 @@ discard block |
||
479 | 479 | * @param int $owner numeric user id |
480 | 480 | * @return boolean true on success, false otherwise |
481 | 481 | */ |
482 | - static function chown($path,$owner) |
|
482 | + static function chown($path, $owner) |
|
483 | 483 | { |
484 | - unset($path, $owner); // not used, but required by interface |
|
484 | + unset($path, $owner); // not used, but required by interface |
|
485 | 485 | |
486 | 486 | return false; |
487 | 487 | } |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | * @param int $group numeric group id |
496 | 496 | * @return boolean true on success, false otherwise |
497 | 497 | */ |
498 | - static function chgrp($path,$group) |
|
498 | + static function chgrp($path, $group) |
|
499 | 499 | { |
500 | - unset($path, $group); // not used, but required by interface |
|
500 | + unset($path, $group); // not used, but required by interface |
|
501 | 501 | |
502 | 502 | return false; |
503 | 503 | } |
@@ -509,13 +509,13 @@ discard block |
||
509 | 509 | * @param int $options |
510 | 510 | * @return booelan |
511 | 511 | */ |
512 | - function dir_opendir ( $url, $options ) |
|
512 | + function dir_opendir($url, $options) |
|
513 | 513 | { |
514 | 514 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)"); |
515 | 515 | |
516 | 516 | $this->opened_dir = null; |
517 | 517 | |
518 | - $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url,PHP_URL_PATH)); |
|
518 | + $path = Vfs::decodePath(Vfs::parse_url($this->opened_dir_url = $url, PHP_URL_PATH)); |
|
519 | 519 | |
520 | 520 | // ToDo: check access rights |
521 | 521 | |
@@ -553,31 +553,31 @@ discard block |
||
553 | 553 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
554 | 554 | * @return array |
555 | 555 | */ |
556 | - static function url_stat ( $url, $flags ) |
|
556 | + static function url_stat($url, $flags) |
|
557 | 557 | { |
558 | 558 | $parts = Vfs::parse_url($url); |
559 | 559 | $path = Vfs::decodePath($parts['path']); |
560 | 560 | |
561 | - $stat = @stat($path); // suppressed the stat failed warnings |
|
561 | + $stat = @stat($path); // suppressed the stat failed warnings |
|
562 | 562 | |
563 | 563 | if ($stat) |
564 | 564 | { |
565 | 565 | // set owner, group and mode from mount options |
566 | 566 | $uid = $gid = $mode = null; |
567 | - if (!self::parse_query($parts['query'],$uid,$gid,$mode)) |
|
567 | + if (!self::parse_query($parts['query'], $uid, $gid, $mode)) |
|
568 | 568 | { |
569 | 569 | return false; |
570 | 570 | } |
571 | 571 | $stat['uid'] = $stat[4] = $uid; |
572 | 572 | $stat['gid'] = $stat[5] = $gid; |
573 | - $stat['mode'] = $stat[2] = $stat['mode'] & self::MODE_DIR ? self::MODE_DIR | $mode : self::MODE_FILE | ($mode & ~0111); |
|
573 | + $stat['mode'] = $stat[2] = $stat['mode']&self::MODE_DIR ? self::MODE_DIR|$mode : self::MODE_FILE|($mode&~0111); |
|
574 | 574 | // write rights also depend on the write rights of the webserver |
575 | 575 | if (!is_writable($path)) |
576 | 576 | { |
577 | - $stat['mode'] = $stat[2] = $stat['mode'] & ~0222; |
|
577 | + $stat['mode'] = $stat[2] = $stat['mode']&~0222; |
|
578 | 578 | } |
579 | 579 | } |
580 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
580 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o', $mode).", mode=".sprintf('0%o', $stat['mode']).'='.Vfs::int2mode($stat['mode'])); |
|
581 | 581 | return $stat; |
582 | 582 | } |
583 | 583 | |
@@ -591,13 +591,13 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return string |
593 | 593 | */ |
594 | - function dir_readdir ( ) |
|
594 | + function dir_readdir( ) |
|
595 | 595 | { |
596 | 596 | do { |
597 | 597 | $file = readdir($this->opened_dir); |
598 | 598 | |
599 | - $ignore = !($file === false || // stop if no more dirs or |
|
600 | - ($file != '.' && $file != '..' )); // file not . or .. |
|
599 | + $ignore = !($file === false || // stop if no more dirs or |
|
600 | + ($file != '.' && $file != '..')); // file not . or .. |
|
601 | 601 | if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file)); |
602 | 602 | } |
603 | 603 | while ($ignore); |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * |
619 | 619 | * @return boolean |
620 | 620 | */ |
621 | - function dir_rewinddir ( ) |
|
621 | + function dir_rewinddir( ) |
|
622 | 622 | { |
623 | 623 | return rewinddir($this->opened_dir); |
624 | 624 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @return boolean |
632 | 632 | */ |
633 | - function dir_closedir ( ) |
|
633 | + function dir_closedir( ) |
|
634 | 634 | { |
635 | 635 | closedir($this->opened_dir); |
636 | 636 | |
@@ -648,18 +648,18 @@ discard block |
||
648 | 648 | * @param int &$mode default if not set is 05 r-x for others |
649 | 649 | * @return boolean true on successfull parse, false on error |
650 | 650 | */ |
651 | - static function parse_query($query,&$uid,&$gid,&$mode) |
|
651 | + static function parse_query($query, &$uid, &$gid, &$mode) |
|
652 | 652 | { |
653 | 653 | $params = null; |
654 | - parse_str(is_array($query) ? $query['query'] : $query,$params); |
|
654 | + parse_str(is_array($query) ? $query['query'] : $query, $params); |
|
655 | 655 | |
656 | 656 | // setting the default perms root.root r-x for other |
657 | 657 | $uid = $gid = 0; |
658 | 658 | $mode = 05; |
659 | 659 | |
660 | - foreach($params as $name => $value) |
|
660 | + foreach ($params as $name => $value) |
|
661 | 661 | { |
662 | - switch($name) |
|
662 | + switch ($name) |
|
663 | 663 | { |
664 | 664 | case 'user': |
665 | 665 | if (!is_numeric($value)) |
@@ -668,10 +668,10 @@ discard block |
||
668 | 668 | { |
669 | 669 | $value = 0; |
670 | 670 | } |
671 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','u')) === false) |
|
671 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false) |
|
672 | 672 | { |
673 | 673 | error_log(__METHOD__."('$query') unknown user-name '$value'!"); |
674 | - return false; // wrong user-name |
|
674 | + return false; // wrong user-name |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 | // fall-through |
@@ -690,12 +690,12 @@ discard block |
||
690 | 690 | { |
691 | 691 | $value = 0; |
692 | 692 | } |
693 | - elseif (($value = $GLOBALS['egw']->accounts->name2id($value,'account_lid','g')) === false) |
|
693 | + elseif (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false) |
|
694 | 694 | { |
695 | 695 | error_log(__METHOD__."('$query') unknown group-name '$value'!"); |
696 | - return false; // wrong group-name |
|
696 | + return false; // wrong group-name |
|
697 | 697 | } |
698 | - $value = -$value; // vfs uses positiv gid's! |
|
698 | + $value = -$value; // vfs uses positiv gid's! |
|
699 | 699 | } |
700 | 700 | // fall-through |
701 | 701 | case 'gid': |
@@ -731,9 +731,9 @@ discard block |
||
731 | 731 | { |
732 | 732 | $parts = Vfs::parse_url($url); |
733 | 733 | $get = null; |
734 | - parse_str($parts['query'],$get); |
|
734 | + parse_str($parts['query'], $get); |
|
735 | 735 | |
736 | - $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG,$parts['path']); |
|
736 | + $deny = !$get['exec'] && preg_match(self::SCRIPT_EXTENSIONS_PREG, $parts['path']); |
|
737 | 737 | |
738 | 738 | if (self::LOG_LEVEL > 1 || self::LOG_LEVEL > 0 && $deny) |
739 | 739 | { |
@@ -753,21 +753,21 @@ discard block |
||
753 | 753 | * @todo get $force_download working through webdav |
754 | 754 | * @return string|false string with full download url or false to use default webdav.php url |
755 | 755 | */ |
756 | - static function download_url($_url,$force_download=false) |
|
756 | + static function download_url($_url, $force_download = false) |
|
757 | 757 | { |
758 | - unset($force_download); // not used, but required by interface |
|
758 | + unset($force_download); // not used, but required by interface |
|
759 | 759 | |
760 | - list($url,$query) = explode('?',$_url,2); |
|
760 | + list($url, $query) = explode('?', $_url, 2); |
|
761 | 761 | $get = null; |
762 | - parse_str($query,$get); |
|
763 | - if (empty($get['url'])) return false; // no download url given for this mount-point |
|
762 | + parse_str($query, $get); |
|
763 | + if (empty($get['url'])) return false; // no download url given for this mount-point |
|
764 | 764 | |
765 | - if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
766 | - list($mount_url) = explode('?',$mount_url); |
|
765 | + if (!($mount_url = Vfs::mount_url($_url))) return false; // no mount url found, should not happen |
|
766 | + list($mount_url) = explode('?', $mount_url); |
|
767 | 767 | |
768 | - $relpath = substr($url,strlen($mount_url)); |
|
768 | + $relpath = substr($url, strlen($mount_url)); |
|
769 | 769 | |
770 | - $download_url = Vfs::concat($get['url'],$relpath); |
|
770 | + $download_url = Vfs::concat($get['url'], $relpath); |
|
771 | 771 | if ($download_url[0] == '/') |
772 | 772 | { |
773 | 773 | $download_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://'). |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | * @param string $opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set |
40 | 40 | * @return boolean true if the ressource was opened successful, otherwise false |
41 | 41 | */ |
42 | - function stream_open ( $path, $mode, $options, &$opened_path ); |
|
42 | + function stream_open($path, $mode, $options, &$opened_path); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * This method is called when the stream is closed, using fclose(). |
46 | 46 | * |
47 | 47 | * You must release any resources that were locked or allocated by the stream. |
48 | 48 | */ |
49 | - function stream_close ( ); |
|
49 | + function stream_close( ); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * This method is called in response to fread() and fgets() calls on the stream. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param int $count |
60 | 60 | * @return string/false up to count bytes read or false on EOF |
61 | 61 | */ |
62 | - function stream_read ( $count ); |
|
62 | + function stream_read($count); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * This method is called in response to fwrite() calls on the stream. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $data |
73 | 73 | * @return integer |
74 | 74 | */ |
75 | - function stream_write ( $data ); |
|
75 | + function stream_write($data); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * This method is called in response to feof() calls on the stream. |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
88 | 88 | */ |
89 | - function stream_eof ( ); |
|
89 | + function stream_eof( ); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * This method is called in response to ftell() calls on the stream. |
93 | 93 | * |
94 | 94 | * @return integer current read/write position of the stream |
95 | 95 | */ |
96 | - function stream_tell ( ); |
|
96 | + function stream_tell( ); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * This method is called in response to fseek() calls on the stream. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * SEEK_END - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
108 | 108 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
109 | 109 | */ |
110 | - function stream_seek ( $offset, $whence ); |
|
110 | + function stream_seek($offset, $whence); |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * This method is called in response to fflush() calls on the stream. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
118 | 118 | */ |
119 | - function stream_flush ( ); |
|
119 | + function stream_flush( ); |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * This method is called in response to fstat() calls on the stream. |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return array containing the same values as appropriate for the stream. |
134 | 134 | */ |
135 | - function stream_stat ( ); |
|
135 | + function stream_stat( ); |
|
136 | 136 | |
137 | 137 | /** |
138 | 138 | * This method is called in response to unlink() calls on URL paths associated with the wrapper. |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $path |
144 | 144 | * @return boolean TRUE on success or FALSE on failure |
145 | 145 | */ |
146 | - static function unlink ( $path ); |
|
146 | + static function unlink($path); |
|
147 | 147 | |
148 | 148 | /** |
149 | 149 | * This method is called in response to rename() calls on URL paths associated with the wrapper. |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $path_to |
158 | 158 | * @return boolean TRUE on success or FALSE on failure |
159 | 159 | */ |
160 | - static function rename ( $path_from, $path_to ); |
|
160 | + static function rename($path_from, $path_to); |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * This method is called in response to mkdir() calls on URL paths associated with the wrapper. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
171 | 171 | * @return boolean TRUE on success or FALSE on failure |
172 | 172 | */ |
173 | - static function mkdir ( $path, $mode, $options ); |
|
173 | + static function mkdir($path, $mode, $options); |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * This method is called in response to rmdir() calls on URL paths associated with the wrapper. |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
183 | 183 | * @return boolean TRUE on success or FALSE on failure. |
184 | 184 | */ |
185 | - static function rmdir ( $path, $options ); |
|
185 | + static function rmdir($path, $options); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * This method is called immediately when your stream object is created for examining directory contents with opendir(). |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $path URL that was passed to opendir() and that this object is expected to explore. |
191 | 191 | * @return booelan |
192 | 192 | */ |
193 | - function dir_opendir ( $path, $options ); |
|
193 | + function dir_opendir($path, $options); |
|
194 | 194 | |
195 | 195 | /** |
196 | 196 | * This method is called in response to stat() calls on the URL paths associated with the wrapper. |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper! |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - static function url_stat ( $path, $flags ); |
|
221 | + static function url_stat($path, $flags); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * This method is called in response to readdir(). |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - function dir_readdir ( ); |
|
230 | + function dir_readdir( ); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * This method is called in response to rewinddir(). |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return boolean |
239 | 239 | */ |
240 | - function dir_rewinddir ( ); |
|
240 | + function dir_rewinddir( ); |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * This method is called in response to closedir(). |
@@ -246,5 +246,5 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return boolean |
248 | 248 | */ |
249 | - function dir_closedir ( ); |
|
249 | + function dir_closedir( ); |
|
250 | 250 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | // if we are NOT called as part of an update script, behave like a regular setup script |
13 | 13 | if (!isset($GLOBALS['egw_setup']) || !is_object($GLOBALS['egw_setup'])) |
14 | 14 | { |
15 | - $diagnostics = 1; // can be set to 0=non, 1=some (default for now), 2=all |
|
15 | + $diagnostics = 1; // can be set to 0=non, 1=some (default for now), 2=all |
|
16 | 16 | |
17 | 17 | include('./inc/functions.inc.php'); |
18 | 18 | // Authorize the user to use setup app and load the database |
@@ -25,50 +25,50 @@ discard block |
||
25 | 25 | $GLOBALS['egw_setup']->loaddb(); |
26 | 26 | |
27 | 27 | $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); |
28 | - $setup_tpl = CreateObject('phpgwapi.Template',$tpl_root); |
|
28 | + $setup_tpl = CreateObject('phpgwapi.Template', $tpl_root); |
|
29 | 29 | $setup_tpl->set_file(array( |
30 | 30 | 'T_head' => 'head.tpl', |
31 | 31 | 'T_footer' => 'footer.tpl', |
32 | 32 | )); |
33 | - $GLOBALS['egw_setup']->html->show_header('',False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); |
|
33 | + $GLOBALS['egw_setup']->html->show_header('', False, 'config', $GLOBALS['egw_setup']->ConfigDomain.'('.$GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].')'); |
|
34 | 34 | echo '<h3>'.'Fix mysql DB to match the eGroupWare system_charset'."</h3>\n"; |
35 | 35 | $running_standalone = true; |
36 | 36 | } |
37 | -$db =& $GLOBALS['egw_setup']->db; |
|
38 | -$charset2mysql =& $GLOBALS['egw_setup']->db->Link_ID->charset2mysql; |
|
37 | +$db = & $GLOBALS['egw_setup']->db; |
|
38 | +$charset2mysql = & $GLOBALS['egw_setup']->db->Link_ID->charset2mysql; |
|
39 | 39 | $mysql2charset = array_flip($charset2mysql); |
40 | 40 | |
41 | 41 | $ServerInfo = $db->Link_ID->ServerInfo(); |
42 | -$db_version = (float) $ServerInfo['version']; |
|
42 | +$db_version = (float)$ServerInfo['version']; |
|
43 | 43 | |
44 | 44 | if ($running_standalone || $_REQUEST['debug']) echo "<p>DB-Type='<b>{$GLOBALS['egw_setup']->db->Type}</b>', DB-Version=<b>$db_version</b> ($ServerInfo[description]), eGroupWare system_charset='<b>{$GLOBALS['egw_setup']->system_charset}</b>', DB-connection charset was '<b>{$GLOBALS['egw_setup']->db_charset_was}</b>'</p>\n"; |
45 | 45 | |
46 | 46 | $mysql_system_charset = isset($charset2mysql[$GLOBALS['egw_setup']->system_charset]) ? |
47 | 47 | $charset2mysql[$GLOBALS['egw_setup']->system_charset] : $GLOBALS['egw_setup']->system_charset; |
48 | 48 | |
49 | -if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setup']->system_charset && $GLOBALS['egw_setup']->db_charset_was && |
|
49 | +if (substr($db->Type, 0, 5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setup']->system_charset && $GLOBALS['egw_setup']->db_charset_was && |
|
50 | 50 | $GLOBALS['egw_setup']->system_charset != $GLOBALS['egw_setup']->db_charset_was) |
51 | 51 | { |
52 | 52 | $tables_modified = 'no'; |
53 | 53 | |
54 | 54 | $tables = array(); |
55 | - $db->query("SHOW TABLE STATUS",__LINE__,__FILE__); |
|
55 | + $db->query("SHOW TABLE STATUS", __LINE__, __FILE__); |
|
56 | 56 | while (($row = $db->row(true))) |
57 | 57 | { |
58 | 58 | $tables[$row['Name']] = $row['Collation']; |
59 | 59 | } |
60 | - foreach($tables as $table => $collation) |
|
60 | + foreach ($tables as $table => $collation) |
|
61 | 61 | { |
62 | 62 | $columns = array(); |
63 | - $db->query("SHOW FULL FIELDS FROM `$table`",__LINE__,__FILE__); |
|
64 | - while(($row = $db->row(true))) |
|
63 | + $db->query("SHOW FULL FIELDS FROM `$table`", __LINE__, __FILE__); |
|
64 | + while (($row = $db->row(true))) |
|
65 | 65 | { |
66 | 66 | $columns[] = $row; |
67 | 67 | } |
68 | 68 | //echo $table; _debug_array($columns); |
69 | 69 | $fulltext = $fulltext_back = array(); |
70 | - $db->query("SHOW KEYS FROM `$table`",__LINE__,__FILE__); |
|
71 | - while(($row = $db->row(true))) |
|
70 | + $db->query("SHOW KEYS FROM `$table`", __LINE__, __FILE__); |
|
71 | + while (($row = $db->row(true))) |
|
72 | 72 | { |
73 | 73 | if ($row['Index_type'] == 'FULLTEXT') |
74 | 74 | { |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | $alter_table = $alter_table_back = array(); |
80 | - foreach($columns as $column) |
|
80 | + foreach ($columns as $column) |
|
81 | 81 | { |
82 | - if ($column['Collation'] && preg_match('/^(char|varchar|.*text)\(?([0-9]*)\)?$/i',$column['Type'],$matches)) |
|
82 | + if ($column['Collation'] && preg_match('/^(char|varchar|.*text)\(?([0-9]*)\)?$/i', $column['Type'], $matches)) |
|
83 | 83 | { |
84 | - list(,$type,$size) = $matches; |
|
85 | - list($charset) = explode('_',$column['Collation']); |
|
84 | + list(,$type, $size) = $matches; |
|
85 | + list($charset) = explode('_', $column['Collation']); |
|
86 | 86 | |
87 | 87 | if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset]; |
88 | 88 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | else |
99 | 99 | { |
100 | - $bintype = str_replace('text','blob',$type); |
|
100 | + $bintype = str_replace('text', 'blob', $type); |
|
101 | 101 | } |
102 | 102 | //echo "<p>$table.$col $type CHARACTER SET $charset $default $null</p>\n"; |
103 | 103 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | $idx_name = $fulltext[$col]; |
110 | 110 | $idx_cols = array(); |
111 | - foreach($fulltext as $c => $i) |
|
111 | + foreach ($fulltext as $c => $i) |
|
112 | 112 | { |
113 | 113 | if ($i == $idx_name) |
114 | 114 | { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | - list($charset) = explode('_',$collation); |
|
127 | + list($charset) = explode('_', $collation); |
|
128 | 128 | if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset]; |
129 | 129 | if ($charset != $GLOBALS['egw_setup']->system_charset) |
130 | 130 | { |
@@ -132,26 +132,26 @@ discard block |
||
132 | 132 | } |
133 | 133 | if (count($alter_table)) |
134 | 134 | { |
135 | - $alter_table = "ALTER TABLE $table\n".implode(",\n",$alter_table); |
|
135 | + $alter_table = "ALTER TABLE $table\n".implode(",\n", $alter_table); |
|
136 | 136 | |
137 | 137 | if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table)."</p>\n"; |
138 | - if (!$db->query($alter_table,__LINE__,__FILE__)) |
|
138 | + if (!$db->query($alter_table, __LINE__, __FILE__)) |
|
139 | 139 | { |
140 | 140 | echo "<p>SQL Error: ".nl2br($alter_table)."</p>\n"; |
141 | 141 | echo "<b>{$db->Type} Error</b>: {$db->Errno} ({$db->Error})</p>\n"; |
142 | 142 | echo "<p>continuing ...</p>\n"; |
143 | 143 | continue; |
144 | 144 | } |
145 | - foreach($fulltext_back as $idx_name => $idx_cols) |
|
145 | + foreach ($fulltext_back as $idx_name => $idx_cols) |
|
146 | 146 | { |
147 | - $alter_table_back[] = " ADD FULLTEXT `$idx_name` (`".implode('`,`',$idx_cols)."`)"; |
|
147 | + $alter_table_back[] = " ADD FULLTEXT `$idx_name` (`".implode('`,`', $idx_cols)."`)"; |
|
148 | 148 | } |
149 | 149 | if (count($alter_table_back)) |
150 | 150 | { |
151 | - $alter_table_back = "ALTER TABLE $table\n".implode(",\n",$alter_table_back); |
|
151 | + $alter_table_back = "ALTER TABLE $table\n".implode(",\n", $alter_table_back); |
|
152 | 152 | |
153 | 153 | if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table_back)."</p>\n"; |
154 | - if (!$db->query($alter_table_back,__LINE__,__FILE__)) |
|
154 | + if (!$db->query($alter_table_back, __LINE__, __FILE__)) |
|
155 | 155 | { |
156 | 156 | echo "<p><b>SQL Error</b>: ".nl2br($alter_table_back)."</p>\n"; |
157 | 157 | echo "<b>{$db->Type} Error</b>: {$db->Errno} ({$db->Error})</p>\n"; |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | // change the default charset of the DB |
166 | - $db->query("SHOW CREATE DATABASE `$db->Database`",__LINE__,__FILE__); |
|
166 | + $db->query("SHOW CREATE DATABASE `$db->Database`", __LINE__, __FILE__); |
|
167 | 167 | $create_db = $db->next_record() ? $db->f(1) : ''; |
168 | - if (preg_match('/CHARACTER SET ([a-z1-9_-]+) /i',$create_db,$matches) && $matches[1] != $mysql_system_charset) |
|
168 | + if (preg_match('/CHARACTER SET ([a-z1-9_-]+) /i', $create_db, $matches) && $matches[1] != $mysql_system_charset) |
|
169 | 169 | { |
170 | 170 | $alter_db = "ALTER DATABASE `$db->Database` DEFAULT CHARACTER SET $mysql_system_charset"; |
171 | 171 | if ($running_standalone || $_REQUEST['debug']) echo '<p>'.$alter_db."</p>\n"; |
172 | - $db->query($alter_db,__LINE__,__FILE__); |
|
172 | + $db->query($alter_db, __LINE__, __FILE__); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | if ($running_standalone || $_REQUEST['debug']) |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string $config_passwd=null pw of above user |
24 | 24 | * @param boolean $verbose=false if true, echos out some status information during the run |
25 | 25 | */ |
26 | - function __construct($domain,$config_user=null,$config_passwd=null) |
|
26 | + function __construct($domain, $config_user = null, $config_passwd = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($domain)) |
29 | 29 | { |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
46 | 46 | * @throws Exception('header.inc.php not found!'); |
47 | 47 | */ |
48 | - protected function exec($check_only=false) |
|
48 | + protected function exec($check_only = false) |
|
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) return true; // nothing to check, no arguments ... |
|
51 | 51 | |
52 | 52 | // instanciate setup object and check authorisation |
53 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
53 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
54 | 54 | |
55 | - $this->check_installed($this->domain,15,$this->verbose); |
|
55 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
56 | 56 | |
57 | 57 | global $setup_info; |
58 | - foreach($setup_info as $appname => $info) |
|
58 | + foreach ($setup_info as $appname => $info) |
|
59 | 59 | { |
60 | 60 | if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
61 | 61 | } |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function vfs_storage_mode_options($config) |
22 | 22 | { |
23 | - if (!isset($config['vfs_fstab']) || $config['vfs_fstab'] == json_encode($default=array( |
|
23 | + if (!isset($config['vfs_fstab']) || $config['vfs_fstab'] == json_encode($default = array( |
|
24 | 24 | '/' => 'sqlfs://$host/', |
25 | 25 | '/apps' => 'links://$host/apps', |
26 | 26 | )) || $config['vfs_fstab'] == serialize($default)) // detect old serialized value too |
27 | 27 | { |
28 | 28 | $config['vfs_storage_mode'] = 'fs'; |
29 | 29 | } |
30 | - elseif($config['vfs_fstab'] == json_encode($default_db=array( |
|
30 | + elseif ($config['vfs_fstab'] == json_encode($default_db = array( |
|
31 | 31 | '/' => 'sqlfs://$host/?storage=db', |
32 | 32 | '/apps' => 'links://$host/apps?storage=db', |
33 | 33 | )) || $config['vfs_fstab'] == serialize($default_db)) // detect old serialized value too |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | $config['vfs_storage_mode'] = 'custom'; |
40 | 40 | } |
41 | 41 | //_debug_array(array_intersect_key($config,array('vfs_fstab'=>1,'vfs_storage_mode'=>1))); |
42 | - foreach(array( |
|
42 | + foreach (array( |
|
43 | 43 | 'fs' => lang('Filesystem (default)'), |
44 | 44 | 'db' => lang('Database').' (problems with files > 1MB)', |
45 | - 'custom' => lang('Custom set via %1','filemanager/cli.php mount'), |
|
45 | + 'custom' => lang('Custom set via %1', 'filemanager/cli.php mount'), |
|
46 | 46 | ) as $name => $label) |
47 | 47 | { |
48 | 48 | if ($name != 'custom' || $name === $config['vfs_storage_mode']) // dont show custom, if not custom |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | |
58 | 58 | function encryptalgo($config) |
59 | 59 | { |
60 | - if(@function_exists('mcrypt_list_algorithms')) |
|
60 | + if (@function_exists('mcrypt_list_algorithms')) |
|
61 | 61 | { |
62 | 62 | $listed = array(); |
63 | - if(!isset($config['mcrypt_algo'])) |
|
63 | + if (!isset($config['mcrypt_algo'])) |
|
64 | 64 | { |
65 | - $config['mcrypt_algo'] = 'tripledes'; /* MCRYPT_TRIPLEDES */ |
|
65 | + $config['mcrypt_algo'] = 'tripledes'; /* MCRYPT_TRIPLEDES */ |
|
66 | 66 | } |
67 | 67 | $algos = @mcrypt_list_algorithms(); |
68 | 68 | $found = False; |
69 | 69 | |
70 | 70 | $out = ''; |
71 | - while(list($key,$value) = each($algos)) |
|
71 | + while (list($key, $value) = each($algos)) |
|
72 | 72 | { |
73 | 73 | $found = True; |
74 | 74 | /* Only show each once - seems this is a problem in some installs */ |
75 | - if(!in_array($value,$listed)) |
|
75 | + if (!in_array($value, $listed)) |
|
76 | 76 | { |
77 | - if($config['mcrypt_algo'] == $value) |
|
77 | + if ($config['mcrypt_algo'] == $value) |
|
78 | 78 | { |
79 | 79 | $selected = ' selected="selected"'; |
80 | 80 | } |
@@ -84,29 +84,29 @@ discard block |
||
84 | 84 | } |
85 | 85 | $descr = strtoupper($value); |
86 | 86 | |
87 | - $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
|
87 | + $out .= '<option value="'.$value.'"'.$selected.'>'.$descr.'</option>'."\n"; |
|
88 | 88 | $listed[] = $value; |
89 | 89 | } |
90 | 90 | } |
91 | - if(!$found) |
|
91 | + if (!$found) |
|
92 | 92 | { |
93 | 93 | /* Something is wrong with their mcrypt install or php.ini */ |
94 | - $out = '<option value="">' . lang('no algorithms available') . '</option>' . "\n"; |
|
94 | + $out = '<option value="">'.lang('no algorithms available').'</option>'."\n"; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | else |
98 | 98 | { |
99 | - $out = '<option value="tripledes">TRIPLEDES</option>' . "\n"; |
|
99 | + $out = '<option value="tripledes">TRIPLEDES</option>'."\n"; |
|
100 | 100 | } |
101 | 101 | return $out; |
102 | 102 | } |
103 | 103 | |
104 | 104 | function encryptmode($config) |
105 | 105 | { |
106 | - if(@function_exists('mcrypt_list_modes')) |
|
106 | + if (@function_exists('mcrypt_list_modes')) |
|
107 | 107 | { |
108 | 108 | $listed = array(); |
109 | - if(!isset($config['mcrypt_mode'])) |
|
109 | + if (!isset($config['mcrypt_mode'])) |
|
110 | 110 | { |
111 | 111 | $config['mcrypt_mode'] = 'cbc'; /* MCRYPT_MODE_CBC */ |
112 | 112 | } |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | $found = False; |
115 | 115 | |
116 | 116 | $out = ''; |
117 | - while(list($key,$value) = each($modes)) |
|
117 | + while (list($key, $value) = each($modes)) |
|
118 | 118 | { |
119 | 119 | $found = True; |
120 | 120 | /* Only show each once - seems this is a problem in some installs */ |
121 | - if(!in_array($value,$listed)) |
|
121 | + if (!in_array($value, $listed)) |
|
122 | 122 | { |
123 | - if($config['mcrypt_mode'] == $value) |
|
123 | + if ($config['mcrypt_mode'] == $value) |
|
124 | 124 | { |
125 | 125 | $selected = ' selected="selected"'; |
126 | 126 | } |
@@ -130,34 +130,34 @@ discard block |
||
130 | 130 | } |
131 | 131 | $descr = strtoupper($value); |
132 | 132 | |
133 | - $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
|
133 | + $out .= '<option value="'.$value.'"'.$selected.'>'.$descr.'</option>'."\n"; |
|
134 | 134 | $listed[] = $value; |
135 | 135 | } |
136 | 136 | } |
137 | - if(!$found) |
|
137 | + if (!$found) |
|
138 | 138 | { |
139 | 139 | /* Something is wrong with their mcrypt install or php.ini */ |
140 | - $out = '<option value="" selected="selected">' . lang('no modes available') . '</option>' . "\n"; |
|
140 | + $out = '<option value="" selected="selected">'.lang('no modes available').'</option>'."\n"; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - $out = '<option value="cbc" selected="selected">CBC</option>' . "\n"; |
|
145 | + $out = '<option value="cbc" selected="selected">CBC</option>'."\n"; |
|
146 | 146 | } |
147 | 147 | return $out; |
148 | 148 | } |
149 | 149 | |
150 | -function passwdhashes($config,$return_hashes=false) |
|
150 | +function passwdhashes($config, $return_hashes = false) |
|
151 | 151 | { |
152 | - $hashes = sql_passwdhashes($config,true); |
|
152 | + $hashes = sql_passwdhashes($config, true); |
|
153 | 153 | if (isset($hashes['crypt'])) |
154 | 154 | { |
155 | - $hashes['des'] = 'des (=crypt)'; // old LDAP name for crypt |
|
155 | + $hashes['des'] = 'des (=crypt)'; // old LDAP name for crypt |
|
156 | 156 | } |
157 | 157 | return $return_hashes ? $hashes : _options_from($hashes, $config['ldap_encryption_type'] ? $config['ldap_encryption_type'] : 'des'); |
158 | 158 | } |
159 | 159 | |
160 | -function sql_passwdhashes($config, $return_hashes=false, &$securest=null) |
|
160 | +function sql_passwdhashes($config, $return_hashes = false, &$securest = null) |
|
161 | 161 | { |
162 | 162 | $hashes = Api\Auth::passwdhashes($securest); |
163 | 163 | |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | */ |
173 | 173 | function auth_types($config) |
174 | 174 | { |
175 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type']); |
|
175 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type']); |
|
176 | 176 | } |
177 | 177 | function auth_type_syncml($config) |
178 | 178 | { |
179 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type_syncml']); |
|
179 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type_syncml']); |
|
180 | 180 | } |
181 | 181 | function auth_type_groupdav($config) |
182 | 182 | { |
183 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type_groupdav']); |
|
183 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type_groupdav']); |
|
184 | 184 | } |
185 | 185 | function auth_type_activesync($config) |
186 | 186 | { |
187 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type_activesync']); |
|
187 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type_activesync']); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | * @param string $selected value of selected optino |
206 | 206 | * @return string |
207 | 207 | */ |
208 | -function _options_from(array $options,$selected) |
|
208 | +function _options_from(array $options, $selected) |
|
209 | 209 | { |
210 | - foreach($options as $value => $label) |
|
210 | + foreach ($options as $value => $label) |
|
211 | 211 | { |
212 | - $out .= '<option value="' . htmlspecialchars($value) . '"' . |
|
213 | - ($selected == $value ? ' selected="selected"' : '') . '>' . $label . '</option>' . "\n"; |
|
212 | + $out .= '<option value="'.htmlspecialchars($value).'"'. |
|
213 | + ($selected == $value ? ' selected="selected"' : '').'>'.$label.'</option>'."\n"; |
|
214 | 214 | } |
215 | 215 | return $out; |
216 | 216 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param boolean $verbose =false if true, echos out some status information during the run |
31 | 31 | * @param string $app =null single application to update or install |
32 | 32 | */ |
33 | - function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$verbose=false,$app=null) |
|
33 | + function __construct($domain, $config_user = null, $config_passwd = null, $backup = null, $verbose = false, $app = null) |
|
34 | 34 | { |
35 | 35 | if (!is_array($domain)) |
36 | 36 | { |
@@ -55,32 +55,32 @@ discard block |
||
55 | 55 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
56 | 56 | * @throws Exception('header.inc.php not found!'); |
57 | 57 | */ |
58 | - protected function exec($check_only=false) |
|
58 | + protected function exec($check_only = false) |
|
59 | 59 | { |
60 | 60 | global $setup_info; |
61 | 61 | |
62 | 62 | // instanciate setup object and check authorisation |
63 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
63 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
64 | 64 | |
65 | - $this->check_installed($this->domain,array(14),$this->verbose); |
|
65 | + $this->check_installed($this->domain, array(14), $this->verbose); |
|
66 | 66 | |
67 | 67 | if ($GLOBALS['egw_info']['setup']['stage']['db'] != 4 && |
68 | 68 | (!$this->app || !in_array($this->app, self::$apps_to_install) && !in_array($this->app, self::$apps_to_upgrade)) && |
69 | 69 | !self::check_autoinstall()) |
70 | 70 | { |
71 | - return lang('No update necessary, domain %1(%2) is up to date.',$this->domain,$GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
71 | + return lang('No update necessary, domain %1(%2) is up to date.', $this->domain, $GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
72 | 72 | } |
73 | 73 | if ($check_only) return lang('Update necessary.'); |
74 | 74 | |
75 | 75 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
76 | 76 | |
77 | - self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
77 | + self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
78 | 78 | |
79 | 79 | // request to install a single app |
80 | 80 | if ($this->app && in_array($this->app, self::$apps_to_install)) |
81 | 81 | { |
82 | 82 | $app_title = $setup_info[$this->app]['title'] ? $setup_info[$this->app]['title'] : $setup_info[$this->app]['name']; |
83 | - self::_echo_message($this->verbose,lang('Start installing application %1 ...',$app_title)); |
|
83 | + self::_echo_message($this->verbose, lang('Start installing application %1 ...', $app_title)); |
|
84 | 84 | ob_start(); |
85 | 85 | $terror = array($this->app => $setup_info[$this->app]); |
86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $errors = self::$egw_setup->process->current($terror, $this->verbose); |
90 | 90 | $terror = self::$egw_setup->process->default_records($errors, $this->verbose); |
91 | - echo $app_title . ' ' . lang('tables installed, unless there are errors printed above') . '.'; |
|
91 | + echo $app_title.' '.lang('tables installed, unless there are errors printed above').'.'; |
|
92 | 92 | } |
93 | 93 | else |
94 | 94 | { |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | { |
103 | 103 | self::$egw_setup->register_app($setup_info[$this->app]['name']); |
104 | 104 | } |
105 | - echo $app_title . ' ' . lang('registered') . '.'; |
|
105 | + echo $app_title.' '.lang('registered').'.'; |
|
106 | 106 | |
107 | 107 | if ($setup_info[$this->app]['hooks']) |
108 | 108 | { |
109 | 109 | self::$egw_setup->register_hooks($setup_info[$this->app]['name']); |
110 | - echo "\n".$app_title . ' ' . lang('hooks registered') . '.'; |
|
110 | + echo "\n".$app_title.' '.lang('hooks registered').'.'; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | 114 | else |
115 | 115 | { |
116 | - self::_echo_message($this->verbose,lang('Start updating the database ...')); |
|
116 | + self::_echo_message($this->verbose, lang('Start updating the database ...')); |
|
117 | 117 | ob_start(); |
118 | - self::$egw_setup->process->pass($setup_info,'upgrade',false); |
|
118 | + self::$egw_setup->process->pass($setup_info, 'upgrade', false); |
|
119 | 119 | } |
120 | 120 | $messages = ob_get_contents(); |
121 | 121 | ob_end_clean(); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @version $Id$ |
12 | 12 | */ |
13 | 13 | |
14 | -chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
14 | +chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
15 | 15 | |
16 | 16 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
17 | 17 | { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | $ids = explode(',', $_SERVER['argv'][0]); |
41 | 41 | $change = array(); |
42 | -while($ids) |
|
42 | +while ($ids) |
|
43 | 43 | { |
44 | 44 | $from = (int)array_shift($ids); |
45 | 45 | $to = (int)array_shift($ids); |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | |
67 | 67 | chown_grp($path, null, $recursive); |
68 | 68 | |
69 | -function chown_grp($path, array $stat=null, $recursive=false) |
|
69 | +function chown_grp($path, array $stat = null, $recursive = false) |
|
70 | 70 | { |
71 | 71 | global $change; |
72 | 72 | |
73 | 73 | if (is_null($stat) && !($stat = stat($path))) return false; |
74 | 74 | |
75 | - if (isset($change[$stat['uid']]) && !chown($path, $uid=$change[$stat['uid']])) |
|
75 | + if (isset($change[$stat['uid']]) && !chown($path, $uid = $change[$stat['uid']])) |
|
76 | 76 | { |
77 | 77 | echo "Faild to set new owner #$uid for $path\n"; |
78 | 78 | } |
79 | - if (isset($change[-$stat['gid']]) && !chgrp($path, $gid=-$change[-$stat['gid']])) |
|
79 | + if (isset($change[-$stat['gid']]) && !chgrp($path, $gid = -$change[-$stat['gid']])) |
|
80 | 80 | { |
81 | 81 | echo "Faild to set new group #$gid for $path\n"; |
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($recursive && is_dir($path)) |
85 | 85 | { |
86 | - foreach(new DirectoryIterator($path) as $child) |
|
86 | + foreach (new DirectoryIterator($path) as $child) |
|
87 | 87 | { |
88 | 88 | if (!$child->isDot()) |
89 | 89 | chown_grp($child->getPathname(), array( |
@@ -20,9 +20,9 @@ |
||
20 | 20 | 'name' => 'eGroupware core team', |
21 | 21 | 'email' => '[email protected]' |
22 | 22 | ); |
23 | -$setup_info['importexport']['autoinstall'] = true; // install automatically on update |
|
23 | +$setup_info['importexport']['autoinstall'] = true; // install automatically on update |
|
24 | 24 | |
25 | -$setup_info['importexport']['license'] = 'GPL'; |
|
25 | +$setup_info['importexport']['license'] = 'GPL'; |
|
26 | 26 | $setup_info['importexport']['description'] = |
27 | 27 | ''; |
28 | 28 | $setup_info['importexport']['note'] = |
@@ -12,15 +12,15 @@ |
||
12 | 12 | $phpgw_baseline = array( |
13 | 13 | 'egw_importexport_definitions' => array( |
14 | 14 | 'fd' => array( |
15 | - 'definition_id' => array('type' => 'auto','nullable' => False), |
|
16 | - 'name' => array('type' => 'varchar','precision' => '255'), |
|
17 | - 'application' => array('type' => 'varchar','precision' => '50'), |
|
18 | - 'plugin' => array('type' => 'varchar','precision' => '100'), |
|
19 | - 'type' => array('type' => 'varchar','precision' => '20'), |
|
20 | - 'allowed_users' => array('type' => 'varchar','meta' => 'account-commasep','precision' => '255'), |
|
15 | + 'definition_id' => array('type' => 'auto', 'nullable' => False), |
|
16 | + 'name' => array('type' => 'varchar', 'precision' => '255'), |
|
17 | + 'application' => array('type' => 'varchar', 'precision' => '50'), |
|
18 | + 'plugin' => array('type' => 'varchar', 'precision' => '100'), |
|
19 | + 'type' => array('type' => 'varchar', 'precision' => '20'), |
|
20 | + 'allowed_users' => array('type' => 'varchar', 'meta' => 'account-commasep', 'precision' => '255'), |
|
21 | 21 | 'plugin_options' => array('type' => 'longtext'), |
22 | - 'owner' => array('type' => 'int','meta' => 'account','precision' => '4'), |
|
23 | - 'description' => array('type' => 'varchar','precision' => '255'), |
|
22 | + 'owner' => array('type' => 'int', 'meta' => 'account', 'precision' => '4'), |
|
23 | + 'description' => array('type' => 'varchar', 'precision' => '255'), |
|
24 | 24 | 'modified' => array('type' => 'timestamp'), |
25 | 25 | 'filter' => array('type' => 'longtext') |
26 | 26 | ), |