Passed
Push — develop ( 44946f...c70476 )
by Jens
02:51
created
cloudcontrol/library/components/DocumentComponent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 
16 16
 			$relativeDocumentUri = current($this->matchedSitemapItem->matches[1]);
17 17
 			if (isset($this->parameters['folder'])) {
18
-				$relativeDocumentUri = $this->parameters['folder'] . $relativeDocumentUri;
18
+				$relativeDocumentUri = $this->parameters['folder'].$relativeDocumentUri;
19 19
 			}
20 20
 
21 21
 			$document = $storage->getDocumentBySlug($relativeDocumentUri);
Please login to merge, or discard this patch.
cloudcontrol/library/components/BaseComponent.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		 * @param array   $parameters
41 41
 		 * @param         $matchedSitemapItem
42 42
 		 */
43
-		public function __construct($template='', Request $request, $parameters=array(), $matchedSitemapItem)
43
+		public function __construct($template = '', Request $request, $parameters = array(), $matchedSitemapItem)
44 44
 		{
45 45
 			$this->template = $template;
46 46
 			$this->request = $request;
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 		 * @return string
87 87
 		 * @throws \Exception
88 88
 		 */
89
-		public function renderTemplate($template='')
89
+		public function renderTemplate($template = '')
90 90
 		{
91
-			$templatePath = __DIR__ . '/../../templates/' . $template . '.php';
91
+			$templatePath = __DIR__.'/../../templates/'.$template.'.php';
92 92
 			if (realpath($templatePath) !== false) {
93 93
 				ob_clean();
94 94
 				$this->parameters['request'] = $this->request;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 				include($templatePath);
97 97
 				return ob_get_contents();
98 98
 			} else {
99
-				throw new \Exception('Couldnt find template ' . $templatePath);
99
+				throw new \Exception('Couldnt find template '.$templatePath);
100 100
 			}
101 101
 		}
102 102
 	}
Please login to merge, or discard this patch.
cloudcontrol/library/components/CmsComponent.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 				$this->parameters['mainNavClass'] = 'documents';
126 126
 				if (isset($request::$post['title'], $request::$post['path'])) {
127 127
 					$this->storage->addDocumentFolder($request::$post);
128
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/documents');
128
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/documents');
129 129
 					exit;
130 130
 				}
131 131
 			} elseif ($relativeCmsUri == '/documents/new-document' && isset($request::$get['path']) && in_array('documents', $userRights)) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				if (isset($request::$get['documentType'])) {
136 136
 					if (isset($request::$post['title'], $request::$get['documentType'], $request::$get['path'])) {
137 137
 						$this->storage->addDocument($request::$post);
138
-						header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/documents');
138
+						header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/documents');
139 139
 						exit;
140 140
 					}
141 141
 					$this->parameters['documentType'] = $this->storage->getDocumentTypeBySlug($request::$get['documentType'], true);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 				$this->parameters['smallestImage'] = $this->storage->getSmallestImageSet()->slug;
150 150
 				if (isset($request::$post['title'], $request::$get['slug'])) {
151 151
 					$this->storage->saveDocument($request::$post);
152
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/documents');
152
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/documents');
153 153
 					exit;
154 154
 				}
155 155
 				$this->parameters['document'] = $this->storage->getDocumentBySlug($request::$get['slug']);
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 				array_pop($path);
171 171
 				$path = implode('/', $path);
172 172
 
173
-				$request::$get['path'] = '/' . $path;
173
+				$request::$get['path'] = '/'.$path;
174 174
 
175 175
 				if (isset($request::$post['title'], $request::$post['content'])) {
176 176
 					$this->storage->saveDocumentFolder($request::$post);
177
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/documents');
177
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/documents');
178 178
 					exit;
179 179
 				}
180 180
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 				$this->parameters['folder'] = $folder;
183 183
 			} else if ($relativeCmsUri == '/documents/delete-document' && isset($request::$get['slug']) && in_array('documents', $userRights)) {
184 184
 				$this->storage->deleteDocumentBySlug($request::$get['slug']);
185
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/documents');
185
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/documents');
186 186
 				exit;
187 187
 			} else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get['slug']) && in_array('documents', $userRights)) {
188 188
 				$this->storage->deleteDocumentFolderBySlug($request::$get['slug']);
189
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/documents');
189
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/documents');
190 190
 				exit;
191 191
 			} elseif ($relativeCmsUri == '/sitemap' && in_array('sitemap', $userRights)) {
192 192
 				$template = 'cms/sitemap';
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 				$this->parameters['mainNavClass'] = 'sitemap';
201 201
 				if (isset($request::$post['title'], $request::$post['template'], $request::$post['component'])) {
202 202
 					$this->storage->addSitemapItem($request::$post);
203
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/sitemap');
203
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/sitemap');
204 204
 					exit;
205 205
 				}
206 206
 			} elseif ($relativeCmsUri == '/sitemap/edit' && isset($request::$get['slug']) && in_array('sitemap', $userRights)) {
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 				$sitemapItem = $this->storage->getSitemapItemBySlug($request::$get['slug']);
210 210
 				if (isset($request::$post['title'], $request::$post['template'], $request::$post['component'])) {
211 211
 					$this->storage->saveSitemapItem($request::$get['slug'], $request::$post);
212
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/sitemap');
212
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/sitemap');
213 213
 					exit;
214 214
 				}
215 215
 				$this->parameters['sitemapItem'] = $sitemapItem;
216 216
 			} elseif ($relativeCmsUri == '/sitemap/delete' && isset($request::$get['slug']) && in_array('sitemap', $userRights)) {
217 217
 				$this->storage->deleteSitemapItemBySlug($request::$get['slug']);
218
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/sitemap');
218
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/sitemap');
219 219
 				exit;
220 220
 			} elseif ($relativeCmsUri == '/images' && in_array('images', $userRights)) {
221 221
 				$template = 'cms/images';
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 				$this->parameters['mainNavClass'] = 'images';
232 232
 				if (isset($_FILES['file'])) {
233 233
 					$this->storage->addImage($_FILES['file']);
234
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/images');
234
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/images');
235 235
 					exit;
236 236
 				}
237 237
 			} elseif ($relativeCmsUri == '/images/delete' && isset($request::$get['file']) && in_array('images', $userRights)) {
238 238
 				$this->storage->deleteImageByName($request::$get['file']);
239
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/images');
239
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/images');
240 240
 				exit;
241 241
 			} elseif ($relativeCmsUri == '/images/show' && isset($request::$get['file']) && in_array('images', $userRights)) {
242 242
 				$template = 'cms/images/show';
@@ -255,30 +255,30 @@  discard block
 block discarded – undo
255 255
 				$this->parameters['mainNavClass'] = 'files';
256 256
 				if (isset($_FILES['file'])) {
257 257
 					$this->storage->addFile($_FILES['file']);
258
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/files');
258
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/files');
259 259
 					exit;
260 260
 				}
261 261
 			} elseif ($relativeCmsUri == '/files/get' && isset($request::$get['file']) && in_array('files', $userRights)) {
262 262
 				$file = $this->storage->getFileByName($request::$get['file']);
263
-				$path = realpath(__DIR__ . '/../../www/files/');
264
-				$quoted = sprintf('"%s"', addcslashes(basename($path . '/' . $file->file), '"\\'));
265
-				$size   = filesize($path . '/' . $file->file);
263
+				$path = realpath(__DIR__.'/../../www/files/');
264
+				$quoted = sprintf('"%s"', addcslashes(basename($path.'/'.$file->file), '"\\'));
265
+				$size   = filesize($path.'/'.$file->file);
266 266
 
267 267
 				header('Content-Description: File Transfer');
268
-				header('Content-Type: ' . $file->type);
269
-				header('Content-Disposition: attachment; filename=' . $quoted);
268
+				header('Content-Type: '.$file->type);
269
+				header('Content-Disposition: attachment; filename='.$quoted);
270 270
 				header('Content-Transfer-Encoding: binary');
271 271
 				header('Connection: Keep-Alive');
272 272
 				header('Expires: 0');
273 273
 				header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
274 274
 				header('Pragma: public');
275
-				header('Content-Length: ' . $size);
275
+				header('Content-Length: '.$size);
276 276
 
277
-				readfile($path . '/' . $file->file);
277
+				readfile($path.'/'.$file->file);
278 278
 				exit;
279 279
 			} elseif ($relativeCmsUri == '/files/delete' && isset($request::$get['file']) && in_array('files', $userRights)) {
280 280
 				$this->storage->deleteFileByName($request::$get['file']);
281
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/files');
281
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/files');
282 282
 				exit;
283 283
 			} elseif ($relativeCmsUri == '/configuration' && in_array('configuration', $userRights)) {
284 284
 				$template = 'cms/configuration';
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 				$this->parameters['mainNavClass'] = 'configuration';
293 293
 				if (isset($_POST['username'])) {
294 294
 					$this->storage->addUser($request::$post);
295
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/users');
295
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/users');
296 296
 					exit;
297 297
 				}
298 298
 			} elseif ($relativeCmsUri == '/configuration/users/delete' && isset($request::$get['slug']) && in_array('configuration', $userRights)) {
299 299
 				$this->storage->deleteUserBySlug($request::$get['slug']);
300
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/users');
300
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/users');
301 301
 				exit;
302 302
 			} elseif ($relativeCmsUri == '/configuration/users/edit' && isset($request::$get['slug']) && in_array('configuration', $userRights)) {
303 303
 				$template = 'cms/configuration/users-form';
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 				$this->parameters['user'] = $this->storage->getUserBySlug($request::$get['slug']);
306 306
 				if (isset($_POST['username'])) {
307 307
 					$this->storage->saveUser($request::$get['slug'], $request::$post);
308
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/users');
308
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/users');
309 309
 					exit;
310 310
 				}
311 311
 			} elseif ($relativeCmsUri == '/configuration/document-types' && in_array('configuration', $userRights)) {
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 				$bricks = $this->storage->getBricks();
319 319
 				if (isset($request::$post['title'])) {
320 320
 					$this->storage->addDocumentType($request::$post);
321
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/document-types');
321
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/document-types');
322 322
 					exit;
323 323
 				}
324 324
 				$this->parameters['bricks'] = $bricks;
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 				$bricks = $this->storage->getBricks();
330 330
 				if (isset($request::$post['title'])) {
331 331
 					$this->storage->saveDocumentType($request::$get['slug'], $request::$post);
332
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/document-types');
332
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/document-types');
333 333
 					exit;
334 334
 				}
335 335
 				$this->parameters['documentType'] = $documentType;
336 336
 				$this->parameters['bricks'] = $bricks;
337 337
 			} elseif ($relativeCmsUri == '/configuration/document-types/delete' && isset($request::$get['slug']) && in_array('configuration', $userRights)) {
338 338
 				$this->storage->deleteDocumentTypeBySlug($request::$get['slug']);
339
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/document-types');
339
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/document-types');
340 340
 				exit;
341 341
 			} elseif ($relativeCmsUri == '/configuration/bricks' && in_array('configuration', $userRights)) {
342 342
 				$template = 'cms/configuration/bricks';
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 				$this->parameters['mainNavClass'] = 'configuration';
348 348
 				if (isset($request::$post['title'])) {
349 349
 					$this->storage->addBrick($request::$post);
350
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/bricks');
350
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/bricks');
351 351
 					exit;
352 352
 				}
353 353
 			} elseif ($relativeCmsUri == '/configuration/bricks/edit' && isset($request::$get['slug']) && in_array('configuration', $userRights)) {
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
 				$brick = $this->storage->getBrickBySlug($request::$get['slug']);
357 357
 				if (isset($request::$post['title'])) {
358 358
 					$this->storage->saveBrick($request::$get['slug'], $request::$post);
359
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/bricks');
359
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/bricks');
360 360
 					exit;
361 361
 				}
362 362
 				$this->parameters['brick'] = $brick;
363 363
 			} elseif ($relativeCmsUri == '/configuration/bricks/delete' && isset($request::$get['slug']) && in_array('configuration', $userRights)) {
364 364
 				$this->storage->deleteBrickBySlug($request::$get['slug']);
365
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/bricks');
365
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/bricks');
366 366
 				exit;
367 367
 			} elseif ($relativeCmsUri == '/configuration/image-set' && in_array('configuration', $userRights)) {
368 368
 				$template = 'cms/configuration/image-set';
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 				$imageSet = $this->storage->getImageSetBySlug($request::$get['slug']);
375 375
 				if (isset($request::$post['title'])) {
376 376
 					$this->storage->saveImageSet($request::$get['slug'], $request::$post);
377
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/image-set');
377
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/image-set');
378 378
 					exit;
379 379
 				}
380 380
 				$this->parameters['imageSet'] = $imageSet;
@@ -383,17 +383,17 @@  discard block
 block discarded – undo
383 383
 				$this->parameters['mainNavClass'] = 'configuration';
384 384
 				if (isset($request::$post['title'])) {
385 385
 					$this->storage->addImageSet($request::$post);
386
-					header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/image-set');
386
+					header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/image-set');
387 387
 					exit;
388 388
 				}
389 389
 			} elseif ($relativeCmsUri == '/configuration/image-set/delete' && isset($request::$get['slug']) && in_array('configuration', $userRights)) {
390 390
 				$this->storage->deleteImageSetBySlug($request::$get['slug']);
391
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix'] . '/configuration/image-set');
391
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix'].'/configuration/image-set');
392 392
 				exit;
393 393
 			} elseif ($relativeCmsUri == '/log-off') {
394 394
 				$_SESSION['cloudcontrol'] = null;
395 395
 				unset($_SESSION['cloudcontrol']);
396
-				header('Location: ' . $request::$subfolders . $this->parameters['cmsPrefix']);
396
+				header('Location: '.$request::$subfolders.$this->parameters['cmsPrefix']);
397 397
 				exit;
398 398
 			}
399 399
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 				$whitelistIps = explode(',', $this->parameters['whitelistIps']);
409 409
 				$whitelistIps = array_map("trim", $whitelistIps);
410 410
 				if (!in_array($remoteAddress, $whitelistIps)) {
411
-					throw new \Exception('Ip address ' . $remoteAddress . ' is not on whitelist');
411
+					throw new \Exception('Ip address '.$remoteAddress.' is not on whitelist');
412 412
 				}
413 413
 			}
414 414
 		}
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 				$blacklistIps = explode(',', $this->parameters['blacklistIps']);
420 420
 				$blacklistIps = array_map("trim", $blacklistIps);
421 421
 				if (in_array($remoteAddress, $blacklistIps)) {
422
-					throw new \Exception('Ip address ' . $remoteAddress . ' is on blacklist');
422
+					throw new \Exception('Ip address '.$remoteAddress.' is on blacklist');
423 423
 				}
424 424
 			}
425 425
 		}
Please login to merge, or discard this patch.
cloudcontrol/library/cc/autoloader.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 spl_autoload_extensions('.php');
3 3
 spl_autoload_register("autoloader");
4 4
 
5
-$rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)) . '/../../') . '/');
5
+$rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)).'/../../').'/');
6 6
 
7 7
 /**
8 8
  * The function to be registered as the default autoload functino
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 	
34 34
 	global $rootPath;
35
-	$file = $rootPath . str_replace('\\', '/', $class) . ".php";
35
+	$file = $rootPath.str_replace('\\', '/', $class).".php";
36 36
 	$debug_backtrace = debug_backtrace();
37 37
 	
38 38
 	if (file_exists($file)) {
39 39
 		require_once($file);
40 40
 		if ($throwException) {
41 41
 			if (class_exists($class, false) == false && interface_exists($class, false) == false) {
42
-				throw new \Exception('Could not load class "' . $class . '" in file ' . $file);
42
+				throw new \Exception('Could not load class "'.$class.'" in file '.$file);
43 43
 			} else {
44 44
 				return true;
45 45
 			}
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	} else {
49 49
 		if (isset($debug_backtrace[2]) && isset($debug_backtrace[2]['file']) && isset($debug_backtrace[2]['line'])) {			
50 50
 			if ($throwException) {
51
-				errorHandler(0, 'Could not load class \'' . $class . '\' in file ' . $rootPath . $file, $debug_backtrace[2]['file'], $debug_backtrace[2]['line']);
51
+				errorHandler(0, 'Could not load class \''.$class.'\' in file '.$rootPath.$file, $debug_backtrace[2]['file'], $debug_backtrace[2]['line']);
52 52
 			} else {
53 53
 				return false;
54 54
 			}			
55 55
 		} else {
56 56
 			if ($throwException) {
57
-				throw new \Exception('Could not load class "' . $class . '" in file ' . $file . "\n" . 'Called from unknown origin.');
57
+				throw new \Exception('Could not load class "'.$class.'" in file '.$file."\n".'Called from unknown origin.');
58 58
 			} else {
59 59
 				return false;
60 60
 			}
Please login to merge, or discard this patch.
cloudcontrol/library/cc/cc.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		return '0 seconds';
35 35
 	}
36 36
 
37
-	$a = array( 365 * 24 * 60 * 60  =>  'year',
37
+	$a = array(365 * 24 * 60 * 60  =>  'year',
38 38
 				30 * 24 * 60 * 60  =>  'month',
39 39
 				24 * 60 * 60  =>  'day',
40 40
 				60 * 60  =>  'hour',
41 41
 				60  =>  'minute',
42 42
 				1  =>  'second'
43 43
 	);
44
-	$a_plural = array( 'year'   => 'years',
44
+	$a_plural = array('year'   => 'years',
45 45
 					   'month'  => 'months',
46 46
 					   'day'    => 'days',
47 47
 					   'hour'   => 'hours',
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 		if ($d >= 1)
56 56
 		{
57 57
 			$r = round($d);
58
-			return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago';
58
+			return $r.' '.($r > 1 ? $a_plural[$str] : $str).' ago';
59 59
 		}
60 60
 	}
61 61
 }
62 62
 
63
-function humanFileSize($size,$unit="") {
64
-	if( (!$unit && $size >= 1<<30) || $unit == "GB")
65
-		return number_format($size/(1<<30),2)."GB";
66
-	if( (!$unit && $size >= 1<<20) || $unit == "MB")
67
-		return number_format($size/(1<<20),2)."MB";
68
-	if( (!$unit && $size >= 1<<10) || $unit == "KB")
69
-		return number_format($size/(1<<10),2)."KB";
63
+function humanFileSize($size, $unit = "") {
64
+	if ((!$unit && $size >= 1 << 30) || $unit == "GB")
65
+		return number_format($size / (1 << 30), 2)."GB";
66
+	if ((!$unit && $size >= 1 << 20) || $unit == "MB")
67
+		return number_format($size / (1 << 20), 2)."MB";
68
+	if ((!$unit && $size >= 1 << 10) || $unit == "KB")
69
+		return number_format($size / (1 << 10), 2)."KB";
70 70
 	return number_format($size)." bytes";
71 71
 }
72 72
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @return mixed|string
115 115
  */
116
-function slugify($str, $replace=array(), $delimiter='-') {
117
-	if( !empty($replace) ) {
118
-		$str = str_replace((array)$replace, ' ', $str);
116
+function slugify($str, $replace = array(), $delimiter = '-') {
117
+	if (!empty($replace)) {
118
+		$str = str_replace((array) $replace, ' ', $str);
119 119
 	}
120 120
 
121 121
 	$clean = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str);
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
 {
137 137
 	$debug_backtrace = current(debug_backtrace());
138 138
 	if (PHP_SAPI == 'cli') {
139
-		echo 'Dump: ' . $debug_backtrace['file'] . ':' . $debug_backtrace['line'] . "\n";
139
+		echo 'Dump: '.$debug_backtrace['file'].':'.$debug_backtrace['line']."\n";
140 140
 		foreach (func_get_args() as $data) {
141 141
 			var_dump($data);
142 142
 		}
143 143
 	} else {
144 144
 		ob_clean();
145
-		echo '<div>Dump: ' . $debug_backtrace['file'] . ':<b>' . $debug_backtrace['line'] . "</b></div>";
145
+		echo '<div>Dump: '.$debug_backtrace['file'].':<b>'.$debug_backtrace['line']."</b></div>";
146 146
 		echo '<pre>';
147 147
 		foreach (func_get_args() as $data) {
148 148
 			echo "<code>";
Please login to merge, or discard this patch.
cloudcontrol/library/cc/errorhandler.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * @param $e
11 11
  */
12
-function exceptionHandler ($e) {
13
-	renderError($e->getMessage(),$e->getFile(),$e->getLine(),$e->getCode(),$e->getTrace());
12
+function exceptionHandler($e) {
13
+	renderError($e->getMessage(), $e->getFile(), $e->getLine(), $e->getCode(), $e->getTrace());
14 14
 }
15 15
 
16 16
 /**
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
  * @param $errfile
22 22
  * @param $errline
23 23
  */
24
-function errorHandler ($errno, $errstr, $errfile, $errline) {
25
-	renderError($errstr,$errfile,$errline,$errno,debug_backtrace());
24
+function errorHandler($errno, $errstr, $errfile, $errline) {
25
+	renderError($errstr, $errfile, $errline, $errno, debug_backtrace());
26 26
 }
27 27
 
28 28
 /**
29 29
  * When an error occurs that kills the process, still try
30 30
  * to show it using a shutdownHandler.
31 31
  */
32
-function shutdownHandler () {
32
+function shutdownHandler() {
33 33
 	$error = error_get_last(); 
34 34
     if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { 
35
-        errorHandler($error['type'],$error['message'],$error['file'],$error['line']);
35
+        errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
36 36
     }elseif ($error['type'] == 1) {
37 37
         dump($error);
38 38
     }
@@ -50,28 +50,28 @@  discard block
 block discarded – undo
50 50
 	$errstr = '';
51 51
 	switch ($jsonErrorNr) {
52 52
         case JSON_ERROR_NONE:
53
-            $errstr .= ' - No errors' . PHP_EOL;
53
+            $errstr .= ' - No errors'.PHP_EOL;
54 54
         break;
55 55
         case JSON_ERROR_DEPTH:
56
-            $errstr .= ' - Maximum stack depth exceeded' . PHP_EOL;
56
+            $errstr .= ' - Maximum stack depth exceeded'.PHP_EOL;
57 57
         break;
58 58
         case JSON_ERROR_STATE_MISMATCH:
59
-            $errstr .= ' - Underflow or the modes mismatch' . PHP_EOL;
59
+            $errstr .= ' - Underflow or the modes mismatch'.PHP_EOL;
60 60
         break;
61 61
         case JSON_ERROR_CTRL_CHAR:
62
-            $errstr .= ' - Unexpected control character found' . PHP_EOL;
62
+            $errstr .= ' - Unexpected control character found'.PHP_EOL;
63 63
         break;
64 64
         case JSON_ERROR_SYNTAX:
65
-            $errstr .= ' - Syntax error, malformed JSON' . PHP_EOL;
65
+            $errstr .= ' - Syntax error, malformed JSON'.PHP_EOL;
66 66
         break;
67 67
         case JSON_ERROR_UTF8:
68
-            $errstr .= ' - Malformed UTF-8 characters, possibly incorrectly encoded' . PHP_EOL;
68
+            $errstr .= ' - Malformed UTF-8 characters, possibly incorrectly encoded'.PHP_EOL;
69 69
         break;
70 70
         default:
71
-            $errstr = ' - Unknown error' . PHP_EOL;
71
+            $errstr = ' - Unknown error'.PHP_EOL;
72 72
         break;
73 73
     }
74
-	errorHandler ($jsonErrorNr, $errstr, $file, $line);
74
+	errorHandler($jsonErrorNr, $errstr, $file, $line);
75 75
 }
76 76
 
77 77
 /**
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
  * @param array  $trace
85 85
  * @param string $httpHeader
86 86
  */
87
-function renderError ($message='', $file='', $line='', $code=0, $trace=array(), $httpHeader = 'HTTP/1.0 500 Internal Server Error') {
87
+function renderError($message = '', $file = '', $line = '', $code = 0, $trace = array(), $httpHeader = 'HTTP/1.0 500 Internal Server Error') {
88 88
 	$file_lines = file_exists($file) ? file($file) : array();
89 89
     $range = ($line - 15) < 0 ? range(1, 30) : range($line - 15, $line + 15);
90 90
     $lines = array();
91 91
 
92 92
     foreach ($range as $line_number) {
93
-        if(isset($file_lines[$line_number-1])) {
94
-            $lines[$line_number] = $file_lines[$line_number-1];
93
+        if (isset($file_lines[$line_number - 1])) {
94
+            $lines[$line_number] = $file_lines[$line_number - 1];
95 95
         }
96 96
     }
97 97
 	if (ob_get_contents()) ob_end_clean();
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 		'trace' 		=> $trace,
105 105
 		'httpHeader' 	=> $httpHeader,
106 106
 	);
107
-	if (file_exists(realpath(__DIR__) . '/errorview.php')) {
108
-		include(realpath(__DIR__) . '/errorview.php');
107
+	if (file_exists(realpath(__DIR__).'/errorview.php')) {
108
+		include(realpath(__DIR__).'/errorview.php');
109 109
 	} else {
110 110
 		header('Content-type: application/json');
111 111
 		die(json_encode($error));
Please login to merge, or discard this patch.
cloudcontrol/library/cc/Request.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@
 block discarded – undo
47 47
 		{
48 48
 			global $rootPath;
49 49
 			
50
-			self::$subfolders = '/' . str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath));
50
+			self::$subfolders = '/'.str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath));
51 51
 			self::$requestUri = $_SERVER['REQUEST_URI'];
52 52
 			self::$queryString = $_SERVER['QUERY_STRING'];
53
-			self::$relativeUri = str_replace('?' . self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri));
53
+			self::$relativeUri = str_replace('?'.self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri));
54 54
 			self::$requestParameters = explode('/', self::$relativeUri);
55 55
 			
56 56
 			self::$get = $_GET;
Please login to merge, or discard this patch.
cloudcontrol/library/cc/Application.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 		 */
66 66
 		private function config()
67 67
 		{
68
-			$configPath = __DIR__ . '/../../config.json';
68
+			$configPath = __DIR__.'/../../config.json';
69 69
 			if (realpath($configPath) !== false) {
70 70
 				$json = file_get_contents($configPath);
71 71
 				$this->config = json_decode($json);
72 72
 			} else {
73
-				throw new \Exception('Couldn\'t find config file in path ' . $configPath);
73
+				throw new \Exception('Couldn\'t find config file in path '.$configPath);
74 74
 			}
75 75
 		}
76 76
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		private function sitemapMatching($request)
94 94
 		{
95 95
 			$sitemap = $this->storage->getSitemap();
96
-			$relativeUri = '/' . $request::$relativeUri;
96
+			$relativeUri = '/'.$request::$relativeUri;
97 97
 
98 98
 			foreach ($sitemap as $sitemapItem) {
99 99
 				if ($sitemapItem->regex) {
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 		 * @return mixed
154 154
 		 * @throws \Exception
155 155
 		 */
156
-		private function getComponentObject($class='', $template='', $parameters=array(), $matchedSitemapItem)
156
+		private function getComponentObject($class = '', $template = '', $parameters = array(), $matchedSitemapItem)
157 157
 		{
158
-			$libraryComponentName = '\\library\\components\\' . $class;
159
-			$userComponentName = '\\components\\' . $class;
158
+			$libraryComponentName = '\\library\\components\\'.$class;
159
+			$userComponentName = '\\components\\'.$class;
160 160
 			
161 161
 			if (\autoLoad($libraryComponentName, false)) {
162 162
 				$component = new $libraryComponentName($template, $this->request, $parameters, $matchedSitemapItem);
163 163
 			} elseif (\autoLoad($userComponentName, false)) {
164 164
 				$component = new $userComponentName($template, $this->request, $parameters, $matchedSitemapItem);
165 165
 			} else {
166
-				throw new \Exception('Could not load component ' . $class);
166
+				throw new \Exception('Could not load component '.$class);
167 167
 			}
168 168
 			
169 169
 			if (!$component instanceof Component) {
Please login to merge, or discard this patch.
cloudcontrol/library/images/Image.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 					$imageContent = file_get_contents($imageContainer);
33 33
 					$this->_imageResource = imagecreatefromstring($imageContent);
34 34
 				}
35
-			} elseif(is_string($imageContainer)) {
35
+			} elseif (is_string($imageContainer)) {
36 36
 				$this->_imageResource = imagecreatefromstring($imageContainer);
37 37
 			} else {
38
-				throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>' . var_export($imageContainer, true) . '</pre>');
38
+				throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>'.var_export($imageContainer, true).'</pre>');
39 39
 			}
40 40
 		}
41 41
 		
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 			
56 56
 			if ($mimeTypeConstantValue == IMAGETYPE_GIF) {
57 57
 				return imagegif($imageResource, $path);
58
-			} elseif ($mimeTypeConstantValue == IMAGETYPE_JPEG)  {
58
+			} elseif ($mimeTypeConstantValue == IMAGETYPE_JPEG) {
59 59
 				return imagejpeg($imageResource, $path, $quality);
60 60
 			} elseif ($mimeTypeConstantValue == IMAGETYPE_PNG) {
61
-				return imagepng($imageResource, $path, (intval($quality / 10) -1));
61
+				return imagepng($imageResource, $path, (intval($quality / 10) - 1));
62 62
 			}
63 63
 			else {
64 64
 				throw new \Exception('Not a valid mimetypeconstant given see function documentation');
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			if (function_exists('exif_imagetype')) {
80 80
 				$exif = exif_imagetype($imagePath);
81 81
 			} else {
82
-				if ((list($width, $height, $type, $attr) = getimagesize($imagePath)) !== false ) {
82
+				if ((list($width, $height, $type, $attr) = getimagesize($imagePath)) !== false) {
83 83
 					$exif = $type;
84 84
 				} else {
85 85
 					$exif = false;
@@ -99,86 +99,86 @@  discard block
 block discarded – undo
99 99
 		public function CreateImageFromBmp($p_sFile)
100 100
 		{
101 101
 			//    Load the image into a string 
102
-			$file    =    fopen($p_sFile,"rb"); 
103
-			$read    =    fread($file,10); 
104
-			while(!feof($file)&&($read<>"")) 
105
-				$read    .=    fread($file,1024); 
102
+			$file    = fopen($p_sFile, "rb"); 
103
+			$read    = fread($file, 10); 
104
+			while (!feof($file) && ($read <> "")) 
105
+				$read .= fread($file, 1024); 
106 106
 			
107
-			$temp    =    unpack("H*",$read); 
108
-			$hex    =    $temp[1]; 
109
-			$header    =    substr($hex,0,108);
110
-			$width=null;
111
-			$height=null;
107
+			$temp = unpack("H*", $read); 
108
+			$hex = $temp[1]; 
109
+			$header = substr($hex, 0, 108);
110
+			$width = null;
111
+			$height = null;
112 112
 			
113 113
 			//    Process the header 
114 114
 			//    Structure: http://www.fastgraph.com/help/bmp_header_format.html 
115
-			if (substr($header,0,4)=="424d") 
115
+			if (substr($header, 0, 4) == "424d") 
116 116
 			{ 
117 117
 				//    Cut it in parts of 2 bytes 
118
-				$header_parts    =    str_split($header,2); 
118
+				$header_parts = str_split($header, 2); 
119 119
 				
120 120
 				//    Get the width        4 bytes 
121
-				$width            =    hexdec($header_parts[19].$header_parts[18]); 
121
+				$width = hexdec($header_parts[19].$header_parts[18]); 
122 122
 				
123 123
 				//    Get the height        4 bytes 
124
-				$height            =    hexdec($header_parts[23].$header_parts[22]); 
124
+				$height = hexdec($header_parts[23].$header_parts[22]); 
125 125
 				
126 126
 				//    Unset the header params 
127 127
 				unset($header_parts); 
128 128
 			} 
129 129
 			
130 130
 			//    Define starting X and Y 
131
-			$x                =    0; 
132
-			$y                =    1; 
131
+			$x                = 0; 
132
+			$y                = 1; 
133 133
 			
134 134
 			//    Create newimage 
135
-			$image            =    imagecreatetruecolor($width,$height); 
135
+			$image            = imagecreatetruecolor($width, $height); 
136 136
 			
137 137
 			//    Grab the body from the image 
138
-			$body            =    substr($hex,108); 
138
+			$body = substr($hex, 108); 
139 139
 
140 140
 			//    Calculate if padding at the end-line is needed 
141 141
 			//    Divided by two to keep overview. 
142 142
 			//    1 byte = 2 HEX-chars 
143
-			$body_size        =    (strlen($body)/2); 
144
-			$header_size    =    ($width*$height); 
143
+			$body_size = (strlen($body) / 2); 
144
+			$header_size = ($width * $height); 
145 145
 
146 146
 			//    Use end-line padding? Only when needed 
147
-			$usePadding        =    ($body_size>($header_size*3)+4); 
147
+			$usePadding = ($body_size > ($header_size * 3) + 4); 
148 148
 			
149 149
 			//    Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption 
150 150
 			//    Calculate the next DWORD-position in the body 
151
-			for ($i=0;$i<$body_size;$i+=3) 
151
+			for ($i = 0; $i < $body_size; $i += 3) 
152 152
 			{ 
153 153
 				//    Calculate line-ending and padding 
154
-				if ($x>=$width) 
154
+				if ($x >= $width) 
155 155
 				{ 
156 156
 					//    If padding needed, ignore image-padding 
157 157
 					//    Shift i to the ending of the current 32-bit-block 
158 158
 					if ($usePadding) 
159
-						$i    +=    $width%4; 
159
+						$i += $width % 4; 
160 160
 					
161 161
 					//    Reset horizontal position 
162
-					$x    =    0; 
162
+					$x = 0; 
163 163
 					
164 164
 					//    Raise the height-position (bottom-up) 
165 165
 					$y++; 
166 166
 					
167 167
 					//    Reached the image-height? Break the for-loop 
168
-					if ($y>$height) 
168
+					if ($y > $height) 
169 169
 						break; 
170 170
 				} 
171 171
 				
172 172
 				//    Calculation of the RGB-pixel (defined as BGR in image-data) 
173 173
 				//    Define $i_pos as absolute position in the body 
174
-				$i_pos    =    $i*2; 
175
-				$r        =    hexdec($body[$i_pos+4].$body[$i_pos+5]); 
176
-				$g        =    hexdec($body[$i_pos+2].$body[$i_pos+3]); 
177
-				$b        =    hexdec($body[$i_pos].$body[$i_pos+1]); 
174
+				$i_pos    = $i * 2; 
175
+				$r        = hexdec($body[$i_pos + 4].$body[$i_pos + 5]); 
176
+				$g        = hexdec($body[$i_pos + 2].$body[$i_pos + 3]); 
177
+				$b        = hexdec($body[$i_pos].$body[$i_pos + 1]); 
178 178
 				
179 179
 				//    Calculate and draw the pixel 
180
-				$color    =    imagecolorallocate($image,$r,$g,$b); 
181
-				imagesetpixel($image,$x,$height-$y,$color); 
180
+				$color    = imagecolorallocate($image, $r, $g, $b); 
181
+				imagesetpixel($image, $x, $height - $y, $color); 
182 182
 				
183 183
 				//    Raise the horizontal position 
184 184
 				$x++; 
Please login to merge, or discard this patch.