@@ -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 | |
@@ -184,8 +184,8 @@ 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) { |
@@ -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 | |
@@ -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[strlen($newWidth)-1] == '%') { |
|
| 443 | +if ($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[strlen($newHeight)-1] == '%') { |
|
| 468 | +if ($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,25 +482,25 @@ 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 | - '3:1' => 3/1, |
|
| 488 | - '3:2' => 3/2, |
|
| 489 | - '4:3' => 4/3, |
|
| 490 | - '8:5' => 8/5, |
|
| 491 | - '16:10' => 16/10, |
|
| 492 | - '16:9' => 16/9, |
|
| 487 | + '3:1' => 3 / 1, |
|
| 488 | + '3:2' => 3 / 2, |
|
| 489 | + '4:3' => 4 / 3, |
|
| 490 | + '8:5' => 8 / 5, |
|
| 491 | + '16:10' => 16 / 10, |
|
| 492 | + '16:9' => 16 / 9, |
|
| 493 | 493 | 'golden' => 1.618, |
| 494 | 494 | ); |
| 495 | 495 | }); |
| 496 | 496 | |
| 497 | 497 | // Check to replace predefined aspect ratio |
| 498 | 498 | $aspectRatios = call_user_func($aspectRatioConstant); |
| 499 | -$negateAspectRatio = ($aspectRatio[0] == '!') ? true : false; |
|
| 499 | +$negateAspectRatio = ($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) { |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 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 | |
@@ -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 | |
@@ -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); |
@@ -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 |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | $items = isset($items) ? $items : null; |
| 12 | 12 | // var_dump($items); |
| 13 | 13 | // $session = $this->di->get("session"); |
| 14 | -$tags = []; |
|
| 14 | +$tags = [ ]; |
|
| 15 | 15 | ?> |
| 16 | 16 | |
| 17 | 17 | <?php if (!$items) : ?> |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | <h1>All tags</h1> |
| 26 | 26 | </header> |
| 27 | 27 | <?php foreach ($items as $item) : ?> |
| 28 | - <?php $tags = explode(", ", $item->tag);?> |
|
| 28 | + <?php $tags = explode(", ", $item->tag); ?> |
|
| 29 | 29 | <section> |
| 30 | 30 | <?php foreach ($tags as $tag) : ?> |
| 31 | 31 | <a href="tags/tag/<?= $tag ?>"><?= $tag ?></a> |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | <?php foreach ($styles as $key => $value) : |
| 24 | 24 | $selected = $key === $activeStyle ? "selected=\"selected\"" : null; |
| 25 | 25 | ?> |
| 26 | - <option <?= $selected ?> value="<?= $key ?>"><?= "[ $key ] - {$value["shortDescription"]}" ?></option> |
|
| 26 | + <option <?= $selected ?> value="<?= $key ?>"><?= "[ $key ] - {$value[ "shortDescription" ]}" ?></option> |
|
| 27 | 27 | <?php endforeach; ?> |
| 28 | 28 | </select> |
| 29 | 29 | </label> |
@@ -10,9 +10,9 @@ |
||
| 10 | 10 | //echo showEnvironment(get_defined_vars(), get_defined_functions()); |
| 11 | 11 | |
| 12 | 12 | // Prepare classes |
| 13 | -$classes[] = "flashmessage info"; |
|
| 13 | +$classes[ ] = "flashmessage info"; |
|
| 14 | 14 | if (isset($class)) { |
| 15 | - $classes[] = $class; |
|
| 15 | + $classes[ ] = $class; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | //echo showEnvironment(get_defined_vars(), get_defined_functions()); |
| 11 | 11 | |
| 12 | 12 | // Prepare classes |
| 13 | -$classes[] = "next-previous"; |
|
| 13 | +$classes[ ] = "next-previous"; |
|
| 14 | 14 | if (isset($class)) { |
| 15 | - $classes[] = $class; |
|
| 15 | + $classes[ ] = $class; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // Prepare titles |
| 19 | -$nextTitle = $next["title"]; |
|
| 20 | -$prevTitle = $previous["title"]; |
|
| 19 | +$nextTitle = $next[ "title" ]; |
|
| 20 | +$prevTitle = $previous[ "title" ]; |
|
| 21 | 21 | |
| 22 | 22 | if (isset($nextPreviousTitle) && $nextPreviousTitle === false) { |
| 23 | 23 | $nextTitle = t("Next"); |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | ?><div <?= classList($classes) ?>> |
| 30 | 30 | <?php if (isset($next)) : ?> |
| 31 | - <div class="next"><a href="<?= url($next["route"]) ?>"><?= $nextTitle ?></a> »</div> |
|
| 31 | + <div class="next"><a href="<?= url($next[ "route" ]) ?>"><?= $nextTitle ?></a> »</div> |
|
| 32 | 32 | <?php endif; ?> |
| 33 | 33 | |
| 34 | 34 | <?php if (isset($previous)) : ?> |
| 35 | - <div class="previous">« <a href="<?= url($previous["route"]) ?>"><?= $prevTitle ?></a></div> |
|
| 35 | + <div class="previous">« <a href="<?= url($previous[ "route" ]) ?>"><?= $prevTitle ?></a></div> |
|
| 36 | 36 | <?php endif; ?> |
| 37 | 37 | </div> |
@@ -10,9 +10,9 @@ discard block |
||
| 10 | 10 | //echo showEnvironment(get_defined_vars(), get_defined_functions()); |
| 11 | 11 | |
| 12 | 12 | // Prepare classes |
| 13 | -$classes[] = "block toc"; |
|
| 13 | +$classes[ ] = "block toc"; |
|
| 14 | 14 | if (isset($class)) { |
| 15 | - $classes[] = $class; |
|
| 15 | + $classes[ ] = $class; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // Prepare title |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | <?php |
| 34 | 34 | foreach ($toc as $route => $item) { |
| 35 | - $text = $item["title"]; |
|
| 36 | - if ($item["linkable"] !== false) { |
|
| 35 | + $text = $item[ "title" ]; |
|
| 36 | + if ($item[ "linkable" ] !== false) { |
|
| 37 | 37 | $text = "<a href=\"" . url($route) . "\">$text</a>"; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $class = "level-${item["level"]}"; |
|
| 41 | - if ($item["sectionHeader"] === true) { |
|
| 40 | + $class = "level-${item[ "level" ]}"; |
|
| 41 | + if ($item[ "sectionHeader" ] === true) { |
|
| 42 | 42 | $class = "section-header"; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -16,9 +16,9 @@ |
||
| 16 | 16 | <p>Here is a set of utilities to use when learning, developing, testing and debugging Anax.</p> |
| 17 | 17 | |
| 18 | 18 | <ul> |
| 19 | - <li><a href="<?= url($mount."di") ?>">DI (show loaded services in $di)</a></li> |
|
| 20 | - <li><a href="<?= url($mount."request") ?>">Request (show details on current request)</a></li> |
|
| 21 | - <li><a href="<?= url($mount."router") ?>">Router (show loaded routes)</a></li> |
|
| 22 | - <li><a href="<?= url($mount."session") ?>">Session (show session data)</a></li> |
|
| 23 | - <li><a href="<?= url($mount."view") ?>">View (debug and inspect views)</a></li> |
|
| 19 | + <li><a href="<?= url($mount . "di") ?>">DI (show loaded services in $di)</a></li> |
|
| 20 | + <li><a href="<?= url($mount . "request") ?>">Request (show details on current request)</a></li> |
|
| 21 | + <li><a href="<?= url($mount . "router") ?>">Router (show loaded routes)</a></li> |
|
| 22 | + <li><a href="<?= url($mount . "session") ?>">Session (show session data)</a></li> |
|
| 23 | + <li><a href="<?= url($mount . "view") ?>">View (debug and inspect views)</a></li> |
|
| 24 | 24 | </ul> |
@@ -21,5 +21,5 @@ |
||
| 21 | 21 | <pre><?= var_dump($session) ?></pre> |
| 22 | 22 | |
| 23 | 23 | <p> |
| 24 | - <a href="<?= url($mount."session") ?>">Back to session<a> |
|
| 24 | + <a href="<?= url($mount . "session") ?>">Back to session<a> |
|
| 25 | 25 | </p> |
@@ -21,6 +21,6 @@ |
||
| 21 | 21 | <pre><?= var_dump($session) ?></pre> |
| 22 | 22 | |
| 23 | 23 | <p> |
| 24 | - <a href="<?= url($mount."session/increment") ?>">Add to session and increment<a> | |
|
| 25 | - <a href="<?= url($mount."session/destroy") ?>">Destroy session<a> |
|
| 24 | + <a href="<?= url($mount . "session/increment") ?>">Add to session and increment<a> | |
|
| 25 | + <a href="<?= url($mount . "session/destroy") ?>">Destroy session<a> |
|
| 26 | 26 | </p> |