Skip to content

Instantly share code, notes, and snippets.

@swape
Created January 15, 2014 12:13
Show Gist options
  • Save swape/8435146 to your computer and use it in GitHub Desktop.
Save swape/8435146 to your computer and use it in GitHub Desktop.
ssl proxy to show non ssl images in ssl env.
<?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