Advertisement
althindor

Profile BG Controller

Dec 21st, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.11 KB | None | 0 0
  1. <?PHP
  2.  
  3.     // Get current time -- just the hour.
  4.     date_default_timezone_set('America/New_York');
  5.     $currentHour = date('H');
  6.    
  7.     // Default state is night time.
  8.     // This code generates the "snow" state.
  9.    
  10.     $isSnowNew = rand(0,1);
  11.     if ($isSnowNew) {$farBack = "https://i.imgur.com/PlmL3cQ.jpg";}
  12.     else {$farBack = "https://i.imgur.com/3W5Ujmx.png";}
  13.    
  14.     $snowFile = fopen("issnow.txt", "r");
  15.     $isSnow = fread($snowFile, filesize("issnow.txt"));
  16.     fclose($snowFile);
  17.    
  18.     if ($isSnow) {
  19.         $snow1 = "https://i.imgur.com/K9gJQyr.png";
  20.         $snow2 = "https://i.imgur.com/4g2qq6a.png";
  21.         $snow3 = "https://i.imgur.com/82niRaZ.png";
  22.         $mainBackground = "https://i.imgur.com/qprrF9Q.png";
  23.         $liteBackground = "https://i.imgur.com/TVccBzx.png";
  24.     }
  25.     else {
  26.         $snow1 = "trans.png";
  27.         $snow2 = "trans.png";
  28.         $snow3 = "trans.png";
  29.         $mainBackground = "https://i.imgur.com/Ypl6jxI.png";
  30.         $liteBackground = "https://i.imgur.com/k1sxO3E.png";
  31.     }
  32.    
  33.     // Set other states based on current time.
  34.    
  35.     /*
  36.     if ($currentHour >= 6 && $currentHour < 7) {
  37.         $mainBackground = "MorningBase.png";
  38.         $liteBackground = "MorningLite.png";
  39.     }
  40.    
  41.     if ($currentHour >= 7 && $currentHour < 16) {
  42.         $mainBackground = "DaylightBase.png";
  43.         $liteBackground = "DaylightLite.png";
  44.     }
  45.    
  46.     if ($currentHour >= 16 && $currentHour < 17) {
  47.         $mainBackground = "EveningBase.png";
  48.         $liteBackground = "EveningLite.png";
  49.     }
  50.     */
  51.    
  52.     // Get which image the client wants.
  53.     $imageReq = $_SERVER["QUERY_STRING"];
  54.    
  55.     switch ($imageReq) {
  56.         case "far" :
  57.        
  58.             // This is an extremely fragile method for randomizing the snow state.
  59.             $snowFile = fopen("issnow.txt", "w");
  60.             $isSnow = fwrite($snowFile, $isSnowNew);
  61.             fclose($snowFile);
  62.            
  63.             // Resume sending file.
  64.             header("Location: " . $farBack);
  65.             exit;
  66.            
  67.         case "base" :
  68.             header("Location: " . $mainBackground);
  69.             exit;
  70.         case "lite" :
  71.             header("Location: " . $liteBackground);
  72.             exit;
  73.         case "snow1" :
  74.             header("Location: " . $snow1);
  75.             exit;
  76.         case "snow2" :
  77.             header("Location: " . $snow2);
  78.             exit;
  79.         case "snow3" :
  80.             header("Location: " . $snow3);
  81.             exit;
  82.            
  83.     }
  84.    
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement