Created
June 12, 2018 04:47
-
-
Save agentcobra/5bf4d805a50c621990aa0521081d93e6 to your computer and use it in GitHub Desktop.
connexion snippet
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 | |
if ($_POST) { | |
if($_POST['uni'] != $_SERVER['HTTP_ORIGIN']) | |
{ | |
/** | |
* Redirect with POST data. | |
* | |
* @param string $url URL. | |
* @param array $post_data POST data. Example: array('foo' => 'var', 'id' => 123) | |
* @param array $headers Optional. Extra headers to send. | |
*/ | |
function redirect_post($url, array $data, array $headers = null) { | |
$params = array( | |
'http' => array( | |
'method' => 'POST', | |
'content' => http_build_query($data) | |
) | |
); | |
if (!is_null($headers)) { | |
$params['http']['header'] = ''; | |
foreach ($headers as $k => $v) { | |
$params['http']['header'] .= "$k: $v\n"; | |
} | |
} | |
$ctx = stream_context_create($params); | |
$fp = @fopen($url, 'rb', false, $ctx); | |
if ($fp) { | |
echo @stream_get_contents($fp); | |
die(); | |
} else { | |
// Error | |
throw new Exception("Error loading '$url', $php_errormsg"); | |
} | |
} | |
redirect_post($_POST['uni'], $_POST); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment