0) { // Static IV $iv = base64_decode("bjzgz7z9zag="); // Fetch the rest of the string, this must be data. mmmmmm, dataaaa. $crypttext = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $crypttext, MCRYPT_MODE_CBC, $iv); return trim($crypttext); } else { // Image here possibly? die("Incorrect key"); } } function outputImg($imgpath) { $imgopt = @getimagesize($imgpath); if ($imgopt['mime'] == "image/gif" || $imgopt['mime'] == "image/jpeg" || $imgopt['mime'] == "image/png") { // 304 not needed, as nginx caches the files for us. // $lastmodified = date('D, j M Y G:i:s T', filemtime($imgpath)); // Send a 304? // if (strtotime($lastmodified) <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { // header($_SERVER['SERVER_PROTOCOL']." 304 Not Modified"); // } else { // Nope, output the image header('Content-type: '.$imgopt['mime']); $todayDate = date("Y-m-d");// current date $dateOneMonthAdded = strtotime(date("Y-m-d", strtotime($todayDate)) . "+2 weeks"); // How long in the future $cachedate = date('D, j M Y G:i:s T', $dateOneMonthAdded); // header('Cache-Control: public'); header('Cache-Control: max-age=28800'); header('Expires: '.$cachedate); header('Last-Modified: '.$lastmodified); echo file_get_contents($imgpath); // } } else { header("HTTP/1.0 404 Not Found"); } // Cya die(); } $imgurl = $_GET['imgurl']; $limgurl = decProxyStr($imgurl); $imgpath = "/var/PATH/webcache/".md5($imgurl); //echo "imgpath = ".$limgurl." ---
"; $header = "User-Agent: BiggiDK ImageCache 0.1\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; if (file_exists($imgpath)) { outputImg($imgpath); } // Proxy $proxies = array("x.x.x.x:3128","x.x.x.y:3128","x.x.x.z:3128"); shuffle($proxies); $count = 0; foreach ($proxies as $proxy) { $count++; $context_options = array ( 'http' => array ( 'method' => 'GET', 'header'=> $header, 'proxy' => $proxy, 'request_fulluri' => True, 'content' => $dstrm, 'timeout' => 30 ) ); $context = stream_context_create($context_options); $content = file_get_contents($limgurl, false, $context); if (strlen($content) > 0) { if (file_put_contents($imgpath, $content) !== FALSE) { outputImg($imgpath); } } else { // Error? Show a default error image - Please remember to change this unless the website owner gives you permission to use it. if (file_put_contents($imgpath, file_get_contents("http://www.wingchun.edu.au/app_themes/plastic%20blue/scheduler/statusinfo/error.png", false, $context)) !== FALSE) { if ($count == count($proxies)) { outputImg($imgpath); } // } else { // echo "total failure. -- ".$imgpath; } } } // If the content hasn't been outputed yet, we can assume that something went wrong, or the file simply does not exist. 404, IN YOUR FACE! header("HTTP/1.0 404 Not Found"); die();