Created
September 11, 2012 02:26
-
-
Save cccaldas/3695486 to your computer and use it in GitHub Desktop.
proxy.php
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 | |
$filename = $_GET["url"]; | |
$fsize = getSizeFile($filename); | |
header("Content-Type: image/jpeg"); | |
header("Content-Length: ".$fsize); | |
readfile($filename); | |
function getSizeFile($url) { | |
if (substr($url, 0, 4) == "http") { | |
$x = array_change_key_case(get_headers($url, 1), CASE_LOWER); | |
if (strcasecmp($x[0], "HTTP/1.1 200 OK") != 0) { | |
$x = $x["content-length"][1]; | |
} | |
else { | |
$x = $x["content-length"]; | |
} | |
} | |
else { | |
$x = @filesize($url); | |
} | |
return $x; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment