@@ -26,14 +26,14 @@ |
||
| 26 | 26 | |
| 27 | 27 | // Define which ratio will be used, depending on which is the smallest side |
| 28 | 28 | $ratio = min($hRatio, $wRatio); |
| 29 | - if($ratio > 1) $ratio = 1; |
|
| 29 | + if ($ratio > 1) $ratio = 1; |
|
| 30 | 30 | |
| 31 | 31 | // Define sizes |
| 32 | 32 | $this->_destWidth = floor($originalWidth * $ratio); |
| 33 | 33 | $this->_destHeight = floor($originalHeight * $ratio); |
| 34 | 34 | |
| 35 | 35 | // Define margins |
| 36 | - $this->_destX = floor(($this->_width - $this->_destWidth) / 2); |
|
| 36 | + $this->_destX = floor(($this->_width - $this->_destWidth) / 2); |
|
| 37 | 37 | $this->_destY = floor(($this->_height - $this->_destHeight) / 2); |
| 38 | 38 | |
| 39 | 39 | // Execute the Crop method with the given parameters |
@@ -26,7 +26,9 @@ |
||
| 26 | 26 | |
| 27 | 27 | // Define which ratio will be used, depending on which is the smallest side |
| 28 | 28 | $ratio = min($hRatio, $wRatio); |
| 29 | - if($ratio > 1) $ratio = 1; |
|
| 29 | + if($ratio > 1) { |
|
| 30 | + $ratio = 1; |
|
| 31 | + } |
|
| 30 | 32 | |
| 31 | 33 | // Define sizes |
| 32 | 34 | $this->_destWidth = floor($originalWidth * $ratio); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @param resource $imageResource |
| 19 | 19 | * @return resource |
| 20 | - */ |
|
| 20 | + */ |
|
| 21 | 21 | public function Execute($imageResource) |
| 22 | 22 | { |
| 23 | 23 | // Define the origial width and height |
@@ -62,8 +62,8 @@ |
||
| 62 | 62 | |
| 63 | 63 | // Preserve transparency |
| 64 | 64 | imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127)); |
| 65 | - imagealphablending($new, false); |
|
| 66 | - imagesavealpha($new, true); |
|
| 65 | + imagealphablending($new, false); |
|
| 66 | + imagesavealpha($new, true); |
|
| 67 | 67 | |
| 68 | 68 | imagecopyresampled($new, $imageResource, $this->_destX, $this->_destY, $this->_x, $this->_y, $this->_destWidth, $this->_destHeight, $originalWidth, $originalHeight); |
| 69 | 69 | |
@@ -40,7 +40,9 @@ |
||
| 40 | 40 | |
| 41 | 41 | // Define which ratio will be used, depending on which is the biggest side |
| 42 | 42 | $ratio = $wRatio < $hRatio ? $wRatio : $hRatio; |
| 43 | - if ($ratio < 1) $ratio = 1; |
|
| 43 | + if ($ratio < 1) { |
|
| 44 | + $ratio = 1; |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | // Calculate the destination width, height, x and y |
| 46 | 48 | $this->_destWidth = $originalWidth / $ratio; |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $output = ''; |
| 50 | 50 | for ($i = 0; $i < $count; $i += 16) { |
| 51 | 51 | $random_state = |
| 52 | - md5(microtime() . $random_state); |
|
| 52 | + md5(microtime().$random_state); |
|
| 53 | 53 | $output .= |
| 54 | 54 | pack('H*', md5($random_state)); |
| 55 | 55 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function shutdownHandler () { |
| 33 | 33 | $error = error_get_last(); |
| 34 | - if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { |
|
| 35 | - errorHandler($error['type'],$error['message'],$error['file'],$error['line']); |
|
| 36 | - }elseif ($error['type'] == 1) { |
|
| 37 | - dump($error); |
|
| 38 | - } |
|
| 34 | + if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { |
|
| 35 | + errorHandler($error['type'],$error['message'],$error['file'],$error['line']); |
|
| 36 | + }elseif ($error['type'] == 1) { |
|
| 37 | + dump($error); |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -49,28 +49,28 @@ discard block |
||
| 49 | 49 | $jsonErrorNr = json_last_error(); |
| 50 | 50 | $errstr = ''; |
| 51 | 51 | switch ($jsonErrorNr) { |
| 52 | - case JSON_ERROR_NONE: |
|
| 53 | - $errstr .= ' - No errors' . PHP_EOL; |
|
| 54 | - break; |
|
| 55 | - case JSON_ERROR_DEPTH: |
|
| 56 | - $errstr .= ' - Maximum stack depth exceeded' . PHP_EOL; |
|
| 57 | - break; |
|
| 58 | - case JSON_ERROR_STATE_MISMATCH: |
|
| 59 | - $errstr .= ' - Underflow or the modes mismatch' . PHP_EOL; |
|
| 60 | - break; |
|
| 61 | - case JSON_ERROR_CTRL_CHAR: |
|
| 62 | - $errstr .= ' - Unexpected control character found' . PHP_EOL; |
|
| 63 | - break; |
|
| 64 | - case JSON_ERROR_SYNTAX: |
|
| 65 | - $errstr .= ' - Syntax error, malformed JSON' . PHP_EOL; |
|
| 66 | - break; |
|
| 67 | - case JSON_ERROR_UTF8: |
|
| 68 | - $errstr .= ' - Malformed UTF-8 characters, possibly incorrectly encoded' . PHP_EOL; |
|
| 69 | - break; |
|
| 70 | - default: |
|
| 71 | - $errstr = ' - Unknown error' . PHP_EOL; |
|
| 72 | - break; |
|
| 73 | - } |
|
| 52 | + case JSON_ERROR_NONE: |
|
| 53 | + $errstr .= ' - No errors' . PHP_EOL; |
|
| 54 | + break; |
|
| 55 | + case JSON_ERROR_DEPTH: |
|
| 56 | + $errstr .= ' - Maximum stack depth exceeded' . PHP_EOL; |
|
| 57 | + break; |
|
| 58 | + case JSON_ERROR_STATE_MISMATCH: |
|
| 59 | + $errstr .= ' - Underflow or the modes mismatch' . PHP_EOL; |
|
| 60 | + break; |
|
| 61 | + case JSON_ERROR_CTRL_CHAR: |
|
| 62 | + $errstr .= ' - Unexpected control character found' . PHP_EOL; |
|
| 63 | + break; |
|
| 64 | + case JSON_ERROR_SYNTAX: |
|
| 65 | + $errstr .= ' - Syntax error, malformed JSON' . PHP_EOL; |
|
| 66 | + break; |
|
| 67 | + case JSON_ERROR_UTF8: |
|
| 68 | + $errstr .= ' - Malformed UTF-8 characters, possibly incorrectly encoded' . PHP_EOL; |
|
| 69 | + break; |
|
| 70 | + default: |
|
| 71 | + $errstr = ' - Unknown error' . PHP_EOL; |
|
| 72 | + break; |
|
| 73 | + } |
|
| 74 | 74 | errorHandler ($jsonErrorNr, $errstr, $file, $line); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 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 | - $range = ($line - 15) < 0 ? range(1, 30) : range($line - 15, $line + 15); |
|
| 90 | - $lines = array(); |
|
| 89 | + $range = ($line - 15) < 0 ? range(1, 30) : range($line - 15, $line + 15); |
|
| 90 | + $lines = array(); |
|
| 91 | 91 | |
| 92 | - foreach ($range as $line_number) { |
|
| 93 | - if(isset($file_lines[$line_number-1])) { |
|
| 94 | - $lines[$line_number] = $file_lines[$line_number-1]; |
|
| 95 | - } |
|
| 96 | - } |
|
| 92 | + foreach ($range as $line_number) { |
|
| 93 | + if(isset($file_lines[$line_number-1])) { |
|
| 94 | + $lines[$line_number] = $file_lines[$line_number-1]; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | if (ob_get_contents()) ob_end_clean(); |
| 98 | 98 | $error = array( |
| 99 | 99 | 'message' => $message, |
@@ -9,8 +9,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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)); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $error = error_get_last(); |
| 34 | 34 | if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { |
| 35 | 35 | errorHandler($error['type'],$error['message'],$error['file'],$error['line']); |
| 36 | - }elseif ($error['type'] == 1) { |
|
| 36 | + } elseif ($error['type'] == 1) { |
|
| 37 | 37 | dump($error); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -94,7 +94,9 @@ discard block |
||
| 94 | 94 | $lines[$line_number] = $file_lines[$line_number-1]; |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | - if (ob_get_contents()) ob_end_clean(); |
|
| 97 | + if (ob_get_contents()) { |
|
| 98 | + ob_end_clean(); |
|
| 99 | + } |
|
| 98 | 100 | $error = array( |
| 99 | 101 | 'message' => $message, |
| 100 | 102 | 'file' => $file, |
@@ -47,10 +47,10 @@ |
||
| 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; |
@@ -65,12 +65,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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) { |