@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * Custom exception handler. |
| 13 | 13 | */ |
| 14 | -set_exception_handler(function ($exception) { |
|
| 14 | +set_exception_handler(function($exception) { |
|
| 15 | 15 | errorPage( |
| 16 | 16 | "<p><b>img.php: Uncaught exception:</b> <p>" |
| 17 | 17 | . $exception->getMessage() |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * Get configuration options from file, if the file exists, else use $config |
| 29 | 29 | * if its defined or create an empty $config. |
| 30 | 30 | */ |
| 31 | -$configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php'; |
|
| 31 | +$configFile = __DIR__ . '/' . basename(__FILE__, '.php') . '_config.php'; |
|
| 32 | 32 | |
| 33 | 33 | if (is_file($configFile)) { |
| 34 | 34 | $config = require $configFile; |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | * Setup the autoloader, but not when using a bundle. |
| 48 | 48 | */ |
| 49 | 49 | if (!defined("CIMAGE_BUNDLE")) { |
| 50 | - if (!isset($config["autoloader"])) { |
|
| 50 | + if (!isset($config[ "autoloader" ])) { |
|
| 51 | 51 | die("CImage: Missing autoloader."); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - require $config["autoloader"]; |
|
| 54 | + require $config[ "autoloader" ]; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Specific settings for each mode |
| 91 | -if ($mode == 'strict') { |
|
| 91 | +if ($mode=='strict') { |
|
| 92 | 92 | |
| 93 | 93 | error_reporting(0); |
| 94 | 94 | ini_set('display_errors', 0); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $status = false; |
| 98 | 98 | $verboseFile = false; |
| 99 | 99 | |
| 100 | -} elseif ($mode == 'production') { |
|
| 100 | +} elseif ($mode=='production') { |
|
| 101 | 101 | |
| 102 | 102 | error_reporting(-1); |
| 103 | 103 | ini_set('display_errors', 0); |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | $status = false; |
| 107 | 107 | $verboseFile = false; |
| 108 | 108 | |
| 109 | -} elseif ($mode == 'development') { |
|
| 109 | +} elseif ($mode=='development') { |
|
| 110 | 110 | |
| 111 | 111 | error_reporting(-1); |
| 112 | 112 | ini_set('display_errors', 1); |
| 113 | 113 | ini_set('log_errors', 0); |
| 114 | 114 | $verboseFile = false; |
| 115 | 115 | |
| 116 | -} elseif ($mode == 'test') { |
|
| 116 | +} elseif ($mode=='test') { |
|
| 117 | 117 | |
| 118 | 118 | error_reporting(-1); |
| 119 | 119 | ini_set('display_errors', 1); |
@@ -155,20 +155,20 @@ discard block |
||
| 155 | 155 | if ($pwd) { |
| 156 | 156 | switch ($pwdType) { |
| 157 | 157 | case 'md5': |
| 158 | - $passwordMatch = ($pwdConfig === md5($pwd)); |
|
| 158 | + $passwordMatch = ($pwdConfig===md5($pwd)); |
|
| 159 | 159 | break; |
| 160 | 160 | case 'hash': |
| 161 | 161 | $passwordMatch = password_verify($pwd, $pwdConfig); |
| 162 | 162 | break; |
| 163 | 163 | case 'text': |
| 164 | - $passwordMatch = ($pwdConfig === $pwd); |
|
| 164 | + $passwordMatch = ($pwdConfig===$pwd); |
|
| 165 | 165 | break; |
| 166 | 166 | default: |
| 167 | 167 | $passwordMatch = false; |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | -if ($pwdAlways && $passwordMatch !== true) { |
|
| 171 | +if ($pwdAlways && $passwordMatch!==true) { |
|
| 172 | 172 | errorPage("Password required and does not match or exists.", 403); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -184,19 +184,19 @@ discard block |
||
| 184 | 184 | $allowHotlinking = getConfig('allow_hotlinking', true); |
| 185 | 185 | $hotlinkingWhitelist = getConfig('hotlinking_whitelist', array()); |
| 186 | 186 | |
| 187 | -$serverName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null; |
|
| 188 | -$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; |
|
| 187 | +$serverName = isset($_SERVER[ 'SERVER_NAME' ]) ? $_SERVER[ 'SERVER_NAME' ] : null; |
|
| 188 | +$referer = isset($_SERVER[ 'HTTP_REFERER' ]) ? $_SERVER[ 'HTTP_REFERER' ] : null; |
|
| 189 | 189 | $refererHost = parse_url($referer, PHP_URL_HOST); |
| 190 | 190 | |
| 191 | 191 | if (!$allowHotlinking) { |
| 192 | 192 | if ($passwordMatch) { |
| 193 | 193 | ; // Always allow when password match |
| 194 | 194 | verbose("Hotlinking since passwordmatch"); |
| 195 | - } elseif ($passwordMatch === false) { |
|
| 195 | + } elseif ($passwordMatch===false) { |
|
| 196 | 196 | errorPage("Hotlinking/leeching not allowed when password missmatch.", 403); |
| 197 | 197 | } elseif (!$referer) { |
| 198 | 198 | errorPage("Hotlinking/leeching not allowed and referer is missing.", 403); |
| 199 | - } elseif (strcmp($serverName, $refererHost) == 0) { |
|
| 199 | + } elseif (strcmp($serverName, $refererHost)==0) { |
|
| 200 | 200 | ; // Allow when serverName matches refererHost |
| 201 | 201 | verbose("Hotlinking disallowed but serverName matches refererHost."); |
| 202 | 202 | } elseif (!empty($hotlinkingWhitelist)) { |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | $allowRemote = getConfig('remote_allow', false); |
| 285 | 285 | |
| 286 | -if ($allowRemote && $passwordMatch !== false) { |
|
| 286 | +if ($allowRemote && $passwordMatch!==false) { |
|
| 287 | 287 | $cacheRemote = $cache->getPathToSubdir("remote"); |
| 288 | 288 | |
| 289 | 289 | $pattern = getConfig('remote_pattern', null); |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | verbose("shortcut = $shortcut"); |
| 308 | 308 | |
| 309 | 309 | if (isset($shortcut) |
| 310 | - && isset($shortcutConfig[$shortcut])) { |
|
| 310 | + && isset($shortcutConfig[ $shortcut ])) { |
|
| 311 | 311 | |
| 312 | - parse_str($shortcutConfig[$shortcut], $get); |
|
| 313 | - verbose("shortcut-constant = {$shortcutConfig[$shortcut]}"); |
|
| 312 | + parse_str($shortcutConfig[ $shortcut ], $get); |
|
| 313 | + verbose("shortcut-constant = {$shortcutConfig[ $shortcut ]}"); |
|
| 314 | 314 | $_GET = array_merge($_GET, $get); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | preg_match($validFilename, $srcImage) |
| 346 | 346 | or errorPage('Source filename contains invalid characters.', 404); |
| 347 | 347 | |
| 348 | -if ($dummyEnabled && $srcImage === $dummyFilename) { |
|
| 348 | +if ($dummyEnabled && $srcImage===$dummyFilename) { |
|
| 349 | 349 | |
| 350 | 350 | // Prepare to create a dummy image and use it as the source image. |
| 351 | 351 | $dummyImage = true; |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | preg_match($validFilename, $srcImage) |
| 369 | 369 | or errorPage('Source (alt) filename contains invalid characters.', 404); |
| 370 | 370 | |
| 371 | - if ($dummyEnabled && $srcImage === $dummyFilename) { |
|
| 371 | + if ($dummyEnabled && $srcImage===$dummyFilename) { |
|
| 372 | 372 | // Check if src-alt is the dummy image |
| 373 | 373 | $dummyImage = true; |
| 374 | 374 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | // Check that the image is a file below the directory 'image_path'. |
| 389 | 389 | $imageDir = realpath($imagePath); |
| 390 | 390 | |
| 391 | - substr_compare($imageDir, $pathToImage, 0, strlen($imageDir)) == 0 |
|
| 391 | + substr_compare($imageDir, $pathToImage, 0, strlen($imageDir))==0 |
|
| 392 | 392 | or errorPage( |
| 393 | 393 | 'Security constraint: Source image is not below the directory "image_path" |
| 394 | 394 | as specified in the config file img_config.php.', |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * Manage size constants from config file, use constants to replace values |
| 405 | 405 | * for width and height. |
| 406 | 406 | */ |
| 407 | -$sizeConstant = getConfig('size_constant', function () { |
|
| 407 | +$sizeConstant = getConfig('size_constant', function() { |
|
| 408 | 408 | |
| 409 | 409 | // Set sizes to map constant to value, easier to use with width or height |
| 410 | 410 | $sizes = array( |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $gridColumns = 24; |
| 419 | 419 | |
| 420 | 420 | for ($i = 1; $i <= $gridColumns; $i++) { |
| 421 | - $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth; |
|
| 421 | + $sizes[ 'c' . $i ] = ($gridColumnWidth + $gridGutterWidth)*$i - $gridGutterWidth; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | return $sizes; |
@@ -435,12 +435,12 @@ discard block |
||
| 435 | 435 | $maxWidth = getConfig('max_width', 2000); |
| 436 | 436 | |
| 437 | 437 | // Check to replace predefined size |
| 438 | -if (isset($sizes[$newWidth])) { |
|
| 439 | - $newWidth = $sizes[$newWidth]; |
|
| 438 | +if (isset($sizes[ $newWidth ])) { |
|
| 439 | + $newWidth = $sizes[ $newWidth ]; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Support width as % of original width |
| 443 | -if ($newWidth && $newWidth[strlen($newWidth)-1] == '%') { |
|
| 443 | +if ($newWidth && $newWidth[ strlen($newWidth) - 1 ]=='%') { |
|
| 444 | 444 | is_numeric(substr($newWidth, 0, -1)) |
| 445 | 445 | or errorPage('Width % not numeric.', 404); |
| 446 | 446 | } else { |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | $maxHeight = getConfig('max_height', 2000); |
| 461 | 461 | |
| 462 | 462 | // Check to replace predefined size |
| 463 | -if (isset($sizes[$newHeight])) { |
|
| 464 | - $newHeight = $sizes[$newHeight]; |
|
| 463 | +if (isset($sizes[ $newHeight ])) { |
|
| 464 | + $newHeight = $sizes[ $newHeight ]; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | // height |
| 468 | -if ($newHeight && $newHeight[strlen($newHeight)-1] == '%') { |
|
| 468 | +if ($newHeight && $newHeight[ strlen($newHeight) - 1 ]=='%') { |
|
| 469 | 469 | is_numeric(substr($newHeight, 0, -1)) |
| 470 | 470 | or errorPage('Height % out of range.', 404); |
| 471 | 471 | } else { |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * aspect-ratio, ar - affecting the resulting image width, height and resize options |
| 483 | 483 | */ |
| 484 | 484 | $aspectRatio = get(array('aspect-ratio', 'ar')); |
| 485 | -$aspectRatioConstant = getConfig('aspect_ratio_constant', function () { |
|
| 485 | +$aspectRatioConstant = getConfig('aspect_ratio_constant', function() { |
|
| 486 | 486 | return array( |
| 487 | 487 | '3:1' => 3/1, |
| 488 | 488 | '3:2' => 3/2, |
@@ -496,15 +496,15 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | // Check to replace predefined aspect ratio |
| 498 | 498 | $aspectRatios = call_user_func($aspectRatioConstant); |
| 499 | -$negateAspectRatio = ($aspectRatio && $aspectRatio[0] == '!') ? true : false; |
|
| 499 | +$negateAspectRatio = ($aspectRatio && $aspectRatio[ 0 ]=='!') ? true : false; |
|
| 500 | 500 | $aspectRatio = $negateAspectRatio ? substr($aspectRatio, 1) : $aspectRatio; |
| 501 | 501 | |
| 502 | -if (isset($aspectRatios[$aspectRatio])) { |
|
| 503 | - $aspectRatio = $aspectRatios[$aspectRatio]; |
|
| 502 | +if (isset($aspectRatios[ $aspectRatio ])) { |
|
| 503 | + $aspectRatio = $aspectRatios[ $aspectRatio ]; |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | if ($negateAspectRatio) { |
| 507 | - $aspectRatio = 1 / $aspectRatio; |
|
| 507 | + $aspectRatio = 1/$aspectRatio; |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | is_null($aspectRatio) |
@@ -565,10 +565,10 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | verbose("fill-to-fit = $fillToFit"); |
| 567 | 567 | |
| 568 | -if ($fillToFit !== null) { |
|
| 568 | +if ($fillToFit!==null) { |
|
| 569 | 569 | |
| 570 | 570 | if (!empty($fillToFit)) { |
| 571 | - $bgColor = $fillToFit; |
|
| 571 | + $bgColor = $fillToFit; |
|
| 572 | 572 | verbose("fillToFit changed bgColor to = $bgColor"); |
| 573 | 573 | } |
| 574 | 574 | |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | $useOriginal = getDefined(array('skip-original', 'so'), false, true); |
| 612 | 612 | $useOriginalDefault = getConfig('skip_original', false); |
| 613 | 613 | |
| 614 | -if ($useOriginalDefault === true) { |
|
| 614 | +if ($useOriginalDefault===true) { |
|
| 615 | 615 | verbose("skip original is default ON"); |
| 616 | 616 | $useOriginal = false; |
| 617 | 617 | } |
@@ -755,13 +755,13 @@ discard block |
||
| 755 | 755 | $filters = array(); |
| 756 | 756 | $filter = get(array('filter', 'f')); |
| 757 | 757 | if ($filter) { |
| 758 | - $filters[] = $filter; |
|
| 758 | + $filters[ ] = $filter; |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | for ($i = 0; $i < 10; $i++) { |
| 762 | 762 | $filter = get(array("filter{$i}", "f{$i}")); |
| 763 | 763 | if ($filter) { |
| 764 | - $filters[] = $filter; |
|
| 764 | + $filters[ ] = $filter; |
|
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | |
| 779 | 779 | verbose("outputformat = $outputFormat"); |
| 780 | 780 | |
| 781 | -if ($outputFormat == 'ascii') { |
|
| 781 | +if ($outputFormat=='ascii') { |
|
| 782 | 782 | $defaultOptions = getConfig( |
| 783 | 783 | 'ascii-options', |
| 784 | 784 | array( |
@@ -791,25 +791,25 @@ discard block |
||
| 791 | 791 | $options = get('ascii'); |
| 792 | 792 | $options = explode(',', $options); |
| 793 | 793 | |
| 794 | - if (isset($options[0]) && !empty($options[0])) { |
|
| 795 | - $defaultOptions['characterSet'] = $options[0]; |
|
| 794 | + if (isset($options[ 0 ]) && !empty($options[ 0 ])) { |
|
| 795 | + $defaultOptions[ 'characterSet' ] = $options[ 0 ]; |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - if (isset($options[1]) && !empty($options[1])) { |
|
| 799 | - $defaultOptions['scale'] = $options[1]; |
|
| 798 | + if (isset($options[ 1 ]) && !empty($options[ 1 ])) { |
|
| 799 | + $defaultOptions[ 'scale' ] = $options[ 1 ]; |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if (isset($options[2]) && !empty($options[2])) { |
|
| 803 | - $defaultOptions['luminanceStrategy'] = $options[2]; |
|
| 802 | + if (isset($options[ 2 ]) && !empty($options[ 2 ])) { |
|
| 803 | + $defaultOptions[ 'luminanceStrategy' ] = $options[ 2 ]; |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | if (count($options) > 3) { |
| 807 | 807 | // Last option is custom character string |
| 808 | - unset($options[0]); |
|
| 809 | - unset($options[1]); |
|
| 810 | - unset($options[2]); |
|
| 808 | + unset($options[ 0 ]); |
|
| 809 | + unset($options[ 1 ]); |
|
| 810 | + unset($options[ 2 ]); |
|
| 811 | 811 | $characterString = implode($options); |
| 812 | - $defaultOptions['customCharacterSet'] = $characterString; |
|
| 812 | + $defaultOptions[ 'customCharacterSet' ] = $characterString; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | $img->setAsciiOptions($defaultOptions); |
@@ -923,7 +923,7 @@ discard block |
||
| 923 | 923 | /** |
| 924 | 924 | * Prepare a dummy image and use it as source image. |
| 925 | 925 | */ |
| 926 | -if ($dummyImage === true) { |
|
| 926 | +if ($dummyImage===true) { |
|
| 927 | 927 | $dummyDir = $cache->getPathToSubdir("dummy"); |
| 928 | 928 | |
| 929 | 929 | $img->setSaveFolder($dummyDir) |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | if ($status) { |
| 984 | 984 | $text = "img.php version = " . CIMAGE_VERSION . "\n"; |
| 985 | 985 | $text .= "PHP version = " . PHP_VERSION . "\n"; |
| 986 | - $text .= "Running on: " . $_SERVER['SERVER_SOFTWARE'] . "\n"; |
|
| 986 | + $text .= "Running on: " . $_SERVER[ 'SERVER_SOFTWARE' ] . "\n"; |
|
| 987 | 987 | $text .= "Allow remote images = $allowRemote\n"; |
| 988 | 988 | |
| 989 | 989 | $res = $cache->getStatusOfSubdir(""); |
@@ -1015,10 +1015,10 @@ discard block |
||
| 1015 | 1015 | $no = extension_loaded('gd') ? null : 'NOT'; |
| 1016 | 1016 | $text .= "Extension gd is $no loaded.<br>"; |
| 1017 | 1017 | |
| 1018 | - $text .= checkExternalCommand("PNG LOSSY", $postProcessing["png_lossy"], $postProcessing["png_lossy_cmd"]); |
|
| 1019 | - $text .= checkExternalCommand("PNG FILTER", $postProcessing["png_filter"], $postProcessing["png_filter_cmd"]); |
|
| 1020 | - $text .= checkExternalCommand("PNG DEFLATE", $postProcessing["png_deflate"], $postProcessing["png_deflate_cmd"]); |
|
| 1021 | - $text .= checkExternalCommand("JPEG OPTIMIZE", $postProcessing["jpeg_optimize"], $postProcessing["jpeg_optimize_cmd"]); |
|
| 1018 | + $text .= checkExternalCommand("PNG LOSSY", $postProcessing[ "png_lossy" ], $postProcessing[ "png_lossy_cmd" ]); |
|
| 1019 | + $text .= checkExternalCommand("PNG FILTER", $postProcessing[ "png_filter" ], $postProcessing[ "png_filter_cmd" ]); |
|
| 1020 | + $text .= checkExternalCommand("PNG DEFLATE", $postProcessing[ "png_deflate" ], $postProcessing[ "png_deflate_cmd" ]); |
|
| 1021 | + $text .= checkExternalCommand("JPEG OPTIMIZE", $postProcessing[ "jpeg_optimize" ], $postProcessing[ "jpeg_optimize_cmd" ]); |
|
| 1022 | 1022 | |
| 1023 | 1023 | if (!$no) { |
| 1024 | 1024 | $text .= print_r(gd_info(), 1); |
@@ -1101,12 +1101,12 @@ discard block |
||
| 1101 | 1101 | */ |
| 1102 | 1102 | if ($verbose) { |
| 1103 | 1103 | $query = array(); |
| 1104 | - parse_str($_SERVER['QUERY_STRING'], $query); |
|
| 1105 | - unset($query['verbose']); |
|
| 1106 | - unset($query['v']); |
|
| 1107 | - unset($query['nocache']); |
|
| 1108 | - unset($query['nc']); |
|
| 1109 | - unset($query['json']); |
|
| 1104 | + parse_str($_SERVER[ 'QUERY_STRING' ], $query); |
|
| 1105 | + unset($query[ 'verbose' ]); |
|
| 1106 | + unset($query[ 'v' ]); |
|
| 1107 | + unset($query[ 'nocache' ]); |
|
| 1108 | + unset($query[ 'nc' ]); |
|
| 1109 | + unset($query[ 'json' ]); |
|
| 1110 | 1110 | $url1 = '?' . htmlentities(urldecode(http_build_query($query))); |
| 1111 | 1111 | $url2 = '?' . urldecode(http_build_query($query)); |
| 1112 | 1112 | echo <<<EOD |
@@ -10,9 +10,9 @@ |
||
| 10 | 10 | //echo showEnvironment(get_defined_vars(), get_defined_functions()); |
| 11 | 11 | |
| 12 | 12 | // Prepare classes |
| 13 | -$classes[] = "article"; |
|
| 13 | +$classes[ ] = "article"; |
|
| 14 | 14 | if (isset($class)) { |
| 15 | - $classes[] = $class; |
|
| 15 | + $classes[ ] = $class; |
|
| 16 | 16 | } |
| 17 | 17 | ?> |
| 18 | 18 | <article <?= classList($classes) ?>> |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | function getGet($key, $default = null) |
| 11 | 11 | { |
| 12 | - return isset($_GET[$key]) |
|
| 13 | - ? $_GET[$key] |
|
| 12 | + return isset($_GET[ $key ]) |
|
| 13 | + ? $_GET[ $key ] |
|
| 14 | 14 | : $default; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | return array_replace($key, array_intersect_key($_POST, $key)); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - return isset($_POST[$key]) |
|
| 34 | - ? $_POST[$key] |
|
| 33 | + return isset($_POST[ $key ]) |
|
| 34 | + ? $_POST[ $key ] |
|
| 35 | 35 | : $default; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | function orderby2($column, $route) |
| 68 | 68 | { |
| 69 | - $asc = mergeQueryString(["orderby" => $column, "order" => "asc"], $route); |
|
| 70 | - $desc = mergeQueryString(["orderby" => $column, "order" => "desc"], $route); |
|
| 69 | + $asc = mergeQueryString([ "orderby" => $column, "order" => "asc" ], $route); |
|
| 70 | + $desc = mergeQueryString([ "orderby" => $column, "order" => "desc" ], $route); |
|
| 71 | 71 | |
| 72 | 72 | return <<<EOD |
| 73 | 73 | <span class="orderby"> |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | function mergeQueryString($options, $prepend = "?") |
| 93 | 93 | { |
| 94 | 94 | // Parse querystring into array |
| 95 | - $query = []; |
|
| 96 | - parse_str($_SERVER["QUERY_STRING"], $query); |
|
| 95 | + $query = [ ]; |
|
| 96 | + parse_str($_SERVER[ "QUERY_STRING" ], $query); |
|
| 97 | 97 | |
| 98 | 98 | // Merge query string with new options |
| 99 | 99 | $query = array_merge($query, $options); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | function slugify($str) |
| 142 | 142 | { |
| 143 | 143 | $str = mb_strtolower(trim($str)); |
| 144 | - $str = str_replace(['å','ä'], 'a', $str); |
|
| 144 | + $str = str_replace([ 'å', 'ä' ], 'a', $str); |
|
| 145 | 145 | $str = str_replace('ö', 'o', $str); |
| 146 | 146 | $str = preg_replace('/[^a-z0-9-]/', '-', $str); |
| 147 | 147 | $str = trim(preg_replace('/-+/', '-', $str), '-'); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function add( |
| 54 | 54 | $template, |
| 55 | - array $data = [], |
|
| 55 | + array $data = [ ], |
|
| 56 | 56 | string $region = "main", |
| 57 | 57 | int $sort = 0 |
| 58 | 58 | ) : object { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return object |
| 73 | 73 | */ |
| 74 | - public function render(array $data = [], int $status = 200) |
|
| 74 | + public function render(array $data = [ ], int $status = 200) |
|
| 75 | 75 | { |
| 76 | 76 | $view = $this->di->get("view"); |
| 77 | 77 | $view->add($this->layout, $data, "layout"); |
@@ -51,13 +51,13 @@ |
||
| 51 | 51 | $page->add( |
| 52 | 52 | "anax/v2/error/default", |
| 53 | 53 | [ |
| 54 | - "header" => $pages[$path][0], |
|
| 55 | - "text" => $pages[$path][1], |
|
| 54 | + "header" => $pages[ $path ][ 0 ], |
|
| 55 | + "text" => $pages[ $path ][ 1 ], |
|
| 56 | 56 | ] |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | return $page->render([ |
| 60 | - "title" => $pages[$path][0] |
|
| 60 | + "title" => $pages[ $path ][ 0 ] |
|
| 61 | 61 | ], $path); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $content = file_get_contents($file); |
| 50 | 50 | $content = $this->di->get("textfilter")->parse( |
| 51 | 51 | $content, |
| 52 | - ["frontmatter", "variable", "shortcode", "markdown", "titlefromheader"] |
|
| 52 | + [ "frontmatter", "variable", "shortcode", "markdown", "titlefromheader" ] |
|
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | // Add content as a view and then render the page |
@@ -47,14 +47,14 @@ |
||
| 47 | 47 | |
| 48 | 48 | $page = $this->di->get("page"); |
| 49 | 49 | $page->add( |
| 50 | - "anax/v2/dev/{$pages[$path]}", |
|
| 50 | + "anax/v2/dev/{$pages[ $path ]}", |
|
| 51 | 51 | [ |
| 52 | 52 | "mount" => "dev/" |
| 53 | 53 | ] |
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | return $page->render([ |
| 57 | - "title" => ucfirst($pages[$path]), |
|
| 57 | + "title" => ucfirst($pages[ $path ]), |
|
| 58 | 58 | "baseTitle" => " | Anax development utilities" |
| 59 | 59 | ]); |
| 60 | 60 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | "submit" => [ |
| 42 | 42 | "type" => "submit", |
| 43 | 43 | "value" => "Login", |
| 44 | - "callback" => [$this, "callbackSubmit"] |
|
| 44 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 45 | 45 | ], |
| 46 | 46 | ] |
| 47 | 47 | ); |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | public function callbackSubmit() |
| 59 | 59 | { |
| 60 | 60 | // Get values from the submitted form |
| 61 | - $username = $this->form->value("username"); |
|
| 62 | - $password = $this->form->value("password"); |
|
| 61 | + $username = $this->form->value("username"); |
|
| 62 | + $password = $this->form->value("password"); |
|
| 63 | 63 | |
| 64 | 64 | // Try to login |
| 65 | 65 | $user = new User(); |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | "email" => [ |
| 44 | 44 | "type" =>"email", |
| 45 | 45 | "label" => "Email", |
| 46 | - "validation" => ["email"], |
|
| 46 | + "validation" => [ "email" ], |
|
| 47 | 47 | ], |
| 48 | 48 | |
| 49 | 49 | "submit" => [ |
| 50 | 50 | "type" => "submit", |
| 51 | 51 | "value" => "Register", |
| 52 | - "callback" => [$this, "callbackSubmit"] |
|
| 52 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 53 | 53 | ], |
| 54 | 54 | ] |
| 55 | 55 | ); |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | public function callbackSubmit() : bool |
| 67 | 67 | { |
| 68 | 68 | // Get values from the submitted form |
| 69 | - $username = $this->form->value("username"); |
|
| 69 | + $username = $this->form->value("username"); |
|
| 70 | 70 | $password = $this->form->value("password"); |
| 71 | 71 | $passwordAgain = $this->form->value("password-again"); |
| 72 | 72 | $email = $this->form->value("email"); |
| 73 | 73 | |
| 74 | 74 | // Check password matches |
| 75 | - if ($password !== $passwordAgain ) { |
|
| 75 | + if ($password!==$passwordAgain) { |
|
| 76 | 76 | $this->form->rememberValues(); |
| 77 | 77 | $this->form->addOutput("Password did not match."); |
| 78 | 78 | return false; |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | $db = $this->di->get("dbqb"); |
| 83 | 83 | $password = password_hash($password, PASSWORD_DEFAULT); |
| 84 | 84 | $db->connect() |
| 85 | - ->insert("users", ["username", "password", "email"]) |
|
| 86 | - ->execute([$username, $password, $email]); |
|
| 85 | + ->insert("users", [ "username", "password", "email" ]) |
|
| 86 | + ->execute([ $username, $password, $email ]); |
|
| 87 | 87 | |
| 88 | 88 | // $this->form->addOutput("User was created."); |
| 89 | 89 | return true; |