Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
doc/check_namespace.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 function check_namespace($file)
25 25
 {
26 26
 	global $prog;
27
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
27
+	if (basename($file) == $prog) return true; // dont fix ourself ;-)
28 28
 
29 29
 	if (($content = file_get_contents($file)) === false) return false;
30 30
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 	// find classes declared in file itself, in case they are used
38 38
 	$declared = array();
39
-	foreach(explode("\n", $lines) as $num => $line)
39
+	foreach (explode("\n", $lines) as $num => $line)
40 40
 	{
41 41
 		$matches = null;
42 42
 		if (preg_match('/class\s+([^ ]+)/', $line, $matches))
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	$namespace = '';
48 48
 	$use = array();
49 49
 	$allways = array('self', 'parent', 'static');
50
-	foreach(explode("\n", $lines) as $num => $line)
50
+	foreach (explode("\n", $lines) as $num => $line)
51 51
 	{
52 52
 		$matches = null;
53 53
 		if (preg_match('/namespace\s+([A-Za-z0-9_\\\\]+);/', $line, $matches))
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 		if (preg_match('/use\s+([^;]+);/', $line, $matches))
61 61
 		{
62
-			foreach(preg_split('/,\s*/', $matches[1]) as $alias)
62
+			foreach (preg_split('/,\s*/', $matches[1]) as $alias)
63 63
 			{
64 64
 				$parts = explode('\\', $alias);
65 65
 				$use[$alias] = array_pop($parts);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			$all_matches_raw = array_merge($all_matches_raw, $matches[1]);
76 76
 		}
77 77
 		$all_matches = array_unique($all_matches_raw);
78
-		foreach($all_matches as $c => $class)
78
+		foreach ($all_matches as $c => $class)
79 79
 		{
80 80
 			$parts = explode('\\', $class);
81 81
 			$first_part = array_shift($parts);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		}
94 94
 		if ($all_matches)
95 95
 		{
96
-			echo (1+$num).":\t".$line."\n";
96
+			echo (1 + $num).":\t".$line."\n";
97 97
 			echo "--> ".implode(', ', $all_matches)."\n\n";
98 98
 		}
99 99
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 {
112 112
 	if (!is_dir($dir)) return false;
113 113
 
114
-	foreach(scandir($dir) as $file)
114
+	foreach (scandir($dir) as $file)
115 115
 	{
116 116
 		if ($file == '.' || $file == '..') continue;
117 117
 
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		{
120 120
 			check_namespace_recursive($dir.'/'.$file);
121 121
 		}
122
-		elseif(substr($file,-4) == '.php')
122
+		elseif (substr($file, -4) == '.php')
123 123
 		{
124
-			echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': ';
124
+			echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': ';
125 125
 			check_namespace($dir.'/'.$file);
126 126
 		}
127 127
 	}
128
-	echo "\r".str_repeat(' ',100)."\r";
128
+	echo "\r".str_repeat(' ', 100)."\r";
129 129
 	return true;
130 130
 }
131 131
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
  *
135 135
  * @param string $error =null
136 136
  */
137
-function usage($error=null)
137
+function usage($error = null)
138 138
 {
139 139
 	global $prog;
140 140
 	echo "Usage: $prog [-h|--help] file or dir\n\n";
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 if (!$args) usage();
149 149
 
150 150
 $replace_file = false;
151
-while(($arg = array_shift($args)))
151
+while (($arg = array_shift($args)))
152 152
 {
153
-	switch($arg)
153
+	switch ($arg)
154 154
 	{
155 155
 		case '-h':
156 156
 		case '--help':
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 
171 171
 if (!is_dir($arg))
172 172
 {
173
-	check_namespace($arg,$replace_file);
173
+	check_namespace($arg, $replace_file);
174 174
 }
175 175
 else
176 176
 {
177
-	check_namespace_recursive($arg,$replace_file);
177
+	check_namespace_recursive($arg, $replace_file);
178 178
 }
179 179
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +41 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,10 +10,13 @@  discard block
 block discarded – undo
10 10
  * @version $Id$
11 11
  */
12 12
 
13
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling as web-page
13
+if (php_sapi_name() !== 'cli')
14
+{
15
+	// security precaution: forbit calling as web-page
14 16
 {
15 17
 	die('<h1>check_namespace.php must NOT be called as web-page --> exiting !!!</h1>');
16 18
 }
19
+}
17 20
 
18 21
 /**
19 22
  * Check namespace usage in converted code
@@ -24,9 +27,16 @@  discard block
 block discarded – undo
24 27
 function check_namespace($file)
25 28
 {
26 29
 	global $prog;
27
-	if (basename($file) == $prog) return true;	// dont fix ourself ;-)
30
+	if (basename($file) == $prog)
31
+	{
32
+		return true;
33
+	}
34
+	// dont fix ourself ;-)
28 35
 
29
-	if (($content = file_get_contents($file)) === false) return false;
36
+	if (($content = file_get_contents($file)) === false)
37
+	{
38
+		return false;
39
+	}
30 40
 
31 41
 	// replace commented lines with empty ones
32 42
 	$lines = preg_replace_callback('#(//.*$|/\\*.*\\*/)#msU', function($matches)
@@ -55,7 +65,10 @@  discard block
 block discarded – undo
55 65
 			$namespace = $matches[1];
56 66
 			$use = array();
57 67
 		}
58
-		if ($namespace === '') continue;
68
+		if ($namespace === '')
69
+		{
70
+			continue;
71
+		}
59 72
 
60 73
 		if (preg_match('/use\s+([^;]+);/', $line, $matches))
61 74
 		{
@@ -109,11 +122,17 @@  discard block
 block discarded – undo
109 122
  */
110 123
 function check_namespace_recursive($dir)
111 124
 {
112
-	if (!is_dir($dir)) return false;
125
+	if (!is_dir($dir))
126
+	{
127
+		return false;
128
+	}
113 129
 
114 130
 	foreach(scandir($dir) as $file)
115 131
 	{
116
-		if ($file == '.' || $file == '..') continue;
132
+		if ($file == '.' || $file == '..')
133
+		{
134
+			continue;
135
+		}
117 136
 
118 137
 		if (is_dir($dir.'/'.$file))
119 138
 		{
@@ -138,14 +157,20 @@  discard block
 block discarded – undo
138 157
 {
139 158
 	global $prog;
140 159
 	echo "Usage: $prog [-h|--help] file or dir\n\n";
141
-	if ($error) echo $error."\n\n";
160
+	if ($error)
161
+	{
162
+		echo $error."\n\n";
163
+	}
142 164
 	exit($error ? 1 : 0);
143 165
 }
144 166
 
145 167
 $args = $_SERVER['argv'];
146 168
 $prog = basename(array_shift($args));
147 169
 
148
-if (!$args) usage();
170
+if (!$args)
171
+{
172
+	usage();
173
+}
149 174
 
150 175
 $replace_file = false;
151 176
 while(($arg = array_shift($args)))
@@ -158,15 +183,21 @@  discard block
 block discarded – undo
158 183
 			break;
159 184
 
160 185
 		default:
161
-			if ($args)	// not last argument
186
+			if ($args)
187
+			{
188
+				// not last argument
162 189
 			{
163 190
 				usage("Unknown argument '$arg'!");
164 191
 			}
192
+			}
165 193
 			break 2;
166 194
 	}
167 195
 }
168 196
 
169
-if (!file_exists($arg)) usage("Error: $arg not found!");
197
+if (!file_exists($arg))
198
+{
199
+	usage("Error: $arg not found!");
200
+}
170 201
 
171 202
 if (!is_dir($arg))
172 203
 {
Please login to merge, or discard this patch.
doc/config2xet.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 			</columns>
57 57
 			<rows>
58 58
 ';
59
-foreach($trs[2] as $n => $tr)
59
+foreach ($trs[2] as $n => $tr)
60 60
 {
61 61
 	if (strpos($tr, '{title}') || strpos($tr, '<input type="submit"')) continue;
62 62
 
@@ -64,25 +64,25 @@  discard block
 block discarded – undo
64 64
 	{
65 65
 		die("No td tags found in $n. tr: $tr");
66 66
 	}
67
-	if (($commented = !empty($trs[1][$n])? $trs[1][$n] : ''))
67
+	if (($commented = !empty($trs[1][$n]) ? $trs[1][$n] : ''))
68 68
 	{
69 69
 		echo "\t\t\t\t$commented\n";
70 70
 	}
71 71
 	echo "\t\t\t\t<row>\n";
72
-	foreach($tds[2] as $t => $td)
72
+	foreach ($tds[2] as $t => $td)
73 73
 	{
74 74
 		if (preg_match('|^\s*<([^ >]+)\s*([^/>]+)/?>(.*)\s*$|sui', $td, $matches))
75 75
 		{
76 76
 			$attrs = preg_match_all('|\s*([^=]+)="([^"]+)"|', $matches[2], $attrs) ?
77 77
 				array_combine($attrs[1], $attrs[2]) : array();
78 78
 
79
-			switch($matches[1])
79
+			switch ($matches[1])
80 80
 			{
81 81
 				case 'input':
82 82
 				case 'textarea':
83 83
 					echo "\t\t\t\t\t<textbox id=\"".$attrs['name'].'"';
84 84
 					unset($attrs['value'], $attrs['name']);
85
-					foreach($attrs as $name => $value)
85
+					foreach ($attrs as $name => $value)
86 86
 					{
87 87
 						if ($name == 'type' && $value == 'password') $value = 'passwd';
88 88
 						echo " $name=\"$value\"";
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 				case 'select':
104 104
 					echo "\t\t\t\t\t<select id=\"".$attrs['name'].'"';
105 105
 					unset($attrs['name']);
106
-					foreach($attrs as $name => $value)
106
+					foreach ($attrs as $name => $value)
107 107
 					{
108 108
 						echo " $name=\"$value\"";
109 109
 					}
110 110
 					echo ">\n";
111 111
 					if (preg_match_all('|<option\s+value="([^"]*)"\s*({selected_[^}]+})?>(.*)</option>|Usui', $matches[3], $options))
112 112
 					{
113
-						foreach($options[3] as $i => $label)
113
+						foreach ($options[3] as $i => $label)
114 114
 						{
115 115
 							$label = preg_replace_callback('/{lang_([^}]+)}/', function($matches)
116 116
 							{
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			echo "/>\n";
154 154
 			if (!$commented && !empty($matches[3]) && trim($matches[3])) echo "\t\t\t\t\t<!-- ".trim($matches[3])." -->\n";
155 155
 		}
156
-		elseif(!$commented)
156
+		elseif (!$commented)
157 157
 		{
158 158
 			echo "\t\t\t\t\t<!-- ".trim($td)." -->\n";
159 159
 		}
Please login to merge, or discard this patch.
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,10 @@  discard block
 block discarded – undo
58 58
 ';
59 59
 foreach($trs[2] as $n => $tr)
60 60
 {
61
-	if (strpos($tr, '{title}') || strpos($tr, '<input type="submit"')) continue;
61
+	if (strpos($tr, '{title}') || strpos($tr, '<input type="submit"'))
62
+	{
63
+		continue;
64
+	}
62 65
 
63 66
 	if (!preg_match_all('|<td\s*([^>]*)>(.*)</td>|Usui', $tr, $tds, PREG_PATTERN_ORDER))
64 67
 	{
@@ -84,7 +87,10 @@  discard block
 block discarded – undo
84 87
 					unset($attrs['value'], $attrs['name']);
85 88
 					foreach($attrs as $name => $value)
86 89
 					{
87
-						if ($name == 'type' && $value == 'password') $value = 'passwd';
90
+						if ($name == 'type' && $value == 'password')
91
+						{
92
+							$value = 'passwd';
93
+						}
88 94
 						echo " $name=\"$value\"";
89 95
 					}
90 96
 					echo "/>\n";
@@ -139,7 +145,10 @@  discard block
 block discarded – undo
139 145
 		elseif (preg_match('/^\s*([^{]*){lang_([^}]+)}\s*(.*)$/sui',
140 146
 			str_replace(array('&nbsp;', '<b>', '</b>'), '', $td), $matches))
141 147
 		{
142
-			if (!$commented && trim($matches[1])) echo "\t\t\t\t\t<!-- $matches[1] -->\n";
148
+			if (!$commented && trim($matches[1]))
149
+			{
150
+				echo "\t\t\t\t\t<!-- $matches[1] -->\n";
151
+			}
143 152
 			echo "\t\t\t\t\t<description value=\"".htmlspecialchars(str_replace('_', ' ', $matches[2])).'"';
144 153
 			if (trim($matches[3]) == ':')
145 154
 			{
@@ -151,7 +160,10 @@  discard block
 block discarded – undo
151 160
 				echo ' span="all" class="subHeader"';
152 161
 			}
153 162
 			echo "/>\n";
154
-			if (!$commented && !empty($matches[3]) && trim($matches[3])) echo "\t\t\t\t\t<!-- ".trim($matches[3])." -->\n";
163
+			if (!$commented && !empty($matches[3]) && trim($matches[3]))
164
+			{
165
+				echo "\t\t\t\t\t<!-- ".trim($matches[3])." -->\n";
166
+			}
155 167
 		}
156 168
 		elseif(!$commented)
157 169
 		{
Please login to merge, or discard this patch.
doc/rpm-build/header.inc.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 // dummy setup file
3 3
 if (strpos($_SERVER['PHP_SELF'],'/setup/') === false)
4 4
 {
5
-        header('Location: /egroupware/setup/');
6
-        exit;
5
+		header('Location: /egroupware/setup/');
6
+		exit;
7 7
 }
8 8
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 // dummy setup file
3
-if (strpos($_SERVER['PHP_SELF'],'/setup/') === false)
3
+if (strpos($_SERVER['PHP_SELF'], '/setup/') === false)
4 4
 {
5 5
         header('Location: /egroupware/setup/');
6 6
         exit;
Please login to merge, or discard this patch.
doc/ldap/nis2rfc2307bis.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  * @version $Id: class.accounts.inc.php 22048 2006-07-08 21:41:42Z ralfbecker $
22 22
  */
23 23
 
24
-if ($argc <= 1 || in_array($argv[1],array('-v','--help')) || $argv[1] == '--accounts-dn' && $argc <= 3|| 
25
-	!is_readable($file = $argv[$argc-1]))
24
+if ($argc <= 1 || in_array($argv[1], array('-v', '--help')) || $argv[1] == '--accounts-dn' && $argc <= 3 || 
25
+	!is_readable($file = $argv[$argc - 1]))
26 26
 {
27 27
 	if ($file)
28 28
 	{
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 }
33 33
 
34 34
 $lines = file($file);
35
-foreach($lines as $l => $line)
35
+foreach ($lines as $l => $line)
36 36
 {
37 37
 	$lines[$l] = rtrim($line);
38 38
 }
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
 {
43 43
 	$group2account = $argv[2];
44 44
 }
45
-$parts = explode('/',$group2account);
45
+$parts = explode('/', $group2account);
46 46
 if (count($parts) != 4)
47 47
 {
48 48
 	die("Wrong format for --group2accounts-dn, use something like '/cn=[^,]+,ou=groups/ou=accounts/'\n");
49 49
 }
50 50
 $replace_with = $parts[2]; unset($parts[2]);
51
-$replace = implode('/',$parts);
51
+$replace = implode('/', $parts);
52 52
 
53 53
 $block = array();
54 54
 $i = 0;
55
-$lines[] = '';	// extra empty line, if none is behind the last block
56
-foreach($lines as $l => $line)
55
+$lines[] = ''; // extra empty line, if none is behind the last block
56
+foreach ($lines as $l => $line)
57 57
 {
58 58
 	if ($line)
59 59
 	{
60
-		@list($attr,$value) = explode(': ',$line,2);
61
-		switch($attr)
60
+		@list($attr, $value) = explode(': ', $line, 2);
61
+		switch ($attr)
62 62
 		{
63 63
 			case 'dn':
64 64
 				$dn = $value;
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 				$structural = $value;
71 71
 				break;
72 72
 			case 'memberUid':
73
-				$member_dn = 'uid='.$value.','.preg_replace($replace,$replace_with,$dn);
74
-				if (!in_array('dn: '.$member_dn,$lines)) continue;	// member does not exist --> ignore him!
73
+				$member_dn = 'uid='.$value.','.preg_replace($replace, $replace_with, $dn);
74
+				if (!in_array('dn: '.$member_dn, $lines)) continue; // member does not exist --> ignore him!
75 75
 				$members[] = 'member: '.$member_dn;
76 76
 				// fall-through
77 77
 			default:
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
 	if (!$block) continue;
85 85
 
86 86
 	// got a complete block
87
-	if (in_array('posixGroup',$objectclasses))
87
+	if (in_array('posixGroup', $objectclasses))
88 88
 	{
89
-		switch($structural)
89
+		switch ($structural)
90 90
 		{
91 91
 			case 'namedObject':	// regular SuSE
92
-				unset($objectclasses[array_search('namedObject',$objectclasses)]);
92
+				unset($objectclasses[array_search('namedObject', $objectclasses)]);
93 93
 				// fall-through
94 94
 			case 'posixGroup':	// nis
95 95
 				$objectclasses[] = $structural = 'groupOfNames';
96
-				if (!$members) $members[] = 'member: '.$dn;	// member is a required attribute!
97
-				$data = array_merge($members,$data);
96
+				if (!$members) $members[] = 'member: '.$dn; // member is a required attribute!
97
+				$data = array_merge($members, $data);
98 98
 				break;
99 99
 			case 'groupOfNames':	// ok, already what we want
100 100
 				break;
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 				die("\nposixGroup dn: $dn has as structrualObjectClass $structural, not posixGroup, namedObject or groupOfNames!\n");
103 103
 		}
104 104
 		$block = array('dn: '.$dn,);
105
-		foreach($objectclasses as $class)
105
+		foreach ($objectclasses as $class)
106 106
 		{
107 107
 			$block[] = 'objectClass: '.$class;
108 108
 		}
109 109
 		$block[] = 'structuralObjectClass: '.$class;
110
-		$block = array_merge($block,$data);
110
+		$block = array_merge($block, $data);
111 111
 	}
112
-	echo implode("\n",$block)."\n\n";
112
+	echo implode("\n", $block)."\n\n";
113 113
 
114 114
 	// process next block
115 115
 	$block = $objectclasses = $members = $data = array();
Please login to merge, or discard this patch.
Braces   +14 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,11 @@  discard block
 block discarded – undo
71 71
 				break;
72 72
 			case 'memberUid':
73 73
 				$member_dn = 'uid='.$value.','.preg_replace($replace,$replace_with,$dn);
74
-				if (!in_array('dn: '.$member_dn,$lines)) continue;	// member does not exist --> ignore him!
74
+				if (!in_array('dn: '.$member_dn,$lines))
75
+				{
76
+					continue;
77
+				}
78
+				// member does not exist --> ignore him!
75 79
 				$members[] = 'member: '.$member_dn;
76 80
 				// fall-through
77 81
 			default:
@@ -81,7 +85,10 @@  discard block
 block discarded – undo
81 85
 		$block[] = $line;
82 86
 		continue;
83 87
 	}
84
-	if (!$block) continue;
88
+	if (!$block)
89
+	{
90
+		continue;
91
+	}
85 92
 
86 93
 	// got a complete block
87 94
 	if (in_array('posixGroup',$objectclasses))
@@ -93,7 +100,11 @@  discard block
 block discarded – undo
93 100
 				// fall-through
94 101
 			case 'posixGroup':	// nis
95 102
 				$objectclasses[] = $structural = 'groupOfNames';
96
-				if (!$members) $members[] = 'member: '.$dn;	// member is a required attribute!
103
+				if (!$members)
104
+				{
105
+					$members[] = 'member: '.$dn;
106
+				}
107
+				// member is a required attribute!
97 108
 				$data = array_merge($members,$data);
98 109
 				break;
99 110
 			case 'groupOfNames':	// ok, already what we want
Please login to merge, or discard this patch.
home/setup/tables_update.inc.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 	// Previously all portlets were together in a sub-array, for defaults they
42 42
 	// need to be moved to top level
43 43
 	$preferences = array();
44
-	foreach($GLOBALS['egw_setup']->db->select('egw_preferences','preference_owner,preference_app,preference_value',array(
44
+	foreach ($GLOBALS['egw_setup']->db->select('egw_preferences', 'preference_owner,preference_app,preference_value', array(
45 45
 		'preference_app' => 'home',
46
-	),__LINE__,__FILE__) as $row)
46
+	), __LINE__, __FILE__) as $row)
47 47
 	{
48 48
 		$preferences[] = $row;
49 49
 	}
50
-	foreach($preferences as $row)
50
+	foreach ($preferences as $row)
51 51
 	{
52 52
 		// The following replacement is required for PostgreSQL to work
53 53
 		$app = trim($row['preference_app']);
@@ -62,21 +62,21 @@  discard block
 block discarded – undo
62 62
 			// Too old, skip it
63 63
 			continue;
64 64
 		}
65
-		if($values['portlets'] && is_array($values['portlets']))
65
+		if ($values['portlets'] && is_array($values['portlets']))
66 66
 		{
67
-			foreach($values['portlets'] as $id => $settings)
67
+			foreach ($values['portlets'] as $id => $settings)
68 68
 			{
69 69
 				$values["portlet_$id"] = $settings;
70 70
 			}
71 71
 			unset($values['portlets']);
72 72
 		}
73 73
 		$GLOBALS['egw_setup']->db->insert(
74
-			'egw_preferences',array(
74
+			'egw_preferences', array(
75 75
 				'preference_value' => json_encode($values),
76
-			),array(
76
+			), array(
77 77
 				'preference_owner' => $row['preference_owner'],
78 78
 				'preference_app'   => $app,
79
-			),__LINE__,__FILE__
79
+			), __LINE__, __FILE__
80 80
 		);
81 81
 	}
82 82
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 function home_upgrade14_1_001()
92 92
 {
93 93
 	// rename "home-accounts" to "api-accounts"
94
-	foreach(array('link_app1', 'link_app2') as $col)
94
+	foreach (array('link_app1', 'link_app2') as $col)
95 95
 	{
96 96
 		$GLOBALS['egw_setup']->db->update('egw_links', array(
97 97
 				$col => 'api-accounts',
Please login to merge, or discard this patch.
home/inc/class.home_birthday_portlet.inc.php 4 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
-  * Egroupware
4
-  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
5
-  * @package home
6
-  * @subpackage portlet
7
-  * @link http://www.egroupware.org
8
-  * @author Nathan Gray
9
-  * @version $Id$
10
-  */
3
+ * Egroupware
4
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
5
+ * @package home
6
+ * @subpackage portlet
7
+ * @link http://www.egroupware.org
8
+ * @author Nathan Gray
9
+ * @version $Id$
10
+ */
11 11
 
12 12
 use EGroupware\Api;
13 13
 use EGroupware\Api\Etemplate;
Please login to merge, or discard this patch.
Braces   +13 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
   *
18 18
   */
19 19
  class home_birthday_portlet extends home_portlet
20
-{
20
+ {
21 21
 	/**
22 22
 	 * Constructor sets up the portlet according to the user's saved property values
23 23
 	 * for this particular portlet.  It is possible to have multiple instances of the
@@ -32,7 +32,10 @@  discard block
 block discarded – undo
32 32
 	public function __construct(Array &$context = array(), &$need_reload = false)
33 33
 	{
34 34
 		unset($need_reload);	// not used, but required by function signature
35
-		if (false) parent::__construct();
35
+		if (false)
36
+		{
37
+			parent::__construct();
38
+		}
36 39
 
37 40
 		$this->context = $context;
38 41
 	}
@@ -70,10 +73,13 @@  discard block
 block discarded – undo
70 73
 
71 74
 		$etemplate->read('home.birthdays');
72 75
 
73
-		if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')	// calendar Api\Config
76
+		if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
77
+		{
78
+			// calendar Api\Config
74 79
 		{
75 80
 			$content = $this->get_birthdays();
76 81
 		}
82
+		}
77 83
 		$etemplate->set_dom_id($id);
78 84
 
79 85
 		$etemplate->exec('home.home_list_portlet.exec',$content);
@@ -123,7 +129,10 @@  discard block
 block discarded – undo
123 129
 				{
124 130
 					if(substr($contact['bday'],-6) == $day)
125 131
 					{
126
-						if (!$ab_lang_loaded++) Api\Translation::add_app('addressbook');
132
+						if (!$ab_lang_loaded++)
133
+						{
134
+							Api\Translation::add_app('addressbook');
135
+						}
127 136
 						switch($n)
128 137
 						{
129 138
 							case 0:
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	 * @param context Array portlet settings such as size, as well as values for properties
30 30
 	 * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
31 31
 	 */
32
-	public function __construct(Array &$context = array(), &$need_reload = false)
32
+	public function __construct(array &$context = array(), &$need_reload = false)
33 33
 	{
34 34
 		unset($need_reload);	// not used, but required by function signature
35 35
 		if (false) parent::__construct();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct(Array &$context = array(), &$need_reload = false)
33 33
 	{
34
-		unset($need_reload);	// not used, but required by function signature
34
+		unset($need_reload); // not used, but required by function signature
35 35
 		if (false) parent::__construct();
36 36
 
37 37
 		$this->context = $context;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		}
77 77
 		$etemplate->set_dom_id($id);
78 78
 
79
-		$etemplate->exec('home.home_list_portlet.exec',$content);
79
+		$etemplate->exec('home.home_list_portlet.exec', $content);
80 80
 	}
81 81
 
82 82
 	/**
@@ -85,30 +85,30 @@  discard block
 block discarded – undo
85 85
 	protected function get_birthdays()
86 86
 	{
87 87
 		$contacts = new Api\Contacts();
88
-		$month_start = date('-m-',$contacts->now_su);
88
+		$month_start = date('-m-', $contacts->now_su);
89 89
 		$days = $this->context['days'];
90 90
 		$birthdays = array();
91 91
 
92
-		$bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family','','%');
92
+		$bdays = & $contacts->search(array('bday' => $month_start), array('id', 'n_family', 'n_given', 'bday'), 'n_given,n_family', '', '%');
93 93
 		// search accounts too, if not stored in accounts repository
94 94
 		$extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) &&
95 95
 			$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1';
96
-		if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),
97
-			'n_given,n_family','','%',false,'AND',false,array('owner' => 0))))
96
+		if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start), array('id', 'n_family', 'n_given', 'bday'),
97
+			'n_given,n_family', '', '%', false, 'AND', false, array('owner' => 0))))
98 98
 		{
99
-			$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
99
+			$bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2);
100 100
 		}
101
-		if (($month_end = date('-m-',$contacts->now_su+$days*24*3600)) != $month_start)
101
+		if (($month_end = date('-m-', $contacts->now_su + $days * 24 * 3600)) != $month_start)
102 102
 		{
103
-			if (($bdays2 =& $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'),'n_given,n_family','','%')))
103
+			if (($bdays2 = & $contacts->search(array('bday' => $month_end), array('id', 'n_family', 'n_given', 'bday'), 'n_given,n_family', '', '%')))
104 104
 			{
105
-				$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
105
+				$bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2);
106 106
 			}
107 107
 			// search accounts too, if not stored in accounts repository
108
-			if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'),
109
-				'n_given,n_family','','%',false,'AND',false,array('owner' => 0))))
108
+			if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_end), array('id', 'n_family', 'n_given', 'bday'),
109
+				'n_given,n_family', '', '%', false, 'AND', false, array('owner' => 0))))
110 110
 			{
111
-				$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
111
+				$bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2);
112 112
 			}
113 113
 		}
114 114
 		unset($bdays2); unset($extra_accounts_search);
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 		if ($bdays)
117 117
 		{
118 118
 			$ab_lang_loaded = 0;
119
-			for($n = 0; $n <= $days; ++$n)
119
+			for ($n = 0; $n <= $days; ++$n)
120 120
 			{
121
-				$day = date('-m-d',$contacts->now_su+$n*24*3600);
122
-				foreach($bdays as $contact)
121
+				$day = date('-m-d', $contacts->now_su + $n * 24 * 3600);
122
+				foreach ($bdays as $contact)
123 123
 				{
124
-					if(substr($contact['bday'],-6) == $day)
124
+					if (substr($contact['bday'], -6) == $day)
125 125
 					{
126 126
 						if (!$ab_lang_loaded++) Api\Translation::add_app('addressbook');
127
-						switch($n)
127
+						switch ($n)
128 128
 						{
129 129
 							case 0:
130 130
 								$text = lang("Today is %1's birthday!", $contact['n_given'].' '.$contact['n_family']);
Please login to merge, or discard this patch.
home/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 );
20 20
 
21 21
 include('../header.inc.php');
22
-$GLOBALS['egw_info']['flags']['nonavbar']=false;
22
+$GLOBALS['egw_info']['flags']['nonavbar'] = false;
23 23
 
24 24
 // Home is treated specially, so a redirect won't work.
25 25
 $home = new home_ui();
Please login to merge, or discard this patch.
filemanager/cli.php 3 patches
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
 									if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was=$owner,'account_lid',$type[0])) ||
382 382
 										($owner < 0) != ($cmd == 'chgrp'))
383 383
 									{
384
-										die("Unknown $type '$owner_was'!");
384
+										die("unknown $type '$owner_was'!");
385 385
 									}
386 386
 								}
387 387
 								elseif($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) ||
388 388
 										($owner < 0) != ($cmd == 'chgrp')))
389 389
 								{
390
-									die("Unknown $type '$owner_was'!");
390
+									die("unknown $type '$owner_was'!");
391 391
 								}
392 392
 							}
393 393
 							$params = array($url,$owner);
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 					{
446 446
 						if (!($f = fopen($url,'r')))
447 447
 						{
448
-							echo "File $url not found !!!\n\n";
448
+							echo "file $url not found !!!\n\n";
449 449
 						}
450 450
 						else
451 451
 						{
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	}
762 762
 	if (!($from_fp = fopen($from,'r')))
763 763
 	{
764
-		die("File $from not found!\n");
764
+		die("file $from not found!\n");
765 765
 	}
766 766
 	if (!($to_fp = fopen($to,'w')))
767 767
 	{
Please login to merge, or discard this patch.
Braces   +125 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,10 +20,13 @@  discard block
 block discarded – undo
20 20
 
21 21
 error_reporting(error_reporting() & ~E_NOTICE & ~E_DEPRECATED);
22 22
 
23
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling filemanager/cli.php as web-page
23
+if (php_sapi_name() !== 'cli')
24
+{
25
+	// security precaution: forbit calling filemanager/cli.php as web-page
24 26
 {
25 27
 	die('<h1>'.basename(__FILE__).' must NOT be called as web-page --> exiting !!!</h1>');
26 28
 }
29
+}
27 30
 
28 31
 /**
29 32
  * callback if the session-check fails, creates session from user/passwd in $GLOBALS['egw_login_data']
@@ -87,17 +90,23 @@  discard block
 block discarded – undo
87 90
 	$cmd = array_shift($args);
88 91
 }
89 92
 
90
-if (!$args) $args = array('-h');
93
+if (!$args)
94
+{
95
+	$args = array('-h');
96
+}
91 97
 
92 98
 $argv = $find_options = array();
93 99
 while(!is_null($option = array_shift($args)))
94 100
 {
95
-	if ($option == '-' || $option[0] != '-')	// no option --> argument
101
+	if ($option == '-' || $option[0] != '-')
102
+	{
103
+		// no option --> argument
96 104
 	{
97 105
 		// remove quotes from arguments
98 106
 		if (in_array($option[0], array('"', "'")) && $option[0] == substr($option, -1))
99 107
 		{
100 108
 			$option = substr($option, 1, -1);
109
+	}
101 110
 		}
102 111
 		$argv[] = $option;
103 112
 		continue;
@@ -197,7 +206,10 @@  discard block
 block discarded – undo
197 206
 		{
198 207
 			usage('Wrong number of parameters!');
199 208
 		}
200
-		if (($url = $argv[0])) load_wrapper($url);
209
+		if (($url = $argv[0]))
210
+		{
211
+			load_wrapper($url);
212
+		}
201 213
 		if(!Vfs::$is_root)
202 214
 		{
203 215
 			die("You need to be root to do that!\n");
@@ -262,7 +274,10 @@  discard block
 block discarded – undo
262 274
 		break;
263 275
 
264 276
 	case 'rename':
265
-		if (count($argv) != 2) usage('Wrong number of parameters!');
277
+		if (count($argv) != 2)
278
+		{
279
+			usage('Wrong number of parameters!');
280
+		}
266 281
 		load_wrapper($argv[0]);
267 282
 		load_wrapper($argv[1]);
268 283
 		rename($argv[0],$argv[1]);
@@ -273,7 +288,11 @@  discard block
 block discarded – undo
273 288
 		{
274 289
 			die("\nYou need to be root to do that!\n\n");
275 290
 		}
276
-		if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit;	// we need write access, error msg already given
291
+		if (!is_writable($GLOBALS['egw_info']['server']['files_dir']))
292
+		{
293
+			exit;
294
+		}
295
+		// we need write access, error msg already given
277 296
 		$fstab = Vfs::mount();
278 297
 		if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'],'storage=db') === false)
279 298
 		{
@@ -286,7 +305,10 @@  discard block
 block discarded – undo
286 305
 		$num_files = Vfs\Sqlfs\Utils::migrate_db2fs();	// throws exception on error
287 306
 		echo "\n$num_files files migrated from DB to filesystem.\n";
288 307
 		$new_url = preg_replace('/storage=db&?/','',$fstab['/']);
289
-		if (substr($new_url,-1) == '?') $new_url = substr($new_url,0,-1);
308
+		if (substr($new_url,-1) == '?')
309
+		{
310
+			$new_url = substr($new_url,0,-1);
311
+		}
290 312
 		if (Vfs::mount($new_url,'/'))
291 313
 		{
292 314
 			echo "/ successful re-mounted on $new_url\n";
@@ -302,7 +324,10 @@  discard block
 block discarded – undo
302 324
 		{
303 325
 			$url = array_shift($argv);
304 326
 
305
-			if (strpos($url, '://')) load_wrapper($url);
327
+			if (strpos($url, '://'))
328
+			{
329
+				load_wrapper($url);
330
+			}
306 331
 			echo "$cmd $url (long=".(int)$long.", numeric=".(int)$numeric.", recursive=".(int)$recursive.") ".implode(' ', $argv)."\n";
307 332
 
308 333
 			switch($cmd)
@@ -329,7 +354,10 @@  discard block
 block discarded – undo
329 354
 					break;
330 355
 
331 356
 				case 'mkdir':
332
-					if (!mkdir($url,null,$recursive)) echo "Can't create directory, permission denied!\n";
357
+					if (!mkdir($url,null,$recursive))
358
+					{
359
+						echo "Can't create directory, permission denied!\n";
360
+					}
333 361
 					break;
334 362
 
335 363
 				case 'touch':
@@ -428,13 +456,19 @@  discard block
 block discarded – undo
428 456
 					{
429 457
 						if ($argc)
430 458
 						{
431
-							if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) $name = '/';
459
+							if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH))))
460
+							{
461
+								$name = '/';
462
+							}
432 463
 							echo "\n$name:\n";
433 464
 						}
434 465
 						// separate evtl. query part, to re-add it after the file-name
435 466
 						unset($query);
436 467
 						list($url,$query) = explode('?',$url,2);
437
-						if ($query) $query = '?'.$query;
468
+						if ($query)
469
+						{
470
+							$query = '?'.$query;
471
+						}
438 472
 
439 473
 						if (substr($url,-1) == '/')
440 474
 						{
@@ -466,7 +500,10 @@  discard block
 block discarded – undo
466 500
 					{
467 501
 						do_stat($url,$long,$numeric,false,$inode);
468 502
 					}
469
-					if (!$long && $cmd == 'ls') echo "\n";
503
+					if (!$long && $cmd == 'ls')
504
+					{
505
+						echo "\n";
506
+					}
470 507
 					break;
471 508
 			}
472 509
 		}
@@ -669,18 +706,36 @@  discard block
 block discarded – undo
669 706
 			{
670 707
 				$uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) :
671 708
 					(function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']);
672
-				if (is_array($uid)) $uid = $uid['name'];
673
-				if (empty($uid)) $uid = $stat['uid'];
709
+				if (is_array($uid))
710
+				{
711
+					$uid = $uid['name'];
712
+				}
713
+				if (empty($uid))
714
+				{
715
+					$uid = $stat['uid'];
716
+				}
717
+			}
718
+			if (!isset($uid))
719
+			{
720
+				$uid = 'root';
674 721
 			}
675
-			if (!isset($uid)) $uid = 'root';
676 722
 			if ($stat['gid'])
677 723
 			{
678 724
 				$gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) :
679 725
 					(function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']);
680
-				if (is_array($gid)) $gid = $gid['name'];
681
-				if (empty($gid)) $gid = $stat['gid'];
726
+				if (is_array($gid))
727
+				{
728
+					$gid = $gid['name'];
729
+				}
730
+				if (empty($gid))
731
+				{
732
+					$gid = $stat['gid'];
733
+				}
734
+			}
735
+			if (!isset($gid))
736
+			{
737
+				$gid = 'root';
682 738
 			}
683
-			if (!isset($gid)) $gid = 'root';
684 739
 		}
685 740
 		$size = hsize($stat['size']);
686 741
 		$mtime = date('Y-m-d H:i:s',$stat['mtime']);
@@ -703,8 +758,14 @@  discard block
 block discarded – undo
703 758
 
704 759
 function hsize($size)
705 760
 {
706
-	if ($size < 1024) return $size;
707
-	if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024);
761
+	if ($size < 1024)
762
+	{
763
+		return $size;
764
+	}
765
+	if ($size < 1024*1024)
766
+	{
767
+		return sprintf('%3.1lfk',(float)$size/1024);
768
+	}
708 769
 	return sprintf('%3.1lfM',(float)$size/(1024*1024));
709 770
 }
710 771
 
@@ -738,14 +799,20 @@  discard block
 block discarded – undo
738 799
 					++$anz_files;
739 800
 					_cp($f,$t);
740 801
 				}
741
-				if ($perms) _cp_perms($f,$t);
802
+				if ($perms)
803
+				{
804
+					_cp_perms($f,$t);
805
+				}
742 806
 			}
743 807
 			echo ($anz_dirs?"$anz_dirs dir(s) created and ":'')."$anz_files file(s) copied.\n";
744 808
 		}
745 809
 		else
746 810
 		{
747 811
 			_cp($from,$to,true);
748
-			if ($perms) _cp_perms($from,$to);
812
+			if ($perms)
813
+			{
814
+				_cp_perms($from,$to);
815
+			}
749 816
 		}
750 817
 	}
751 818
 }
@@ -774,7 +841,10 @@  discard block
 block discarded – undo
774 841
 	//stream_filter_append($from_fp,'convert.base64-decode');
775 842
 	$count = stream_copy_to_stream($from_fp,$to_fp);
776 843
 
777
-	if ($verbose) echo hsize($count)." bytes written to $to\n";
844
+	if ($verbose)
845
+	{
846
+		echo hsize($count)." bytes written to $to\n";
847
+	}
778 848
 
779 849
 	fclose($from_fp);
780 850
 
@@ -821,7 +891,10 @@  discard block
 block discarded – undo
821 891
 function do_lntree($from,$to)
822 892
 {
823 893
 	echo "lntree $from $to\n";
824
-	if ($from[0] == '/') $from = 'sqlfs://default'.$from;
894
+	if ($from[0] == '/')
895
+	{
896
+		$from = 'sqlfs://default'.$from;
897
+	}
825 898
 	load_wrapper($from);
826 899
 
827 900
 	if (!file_exists($from))
@@ -883,34 +956,55 @@  discard block
 block discarded – undo
883 956
  */
884 957
 function int2mode( $mode )
885 958
 {
886
-	if(($mode & 0xA000) == 0xA000) // Symbolic Link
959
+	if(($mode & 0xA000) == 0xA000)
960
+	{
961
+		// Symbolic Link
887 962
 	{
888 963
 		$sP = 'l';
889 964
 	}
890
-	elseif(($mode & 0xC000) == 0xC000) // Socket
965
+	}
966
+	elseif(($mode & 0xC000) == 0xC000)
967
+	{
968
+		// Socket
891 969
 	{
892 970
 		$sP = 's';
893 971
 	}
894
-	elseif($mode & 0x1000)     // FIFO pipe
972
+	}
973
+	elseif($mode & 0x1000)
974
+	{
975
+		// FIFO pipe
895 976
 	{
896 977
 		$sP = 'p';
897 978
 	}
898
-	elseif($mode & 0x2000) // Character special
979
+	}
980
+	elseif($mode & 0x2000)
981
+	{
982
+		// Character special
899 983
 	{
900 984
 		$sP = 'c';
901 985
 	}
902
-	elseif($mode & 0x4000) // Directory
986
+	}
987
+	elseif($mode & 0x4000)
988
+	{
989
+		// Directory
903 990
 	{
904 991
 		$sP = 'd';
905 992
 	}
906
-	elseif($mode & 0x6000) // Block special
993
+	}
994
+	elseif($mode & 0x6000)
995
+	{
996
+		// Block special
907 997
 	{
908 998
 		$sP = 'b';
909 999
 	}
910
-	elseif($mode & 0x8000) // Regular
1000
+	}
1001
+	elseif($mode & 0x8000)
1002
+	{
1003
+		// Regular
911 1004
 	{
912 1005
 		$sP = '-';
913 1006
 	}
1007
+	}
914 1008
 	else                         // UNKNOWN
915 1009
 	{
916 1010
 		$sP = 'u';
Please login to merge, or discard this patch.
Spacing   +136 added lines, -141 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 use EGroupware\Api;
17 17
 use EGroupware\Api\Vfs;
18 18
 
19
-chdir(dirname(__FILE__));	// to enable our relative pathes to work
19
+chdir(dirname(__FILE__)); // to enable our relative pathes to work
20 20
 
21
-error_reporting(error_reporting() & ~E_NOTICE & ~E_DEPRECATED);
21
+error_reporting(error_reporting()&~E_NOTICE & ~E_DEPRECATED);
22 22
 
23 23
 if (php_sapi_name() !== 'cli')	// security precaution: forbit calling filemanager/cli.php as web-page
24 24
 {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  *
48 48
  * @param string $error_msg ='' error-message to be printed in front of usage
49 49
  */
50
-function usage($error_msg='')
50
+function usage($error_msg = '')
51 51
 {
52 52
 	if ($error_msg)
53 53
 	{
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 }
82 82
 $long = $numeric = $recursive = $perms = $all = $inode = false;
83 83
 $args = $_SERVER['argv'];
84
-$cmd = basename(array_shift($args),'.php');
85
-if ($args[0][0] != '-' && $args[0][0] != '/' && strpos($args[0],'://') === false)
84
+$cmd = basename(array_shift($args), '.php');
85
+if ($args[0][0] != '-' && $args[0][0] != '/' && strpos($args[0], '://') === false)
86 86
 {
87 87
 	$cmd = array_shift($args);
88 88
 }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 if (!$args) $args = array('-h');
91 91
 
92 92
 $argv = $find_options = array();
93
-while(!is_null($option = array_shift($args)))
93
+while (!is_null($option = array_shift($args)))
94 94
 {
95 95
 	if ($option == '-' || $option[0] != '-')	// no option --> argument
96 96
 	{
@@ -103,34 +103,34 @@  discard block
 block discarded – undo
103 103
 		continue;
104 104
 	}
105 105
 
106
-	switch($option)
106
+	switch ($option)
107 107
 	{
108 108
 		default:
109 109
 			if ($cmd == 'find')
110 110
 			{
111
-				if (!in_array($option,array('-type','-depth','-mindepth','-maxdepth','-name','-path',
112
-					'-uid','-user','-nouser','-gid','-group','-nogroup','-mime',
113
-					'-empty','-size','-cmin','-ctime','-mmin','-mtime','-limit','-order','-sort',
114
-					'-hidden','-show-deleted','-name-preg','-path','-path-preg')))
111
+				if (!in_array($option, array('-type', '-depth', '-mindepth', '-maxdepth', '-name', '-path',
112
+					'-uid', '-user', '-nouser', '-gid', '-group', '-nogroup', '-mime',
113
+					'-empty', '-size', '-cmin', '-ctime', '-mmin', '-mtime', '-limit', '-order', '-sort',
114
+					'-hidden', '-show-deleted', '-name-preg', '-path', '-path-preg')))
115 115
 				{
116 116
 					usage("Unknown find option '$option'!");
117 117
 				}
118
-				if (in_array($option,array('-empty','-depth','-nouser','-nogroup','-hidden','-show-deleted')))
118
+				if (in_array($option, array('-empty', '-depth', '-nouser', '-nogroup', '-hidden', '-show-deleted')))
119 119
 				{
120
-					$find_options[substr($option,1)] = true;
120
+					$find_options[substr($option, 1)] = true;
121 121
 				}
122 122
 				else
123 123
 				{
124
-					$find_options[str_replace('-','_',substr($option,1))] = array_shift($args);
124
+					$find_options[str_replace('-', '_', substr($option, 1))] = array_shift($args);
125 125
 				}
126 126
 				break;
127 127
 			}
128 128
 			// multiple options, eg. -rp --> -r -p
129
-			elseif($option[0] == '-' && $option[1] != '-' && strlen($option) > 2)
129
+			elseif ($option[0] == '-' && $option[1] != '-' && strlen($option) > 2)
130 130
 			{
131
-				for($i = 1; $i < strlen($option); ++$i)
131
+				for ($i = 1; $i < strlen($option); ++$i)
132 132
 				{
133
-					array_unshift($args,'-'.$option[$i]);
133
+					array_unshift($args, '-'.$option[$i]);
134 134
 				}
135 135
 				break;
136 136
 			}
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 }
187 187
 if ($user && $passwd)
188 188
 {
189
-	load_egw($user,$passwd,$domain ? $domain : 'default');
189
+	load_egw($user, $passwd, $domain ? $domain : 'default');
190 190
 }
191 191
 $argc = count($argv);
192 192
 
193
-switch($cmd)
193
+switch ($cmd)
194 194
 {
195 195
 	case 'umount':
196 196
 		if ($argc != 1 && !$all)
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 			usage('Wrong number of parameters!');
199 199
 		}
200 200
 		if (($url = $argv[0])) load_wrapper($url);
201
-		if(!Vfs::$is_root)
201
+		if (!Vfs::$is_root)
202 202
 		{
203 203
 			die("You need to be root to do that!\n");
204 204
 		}
205 205
 		if ($all)
206 206
 		{
207
-			Api\Config::save_value('vfs_fstab',$GLOBALS['egw_info']['server']['vfs_fstab']='','phpgwapi');
207
+			Api\Config::save_value('vfs_fstab', $GLOBALS['egw_info']['server']['vfs_fstab'] = '', 'phpgwapi');
208 208
 			echo "Restored default mounts:\n";
209 209
 		}
210 210
 		elseif (!Vfs::umount($url))
@@ -221,16 +221,16 @@  discard block
 block discarded – undo
221 221
 		{
222 222
 			usage('Wrong number of parameters!');
223 223
 		}
224
-		load_wrapper($url=$argv[0]);
224
+		load_wrapper($url = $argv[0]);
225 225
 
226
-		if($argc > 1 && !Vfs::$is_root)
226
+		if ($argc > 1 && !Vfs::$is_root)
227 227
 		{
228 228
 			die("You need to be root to do that!\n");
229 229
 		}
230
-		$fstab = Vfs::mount($url,$path=$argv[1]);
230
+		$fstab = Vfs::mount($url, $path = $argv[1]);
231 231
 		if (is_array($fstab))
232 232
 		{
233
-			foreach($fstab as $path => $url)
233
+			foreach ($fstab as $path => $url)
234 234
 			{
235 235
 				echo "$url\t$path\n";
236 236
 			}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		break;
251 251
 
252 252
 	case 'find':
253
-		do_find($argv,$find_options);
253
+		do_find($argv, $find_options);
254 254
 		break;
255 255
 
256 256
 	case 'lntree':
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 		break;
259 259
 
260 260
 	case 'cp':
261
-		do_cp($argv,$recursive,$perms);
261
+		do_cp($argv, $recursive, $perms);
262 262
 		break;
263 263
 
264 264
 	case 'rename':
265 265
 		if (count($argv) != 2) usage('Wrong number of parameters!');
266 266
 		load_wrapper($argv[0]);
267 267
 		load_wrapper($argv[1]);
268
-		rename($argv[0],$argv[1]);
268
+		rename($argv[0], $argv[1]);
269 269
 		break;
270 270
 
271 271
 	case 'migrate-db2fs':
@@ -273,21 +273,21 @@  discard block
 block discarded – undo
273 273
 		{
274 274
 			die("\nYou need to be root to do that!\n\n");
275 275
 		}
276
-		if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit;	// we need write access, error msg already given
276
+		if (!is_writable($GLOBALS['egw_info']['server']['files_dir'])) exit; // we need write access, error msg already given
277 277
 		$fstab = Vfs::mount();
278
-		if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'],'storage=db') === false)
278
+		if (!is_array($fstab) || !isset($fstab['/']) || strpos($fstab['/'], 'storage=db') === false)
279 279
 		{
280
-			foreach($fstab as $path => $url)
280
+			foreach ($fstab as $path => $url)
281 281
 			{
282 282
 				echo "$url\t$path\n";
283 283
 			}
284 284
 			die("\n/ NOT mounted with 'storage=db' --> no need to convert!\n\n");
285 285
 		}
286
-		$num_files = Vfs\Sqlfs\Utils::migrate_db2fs();	// throws exception on error
286
+		$num_files = Vfs\Sqlfs\Utils::migrate_db2fs(); // throws exception on error
287 287
 		echo "\n$num_files files migrated from DB to filesystem.\n";
288
-		$new_url = preg_replace('/storage=db&?/','',$fstab['/']);
289
-		if (substr($new_url,-1) == '?') $new_url = substr($new_url,0,-1);
290
-		if (Vfs::mount($new_url,'/'))
288
+		$new_url = preg_replace('/storage=db&?/', '', $fstab['/']);
289
+		if (substr($new_url, -1) == '?') $new_url = substr($new_url, 0, -1);
290
+		if (Vfs::mount($new_url, '/'))
291 291
 		{
292 292
 			echo "/ successful re-mounted on $new_url\n";
293 293
 		}
@@ -298,24 +298,24 @@  discard block
 block discarded – undo
298 298
 		break;
299 299
 
300 300
 	default:
301
-		while($argv)
301
+		while ($argv)
302 302
 		{
303 303
 			$url = array_shift($argv);
304 304
 
305 305
 			if (strpos($url, '://')) load_wrapper($url);
306 306
 			echo "$cmd $url (long=".(int)$long.", numeric=".(int)$numeric.", recursive=".(int)$recursive.") ".implode(' ', $argv)."\n";
307 307
 
308
-			switch($cmd)
308
+			switch ($cmd)
309 309
 			{
310 310
 				case 'rm':
311 311
 					if ($recursive)
312 312
 					{
313 313
 						if (!class_exists('EGroupware\\Api\\Vfs'))
314 314
 						{
315
-							die("rm -r only implemented for eGW streams!");	// dont want to repeat the code here
315
+							die("rm -r only implemented for eGW streams!"); // dont want to repeat the code here
316 316
 						}
317
-						array_unshift($argv,$url);
318
-						Vfs::remove($argv,true);
317
+						array_unshift($argv, $url);
318
+						Vfs::remove($argv, true);
319 319
 						$argv = array();
320 320
 					}
321 321
 					else
@@ -329,27 +329,27 @@  discard block
 block discarded – undo
329 329
 					break;
330 330
 
331 331
 				case 'mkdir':
332
-					if (!mkdir($url,null,$recursive)) echo "Can't create directory, permission denied!\n";
332
+					if (!mkdir($url, null, $recursive)) echo "Can't create directory, permission denied!\n";
333 333
 					break;
334 334
 
335 335
 				case 'touch':
336 336
 				case 'chmod':
337 337
 				case 'chown':
338 338
 				case 'chgrp':
339
-					switch($cmd)
339
+					switch ($cmd)
340 340
 					{
341 341
 						case 'touch':
342
-							$params = array($url,$time);
342
+							$params = array($url, $time);
343 343
 							break;
344 344
 						case 'chmod':
345 345
 							if (!isset($mode))
346 346
 							{
347
-								$mode = $url;	// first param is mode
347
+								$mode = $url; // first param is mode
348 348
 								$url = array_shift($argv);
349
-								load_wrapper($url);	// not loaded because mode was in url
349
+								load_wrapper($url); // not loaded because mode was in url
350 350
 							}
351 351
 
352
-							if (strpos($mode,'+') !== false || strpos($mode,'-') !== false)
352
+							if (strpos($mode, '+') !== false || strpos($mode, '-') !== false)
353 353
 							{
354 354
 								$stat = stat($url);
355 355
 								$set = $stat['mode'];
@@ -360,19 +360,19 @@  discard block
 block discarded – undo
360 360
 							}
361 361
 							if (!class_exists('EGroupware\\Api\\Vfs'))
362 362
 							{
363
-								die("chmod only implemented for eGW streams!");	// dont want to repeat the code here
363
+								die("chmod only implemented for eGW streams!"); // dont want to repeat the code here
364 364
 							}
365
-							$set = Vfs::mode2int($mode,$set);
366
-							$params = array($url,$set);
365
+							$set = Vfs::mode2int($mode, $set);
366
+							$params = array($url, $set);
367 367
 							break;
368 368
 						case 'chown':
369 369
 						case 'chgrp':
370 370
 							$type = $cmd == 'chgrp' ? 'group' : 'user';
371 371
 							if (!isset($owner))
372 372
 							{
373
-								$owner = $url;	// first param is owner/group
373
+								$owner = $url; // first param is owner/group
374 374
 								$url = array_shift($argv);
375
-								load_wrapper($url);	// not loaded because owner/group was in url
375
+								load_wrapper($url); // not loaded because owner/group was in url
376 376
 								if ($owner == 'root')
377 377
 								{
378 378
 									$owner = 0;
@@ -383,34 +383,34 @@  discard block
 block discarded – undo
383 383
 									{
384 384
 										die("only numeric user/group-id's allowed for non eGW streams!");
385 385
 									}
386
-									if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was=$owner,'account_lid',$type[0])) ||
386
+									if (!($owner = $GLOBALS['egw']->accounts->name2id($owner_was = $owner, 'account_lid', $type[0])) ||
387 387
 										($owner < 0) != ($cmd == 'chgrp'))
388 388
 									{
389 389
 										die("Unknown $type '$owner_was'!");
390 390
 									}
391 391
 								}
392
-								elseif($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) ||
392
+								elseif ($owner && is_object($GLOBALS['egw']) && (!$GLOBALS['egw']->accounts->id2name($owner) ||
393 393
 										($owner < 0) != ($cmd == 'chgrp')))
394 394
 								{
395 395
 									die("Unknown $type '$owner_was'!");
396 396
 								}
397 397
 							}
398
-							$params = array($url,$owner);
398
+							$params = array($url, $owner);
399 399
 							break;
400 400
 					}
401
-					if (($scheme = Vfs::parse_url($url,PHP_URL_SCHEME)))
401
+					if (($scheme = Vfs::parse_url($url, PHP_URL_SCHEME)))
402 402
 					{
403 403
 						load_wrapper($url);
404 404
 					}
405 405
 					if ($recursive && class_exists('EGroupware\\Api\\Vfs'))
406 406
 					{
407
-						array_unshift($argv,$url);
408
-						$params = array($argv,null,$cmd,$params[1]);
409
-						$cmd = array('EGroupware\\Api\\Vfs','find');
410
-						$argv = array();	// we processed all url's
407
+						array_unshift($argv, $url);
408
+						$params = array($argv, null, $cmd, $params[1]);
409
+						$cmd = array('EGroupware\\Api\\Vfs', 'find');
410
+						$argv = array(); // we processed all url's
411 411
 					}
412 412
 					//echo "calling cmd=".print_r($cmd,true).", params=".print_r($params,true)."\n";
413
-					call_user_func_array($cmd,$params);
413
+					call_user_func_array($cmd, $params);
414 414
 					break;
415 415
 
416 416
 				case 'cat':
@@ -420,35 +420,35 @@  discard block
 block discarded – undo
420 420
 					if ($cmd != 'cat' && $recursive && class_exists('EGroupware\\Api\\Vfs'))
421 421
 					{
422 422
 						load_wrapper($url);
423
-						array_unshift($argv,$url);
424
-						Vfs::find($argv,array('url'=>true,),'do_stat',array($long,$numeric,true,$inode));
423
+						array_unshift($argv, $url);
424
+						Vfs::find($argv, array('url'=>true,), 'do_stat', array($long, $numeric, true, $inode));
425 425
 						$argv = array();
426 426
 					}
427 427
 					elseif (is_dir($url) && ($dir = opendir($url)))
428 428
 					{
429 429
 						if ($argc)
430 430
 						{
431
-							if (!($name = basename(Vfs::parse_url($url,PHP_URL_PATH)))) $name = '/';
431
+							if (!($name = basename(Vfs::parse_url($url, PHP_URL_PATH)))) $name = '/';
432 432
 							echo "\n$name:\n";
433 433
 						}
434 434
 						// separate evtl. query part, to re-add it after the file-name
435 435
 						unset($query);
436
-						list($url,$query) = explode('?',$url,2);
436
+						list($url, $query) = explode('?', $url, 2);
437 437
 						if ($query) $query = '?'.$query;
438 438
 
439
-						if (substr($url,-1) == '/')
439
+						if (substr($url, -1) == '/')
440 440
 						{
441
-							$url = substr($url,0,-1);
441
+							$url = substr($url, 0, -1);
442 442
 						}
443
-						while(($file = readdir($dir)) !== false)
443
+						while (($file = readdir($dir)) !== false)
444 444
 						{
445
-							do_stat($url.'/'.$file.$query,$long,$numeric,false,$inode);
445
+							do_stat($url.'/'.$file.$query, $long, $numeric, false, $inode);
446 446
 						}
447 447
 						closedir($dir);
448 448
 					}
449 449
 					elseif ($cmd == 'cat')
450 450
 					{
451
-						if (!($f = fopen($url,'r')))
451
+						if (!($f = fopen($url, 'r')))
452 452
 						{
453 453
 							echo "File $url not found !!!\n\n";
454 454
 						}
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 						{
457 457
 							if ($argc)
458 458
 							{
459
-								echo "\n".basename(Vfs::parse_url($url,PHP_URL_PATH)).":\n";
459
+								echo "\n".basename(Vfs::parse_url($url, PHP_URL_PATH)).":\n";
460 460
 							}
461 461
 							fpassthru($f);
462 462
 							fclose($f);
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 					}
465 465
 					else
466 466
 					{
467
-						do_stat($url,$long,$numeric,false,$inode);
467
+						do_stat($url, $long, $numeric, false, $inode);
468 468
 					}
469 469
 					if (!$long && $cmd == 'ls') echo "\n";
470 470
 					break;
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
  */
480 480
 function load_wrapper($url)
481 481
 {
482
-	if (($scheme = parse_url($url,PHP_URL_SCHEME)) &&
482
+	if (($scheme = parse_url($url, PHP_URL_SCHEME)) &&
483 483
 		!in_array($scheme, stream_get_wrappers()))
484 484
 	{
485
-		switch($scheme)
485
+		switch ($scheme)
486 486
 		{
487 487
 			case 'webdav':
488 488
 			case 'webdavs':
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 				break;
491 491
 
492 492
 			default:
493
-				if (!isset($GLOBALS['egw']) && !in_array($scheme,array('smb','imap')) &&
494
-					($user = parse_url($url,PHP_URL_USER)) && ($pass = parse_url($url,PHP_URL_PASS)))
493
+				if (!isset($GLOBALS['egw']) && !in_array($scheme, array('smb', 'imap')) &&
494
+					($user = parse_url($url, PHP_URL_USER)) && ($pass = parse_url($url, PHP_URL_PASS)))
495 495
 				{
496
-					load_egw($user, $pass, ($host = parse_url($url,PHP_URL_HOST)) ? $host : 'default');
496
+					load_egw($user, $pass, ($host = parse_url($url, PHP_URL_HOST)) ? $host : 'default');
497 497
 				}
498 498
 				// get eGW's __autoload() function
499 499
 				include_once(EGW_SERVER_ROOT.'/api/src/loader/common.php');
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
  * @param string $passwd
515 515
  * @param string $domain
516 516
  */
517
-function load_egw($user,$passwd,$domain='default')
517
+function load_egw($user, $passwd, $domain = 'default')
518 518
 {
519 519
 	//echo "load_egw($user,$passwd,$domain)\n";
520 520
 	$_REQUEST['domain'] = $domain;
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
 	if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp'))
528 528
 	{
529
-		ini_set('session.save_path','/tmp');	// regular users may have no rights to apache's session dir
529
+		ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir
530 530
 	}
531 531
 
532 532
 	$GLOBALS['egw_info'] = array(
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		)
539 539
 	);
540 540
 
541
-	if (substr($user,0,5) != 'root_')
541
+	if (substr($user, 0, 5) != 'root_')
542 542
 	{
543 543
 		include('../header.inc.php');
544 544
 	}
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	$cmd = $GLOBALS['cmd'];
567
-	if (!in_array($cmd,array('ls','find','mount','umount','eacl','touch','chmod','chown','chgrp')) && $GLOBALS['egw_info']['server']['files_dir'] && !is_writable($GLOBALS['egw_info']['server']['files_dir']))
567
+	if (!in_array($cmd, array('ls', 'find', 'mount', 'umount', 'eacl', 'touch', 'chmod', 'chown', 'chgrp')) && $GLOBALS['egw_info']['server']['files_dir'] && !is_writable($GLOBALS['egw_info']['server']['files_dir']))
568 568
 	{
569 569
 		echo "\nError: eGroupWare's files directory {$GLOBALS['egw_info']['server']['files_dir']} is NOT writable by the user running ".basename(__FILE__)."!\n".
570 570
 			"--> Please run it as the same user the webserver uses or root, otherwise the $cmd command will fail!\n\n";
@@ -595,22 +595,22 @@  discard block
 block discarded – undo
595 595
 	}
596 596
 	if ($argc == 1)
597 597
 	{
598
-		foreach(Vfs::get_eacl($url) as $acl)
598
+		foreach (Vfs::get_eacl($url) as $acl)
599 599
 		{
600
-			$mode = ($acl['rights'] & Vfs::READABLE ? 'r' : '-').
601
-				($acl['rights'] & Vfs::WRITABLE ? 'w' : '-').
602
-				($acl['rights'] & Vfs::EXECUTABLE ? 'x' : '-');
600
+			$mode = ($acl['rights']&Vfs::READABLE ? 'r' : '-').
601
+				($acl['rights']&Vfs::WRITABLE ? 'w' : '-').
602
+				($acl['rights']&Vfs::EXECUTABLE ? 'x' : '-');
603 603
 			echo $acl['path']."\t$mode\t".$GLOBALS['egw']->accounts->id2name($acl['owner'])."\n";
604 604
 		}
605 605
 		return;
606 606
 	}
607 607
 	if ($argc > 1 && !is_numeric($argv[1]))
608 608
 	{
609
-		$mode=$argv[1];
609
+		$mode = $argv[1];
610 610
 		$argv[1] = null;
611
-		for($i = 0; $mode[$i]; ++$i)
611
+		for ($i = 0; $mode[$i]; ++$i)
612 612
 		{
613
-			switch($mode[$i])
613
+			switch ($mode[$i])
614 614
 			{
615 615
 				case 'x': $argv[1] |= Vfs::EXECUTABLE; break;
616 616
 				case 'w': $argv[1] |= Vfs::WRITABLE; break;
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 			}
619 619
 		}
620 620
 	}
621
-	if (!Vfs::eacl($url,$argv[1],$argc > 2 && !is_numeric($argv[2]) ? $GLOBALS['egw']->accounts->name2id($argv[2]) : $argv[2]))
621
+	if (!Vfs::eacl($url, $argv[1], $argc > 2 && !is_numeric($argv[2]) ? $GLOBALS['egw']->accounts->name2id($argv[2]) : $argv[2]))
622 622
 	{
623 623
 		echo "Error setting extended Acl for $argv[0]!\n";
624 624
 	}
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
  * @param boolean $full_path =false true=give full path instead of just filename
634 634
  * @param boolean $inode =false true=display inode (sqlfs id)
635 635
  */
636
-function do_stat($url,$long=false,$numeric=false,$full_path=false,$inode=false)
636
+function do_stat($url, $long = false, $numeric = false, $full_path = false, $inode = false)
637 637
 {
638 638
 	//echo "do_stat($url,$long,$numeric,$full_path)\n";
639
-	$bname = Vfs::parse_url($url,PHP_URL_PATH);
639
+	$bname = Vfs::parse_url($url, PHP_URL_PATH);
640 640
 
641 641
 	if (!$full_path)
642 642
 	{
@@ -667,25 +667,23 @@  discard block
 block discarded – undo
667 667
 		{
668 668
 			if ($stat['uid'])
669 669
 			{
670
-				$uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) :
671
-					(function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']);
670
+				$uid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name($stat['uid']) : (function_exists('posix_getpwuid') ? posix_getpwuid($stat['uid']) : $stat['uid']);
672 671
 				if (is_array($uid)) $uid = $uid['name'];
673 672
 				if (empty($uid)) $uid = $stat['uid'];
674 673
 			}
675 674
 			if (!isset($uid)) $uid = 'root';
676 675
 			if ($stat['gid'])
677 676
 			{
678
-				$gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) :
679
-					(function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']);
677
+				$gid = isset($GLOBALS['egw']) ? $GLOBALS['egw']->accounts->id2name(-abs($stat['gid'])) : (function_exists('posix_getgrgid') ? posix_getgrgid($stat['gid']) : $stat['gid']);
680 678
 				if (is_array($gid)) $gid = $gid['name'];
681 679
 				if (empty($gid)) $gid = $stat['gid'];
682 680
 			}
683 681
 			if (!isset($gid)) $gid = 'root';
684 682
 		}
685 683
 		$size = hsize($stat['size']);
686
-		$mtime = date('Y-m-d H:i:s',$stat['mtime']);
684
+		$mtime = date('Y-m-d H:i:s', $stat['mtime']);
687 685
 		$nlink = $stat['nlink'];
688
-		if (($stat['mode'] & 0xA000) == 0xA000)
686
+		if (($stat['mode']&0xA000) == 0xA000)
689 687
 		{
690 688
 			$symlink = " -> ".(class_exists('EGroupware\\Api\\Vfs') ? Vfs::readlink($url) : readlink($url));
691 689
 		}
@@ -704,12 +702,12 @@  discard block
 block discarded – undo
704 702
 function hsize($size)
705 703
 {
706 704
 	if ($size < 1024) return $size;
707
-	if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024);
708
-	return sprintf('%3.1lfM',(float)$size/(1024*1024));
705
+	if ($size < 1024 * 1024) return sprintf('%3.1lfk', (float)$size / 1024);
706
+	return sprintf('%3.1lfM', (float)$size / (1024 * 1024));
709 707
 }
710 708
 
711 709
 
712
-function do_cp($argv,$recursive=false,$perms=false)
710
+function do_cp($argv, $recursive = false, $perms = false)
713 711
 {
714 712
 	$to = array_pop($argv);
715 713
 	load_wrapper($to);
@@ -721,13 +719,13 @@  discard block
 block discarded – undo
721 719
 		usage("No such directory '$to'!");
722 720
 	}
723 721
 	$anz_dirs = $anz_files = 0;
724
-	foreach($argv as $from)
722
+	foreach ($argv as $from)
725 723
 	{
726 724
 		if (is_dir($from) && (!file_exists($to) || is_dir($to)) && $recursive && class_exists('EGroupware\\Api\\Vfs'))
727 725
 		{
728
-			foreach(Vfs::find($from,array('url' => true)) as $f)
726
+			foreach (Vfs::find($from, array('url' => true)) as $f)
729 727
 			{
730
-				$t = $to.substr($f,strlen($from));
728
+				$t = $to.substr($f, strlen($from));
731 729
 				if (is_dir($f))
732 730
 				{
733 731
 					++$anz_dirs;
@@ -736,43 +734,43 @@  discard block
 block discarded – undo
736 734
 				else
737 735
 				{
738 736
 					++$anz_files;
739
-					_cp($f,$t);
737
+					_cp($f, $t);
740 738
 				}
741
-				if ($perms) _cp_perms($f,$t);
739
+				if ($perms) _cp_perms($f, $t);
742 740
 			}
743
-			echo ($anz_dirs?"$anz_dirs dir(s) created and ":'')."$anz_files file(s) copied.\n";
741
+			echo ($anz_dirs ? "$anz_dirs dir(s) created and " : '')."$anz_files file(s) copied.\n";
744 742
 		}
745 743
 		else
746 744
 		{
747
-			_cp($from,$to,true);
748
-			if ($perms) _cp_perms($from,$to);
745
+			_cp($from, $to, true);
746
+			if ($perms) _cp_perms($from, $to);
749 747
 		}
750 748
 	}
751 749
 }
752 750
 
753
-function _cp($from,$to,$verbose=false)
751
+function _cp($from, $to, $verbose = false)
754 752
 {
755 753
 	load_wrapper($from);
756 754
 
757 755
 	if (is_dir($to))
758 756
 	{
759
-		$path = Vfs::parse_url($from,PHP_URL_PATH);
757
+		$path = Vfs::parse_url($from, PHP_URL_PATH);
760 758
 		if (is_dir($to))
761 759
 		{
762
-			list($to,$query) = explode('?',$to,2);
760
+			list($to, $query) = explode('?', $to, 2);
763 761
 			$to .= '/'.basename($path).($query ? '?'.$query : '');
764 762
 		}
765 763
 	}
766
-	if (!($from_fp = fopen($from,'r')))
764
+	if (!($from_fp = fopen($from, 'r')))
767 765
 	{
768 766
 		die("File $from not found!\n");
769 767
 	}
770
-	if (!($to_fp = fopen($to,'w')))
768
+	if (!($to_fp = fopen($to, 'w')))
771 769
 	{
772 770
 		die("Can't open $to for writing!\n");
773 771
 	}
774 772
 	//stream_filter_append($from_fp,'convert.base64-decode');
775
-	$count = stream_copy_to_stream($from_fp,$to_fp);
773
+	$count = stream_copy_to_stream($from_fp, $to_fp);
776 774
 
777 775
 	if ($verbose) echo hsize($count)." bytes written to $to\n";
778 776
 
@@ -785,11 +783,11 @@  discard block
 block discarded – undo
785 783
 }
786 784
 
787 785
 
788
-function _cp_perms($from,$to)
786
+function _cp_perms($from, $to)
789 787
 {
790 788
 	if (($from_stat = stat($from)) && ($to_stat = stat($to)))
791 789
 	{
792
-		foreach(array(
790
+		foreach (array(
793 791
 			'mode' => 'chmod',
794 792
 			'uid'  => 'chown',
795 793
 			'gid'  => 'chgrp',
@@ -798,27 +796,27 @@  discard block
 block discarded – undo
798 796
 			if ($from_stat[$perm] != $to_stat[$perm])
799 797
 			{
800 798
 				//echo "Vfs::$cmd($to,{$from_stat[$perm]}\n";
801
-				call_user_func(array('EGroupware\\Api\\Vfs',$cmd),$to,$from_stat[$perm]);
799
+				call_user_func(array('EGroupware\\Api\\Vfs', $cmd), $to, $from_stat[$perm]);
802 800
 			}
803 801
 		}
804 802
 	}
805 803
 }
806 804
 
807
-function do_find($bases,$options)
805
+function do_find($bases, $options)
808 806
 {
809
-	foreach($bases as $url)
807
+	foreach ($bases as $url)
810 808
 	{
811 809
 		load_wrapper($url);
812 810
 	}
813
-	$options['url'] = true;	// we use url's not vfs pathes in filemanager/cli.php
811
+	$options['url'] = true; // we use url's not vfs pathes in filemanager/cli.php
814 812
 
815
-	foreach(Vfs::find($bases,$options) as $path)
813
+	foreach (Vfs::find($bases, $options) as $path)
816 814
 	{
817 815
 		echo "$path\n";
818 816
 	}
819 817
 }
820 818
 
821
-function do_lntree($from,$to)
819
+function do_lntree($from, $to)
822 820
 {
823 821
 	echo "lntree $from $to\n";
824 822
 	if ($from[0] == '/') $from = 'sqlfs://default'.$from;
@@ -881,33 +879,33 @@  discard block
 block discarded – undo
881 879
  * @param int $mode
882 880
  * @return string
883 881
  */
884
-function int2mode( $mode )
882
+function int2mode($mode)
885 883
 {
886
-	if(($mode & 0xA000) == 0xA000) // Symbolic Link
884
+	if (($mode&0xA000) == 0xA000) // Symbolic Link
887 885
 	{
888 886
 		$sP = 'l';
889 887
 	}
890
-	elseif(($mode & 0xC000) == 0xC000) // Socket
888
+	elseif (($mode&0xC000) == 0xC000) // Socket
891 889
 	{
892 890
 		$sP = 's';
893 891
 	}
894
-	elseif($mode & 0x1000)     // FIFO pipe
892
+	elseif ($mode&0x1000)     // FIFO pipe
895 893
 	{
896 894
 		$sP = 'p';
897 895
 	}
898
-	elseif($mode & 0x2000) // Character special
896
+	elseif ($mode&0x2000) // Character special
899 897
 	{
900 898
 		$sP = 'c';
901 899
 	}
902
-	elseif($mode & 0x4000) // Directory
900
+	elseif ($mode&0x4000) // Directory
903 901
 	{
904 902
 		$sP = 'd';
905 903
 	}
906
-	elseif($mode & 0x6000) // Block special
904
+	elseif ($mode&0x6000) // Block special
907 905
 	{
908 906
 		$sP = 'b';
909 907
 	}
910
-	elseif($mode & 0x8000) // Regular
908
+	elseif ($mode&0x8000) // Regular
911 909
 	{
912 910
 		$sP = '-';
913 911
 	}
@@ -917,22 +915,19 @@  discard block
 block discarded – undo
917 915
 	}
918 916
 
919 917
 	// owner
920
-	$sP .= (($mode & 0x0100) ? 'r' : '-') .
921
-	(($mode & 0x0080) ? 'w' : '-') .
922
-	(($mode & 0x0040) ? (($mode & 0x0800) ? 's' : 'x' ) :
923
-	(($mode & 0x0800) ? 'S' : '-'));
918
+	$sP .= (($mode&0x0100) ? 'r' : '-').
919
+	(($mode&0x0080) ? 'w' : '-').
920
+	(($mode&0x0040) ? (($mode&0x0800) ? 's' : 'x') : (($mode&0x0800) ? 'S' : '-'));
924 921
 
925 922
 	// group
926
-	$sP .= (($mode & 0x0020) ? 'r' : '-') .
927
-	(($mode & 0x0010) ? 'w' : '-') .
928
-	(($mode & 0x0008) ? (($mode & 0x0400) ? 's' : 'x' ) :
929
-	(($mode & 0x0400) ? 'S' : '-'));
923
+	$sP .= (($mode&0x0020) ? 'r' : '-').
924
+	(($mode&0x0010) ? 'w' : '-').
925
+	(($mode&0x0008) ? (($mode&0x0400) ? 's' : 'x') : (($mode&0x0400) ? 'S' : '-'));
930 926
 
931 927
 	// world
932
-	$sP .= (($mode & 0x0004) ? 'r' : '-') .
933
-	(($mode & 0x0002) ? 'w' : '-') .
934
-	(($mode & 0x0001) ? (($mode & 0x0200) ? 't' : 'x' ) :
935
-	(($mode & 0x0200) ? 'T' : '-'));
928
+	$sP .= (($mode&0x0004) ? 'r' : '-').
929
+	(($mode&0x0002) ? 'w' : '-').
930
+	(($mode&0x0001) ? (($mode&0x0200) ? 't' : 'x') : (($mode&0x0200) ? 'T' : '-'));
936 931
 
937 932
 	return $sP;
938 933
 }
Please login to merge, or discard this patch.
filemanager/test.php 2 patches
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,10 @@  discard block
 block discarded – undo
22 22
 {
23 23
 	$path = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
24 24
 }
25
-if (isset($_REQUEST['path'])) $path = $_REQUEST['path'];
25
+if (isset($_REQUEST['path']))
26
+{
27
+	$path = $_REQUEST['path'];
28
+}
26 29
 echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"').
27 30
 	Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET');
28 31
 
@@ -53,9 +56,12 @@  discard block
 block discarded – undo
53 56
 	$stime = number_format(1000*(microtime(true)-$time),1);
54 57
 
55 58
 	$time2 = microtime(true);
56
-	if ($is_dir)// && ($d = Vfs::opendir($path)))
59
+	if ($is_dir)
60
+	{
61
+		// && ($d = Vfs::opendir($path)))
57 62
 	{
58 63
 		$files = array();
64
+	}
59 65
 		//while(($file = readdir($d)))
60 66
 		foreach(Vfs::scandir($path) as $file)
61 67
 		{
@@ -69,7 +75,10 @@  discard block
 block discarded – undo
69 75
 		//closedir($d);
70 76
 		$time2f = number_format(1000*(microtime(true)-$time2),1);
71 77
 		echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n";
72
-		if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n";
78
+		if($files)
79
+		{
80
+			echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n";
81
+		}
73 82
 	}
74 83
 
75 84
 	echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')';
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 );
19 19
 include('../header.inc.php');
20 20
 
21
-if (!($path = Api\Cache::getSession('filemanger','test')))
21
+if (!($path = Api\Cache::getSession('filemanger', 'test')))
22 22
 {
23 23
 	$path = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
24 24
 }
25 25
 if (isset($_REQUEST['path'])) $path = $_REQUEST['path'];
26
-echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"').
27
-	Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET');
26
+echo Api\Html::form("<p>Path: ".Api\Html::input('path', $path, 'text', 'size="40"').
27
+	Api\Html::submit_button('', lang('Submit'))."</p>\n", array(), '', '', '', '', 'GET');
28 28
 
29 29
 if (isset($path) && !empty($path))
30 30
 {
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 	{
33 33
 		throw new Api\Exception\WrongUserinput('Not an absolute path!');
34 34
 	}
35
-	Api\Cache::setSession('filemanger','test',$path);
35
+	Api\Cache::setSession('filemanger', 'test', $path);
36 36
 
37 37
 	echo "<h2>";
38
-	foreach(explode('/',$path) as $n => $part)
38
+	foreach (explode('/', $path) as $n => $part)
39 39
 	{
40 40
 		$p .= ($p != '/' ? '/' : '').$part;
41
-		echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ','/filemanager/test.php',array('path'=>$p,'cd'=>'no'));
41
+		echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ', '/filemanager/test.php', array('path'=>$p, 'cd'=>'no'));
42 42
 	}
43 43
 	echo "</h2>\n";
44 44
 
@@ -50,29 +50,29 @@  discard block
 block discarded – undo
50 50
 
51 51
 	$time = microtime(true);
52 52
 	$stat = Vfs::stat($path);
53
-	$stime = number_format(1000*(microtime(true)-$time),1);
53
+	$stime = number_format(1000 * (microtime(true) - $time), 1);
54 54
 
55 55
 	$time2 = microtime(true);
56 56
 	if ($is_dir)// && ($d = Vfs::opendir($path)))
57 57
 	{
58 58
 		$files = array();
59 59
 		//while(($file = readdir($d)))
60
-		foreach(Vfs::scandir($path) as $file)
60
+		foreach (Vfs::scandir($path) as $file)
61 61
 		{
62
-			if (Vfs::is_readable($fpath=Vfs::concat($path,$file)))
62
+			if (Vfs::is_readable($fpath = Vfs::concat($path, $file)))
63 63
 			{
64
-				$file = Api\Html::a_href($file,'/filemanager/test.php',array('path'=>$fpath,'cd'=>'no'));
64
+				$file = Api\Html::a_href($file, '/filemanager/test.php', array('path'=>$fpath, 'cd'=>'no'));
65 65
 			}
66 66
 			$file .= ' ('.Vfs::mime_content_type($fpath).')';
67 67
 			$files[] = $file;
68 68
 		}
69 69
 		//closedir($d);
70
-		$time2f = number_format(1000*(microtime(true)-$time2),1);
70
+		$time2f = number_format(1000 * (microtime(true) - $time2), 1);
71 71
 		echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n";
72
-		if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n";
72
+		if ($files) echo '<ol><li>'.implode("</li>\n<li>", $files).'</ol>'."\n";
73 73
 	}
74 74
 
75
-	echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')';
75
+	echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode']) ?sprintf('%o', $stat['mode']).' = '.Vfs::int2mode($stat['mode']) : 'NULL').')';
76 76
 	if (is_array($stat))
77 77
 	{
78 78
 		_debug_array($stat);
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	echo "<p><b>readlink('$path')</b>=".array2string(Vfs::readlink($path))."</p>\n";
90 90
 	$time3 = microtime(true);
91 91
 	$lstat = Vfs::lstat($path);
92
-	$time3f = number_format(1000*(microtime(true)-$time3),1);
93
-	echo "<p><b>lstat('$path')</b> took $time3f ms (mode = ".(isset($lstat['mode'])?sprintf('%o',$lstat['mode']).' = '.Vfs::int2mode($lstat['mode']):'NULL').')';
92
+	$time3f = number_format(1000 * (microtime(true) - $time3), 1);
93
+	echo "<p><b>lstat('$path')</b> took $time3f ms (mode = ".(isset($lstat['mode']) ?sprintf('%o', $lstat['mode']).' = '.Vfs::int2mode($lstat['mode']) : 'NULL').')';
94 94
 	if (is_array($lstat))
95 95
 	{
96 96
 		_debug_array($lstat);
Please login to merge, or discard this patch.