Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
api/src/Json/Push.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 	{
60 60
 		if (!isset(self::$backend))
61 61
 		{
62
-			foreach(self::$backends as $class)
62
+			foreach (self::$backends as $class)
63 63
 			{
64 64
 				if (class_exists($class))
65 65
 				{
Please login to merge, or discard this patch.
api/src/Json/Request.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param boolean $set =null
40 40
 	 * @return boolean
41 41
 	 */
42
-	public static function isJSONRequest($set=null)
42
+	public static function isJSONRequest($set = null)
43 43
 	{
44 44
 		$ret = self::$_hadJSONRequest;
45 45
 		if (isset($set)) self::$_hadJSONRequest = $set;
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 
63 63
 		if (get_magic_quotes_gpc()) $input_data = stripslashes($input_data);
64 64
 
65
-		$json_data = json_decode($input_data,true);
65
+		$json_data = json_decode($input_data, true);
66 66
 		if (is_array($json_data) && isset($json_data['request']) && isset($json_data['request']['parameters']) && is_array($json_data['request']['parameters']))
67 67
 		{
68 68
 			//error_log(__METHOD__.__LINE__.array2string($json_data['request']).function_backtrace());
69
-			$parameters =& $json_data['request']['parameters'];
69
+			$parameters = & $json_data['request']['parameters'];
70 70
 		}
71 71
 		else
72 72
 		{
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 		{
78 78
 			$responses = array();
79 79
 			$response = Response::get();
80
-			foreach($parameters[0] as $uid => $data)
80
+			foreach ($parameters[0] as $uid => $data)
81 81
 			{
82 82
 				//error_log("$uid: menuaction=$data[menuaction], parameters=".array2string($data['parameters']));
83 83
 				$this->handleRequest($data['menuaction'], (array)$data['parameters']);
84 84
 				$responses[$uid] = $response->initResponseArray();
85 85
 				//error_log("responses[$uid]=".array2string($responses[$uid]));
86 86
 			}
87
-			$response->data($responses);	// send all responses as data
87
+			$response->data($responses); // send all responses as data
88 88
 		}
89 89
 		else
90 90
 		{
@@ -100,32 +100,32 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function handleRequest($menuaction, array $parameters)
102 102
 	{
103
-		if (strpos($menuaction,'::') !== false && strpos($menuaction,'.') === false)	// static method name app_something::method
103
+		if (strpos($menuaction, '::') !== false && strpos($menuaction, '.') === false)	// static method name app_something::method
104 104
 		{
105
-			@list($className,$functionName,$handler) = explode('::',$menuaction);
105
+			@list($className, $functionName, $handler) = explode('::', $menuaction);
106 106
 			if (substr($className, 0, 11) == 'EGroupware\\')
107 107
 			{
108 108
 				list(,$appName) = explode('\\', strtolower($className));
109 109
 			}
110 110
 			else
111 111
 			{
112
-				list($appName) = explode('_',$className);
112
+				list($appName) = explode('_', $className);
113 113
 			}
114 114
 
115 115
 			// Check for a real static method, avoid instanciation if it is
116 116
 			$m = new ReflectionMethod($menuaction);
117
-			if($m->isStatic())
117
+			if ($m->isStatic())
118 118
 			{
119 119
 				$ajaxClass = $className;
120 120
 			}
121 121
 		}
122 122
 		else
123 123
 		{
124
-			@list($appName, $className, $functionName, $handler) = explode('.',$menuaction);
124
+			@list($appName, $className, $functionName, $handler) = explode('.', $menuaction);
125 125
 		}
126 126
 		//error_log("json.php: appName=$appName, className=$className, functionName=$functionName, handler=$handler");
127 127
 
128
-		switch($handler)
128
+		switch ($handler)
129 129
 		{
130 130
 			case '/etemplate/process_exec':
131 131
 				$_GET['menuaction'] = $appName.'.'.$className.'.'.$functionName;
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 				break;
152 152
 		}
153 153
 
154
-		if(substr($className,0,4) != 'ajax' && substr($className,-4) != 'ajax' &&
155
-			$menuaction != 'etemplate.etemplate.process_exec' && substr($functionName,0,4) != 'ajax' ||
156
-			!preg_match('/^[A-Za-z0-9_\\\\-]+(\.[A-Za-z0-9_\\\\]+\.|::)[A-Za-z0-9_]+$/',$menuaction))
154
+		if (substr($className, 0, 4) != 'ajax' && substr($className, -4) != 'ajax' &&
155
+			$menuaction != 'etemplate.etemplate.process_exec' && substr($functionName, 0, 4) != 'ajax' ||
156
+			!preg_match('/^[A-Za-z0-9_\\\\-]+(\.[A-Za-z0-9_\\\\]+\.|::)[A-Za-z0-9_]+$/', $menuaction))
157 157
 		{
158 158
 			// stopped for security reasons
159 159
 			error_log("className='$className', functionName='$functionName', menuaction='$menuaction'");
160
-			error_log($_SERVER['PHP_SELF']. ' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
160
+			error_log($_SERVER['PHP_SELF'].' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
161 161
 			// send message also to the user
162
-			throw new Exception\InvalidName($_SERVER['PHP_SELF']. ' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
162
+			throw new Exception\InvalidName($_SERVER['PHP_SELF'].' stopped for security reason. '.$menuaction.' is not valid. class- or function-name must start with ajax!!!');
163 163
 		}
164 164
 
165 165
 		if (isset($template))
Please login to merge, or discard this patch.
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,7 +42,10 @@  discard block
 block discarded – undo
42 42
 	public static function isJSONRequest($set=null)
43 43
 	{
44 44
 		$ret = self::$_hadJSONRequest;
45
-		if (isset($set)) self::$_hadJSONRequest = $set;
45
+		if (isset($set))
46
+		{
47
+			self::$_hadJSONRequest = $set;
48
+		}
46 49
 		return $ret;
47 50
 	}
48 51
 
@@ -60,7 +63,10 @@  discard block
 block discarded – undo
60 63
 		// Remember that we currently are in a JSON request - e.g. used in the redirect code
61 64
 		self::$_hadJSONRequest = true;
62 65
 
63
-		if (get_magic_quotes_gpc()) $input_data = stripslashes($input_data);
66
+		if (get_magic_quotes_gpc())
67
+		{
68
+			$input_data = stripslashes($input_data);
69
+		}
64 70
 
65 71
 		$json_data = json_decode($input_data,true);
66 72
 		if (is_array($json_data) && isset($json_data['request']) && isset($json_data['request']['parameters']) && is_array($json_data['request']['parameters']))
@@ -100,9 +106,12 @@  discard block
 block discarded – undo
100 106
 	 */
101 107
 	public function handleRequest($menuaction, array $parameters)
102 108
 	{
103
-		if (strpos($menuaction,'::') !== false && strpos($menuaction,'.') === false)	// static method name app_something::method
109
+		if (strpos($menuaction,'::') !== false && strpos($menuaction,'.') === false)
110
+		{
111
+			// static method name app_something::method
104 112
 		{
105 113
 			@list($className,$functionName,$handler) = explode('::',$menuaction);
114
+		}
106 115
 			if (substr($className, 0, 11) == 'EGroupware\\')
107 116
 			{
108 117
 				list(,$appName) = explode('\\', strtolower($className));
@@ -179,6 +188,9 @@  discard block
 block discarded – undo
179 188
 			Api\Translation::convert($parameters, 'utf-8'));
180 189
 
181 190
 		// check if we have push notifications, if notifications app available
182
-		if (class_exists('notifications_push')) notifications_push::get();
191
+		if (class_exists('notifications_push'))
192
+		{
193
+			notifications_push::get();
194
+		}
183 195
 	}
184 196
 }
Please login to merge, or discard this patch.
api/src/Json/Tail.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @param string $filename =null if not starting with as slash relative to EGw files dir (this is strongly prefered for security reasons)
70 70
 	 */
71
-	public function __construct($filename=null)
71
+	public function __construct($filename = null)
72 72
 	{
73
-		$this->filenames =& Api\Cache::getSession('phpgwapi', __CLASS__);
73
+		$this->filenames = & Api\Cache::getSession('phpgwapi', __CLASS__);
74 74
 
75 75
 		if ($filename)
76 76
 		{
77 77
 			$this->filename = $filename;
78 78
 
79
-			if (!$this->filenames || !in_array($filename,$this->filenames)) $this->filenames[] = $filename;
79
+			if (!$this->filenames || !in_array($filename, $this->filenames)) $this->filenames[] = $filename;
80 80
 		}
81 81
 	}
82 82
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	 * @param int $start =0 last position in log-file
88 88
 	 * @throws Api\Exception\WrongParameter
89 89
 	 */
90
-	public function ajax_chunk($filename,$start=0)
90
+	public function ajax_chunk($filename, $start = 0)
91 91
 	{
92
-		if (!in_array($filename,$this->filenames))
92
+		if (!in_array($filename, $this->filenames))
93 93
 		{
94 94
 			throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!");
95 95
 		}
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 		if (file_exists($filename))
99 99
 		{
100 100
 			$size = filesize($filename);
101
-			if (!$start || $start < 0 || $start > $size || $size-$start > 4*self::MAX_CHUNK_SIZE)
101
+			if (!$start || $start < 0 || $start > $size || $size - $start > 4 * self::MAX_CHUNK_SIZE)
102 102
 			{
103
-				$start = $size - 4*self::MAX_CHUNK_SIZE;
103
+				$start = $size - 4 * self::MAX_CHUNK_SIZE;
104 104
 				if ($start < 0) $start = 0;
105 105
 			}
106 106
 			$hsize = Api\Vfs::hsize($size);
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	 * @param boolean $truncate =false true: truncate file, false: delete file
132 132
 	 * @throws Api\Exception\WrongParameter
133 133
 	 */
134
-	public function ajax_delete($filename,$truncate=false)
134
+	public function ajax_delete($filename, $truncate = false)
135 135
 	{
136
-		if (!in_array($filename,$this->filenames))
136
+		if (!in_array($filename, $this->filenames))
137 137
 		{
138 138
 			throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!");
139 139
 		}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @return string
156 156
 	 * @throws Api\Exception\WrongParameter
157 157
 	 */
158
-	public function show($header=null)
158
+	public function show($header = null)
159 159
 	{
160 160
 		if (!isset($this->filename))
161 161
 		{
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 <p style="float: left; margin: 5px"><b>'.htmlspecialchars($header).'</b></p>
168 168
 <div style="float: right; margin: 2px; margin-right: 5px">
169 169
 	'.Api\Html::form(
170
-		Api\Html::input('clear_log',lang('Clear window'),'button','id="clear_log"')."\n".
171
-		Api\Html::input('delete_log',lang('Delete file'),'button','id="purge_log"')."\n".
172
-		Api\Html::input('empty_log',lang('Empty file'),'button','id="empty_log"')."\n".
173
-		Api\Html::input('download_log',lang('Download'),'submit','id="download_log"'),
174
-		'','/index.php',array(
170
+		Api\Html::input('clear_log', lang('Clear window'), 'button', 'id="clear_log"')."\n".
171
+		Api\Html::input('delete_log', lang('Delete file'), 'button', 'id="purge_log"')."\n".
172
+		Api\Html::input('empty_log', lang('Empty file'), 'button', 'id="empty_log"')."\n".
173
+		Api\Html::input('download_log', lang('Download'), 'submit', 'id="download_log"'),
174
+		'', '/index.php', array(
175 175
 		'menuaction' => 'api.'.__CLASS__.'.download',
176 176
 		'filename' => $this->filename,
177 177
 	)).'
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 	public function download()
188 188
 	{
189 189
 		$filename = $_GET['filename'];
190
-		if (!in_array($filename,$this->filenames))
190
+		if (!in_array($filename, $this->filenames))
191 191
 		{
192 192
 			throw new Api\Exception\WrongParameter("Not allowed to download '$filename'!");
193 193
 		}
194 194
 		Api\Header\Content::type(basename($filename), 'text/plain');
195 195
 		if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
196
-		for($n=ob_get_level(); $n > 0; --$n)
196
+		for ($n = ob_get_level(); $n > 0; --$n)
197 197
 		{
198
-			ob_end_clean();	// stop all output buffering, to NOT run into memory_limit
198
+			ob_end_clean(); // stop all output buffering, to NOT run into memory_limit
199 199
 		}
200 200
 		readfile($filename);
201 201
 		exit;
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,7 +76,10 @@  discard block
 block discarded – undo
76 76
 		{
77 77
 			$this->filename = $filename;
78 78
 
79
-			if (!$this->filenames || !in_array($filename,$this->filenames)) $this->filenames[] = $filename;
79
+			if (!$this->filenames || !in_array($filename,$this->filenames))
80
+			{
81
+				$this->filenames[] = $filename;
82
+			}
80 83
 		}
81 84
 	}
82 85
 
@@ -93,7 +96,10 @@  discard block
 block discarded – undo
93 96
 		{
94 97
 			throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!");
95 98
 		}
96
-		if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
99
+		if ($filename[0] != '/')
100
+		{
101
+			$filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
102
+		}
97 103
 
98 104
 		if (file_exists($filename))
99 105
 		{
@@ -101,7 +107,10 @@  discard block
 block discarded – undo
101 107
 			if (!$start || $start < 0 || $start > $size || $size-$start > 4*self::MAX_CHUNK_SIZE)
102 108
 			{
103 109
 				$start = $size - 4*self::MAX_CHUNK_SIZE;
104
-				if ($start < 0) $start = 0;
110
+				if ($start < 0)
111
+				{
112
+					$start = 0;
113
+				}
105 114
 			}
106 115
 			$hsize = Api\Vfs::hsize($size);
107 116
 			$content = file_get_contents($filename, false, null, $start, self::MAX_CHUNK_SIZE);
@@ -137,7 +146,10 @@  discard block
 block discarded – undo
137 146
 		{
138 147
 			throw new Api\Exception\WrongParameter("Not allowed to view '$filename'!");
139 148
 		}
140
-		if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
149
+		if ($filename[0] != '/')
150
+		{
151
+			$filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
152
+		}
141 153
 		if ($truncate)
142 154
 		{
143 155
 			file_put_contents($filename, '');
@@ -161,7 +173,10 @@  discard block
 block discarded – undo
161 173
 		{
162 174
 			throw new Api\Exception\WrongParameter("Must be instanciated with filename!");
163 175
 		}
164
-		if (is_null($header)) $header = $this->filename;
176
+		if (is_null($header))
177
+		{
178
+			$header = $this->filename;
179
+		}
165 180
 
166 181
 		return '
167 182
 <p style="float: left; margin: 5px"><b>'.htmlspecialchars($header).'</b></p>
@@ -192,7 +207,10 @@  discard block
 block discarded – undo
192 207
 			throw new Api\Exception\WrongParameter("Not allowed to download '$filename'!");
193 208
 		}
194 209
 		Api\Header\Content::type(basename($filename), 'text/plain');
195
-		if ($filename[0] != '/') $filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
210
+		if ($filename[0] != '/')
211
+		{
212
+			$filename = $GLOBALS['egw_info']['server']['files_dir'].'/'.$filename;
213
+		}
196 214
 		for($n=ob_get_level(); $n > 0; --$n)
197 215
 		{
198 216
 			ob_end_clean();	// stop all output buffering, to NOT run into memory_limit
Please login to merge, or discard this patch.
api/src/CalDAV/IcalIterator.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -249,12 +249,12 @@
 block discarded – undo
249 249
 
250 250
 		$this->component = Horde_Icalendar::newComponent($type, $this);
251 251
 		//error_log(__METHOD__."() this->component = Horde_Icalendar::newComponent('$type', \$this) = ".array2string($this->component));
252
-        if ($this->component === false)
253
-        {
254
-        	error_log(__METHOD__."() Horde_Icalendar::newComponent('$type', \$this) returned FALSE");
255
-        	return;
256
-            //return PEAR::raiseError("Unable to create object for type $type");
257
-        }
252
+		if ($this->component === false)
253
+		{
254
+			error_log(__METHOD__."() Horde_Icalendar::newComponent('$type', \$this) returned FALSE");
255
+			return;
256
+			//return PEAR::raiseError("Unable to create object for type $type");
257
+		}
258 258
 		if ($this->charset && $this->charset != 'utf-8')
259 259
 		{
260 260
 			$data = Api\Translation::convert($data, $this->charset, 'utf-8');
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param array $callback_params =array() further parameters for the callback, 1. parameter is component
107 107
 	 * @param boolean $add_container =false true, add container / $this as last parameter to callback
108 108
 	 */
109
-	public function __construct($ical_file,$base='VCALENDAR',$charset=null,$callback=null,array $callback_params=array(), $add_container=false)
109
+	public function __construct($ical_file, $base = 'VCALENDAR', $charset = null, $callback = null, array $callback_params = array(), $add_container = false)
110 110
 	{
111 111
 		// call parent constructor
112 112
 		parent::__construct();
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		}
132 132
 		if (!is_resource($this->ical_file))
133 133
 		{
134
-			throw new Api\Exception\WrongParameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file),0,100));
134
+			throw new Api\Exception\WrongParameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file), 0, 100));
135 135
 		}
136 136
 	}
137 137
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		{
156 156
 			$line = array_shift($this->unread_lines);
157 157
 		}
158
-		elseif(feof($this->ical_file))
158
+		elseif (feof($this->ical_file))
159 159
 		{
160 160
 			$line = false;
161 161
 		}
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 			$line = fgets($this->ical_file);
165 165
 		}
166 166
 		// check if end of container reached
167
-		if ($this->container && $line && substr($line,0,4+strlen($this->base)) === 'END:'.$this->base)
167
+		if ($this->container && $line && substr($line, 0, 4 + strlen($this->base)) === 'END:'.$this->base)
168 168
 		{
169
-			$this->unread_line($line);	// put back end-of-container, to continue to return false
169
+			$this->unread_line($line); // put back end-of-container, to continue to return false
170 170
 			$line = false;
171 171
 		}
172 172
 		//error_log(__METHOD__."() returning ".($line === false ? 'FALSE' : "'$line'"));
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	protected function unread_line($line)
183 183
 	{
184 184
 		//error_log(__METHOD__."('$line')");
185
-		array_unshift($this->unread_lines,$line);
185
+		array_unshift($this->unread_lines, $line);
186 186
 	}
187 187
 
188 188
 	/**
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 		//error_log(__METHOD__."() returning a ".gettype($this->component));
196 196
 		if ($this->callback)
197 197
 		{
198
-			$ret = is_a($this->component,'Horde_Icalendar');
198
+			$ret = is_a($this->component, 'Horde_Icalendar');
199 199
 			do {
200 200
 				if ($ret === false) $this->next();
201
-				if (!is_a($this->component,'Horde_Icalendar')) return false;
201
+				if (!is_a($this->component, 'Horde_Icalendar')) return false;
202 202
 				$params = $this->callback_params;
203
-				array_unshift($params,$this->component);
203
+				array_unshift($params, $this->component);
204 204
 			}
205
-			while(($ret = call_user_func_array($this->callback,$params)) === false);
205
+			while (($ret = call_user_func_array($this->callback, $params)) === false);
206 206
 
207 207
 			return $ret;
208 208
 		}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	{
228 228
 		unset($this->component);
229 229
 
230
-		while (($line = $this->read_line()) && substr($line,0,6) !== 'BEGIN:')
230
+		while (($line = $this->read_line()) && substr($line, 0, 6) !== 'BEGIN:')
231 231
 		{
232 232
 			// ignore it
233 233
 		}
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 			$this->component = false;
237 237
 			return;
238 238
 		}
239
-		$type = substr(trim($line),6);
239
+		$type = substr(trim($line), 6);
240 240
 
241 241
 		//error_log(__METHOD__."() found $type component");
242 242
 
243 243
 		$data = $line;
244
-		while (($line = $this->read_line()) && substr($line,0,4+strlen($type)) !== 'END:'.$type)
244
+		while (($line = $this->read_line()) && substr($line, 0, 4 + strlen($type)) !== 'END:'.$type)
245 245
 		{
246 246
 			$data .= $line;
247 247
 		}
@@ -276,23 +276,23 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function rewind()
278 278
 	{
279
-		@fseek($this->ical_file,0,SEEK_SET);
279
+		@fseek($this->ical_file, 0, SEEK_SET);
280 280
 
281 281
 		// advance to begin of container
282
-		while(($line = $this->read_line()) && substr($line,0,6+strlen($this->base)) !== 'BEGIN:'.$this->base)
282
+		while (($line = $this->read_line()) && substr($line, 0, 6 + strlen($this->base)) !== 'BEGIN:'.$this->base)
283 283
 		{
284 284
 
285 285
 		}
286 286
 		// if no container start found --> use whole file (rewind) and set container marker
287 287
 		if (!($this->container = $line !== false))
288 288
 		{
289
-			fseek($this->ical_file,0,SEEK_SET);
289
+			fseek($this->ical_file, 0, SEEK_SET);
290 290
 		}
291 291
 		//error_log(__METHOD__."() $this->base container ".($this->container ? 'found' : 'NOT found'));
292 292
 
293 293
 		$data = $line;
294 294
 		// advance to first component
295
-		while (($line = $this->read_line()) && substr($line,0,6) !== 'BEGIN:')
295
+		while (($line = $this->read_line()) && substr($line, 0, 6) !== 'BEGIN:')
296 296
 		{
297 297
 			$matches = null;
298 298
 			if (preg_match('/^VERSION:(\d\.\d)\s*$/ism', $line, $matches))
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		{
308 308
 			$data .= "END:$this->base\n";
309 309
 			//error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')");
310
-			$this->parsevCalendar($data,$this->base,$this->charset);
310
+			$this->parsevCalendar($data, $this->base, $this->charset);
311 311
 		}
312 312
 		if ($line) $this->unread_line($line);
313 313
 
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 * @return boolean
322 322
 	 */
323
-	public function valid ()
323
+	public function valid()
324 324
 	{
325 325
 		//error_log(__METHOD__."() returning ".(is_a($this->component,'Horde_Icalendar') ? 'TRUE' : 'FALSE').' get_class($this->component)='.get_class($this->component));
326
-		return is_a($this->component,'Horde_Icalendar');
326
+		return is_a($this->component, 'Horde_Icalendar');
327 327
 	}
328 328
 }
329 329
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n";
442 442
 	//$calendar_ical = new calendar_ical();
443 443
 	//$calendar_ical->setSupportedFields('file');
444
-	$ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin'));
445
-	foreach($ical_it as $uid => $vevent)
444
+	$ical_it = new IcalIterator($ical_file); //,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin'));
445
+	foreach ($ical_it as $uid => $vevent)
446 446
 	{
447 447
 		echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n";
448 448
 	}
Please login to merge, or discard this patch.
Braces   +29 added lines, -8 removed lines patch added patch discarded remove patch
@@ -116,7 +116,10 @@  discard block
 block discarded – undo
116 116
 		if (is_callable($callback))
117 117
 		{
118 118
 			$this->callback = $callback;
119
-			if ($add_container) $callback_params[] = $this;
119
+			if ($add_container)
120
+			{
121
+				$callback_params[] = $this;
122
+			}
120 123
 			$this->callback_params = $callback_params;
121 124
 		}
122 125
 		if (is_string($ical_file))
@@ -197,8 +200,14 @@  discard block
 block discarded – undo
197 200
 		{
198 201
 			$ret = is_a($this->component,'Horde_Icalendar');
199 202
 			do {
200
-				if ($ret === false) $this->next();
201
-				if (!is_a($this->component,'Horde_Icalendar')) return false;
203
+				if ($ret === false)
204
+				{
205
+					$this->next();
206
+				}
207
+				if (!is_a($this->component,'Horde_Icalendar'))
208
+				{
209
+					return false;
210
+				}
202 211
 				$params = $this->callback_params;
203 212
 				array_unshift($params,$this->component);
204 213
 			}
@@ -231,9 +240,12 @@  discard block
 block discarded – undo
231 240
 		{
232 241
 			// ignore it
233 242
 		}
234
-		if ($line === false)	// end-of-file or end-of-container
243
+		if ($line === false)
244
+		{
245
+			// end-of-file or end-of-container
235 246
 		{
236 247
 			$this->component = false;
248
+		}
237 249
 			return;
238 250
 		}
239 251
 		$type = substr(trim($line),6);
@@ -309,7 +321,10 @@  discard block
 block discarded – undo
309 321
 			//error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')");
310 322
 			$this->parsevCalendar($data,$this->base,$this->charset);
311 323
 		}
312
-		if ($line) $this->unread_line($line);
324
+		if ($line)
325
+		{
326
+			$this->unread_line($line);
327
+		}
313 328
 
314 329
 		// advance to first element
315 330
 		$this->next();
@@ -438,7 +453,10 @@  discard block
 block discarded – undo
438 453
 ';
439 454
 	echo $GLOBALS['egw']->framework->header();
440 455
 	//$ical_file = fopen('/tmp/KalenderFelicitasKubala.ics');
441
-	if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n";
456
+	if (!is_resource($ical_file))
457
+	{
458
+		echo "<pre>$ical_file</pre>\n";
459
+	}
442 460
 	//$calendar_ical = new calendar_ical();
443 461
 	//$calendar_ical->setSupportedFields('file');
444 462
 	$ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin'));
@@ -446,5 +464,8 @@  discard block
 block discarded – undo
446 464
 	{
447 465
 		echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n";
448 466
 	}
449
-	if (is_resource($ical_file)) fclose($ical_file);
450
-}
451 467
\ No newline at end of file
468
+	if (is_resource($ical_file))
469
+	{
470
+		fclose($ical_file);
471
+	}
472
+	}
452 473
\ No newline at end of file
Please login to merge, or discard this patch.
api/src/CalDAV/Hooks.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
 		if ($location == 'preferences')
38 38
 		{
39 39
 			$file = array(
40
-				'Preferences'     => Api\Framework::link('/index.php','menuaction=preferences.preference_settings.index&appname='.$appname),
40
+				'Preferences'     => Api\Framework::link('/index.php', 'menuaction=preferences.preference_settings.index&appname='.$appname),
41 41
 			);
42 42
 			if ($location == 'preferences')
43 43
 			{
44
-				display_section($appname,$file);
44
+				display_section($appname, $file);
45 45
 			}
46 46
 			else
47 47
 			{
48
-				display_sidebox($appname,lang('Preferences'),$file);
48
+				display_sidebox($appname, lang('Preferences'), $file);
49 49
 			}
50 50
 		}
51 51
 	}
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
 		if ($hook_data['setup'])
64 64
 		{
65
-			$apps = array('addressbook','calendar','infolog');
65
+			$apps = array('addressbook', 'calendar', 'infolog');
66 66
 		}
67 67
 		else
68 68
 		{
69 69
 			$apps = array_keys($GLOBALS['egw_info']['user']['apps']);
70 70
 		}
71
-		foreach($apps as $app)
71
+		foreach ($apps as $app)
72 72
 		{
73 73
 			$class_name = $app.'_groupdav';
74 74
 			if (class_exists($class_name, true))
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 					'type'  => 'section',
78 78
 					'title' => $app,
79 79
 				);
80
-				$settings += call_user_func(array($class_name,'get_settings'), $hook_data);
80
+				$settings += call_user_func(array($class_name, 'get_settings'), $hook_data);
81 81
 			}
82 82
 		}
83 83
 
@@ -105,20 +105,20 @@  discard block
 block discarded – undo
105 105
 			if ($GLOBALS['type'] === 'user')
106 106
 			{
107 107
 				$logs = array();
108
-				if (file_exists($log_dir=$GLOBALS['egw_info']['server']['files_dir'].'/groupdav') && ($files = scandir($log_dir)))
108
+				if (file_exists($log_dir = $GLOBALS['egw_info']['server']['files_dir'].'/groupdav') && ($files = scandir($log_dir)))
109 109
 				{
110 110
 					$account_lid_len = strlen($GLOBALS['egw_info']['user']['account_lid']);
111
-					foreach($files as $log)
111
+					foreach ($files as $log)
112 112
 					{
113
-						if (substr($log,0,$account_lid_len+1) == $GLOBALS['egw_info']['user']['account_lid'].'-' &&
114
-							substr($log,-4) == '.log')
113
+						if (substr($log, 0, $account_lid_len + 1) == $GLOBALS['egw_info']['user']['account_lid'].'-' &&
114
+							substr($log, -4) == '.log')
115 115
 						{
116 116
 							$logs['groupdav/'.$log] = Api\DateTime::to(filemtime($log_dir.'/'.$log)).': '.
117
-								str_replace('!','/',substr($log,$account_lid_len+1,-4));
117
+								str_replace('!', '/', substr($log, $account_lid_len + 1, -4));
118 118
 						}
119 119
 					}
120 120
 				}
121
-				$link = Api\Framework::link('/index.php',array(
121
+				$link = Api\Framework::link('/index.php', array(
122 122
 					'menuaction' => 'api.'.__CLASS__.'.log',
123 123
 					'filename' => '',
124 124
 				));
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	public static function log()
154 154
 	{
155 155
 		$filename = $_GET['filename'];
156
-		if (!preg_match('|^groupdav/'.preg_quote($GLOBALS['egw_info']['user']['account_lid'],'|').'-[^/]+\.log$|',$filename))
156
+		if (!preg_match('|^groupdav/'.preg_quote($GLOBALS['egw_info']['user']['account_lid'], '|').'-[^/]+\.log$|', $filename))
157 157
 		{
158 158
 			throw new Api\Exception\WrongParameter("Access denied to file '$filename'!");
159 159
 		}
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 body { background-color: #e0e0e0; overflow: hidden; }
162 162
 pre.tail { background-color: white; padding-left: 5px; margin-left: 5px; }
163 163
 ';
164
-		$header = str_replace('!','/',substr($filename,10+strlen($GLOBALS['egw_info']['user']['account_lid']),-4));
164
+		$header = str_replace('!', '/', substr($filename, 10 + strlen($GLOBALS['egw_info']['user']['account_lid']), -4));
165 165
 		$tail = new Api\Json\Tail($filename);
166
-		$GLOBALS['egw']->framework->render($tail->show($header),false,false);
166
+		$GLOBALS['egw']->framework->render($tail->show($header), false, false);
167 167
 	}
168 168
 }
169 169
\ No newline at end of file
Please login to merge, or discard this patch.
api/src/loader/common.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	{
30 30
 		return stripslashes($var);
31 31
 	}
32
-	foreach($var as $key => $val)
32
+	foreach ($var as $key => $val)
33 33
 	{
34 34
 		$var[$key] = is_array($val) ? array_stripslashes($val) : stripslashes($val);
35 35
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 	if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
51 51
 
52
-	return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
52
+	return $func_overload&2 ? mb_strlen($str, 'ascii') : strlen($str);
53 53
 }
54 54
 
55 55
 /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @param int $len
61 61
  * @return string
62 62
  */
63
-function cut_bytes(&$data,$offset,$len=null)
63
+function cut_bytes(&$data, $offset, $len = null)
64 64
 {
65 65
 	static $func_overload = null;
66 66
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 
69 69
 	if (is_null($len))
70 70
 	{
71
-		return $func_overload & 2 ? mb_substr($data,$offset,bytes($data),'ascii') : substr($data,$offset);
71
+		return $func_overload&2 ? mb_substr($data, $offset, bytes($data), 'ascii') : substr($data, $offset);
72 72
 	}
73
-	return $func_overload & 2 ? mb_substr($data,$offset,$len,'ascii') : substr($data,$offset,$len);
73
+	return $func_overload&2 ? mb_substr($data, $offset, $len, 'ascii') : substr($data, $offset, $len);
74 74
 }
75 75
 
76 76
 if (!function_exists('imap_rfc822_parse_adrlist'))
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 	{
103 103
 		$addresses = array();
104 104
 		$pending = '';
105
-		foreach(explode(',', $address) as $part)
105
+		foreach (explode(',', $address) as $part)
106 106
 		{
107 107
 			$trimmed = trim(($pending ? $pending.',' : '').$part);
108
-			if (($trimmed[0] == '"' && substr($trimmed, -1) != '>')||strpos($part, '@')===false)
108
+			if (($trimmed[0] == '"' && substr($trimmed, -1) != '>') || strpos($part, '@') === false)
109 109
 			{
110 110
 				$pending .= ($pending ? $pending.',' : '').$part;
111 111
 				continue;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		//if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal))	// that's how I read the rfc(2)822
159 159
 		if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal))	// but quoting is never wrong, so quote more then necessary
160 160
 		{
161
-			$personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"';
161
+			$personal = '"'.str_replace(array('\\', '"'), array('\\\\', '\\"'), $personal).'"';
162 162
 		}
163 163
 		return ($personal ? $personal.' <' : '').$mailbox.($host ? '@'.$host : '').($personal ? '>' : '');
164 164
 	}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	{
180 180
 		return array((object)array(
181 181
 			'text' => Horde_Mime::decode($text),
182
-			'charset' => Api\Translation::charset(),	// is already in our internal encoding!
182
+			'charset' => Api\Translation::charset(), // is already in our internal encoding!
183 183
 		));
184 184
 	}
185 185
 }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param int $len
209 209
 	 * @return string
210 210
 	 */
211
-	function mb_substr(&$data, $offset, $len=null)
211
+	function mb_substr(&$data, $offset, $len = null)
212 212
 	{
213 213
 		return is_null($len) ? substr($data, $offset) : substr($data, $offset, $len);
214 214
 	}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 			return 'NULL';
237 237
 		case 'object':
238 238
 		case 'array':
239
-			return str_replace(array("\n",'    '/*,'Array'*/),'',print_r($var,true));
239
+			return str_replace(array("\n", '    '/*,'Array'*/), '', print_r($var, true));
240 240
 	}
241 241
 	return 'UNKNOWN TYPE!';
242 242
 }
@@ -248,18 +248,18 @@  discard block
 block discarded – undo
248 248
  * @param boolean $throw =false should we throw an exception, if $extension could not be loaded, default false = no
249 249
  * @return boolean true if loaded now, false otherwise
250 250
  */
251
-function check_load_extension($extension,$throw=false)
251
+function check_load_extension($extension, $throw = false)
252 252
 {
253 253
 	if (!defined('PHP_SHLIB_PREFIX'))
254 254
 	{
255
-		define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : '');
255
+		define('PHP_SHLIB_PREFIX', PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : '');
256 256
 	}
257 257
 	// we check for the existens of 'dl', as multithreaded webservers dont have it and some hosters disable it !!!
258
-	$loaded = extension_loaded($extension) || function_exists('dl') && @dl($dl=PHP_SHLIB_PREFIX.$extension.'.'.PHP_SHLIB_SUFFIX);
258
+	$loaded = extension_loaded($extension) || function_exists('dl') && @dl($dl = PHP_SHLIB_PREFIX.$extension.'.'.PHP_SHLIB_SUFFIX);
259 259
 
260 260
 	if (!$loaded && $throw)
261 261
 	{
262
-		throw new Exception ("PHP extension '$extension' not loaded AND can NOT be loaded via dl('$dl')!");
262
+		throw new Exception("PHP extension '$extension' not loaded AND can NOT be loaded via dl('$dl')!");
263 263
 	}
264 264
 	return $loaded;
265 265
 }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
  * @param int/string $default_id either a name or an id
284 284
  * @return int account_id
285 285
  */
286
-function get_account_id($account_id = '',$default_id = '')
286
+function get_account_id($account_id = '', $default_id = '')
287 287
 {
288 288
 	if (gettype($account_id) == 'integer')
289 289
 	{
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	{
294 294
 		if ($default_id == '')
295 295
 		{
296
-			return (isset($GLOBALS['egw_info']['user']['account_id'])?$GLOBALS['egw_info']['user']['account_id']:0);
296
+			return (isset($GLOBALS['egw_info']['user']['account_id']) ? $GLOBALS['egw_info']['user']['account_id'] : 0);
297 297
 		}
298 298
 		elseif (is_string($default_id))
299 299
 		{
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	}
304 304
 	elseif (is_string($account_id))
305 305
 	{
306
-		if($GLOBALS['egw']->accounts->exists((int)$account_id) == True)
306
+		if ($GLOBALS['egw']->accounts->exists((int)$account_id) == True)
307 307
 		{
308 308
 			return (int)$account_id;
309 309
 		}
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
  * @param boolean $print =true print or return the content
322 322
  * @return string if !$print
323 323
  */
324
-function _debug_array($array,$print=True)
324
+function _debug_array($array, $print = True)
325 325
 {
326
-	$output = '<pre>'.print_r($array,true)."</pre>\n";
326
+	$output = '<pre>'.print_r($array, true)."</pre>\n";
327 327
 
328 328
 	if ($print)
329 329
 	{
@@ -342,28 +342,28 @@  discard block
 block discarded – undo
342 342
  * @param int $remove =0 number of levels to remove
343 343
  * @return string function-names separated by slashes (beginning with the calling function not this one)
344 344
  */
345
-function function_backtrace($remove=0)
345
+function function_backtrace($remove = 0)
346 346
 {
347 347
 	if (function_exists('debug_backtrace'))
348 348
 	{
349 349
 		$backtrace = debug_backtrace();
350 350
 		//echo "function_backtrace($remove)<pre>".print_r($backtrace,True)."</pre>\n";
351
-		foreach($backtrace as $n => $level)
351
+		foreach ($backtrace as $n => $level)
352 352
 		{
353 353
 			if ($remove-- < 0)
354 354
 			{
355
-				$ret[] = (isset($level['class'])?$level['class'].$level['type']:'').$level['function'].
356
-					($n > 0 && isset($backtrace[$n-1]['line']) ? ':'.$backtrace[$n-1]['line'] : '').	// add line number of call
355
+				$ret[] = (isset($level['class']) ? $level['class'].$level['type'] : '').$level['function'].
356
+					($n > 0 && isset($backtrace[$n - 1]['line']) ? ':'.$backtrace[$n - 1]['line'] : '').// add line number of call
357 357
 					(!$level['class'] && !is_object($level['args'][0]) && $level['function'] != 'unserialize' ?
358
-					'('.substr(str_replace(EGW_SERVER_ROOT,'',(string)$level['args'][0]),0,64).')' : '');
358
+					'('.substr(str_replace(EGW_SERVER_ROOT, '', (string)$level['args'][0]), 0, 64).')' : '');
359 359
 			}
360 360
 		}
361 361
 		if (is_array($ret))
362 362
 		{
363
-			return implode(' / ',$ret);
363
+			return implode(' / ', $ret);
364 364
 		}
365 365
 	}
366
-	return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']);
366
+	return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT, '', $_SERVER['SCRIPT_FILENAME']);
367 367
 }
368 368
 
369 369
 if (!function_exists('lang') || defined('NO_LANG'))	// setup declares an own version
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	 * @param string $vars =null multiple values to replace the placeholders
376 376
 	 * @return string translated message with placeholders replaced
377 377
 	 */
378
-	function lang($key,$vars=null)
378
+	function lang($key, $vars = null)
379 379
 	{
380
-		if(!is_array($vars))
380
+		if (!is_array($vars))
381 381
 		{
382 382
 			$vars = func_get_args();
383
-			array_shift($vars);	// remove $key
383
+			array_shift($vars); // remove $key
384 384
 		}
385
-		return Api\Translation::translate($key,$vars);
385
+		return Api\Translation::translate($key, $vars);
386 386
 	}
387 387
 }
388 388
 
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 	 *
413 413
 	 * @deprecated use $GLOBALS['egw']->framework->sidebox()
414 414
 	 */
415
-	function display_sidebox($appname,$menu_title,$_file)
415
+	function display_sidebox($appname, $menu_title, $_file)
416 416
 	{
417 417
 		$file = str_replace('preferences.uisettings.index', 'preferences.preferences_settings.index', $_file);
418
-		$GLOBALS['egw']->framework->sidebox($appname,$menu_title,$file);
418
+		$GLOBALS['egw']->framework->sidebox($appname, $menu_title, $file);
419 419
 	}
420 420
 }
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,10 @@  discard block
 block discarded – undo
47 47
 {
48 48
 	static $func_overload = null;
49 49
 
50
-	if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
50
+	if (is_null($func_overload))
51
+	{
52
+		$func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
53
+	}
51 54
 
52 55
 	return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str);
53 56
 }
@@ -64,7 +67,10 @@  discard block
 block discarded – undo
64 67
 {
65 68
 	static $func_overload = null;
66 69
 
67
-	if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
70
+	if (is_null($func_overload))
71
+	{
72
+		$func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0;
73
+	}
68 74
 
69 75
 	if (is_null($len))
70 76
 	{
@@ -130,7 +136,10 @@  discard block
 block discarded – undo
130 136
 			{
131 137
 				$personal = str_replace('\\', '', substr($personal, 1, -1));
132 138
 			}
133
-			if (empty($host)) $host = $default_host;
139
+			if (empty($host))
140
+			{
141
+				$host = $default_host;
142
+			}
134 143
 
135 144
 			$addresses[] = (object)array_diff(array(
136 145
 				'mailbox'  => $mailbox,
@@ -153,13 +162,19 @@  discard block
 block discarded – undo
153 162
 	 */
154 163
 	function imap_rfc822_write_address($mailbox, $host, $personal)
155 164
 	{
156
-		if (is_array($personal))  $personal = implode(' ', $personal);
165
+		if (is_array($personal))
166
+		{
167
+			$personal = implode(' ', $personal);
168
+		}
157 169
 
158 170
 		//if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal))	// that's how I read the rfc(2)822
159
-		if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal))	// but quoting is never wrong, so quote more then necessary
171
+		if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal))
172
+		{
173
+			// but quoting is never wrong, so quote more then necessary
160 174
 		{
161 175
 			$personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"';
162 176
 		}
177
+		}
163 178
 		return ($personal ? $personal.' <' : '').$mailbox.($host ? '@'.$host : '').($personal ? '>' : '');
164 179
 	}
165 180
 }
@@ -366,7 +381,9 @@  discard block
 block discarded – undo
366 381
 	return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']);
367 382
 }
368 383
 
369
-if (!function_exists('lang') || defined('NO_LANG'))	// setup declares an own version
384
+if (!function_exists('lang') || defined('NO_LANG'))
385
+{
386
+	// setup declares an own version
370 387
 {
371 388
 	/**
372 389
 	 * function to handle multilanguage support
@@ -380,6 +397,7 @@  discard block
 block discarded – undo
380 397
 		if(!is_array($vars))
381 398
 		{
382 399
 			$vars = func_get_args();
400
+}
383 401
 			array_shift($vars);	// remove $key
384 402
 		}
385 403
 		return Api\Translation::translate($key,$vars);
Please login to merge, or discard this patch.
api/src/loader/deprecated_factory.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  */
28 28
 function CreateObject($class)
29 29
 {
30
-	list($appname,$classname) = explode('.',$class);
30
+	list($appname, $classname) = explode('.', $class);
31 31
 
32 32
 	if (!class_exists($classname))
33 33
 	{
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 				$classname = $replace[$classname];
54 54
 			}
55 55
 		}
56
-		if (!file_exists($f=EGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php'))
56
+		if (!file_exists($f = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php'))
57 57
 		{
58 58
 			throw new Api\Exception\AssertionFailed(__FUNCTION__."($classname) file $f not found!");
59 59
 		}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		require_once(EGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php');
62 62
 	}
63 63
 	$args = func_get_args();
64
-	switch(count($args))
64
+	switch (count($args))
65 65
 	{
66 66
 		case 1:
67 67
 			$obj = new $classname;
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
 			$obj = new $classname($args[1]);
71 71
 			break;
72 72
 		case 3:
73
-			$obj = new $classname($args[1],$args[2]);
73
+			$obj = new $classname($args[1], $args[2]);
74 74
 			break;
75 75
 		case 4:
76
-			$obj = new $classname($args[1],$args[2],$args[3]);
76
+			$obj = new $classname($args[1], $args[2], $args[3]);
77 77
 			break;
78 78
 		default:
79
-			$code = '$obj = new ' . $classname . '(';
80
-			foreach(array_keys($args) as $n)
79
+			$code = '$obj = new '.$classname.'(';
80
+			foreach (array_keys($args) as $n)
81 81
 			{
82 82
 				if ($n)
83 83
 				{
84
-					$code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
84
+					$code .= ($n > 1 ? ',' : '').'$args['.$n.']';
85 85
 				}
86 86
 			}
87 87
 			$code .= ');';
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 function &ExecMethod2($acm)
108 108
 {
109 109
 	// class::method is php5.2.3+
110
-	if (strpos($acm,'::') !== false && version_compare(PHP_VERSION,'5.2.3','<'))
110
+	if (strpos($acm, '::') !== false && version_compare(PHP_VERSION, '5.2.3', '<'))
111 111
 	{
112
-		list($class,$method) = explode('::',$acm);
113
-		$acm = array($class,$method);
112
+		list($class, $method) = explode('::', $acm);
113
+		$acm = array($class, $method);
114 114
 	}
115 115
 	if (!is_callable($acm))
116 116
 	{
117
-		list(,$class,$method) = explode('.',$acm);
118
-		if (!is_object($obj =& $GLOBALS[$class]))
117
+		list(,$class, $method) = explode('.', $acm);
118
+		if (!is_object($obj = & $GLOBALS[$class]))
119 119
 		{
120 120
 			if (class_exists($class))
121 121
 			{
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 		}
129 129
 
130
-		if (!method_exists($obj,$method))
130
+		if (!method_exists($obj, $method))
131 131
 		{
132 132
 			echo "<p><b>".function_backtrace()."</b>: no methode '$method' in class '$class'</p>\n";
133 133
 			return False;
134 134
 		}
135
-		$acm = array($obj,$method);
135
+		$acm = array($obj, $method);
136 136
 	}
137 137
 	$args = func_get_args();
138 138
 	unset($args[0]);
139 139
 
140
-	return call_user_func_array($acm,$args);
140
+	return call_user_func_array($acm, $args);
141 141
 }
142 142
 
143 143
 /**
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
  */
156 156
 function ExecMethod($method, $functionparam = '_UNDEF_', $loglevel = 3, $classparams = '_UNDEF_')
157 157
 {
158
-	unset($loglevel);	// not used
158
+	unset($loglevel); // not used
159 159
 	/* Need to make sure this is working against a single dimensional object */
160
-	$partscount = count(explode('.',$method)) - 1;
160
+	$partscount = count(explode('.', $method)) - 1;
161 161
 
162 162
 	if (!is_callable($method) && $partscount == 2)
163 163
 	{
164
-		list($appname,$classname,$functionname) = explode(".", $method);
164
+		list($appname, $classname, $functionname) = explode(".", $method);
165 165
 		if (!is_object($GLOBALS[$classname]))
166 166
 		{
167 167
 			// please note: no reference assignment (=&) here, as $GLOBALS is a reference itself!!!
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
 			}
180 180
 		}
181 181
 
182
-		if (!method_exists($GLOBALS[$classname],$functionname))
182
+		if (!method_exists($GLOBALS[$classname], $functionname))
183 183
 		{
184 184
 			error_log("ExecMethod('$method', ...) No methode '$functionname' in class '$classname'! ".function_backtrace());
185 185
 			return false;
186 186
 		}
187
-		$method = array($GLOBALS[$classname],$functionname);
187
+		$method = array($GLOBALS[$classname], $functionname);
188 188
 	}
189 189
 	if (is_callable($method))
190 190
 	{
191
-		return $functionparam != '_UNDEF_' ? call_user_func($method,$functionparam) : call_user_func($method);
191
+		return $functionparam != '_UNDEF_' ? call_user_func($method, $functionparam) : call_user_func($method);
192 192
 	}
193 193
 	error_log("ExecMethod('$method', ...) Error in parts! ".function_backtrace());
194 194
 	return false;
Please login to merge, or discard this patch.
api/src/loader/exception.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
  * @param string $vars =null multiple values to replace the placeholders
24 24
  * @return string translated message with placeholders replaced
25 25
  */
26
-function try_lang($key,$vars=null)
26
+function try_lang($key, $vars = null)
27 27
 {
28
-	static $varnames = array('%1','%2','%3','%4');
28
+	static $varnames = array('%1', '%2', '%3', '%4');
29 29
 
30
-	if(!is_array($vars))
30
+	if (!is_array($vars))
31 31
 	{
32 32
 		$vars = func_get_args();
33
-		array_shift($vars);	// remove $key
33
+		array_shift($vars); // remove $key
34 34
 	}
35
-	return class_exists('EGroupware\Api\Translations',false) ? Api\Translation::translate($key,$vars) : str_replace($varnames,$vars,$key);
35
+	return class_exists('EGroupware\Api\Translations', false) ? Api\Translation::translate($key, $vars) : str_replace($varnames, $vars, $key);
36 36
 }
37 37
 
38 38
 /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  * @param Exception|Error $e
42 42
  * @param string &$headline
43 43
  */
44
-function _egw_log_exception($e,&$headline=null)
44
+function _egw_log_exception($e, &$headline = null)
45 45
 {
46 46
 	$trace = explode("\n", $e->getTraceAsString());
47 47
 	if ($e instanceof Api\Exception\NoPermission)
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 	elseif ($e instanceof Api\Exception\WrongUserinput)
56 56
 	{
57
-		$headline = '';	// message contains the whole message, it's usually no real error but some input validation
57
+		$headline = ''; // message contains the whole message, it's usually no real error but some input validation
58 58
 	}
59 59
 	elseif ($e instanceof egw_exception_warning)
60 60
 	{
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 	// log exception to error log, if not running as cli,
69 69
 	// which outputs the error_log to stderr and therefore output it twice to the user
70
-	if(isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] !== 'cli')
70
+	if (isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] !== 'cli')
71 71
 	{
72 72
 		error_log($headline.($e instanceof egw_exception_warning ? ': ' : ' ('.get_class($e).'): ').$e->getMessage());
73
-		foreach($trace as $line)
73
+		foreach ($trace as $line)
74 74
 		{
75 75
 			error_log($line);
76 76
 		}
77 77
 		error_log('# Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid'].
78
-			', Request='.$_SERVER['REQUEST_METHOD'].' '.($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].
78
+			', Request='.$_SERVER['REQUEST_METHOD'].' '.($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].
79 79
 			', User-agent='.$_SERVER['HTTP_USER_AGENT']);
80 80
 	}
81 81
 }
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 	// logging all exceptions to the error_log (if not cli) and get headline
98 98
 	$headline = null;
99
-	_egw_log_exception($e,$headline);
99
+	_egw_log_exception($e, $headline);
100 100
 
101 101
 	// exception handler for cli (command line interface) clients, no html, no logging
102
-	if(!isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] == 'cli')
102
+	if (!isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] == 'cli')
103 103
 	{
104 104
 		echo ($headline ? $headline.': ' : '').$e->getMessage()."\n";
105 105
 		if ($GLOBALS['egw_info']['server']['exception_show_trace'])
106 106
 		{
107 107
 			echo $e->getTraceAsString()."\n";
108 108
 		}
109
-		exit($e->getCode() ? $e->getCode() : 9999);		// allways give a non-zero exit code
109
+		exit($e->getCode() ? $e->getCode() : 9999); // allways give a non-zero exit code
110 110
 	}
111 111
 	// regular GUI exception
112 112
 	if (!isset($GLOBALS['egw_info']['flags']['no_exception_handler']))
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
 		$message .= "</pre>\n";
124 124
 		if (is_a($e, 'EGroupware\Api\Db\Exception\Setup'))
125 125
 		{
126
-			$setup_dir = str_replace(array('home/index.php','index.php'),'setup/',$_SERVER['PHP_SELF']);
126
+			$setup_dir = str_replace(array('home/index.php', 'index.php'), 'setup/', $_SERVER['PHP_SELF']);
127 127
 			$message .= '<a href="'.$setup_dir.'">Run setup to install or configure EGroupware.</a>';
128 128
 		}
129
-		elseif (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->session) && method_exists($GLOBALS['egw'],'link'))
129
+		elseif (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->session) && method_exists($GLOBALS['egw'], 'link'))
130 130
 		{
131 131
 			$message .= '<p><a href="'.$GLOBALS['egw']->link('/index.php').'">'.try_lang('Click here to resume your eGroupWare Session.').'</a></p>';
132 132
 		}
133 133
 		if (is_object($GLOBALS['egw']) && isset($GLOBALS['egw']->framework))
134 134
 		{
135
-			$GLOBALS['egw']->framework->render($message,$headline);
135
+			$GLOBALS['egw']->framework->render($message, $headline);
136 136
 		}
137 137
 		else
138 138
 		{
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 	}
142 142
 	// exception handler sending message back to the client as basic auth message
143
-	elseif($GLOBALS['egw_info']['flags']['no_exception_handler'] == 'basic_auth')
143
+	elseif ($GLOBALS['egw_info']['flags']['no_exception_handler'] == 'basic_auth')
144 144
 	{
145 145
 		$error = str_replace(array("\r", "\n"), array('', ' | '), $e->getMessage());
146 146
 		header('WWW-Authenticate: Basic realm="'.$headline.' '.$error.'"');
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
  * @link http://www.php.net/manual/en/function.set-error-handler.php
166 166
  * @throws ErrorException
167 167
  */
168
-function egw_error_handler ($errno, $errstr, $errfile, $errline)
168
+function egw_error_handler($errno, $errstr, $errfile, $errline)
169 169
 {
170 170
 	switch ($errno)
171 171
 	{
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -188,7 +188,9 @@
 block discarded – undo
188 188
 /**
189 189
  * Used internally to trace warnings
190 190
  */
191
-class egw_exception_warning extends Exception {}
191
+class egw_exception_warning extends Exception
192
+{
193
+}
192 194
 
193 195
 // install our error-handler only for catchable fatal errors and warnings
194 196
 // following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING
Please login to merge, or discard this patch.
api/src/loader/security.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
  * @param array &$var reference of array to check
21 21
  * @param string $name ='' name of the array
22 22
  */
23
-function _check_script_tag(&$var,$name='')
23
+function _check_script_tag(&$var, $name = '')
24 24
 {
25
-	static $preg=null;
25
+	static $preg = null;
26 26
 	//old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i';
27 27
 	if (!isset($preg)) $preg =
28 28
 		// forbidden tags like iframe or script
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 		'<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i';
36 36
 	if (is_array($var))
37 37
 	{
38
-		foreach($var as $key => $val)
38
+		foreach ($var as $key => $val)
39 39
 		{
40 40
 			if (is_array($val))
41 41
 			{
42
-				_check_script_tag($var[$key],$name.'['.$key.']');
42
+				_check_script_tag($var[$key], $name.'['.$key.']');
43 43
 			}
44
-			elseif(strpos($val, '<') !== false)	// speedup: ignore everything without <
44
+			elseif (strpos($val, '<') !== false)	// speedup: ignore everything without <
45 45
 			{
46
-				if (preg_match($preg,$val))
46
+				if (preg_match($preg, $val))
47 47
 				{
48 48
 					// special handling for $_POST[json_data], to decend into it's decoded content, fixing json direct might break json syntax
49 49
 					if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true)))
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 					// attempt to clean the thing
58 58
 					$var[$key] = $val = Api\Html\HtmLawed::purify($val);
59 59
 					// check if we succeeded, if not drop the var anyway, keep the egw_unset_var in any case
60
-					if (preg_match($preg,$val))
60
+					if (preg_match($preg, $val))
61 61
 					{
62 62
 						error_log("*** _check_script_tag($name): unset(${name}[$key]) with value $val***");
63 63
 						unset($var[$key]);
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 	die("<p style='color: ".($num_failed?'red':'black')."'>Tests finished: $num_failed / $total failed</p>");
170 170
 }*/
171 171
 
172
-foreach(array('_GET','_POST','_REQUEST','HTTP_GET_VARS','HTTP_POST_VARS') as $n => $where)
172
+foreach (array('_GET', '_POST', '_REQUEST', 'HTTP_GET_VARS', 'HTTP_POST_VARS') as $n => $where)
173 173
 {
174 174
 	$pregs = array(
175 175
 		'order' => '/^[a-zA-Z0-9_,]*$/',
176 176
 		'sort'  => '/^(ASC|DESC|asc|desc|0|1|2|3|4|5|6|7){0,1}$/',
177 177
 	);
178
-	foreach(array('order','sort') as $name)
178
+	foreach (array('order', 'sort') as $name)
179 179
 	{
180
-		if (isset($GLOBALS[$where][$name]) && !is_array($GLOBALS[$where][$name]) && !preg_match($pregs[$name],$GLOBALS[$where][$name]))
180
+		if (isset($GLOBALS[$where][$name]) && !is_array($GLOBALS[$where][$name]) && !preg_match($pregs[$name], $GLOBALS[$where][$name]))
181 181
 		{
182 182
 			$GLOBALS[$where][$name] = '';
183 183
 		}
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
 	// speeds up the execusion a bit
187 187
 	if (isset($GLOBALS[$where]) && is_array($GLOBALS[$where]) && ($n < 2 || isset($GLOBALS['egw_unset_vars'])))
188 188
 	{
189
-		_check_script_tag($GLOBALS[$where],$where);
189
+		_check_script_tag($GLOBALS[$where], $where);
190 190
 	}
191 191
 }
192 192
 //if (is_array($GLOBALS['egw_unset_vars'])) { echo "egw_unset_vars=<pre>".htmlspecialchars(print_r($GLOBALS['egw_unset_vars'],true))."</pre>"; exit; }
193 193
 
194 194
 // $GLOBALS[egw_info][flags][currentapp] and die  if it contains something nasty or unexpected
195 195
 if (isset($GLOBALS['egw_info']) && isset($GLOBALS['egw_info']['flags']) &&
196
-	isset($GLOBALS['egw_info']['flags']['currentapp']) && !preg_match('/^[A-Za-z0-9_-]+$/',$GLOBALS['egw_info']['flags']['currentapp']))
196
+	isset($GLOBALS['egw_info']['flags']['currentapp']) && !preg_match('/^[A-Za-z0-9_-]+$/', $GLOBALS['egw_info']['flags']['currentapp']))
197 197
 {
198 198
 	error_log(__FILE__.': '.__LINE__.' Invalid $GLOBALS[egw_info][flags][currentapp]='.array2string($GLOBALS['egw_info']['flags']['currentapp']).', $_SERVER[REQUEST_URI]='.array2string($_SERVER[REQUEST_URI]));
199 199
 	die('Invalid $GLOBALS[egw_info][flags][currentapp]!');
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
 			die('GLOBALS overwrite detected!!!');
212 212
 		}
213 213
 		// unregister all globals
214
-		$noUnset = array('GLOBALS','_GET','_POST','_COOKIE','_SERVER','_ENV','_FILES','xajax');
215
-		foreach(array_unique(array_merge(
216
-			array_keys($_GET),array_keys($_POST),array_keys($_COOKIE),array_keys($_SERVER),array_keys($_ENV),array_keys($_FILES),
214
+		$noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_SERVER', '_ENV', '_FILES', 'xajax');
215
+		foreach (array_unique(array_merge(
216
+			array_keys($_GET), array_keys($_POST), array_keys($_COOKIE), array_keys($_SERVER), array_keys($_ENV), array_keys($_FILES),
217 217
 			isset($_SESSION) && is_array($_SESSION) ? array_keys($_SESSION) : array())) as $k)
218 218
 		{
219
-			if (!in_array($k,$noUnset) && isset($GLOBALS[$k]))
219
+			if (!in_array($k, $noUnset) && isset($GLOBALS[$k]))
220 220
 			{
221 221
 				unset($GLOBALS[$k]);
222 222
 			}
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		preg_match('/(^|;|{)[OC]:\d+:"/', $str))
247 247
 	{
248 248
 		error_log(__METHOD__."('$str') contains objects --> return NULL");
249
-		return null;	// null, not false, to not trigger behavior of returning string itself to app code
249
+		return null; // null, not false, to not trigger behavior of returning string itself to app code
250 250
 	}
251 251
 	return unserialize($str);
252 252
 }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
  * @param boolean $allow_not_serialized =false true: return $str as is, if it is no serialized array
318 318
  * @return array|str|false
319 319
  */
320
-function json_php_unserialize($str, $allow_not_serialized=false)
320
+function json_php_unserialize($str, $allow_not_serialized = false)
321 321
 {
322 322
 	if ((in_array($str[0], array('a', 'i', 's', 'b', 'O', 'C')) && $str[1] == ':' || $str === 'N;') &&
323 323
 		($arr = php_safe_unserialize($str)) !== false || $str === 'b:0;')
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 {
25 25
 	static $preg=null;
26 26
 	//old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i';
27
-	if (!isset($preg)) $preg =
27
+	if (!isset($preg))
28
+	{
29
+		$preg =
28 30
 		// forbidden tags like iframe or script
29 31
 		'/(<(\s*\/)?\s*(iframe|script|object|embed|math|meta)[^a-z0-9]|'.
30 32
 		// on* attributes
@@ -33,6 +35,7 @@  discard block
 block discarded – undo
33 35
 		'<[^>]+(href|src|dynsrc|lowsrc|background|style|poster|action)\s*=\s*("|\')?[^"\']*javascript|'.
34 36
 		// benavior:url and expression in style attribute
35 37
 		'<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i';
38
+	}
36 39
 	if (is_array($var))
37 40
 	{
38 41
 		foreach($var as $key => $val)
@@ -41,7 +44,9 @@  discard block
 block discarded – undo
41 44
 			{
42 45
 				_check_script_tag($var[$key],$name.'['.$key.']');
43 46
 			}
44
-			elseif(strpos($val, '<') !== false)	// speedup: ignore everything without <
47
+			elseif(strpos($val, '<') !== false)
48
+			{
49
+				// speedup: ignore everything without <
45 50
 			{
46 51
 				if (preg_match($preg,$val))
47 52
 				{
@@ -49,6 +54,7 @@  discard block
 block discarded – undo
49 54
 					if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true)))
50 55
 					{
51 56
 						_check_script_tag($json_data, $name.'[json_data]');
57
+			}
52 58
 						$_REQUEST[$key] = $var[$key] = json_encode($json_data);
53 59
 						continue;
54 60
 					}
Please login to merge, or discard this patch.