Commit: 0df71ff798c722f3551abb984d3348eb85d85ab4 Author: Levi Morrison <le...@php.net> Mon, 21 Sep 2015 10:28:18 -0600 Parents: 34700d925d52e09550e87c317d98f1ae6f9ffe42 Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=0df71ff798c722f3551abb984d3348eb85d85ab4 Log: Remove oldschool logos and running elephpant There have been many complaints about them. Move the Not Modified checks to the top. Also move other code around so definitions are a bit closer to where they are used. This is why the diff looks messy. Changed paths: M images/logo.php Diff: diff --git a/images/logo.php b/images/logo.php index 89c99d9..f20fd07 100644 --- a/images/logo.php +++ b/images/logo.php @@ -1,10 +1,27 @@ <?php -$refresh = isset($_GET["refresh"]) ? true : false; +$refresh = isset($_GET['refresh']) ? true : false; + +// Be 100% sure the timezone is set +if (ini_get('date.timezone') === '' && function_exists('date_default_timezone_set')) { + date_default_timezone_set('UTC'); +} + +$now = $_SERVER['REQUEST_TIME']; + +if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { + $last = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); + + // Use the same logo for a day + if (strtotime('+1 day', $last) > $now && !$refresh) { + header('HTTP/1.1 304 Not Modified'); + exit; + } +} function imgheader($filename) { $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); - switch($ext) { + switch ($ext) { case 'gif': $hdr = 'image/gif'; break; @@ -53,61 +70,25 @@ function serve_compressed_if_available($logo) { readfile($logo); } -// Be 100% sure the timezone is set -if (ini_get("date.timezone") === "" && function_exists("date_default_timezone_set")) { - date_default_timezone_set("UTC"); -} - -$now = $_SERVER["REQUEST_TIME"]; -if(!isset($_SERVER["QUERY_STRING"])) { - $_SERVER["QUERY_STRING"] = "phpweb"; -} -switch($_SERVER["QUERY_STRING"]) { - case "QA": - case "qa": - $logos = array( - "./logos/qa.jpg", - ); +switch ($_SERVER['QUERY_STRING']) { + case 'QA': + case 'qa': + $logo = './logos/qa.jpg'; break; default: - $logos = array( - "./logos/php-logo.svg", - ); -} - -/* xmas season, december and the first week of January */ -$day = date("z", $now) - date("L", $now); -if ($day < 6 || 365-$day < 32) { - $logos = array("./logos/php-xmas-2013.png"); -} - -/* Every so often.. give the elephpant a chance */ -if ($now % 64 == 0 || $refresh) { - $logos[] = "./logos/elephpant-running-78x48.gif"; -} -if ($now % 240 == 10 || $refresh) { - $logos = array_merge($logos, glob("logos/oldschool/*")); + $logo = './logos/php-logo.svg'; } - -shuffle($logos); -$logo = array_pop($logos); - - -if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { - $last = strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]); - - /* Use the same logo for a day */ - if (strtotime("+1 day", $last) > $now && !$refresh) { - header("HTTP/1.1 304 Not Modified"); - exit; - } +// xmas season, december and the first week of January +$day = date('z', $now) - date('L', $now); +if ($day < 6 || 365 - $day < 32) { + $logo = './logos/php-xmas-2013.png'; } -$future = strtotime("+1 day", $now); -$tsstring = gmdate("D, d M Y H:i:s ", $now) . "GMT"; -header("Last-Modified: " . $tsstring); -header("Expires: " . date(DATE_RSS, $future)); +$future = strtotime('+1 day', $now); +$tsstring = gmdate('D, d M Y H:i:s ', $now) . 'GMT'; +header('Last-Modified: ' . $tsstring); +header('Expires: ' . date(DATE_RSS, $future)); imgheader($logo); serve_compressed_if_available($logo); -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php