Skip to content

Instantly share code, notes, and snippets.

@mekanix
Created October 31, 2013 11:27
Show Gist options
  • Save mekanix/7248140 to your computer and use it in GitHub Desktop.
Save mekanix/7248140 to your computer and use it in GitHub Desktop.
<?php
$url = $_SERVER['MCAC_ATTR_target'] . $_SERVER['REQUEST_URI'];
$ch = curl_init($url);
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post')
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
$myfile = fopen("post.log", "w");
fwrite($myfile, $_POST);
fclose($myfile);
}
$cookie = array();
foreach ($_COOKIE as $key => $value)
{
$cookie[] = $key . '=' . $value;
}
$real_cookie = implode('; ', $cookie);
curl_setopt($ch, CURLOPT_COOKIE, $real_cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$contents = substr($response, $header_size);
curl_close($ch);
$header_text = preg_split('/[\r\n]+/', $header);
foreach ($header_text as $header)
{
header($header);
}
print $contents;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment