Completed
Push — 14.2 ( 7e9bff...017ed3 )
by Ralf
94:20 queued 61:50
created
phpgwapi/inc/class.egw_sharing.inc.php 1 patch
Spacing   +26 added lines, -27 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         // of the request URI ourselves
104 104
         // if request URI contains a full url, remove schema and domain
105 105
 		$matches = null;
106
-        if (preg_match('|^https?://[^/]+(/.*)$|', $path_info=$_SERVER['REQUEST_URI'], $matches))
106
+        if (preg_match('|^https?://[^/]+(/.*)$|', $path_info = $_SERVER['REQUEST_URI'], $matches))
107 107
         {
108 108
         	$path_info = $matches[1];
109 109
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param boolean $keep_session =null null: create a new session, true: try mounting it into existing (already verified) session
142 142
 	 * @return string with sessionid, does NOT return if no session created
143 143
 	 */
144
-	public static function create_session($keep_session=null)
144
+	public static function create_session($keep_session = null)
145 145
 	{
146 146
 		self::$db = $GLOBALS['egw']->db;
147 147
 
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 		// need to reset fs_tab, as resolve_url does NOT work with just share mounted
195 195
 		if (count($GLOBALS['egw_info']['server']['vfs_fstab']) <= 1)
196 196
 		{
197
-			unset($GLOBALS['egw_info']['server']['vfs_fstab']);	// triggers reset of fstab in mount()
197
+			unset($GLOBALS['egw_info']['server']['vfs_fstab']); // triggers reset of fstab in mount()
198 198
 			$GLOBALS['egw_info']['server']['vfs_fstab'] = egw_vfs::mount();
199 199
 			egw_vfs::clearstatcache();
200 200
 		}
201
-		$share['resolve_url'] = egw_vfs::resolve_url($share['share_path'], true, true, true, true);	// true = fix evtl. contained url parameter
201
+		$share['resolve_url'] = egw_vfs::resolve_url($share['share_path'], true, true, true, true); // true = fix evtl. contained url parameter
202 202
 		// if share not writable append ro=1 to mount url to make it readonly
203 203
 		if (!self::$db->from_bool($share['share_writable']))
204 204
 		{
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 		// update accessed timestamp
245 245
 		self::$db->update(self::TABLE, array(
246
-			'share_last_accessed' => $share['share_last_accessed']=time(),
246
+			'share_last_accessed' => $share['share_last_accessed'] = time(),
247 247
 		), array(
248 248
 			'share_id' => $share['share_id'],
249 249
 		), __LINE__, __FILE__);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		if ($keep_session || $sessionid)
286 286
 		{
287 287
 			$_SESSION[egw_session::EGW_INFO_CACHE] = $GLOBALS['egw_info'];
288
-			unset($_SESSION[egw_session::EGW_INFO_CACHE]['flags']);	// dont save the flags, they change on each request
288
+			unset($_SESSION[egw_session::EGW_INFO_CACHE]['flags']); // dont save the flags, they change on each request
289 289
 
290 290
 			$_SESSION[egw_session::EGW_OBJECT_CACHE] = serialize($GLOBALS['egw']);
291 291
 		}
@@ -354,8 +354,7 @@  discard block
 block discarded – undo
354 354
 		// generate random token (using oppenssl if available otherwise mt_rand based auth::randomstring)
355 355
 		do {
356 356
 			$token = function_exists('openssl_random_pseudo_bytes') ?
357
-				base64_encode(openssl_random_pseudo_bytes(3*self::TOKEN_LENGTH/4)) :
358
-				auth::randomstring(self::TOKEN_LENGTH);
357
+				base64_encode(openssl_random_pseudo_bytes(3 * self::TOKEN_LENGTH / 4)) : auth::randomstring(self::TOKEN_LENGTH);
359 358
 			// base64 can contain chars not allowed in our vfs-urls eg. / or #
360 359
 		} while ($token != egw_vfs::encodePathComponent($token));
361 360
 
@@ -375,13 +374,13 @@  discard block
 block discarded – undo
375 374
 	 * @throw egw_excpetion_assertion_failed if user temp. directory does not exist and can not be created
376 375
 	 * @return array with share data, eg. value for key 'share_token'
377 376
 	 */
378
-	public static function create($path, $mode, $name, $recipients, $extra=array())
377
+	public static function create($path, $mode, $name, $recipients, $extra = array())
379 378
 	{
380 379
 		if (!isset(self::$db)) self::$db = $GLOBALS['egw']->db;
381 380
 
382 381
 		if (empty($name)) $name = $path;
383 382
 
384
-		$path2tmp =& egw_cache::getSession(__CLASS__, 'path2tmp');
383
+		$path2tmp = & egw_cache::getSession(__CLASS__, 'path2tmp');
385 384
 
386 385
 		// allow filesystem path only for temp_dir
387 386
 		$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/';
@@ -392,7 +391,7 @@  discard block
 block discarded – undo
392 391
 		}
393 392
 		else
394 393
 		{
395
-			if(parse_url($path, PHP_URL_SCHEME) !== 'vfs')
394
+			if (parse_url($path, PHP_URL_SCHEME) !== 'vfs')
396 395
 			{
397 396
 				$path = 'vfs://default'.($path[0] == '/' ? '' : '/').$path;
398 397
 			}
@@ -406,7 +405,7 @@  discard block
 block discarded – undo
406 405
 		}
407 406
 		// check if file has been shared before, with identical attributes
408 407
 		if (($mode != self::LINK || isset($path2tmp[$path])) &&
409
-			($share = self::$db->select(self::TABLE, '*', $extra+array(
408
+			($share = self::$db->select(self::TABLE, '*', $extra + array(
410 409
 				'share_path' => $mode == 'link' ? $path2tmp[$path] : $vfs_path,
411 410
 				'share_owner' => $GLOBALS['egw_info']['user']['account_id'],
412 411
 				'share_expires' => null,
@@ -417,7 +416,7 @@  discard block
 block discarded – undo
417 416
 			// if yes, just add additional recipients
418 417
 			$share['share_with'] = $share['share_with'] ? explode(',', $share['share_with']) : array();
419 418
 			$need_save = false;
420
-			foreach((array)$recipients as $recipient)
419
+			foreach ((array)$recipients as $recipient)
421 420
 			{
422 421
 				if (!in_array($recipient, $share['share_with']))
423 422
 				{
@@ -447,9 +446,9 @@  discard block
 block discarded – undo
447 446
 				}
448 447
 				$n = 0;
449 448
 				do {
450
-					$tmp_file = egw_vfs::concat($user_tmp, ($n?$n.'.':'').egw_vfs::basename($name));
449
+					$tmp_file = egw_vfs::concat($user_tmp, ($n ? $n.'.' : '').egw_vfs::basename($name));
451 450
 				}
452
-				while(!(is_dir($path) && egw_vfs::mkdir($tmp_file, null, STREAM_MKDIR_RECURSIVE) ||
451
+				while (!(is_dir($path) && egw_vfs::mkdir($tmp_file, null, STREAM_MKDIR_RECURSIVE) ||
453 452
 					!is_dir($path) && (!egw_vfs::file_exists($tmp_file) && ($fp = egw_vfs::fopen($tmp_file, 'x')) ||
454 453
 						// do not copy identical files again to users tmp dir, just re-use them
455 454
 						egw_vfs::file_exists($tmp_file) && egw_vfs::compare(egw_vfs::PREFIX.$tmp_file, $path))) && $n++ < 100);
@@ -474,12 +473,12 @@  discard block
 block discarded – undo
474 473
 				$async = new asyncservice();
475 474
 				if (!$async->read('egw_sharing-tmp-cleanup'))
476 475
 				{
477
-					$async->set_timer(array('day' => 28),'egw_sharing-tmp_cleanup','egw_sharing::tmp_cleanup',null);
476
+					$async->set_timer(array('day' => 28), 'egw_sharing-tmp_cleanup', 'egw_sharing::tmp_cleanup', null);
478 477
 				}
479 478
 			}
480 479
 
481 480
 			$i = 0;
482
-			while(true)	// self::token() can return an existing value
481
+			while (true)	// self::token() can return an existing value
483 482
 			{
484 483
 				try {
485 484
 					self::$db->insert(self::TABLE, $share = array(
@@ -488,12 +487,12 @@  discard block
 block discarded – undo
488 487
 						'share_owner' => $GLOBALS['egw_info']['user']['account_id'],
489 488
 						'share_with' => implode(',', (array)$recipients),
490 489
 						'share_created' => time(),
491
-					)+$extra, false, __LINE__, __FILE__);
490
+					) + $extra, false, __LINE__, __FILE__);
492 491
 
493 492
 					$share['share_id'] = self::$db->get_last_insert_id(self::TABLE, 'share_id');
494 493
 					break;
495 494
 				}
496
-				catch(egw_exception_db $e) {
495
+				catch (egw_exception_db $e) {
497 496
 					if ($i++ > 3) throw $e;
498 497
 					unset($e);
499 498
 				}
@@ -536,8 +535,8 @@  discard block
 block discarded – undo
536 535
 
537 536
 		// get all temp. files, to be able to delete them
538 537
 		$tmp_paths = array();
539
-		foreach(self::$db->select(self::TABLE, 'share_path', array(
540
-			"share_path LIKE '/home/%/.tmp/%'")+$keys, __LINE__, __FILE__, false) as $row)
538
+		foreach (self::$db->select(self::TABLE, 'share_path', array(
539
+			"share_path LIKE '/home/%/.tmp/%'") + $keys, __LINE__, __FILE__, false) as $row)
541 540
 		{
542 541
 			$tmp_paths[] = $row['share_path'];
543 542
 		}
@@ -549,7 +548,7 @@  discard block
 block discarded – undo
549 548
 		// check if temp. files are used elsewhere
550 549
 		if ($tmp_paths)
551 550
 		{
552
-			foreach(self::$db->select(self::TABLE, 'share_path,COUNT(*) AS cnt', array(
551
+			foreach (self::$db->select(self::TABLE, 'share_path,COUNT(*) AS cnt', array(
553 552
 				'share_path' => $tmp_paths,
554 553
 			), __LINE__, __FILE__, false, 'GROUP BY share_path') as $row)
555 554
 			{
@@ -559,7 +558,7 @@  discard block
 block discarded – undo
559 558
 				}
560 559
 			}
561 560
 			// if not delete them
562
-			foreach($tmp_paths as $path)
561
+			foreach ($tmp_paths as $path)
563 562
 			{
564 563
 				egw_vfs::remove($path);
565 564
 			}
@@ -593,11 +592,11 @@  discard block
 block discarded – undo
593 592
 			// remove expired tmp-files unconditionally
594 593
 			$having = 'HAVING MAX(share_expires) < '.self::$db->quote(self::$db->to_timestamp(time())).' OR '.
595 594
 				// remove without expiration date, when created over 100 days ago AND
596
-				'MAX(share_expires) IS NULL AND MAX(share_created) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)). ' AND '.
595
+				'MAX(share_expires) IS NULL AND MAX(share_created) < '.self::$db->quote(self::$db->to_timestamp(time() - self::TMP_KEEP)).' AND '.
597 596
 					// (last accessed over 100 days ago OR never)
598
-					'(MAX(share_last_accessed) IS NULL OR MAX(share_last_accessed) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)).')';
597
+					'(MAX(share_last_accessed) IS NULL OR MAX(share_last_accessed) < '.self::$db->quote(self::$db->to_timestamp(time() - self::TMP_KEEP)).')';
599 598
 
600
-			foreach(self::$db->select(self::TABLE, $cols, array(
599
+			foreach (self::$db->select(self::TABLE, $cols, array(
601 600
 				"share_path LIKE '/home/%/.tmp/%'",
602 601
 			), __LINE__, __FILE__, false, 'GROUP BY share_path '.$having) as $row)
603 602
 			{
@@ -610,7 +609,7 @@  discard block
 block discarded – undo
610 609
 				else
611 610
 				{
612 611
 					$share_ids = array();
613
-					foreach(self::$db->selec(self::TABLE, 'share_id', array(
612
+					foreach (self::$db->selec(self::TABLE, 'share_id', array(
614 613
 						'share_path' => $row['share_path'],
615 614
 					), __LINE__, __FILE__) as $id)
616 615
 					{
Please login to merge, or discard this patch.