Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- // Get current time -- just the hour.
- date_default_timezone_set('America/New_York');
- $currentHour = date('H');
- // Default state is night time.
- // This code generates the "snow" state.
- $isSnowNew = rand(0,1);
- if ($isSnowNew) {$farBack = "https://i.imgur.com/PlmL3cQ.jpg";}
- else {$farBack = "https://i.imgur.com/3W5Ujmx.png";}
- $snowFile = fopen("issnow.txt", "r");
- $isSnow = fread($snowFile, filesize("issnow.txt"));
- fclose($snowFile);
- if ($isSnow) {
- $snow1 = "https://i.imgur.com/K9gJQyr.png";
- $snow2 = "https://i.imgur.com/4g2qq6a.png";
- $snow3 = "https://i.imgur.com/82niRaZ.png";
- $mainBackground = "https://i.imgur.com/qprrF9Q.png";
- $liteBackground = "https://i.imgur.com/TVccBzx.png";
- }
- else {
- $snow1 = "trans.png";
- $snow2 = "trans.png";
- $snow3 = "trans.png";
- $mainBackground = "https://i.imgur.com/Ypl6jxI.png";
- $liteBackground = "https://i.imgur.com/k1sxO3E.png";
- }
- // Set other states based on current time.
- /*
- if ($currentHour >= 6 && $currentHour < 7) {
- $mainBackground = "MorningBase.png";
- $liteBackground = "MorningLite.png";
- }
- if ($currentHour >= 7 && $currentHour < 16) {
- $mainBackground = "DaylightBase.png";
- $liteBackground = "DaylightLite.png";
- }
- if ($currentHour >= 16 && $currentHour < 17) {
- $mainBackground = "EveningBase.png";
- $liteBackground = "EveningLite.png";
- }
- */
- // Get which image the client wants.
- $imageReq = $_SERVER["QUERY_STRING"];
- switch ($imageReq) {
- case "far" :
- // This is an extremely fragile method for randomizing the snow state.
- $snowFile = fopen("issnow.txt", "w");
- $isSnow = fwrite($snowFile, $isSnowNew);
- fclose($snowFile);
- // Resume sending file.
- header("Location: " . $farBack);
- exit;
- case "base" :
- header("Location: " . $mainBackground);
- exit;
- case "lite" :
- header("Location: " . $liteBackground);
- exit;
- case "snow1" :
- header("Location: " . $snow1);
- exit;
- case "snow2" :
- header("Location: " . $snow2);
- exit;
- case "snow3" :
- header("Location: " . $snow3);
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement