Created
January 15, 2014 12:13
-
-
Save swape/8435146 to your computer and use it in GitHub Desktop.
ssl proxy to show non ssl images in ssl env.
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 | |
// https://mysecureserver.com/path_to_this_script/?url=[base64 encoded image link]* | |
$file = base64_decode(@$_GET['url']); | |
$aFile = end(explode('.' , $file)); | |
if($aFile == 'jpg' or $aFile == 'jpeg'){ | |
header('Content-Type: image/jpeg'); | |
}elseif($aFile == 'png'){ | |
header('Content-Type: image/png'); | |
}elseif($aFile == 'gif'){ | |
header('Content-Type: image/gif'); | |
}else{ | |
die('not supported'); | |
} | |
if($file != ''){ | |
$cache_expire = 60*60*24*365; | |
header("Pragma: public"); | |
header("Cache-Control: maxage=". $cache_expire); | |
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache_expire).' GMT'); | |
//... [and get the content using curl or file_get_contents and echo it out ] | |
} | |
exit; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment