Skip to content

Instantly share code, notes, and snippets.

@nicklasos
Last active October 12, 2017 09:55
Show Gist options
  • Save nicklasos/bf8e47edefe62bd14c7940fc6671b66d to your computer and use it in GitHub Desktop.
Save nicklasos/bf8e47edefe62bd14c7940fc6671b66d to your computer and use it in GitHub Desktop.
php
<?php
if (($_SERVER['HTTP_PASSWORD'] ?? null) !== 'ProxyPassword') {
http_response_code(401);
exit();
}
$response = file_get_contents(urldecode($_GET['url']), false, stream_context_create([
'http' => [
'ignore_errors' => true,
'timeout' => 10,
],
]));
foreach ($http_response_header as $header) {
if (preg_match('#HTTP/[0-9\.]+\s+([0-9]+)#', $header, $out)) {
http_response_code($out[1]);
break;
}
}
echo $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment