1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

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.
This commit is contained in:
Levi Morrison
2015-09-21 10:28:18 -06:00
parent 34700d925d
commit 0df71ff798

View File

@@ -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",
);
$logo = './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");
// 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';
}
/* 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/*"));
}
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;
}
}
$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);