Last active
May 8, 2017 13:29
-
-
Save shabbirbhimani/2e36fcbdd91d4aceaf1a92f9f9bfeadd to your computer and use it in GitHub Desktop.
Image Proxy File for vBulletin IMG BBCode - IMTips.co
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$salt = 'XXXX'; //Salt that was used to send hash param | |
$url = urldecode($_REQUEST['u']); // URL encoded parameter | |
if (!$url) die('Invalid Request.'); | |
// We check hash to keep hackers out. | |
$hash = md5($salt.$url.$salt); | |
if ($_REQUEST['h'] != $hash) die('Invalid Request.'); | |
//Start the Curl session | |
$session = curl_init($url); | |
curl_setopt($session, CURLOPT_HEADER, true); | |
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($session, CURLOPT_TIMEOUT, 3); | |
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($session); | |
list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $session ), 2 ); | |
// Split header text into an array. | |
$header_text = preg_split( '/[\r\n]+/', $header ); | |
// Cache for 10 days | |
header("Cache-Control: public, max-age=864000"); | |
header("Pragma: public"); | |
header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 864000)); | |
// Propagate headers to response. | |
foreach ( $header_text as $header ) { | |
if ( preg_match( '/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header ) ) { | |
header( $header ); | |
} | |
} | |
echo $contents; | |
curl_close($session); | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment