Last active
July 11, 2018 13:37
-
-
Save rephlex/a43902711ff56663adefb8aa32e9f5ca to your computer and use it in GitHub Desktop.
phproxy - a simple and stupid php proxy
This file contains hidden or 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 | |
/* | |
purpose: | |
file_get_contents some url, and echo it back to the caller. | |
usage: phproxy.php&url=blah | |
where blah is a urlencoded string, e.g.: | |
real url: https://www.rcgroups.com/forums/external.php?type=RSS2 | |
urlencoded: https%3A%2F%2Fwww.rcgroups.com%2Fforums%2Fexternal.php%3Ftype%3DRSS2 | |
*/ | |
//list of allowed users, a.k.a. "callers" | |
$trustedcallers = array( | |
'52.28.224.227', //rephlex.de ;) | |
'212.223.4.15', | |
'127.0.0.1' ); //localhost or whatever | |
// check trust | |
$trust=false; | |
foreach ($trustedcallers as $test) { | |
if ($_SERVER['REMOTE_ADDR'] == $test) { $trust=true; } | |
} | |
// bail out for untrusted folks | |
if (!$trust) { die('go away!'); } | |
//else, if trusted: do stuff | |
header("Content-type: text/xml"); | |
$url = urldecode($_GET['url']); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
print($result); | |
//that's all, folks! | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment