1
0
Fork 0
mirror of https://github.com/GeoffreyFrogeye/phroxyp.git synced 2024-05-01 19:06:44 +00:00

Merge branch 'gitServ'

This commit is contained in:
Geoffrey Frogeye 2015-04-09 19:46:07 +02:00
commit 4c89cb0cbf

View file

@ -2,17 +2,27 @@
// PROXY
// Config
$serv = 'servclubinfo.insecure.deule.net';
$port = 33736;
$root = '/ci_website';
$serv = 'google.com';
$port = 80;
$root = '';
$localRoot = '';
// Functions
function str_replace_once($search, $replace, $subject) {
$pos = strpos($subject, $search);
if ($pos === false) {
return $subject;
}
return substr($subject, 0, $pos) . $replace . substr($subject, $pos + strlen($search));
}
if (!function_exists('getallheaders')) {
function getallheaders() {
if (!is_array($_SERVER)) {
return array();
}
$headers = array();
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
@ -26,6 +36,7 @@ if (!function_exists('getallheaders')) {
// Target determination
$metd = $_SERVER['REQUEST_METHOD'];
$reqp = $_SERVER['REQUEST_URI'];
// $reqp = str_replace_once($localRoot, '', $reqp);
// Preparing request headers
$reqHeds = "$metd $root$reqp HTTP/1.1\r\n";
@ -53,7 +64,7 @@ if ($metd == 'POST') { // TODO Waaaay too long
$fp = fsockopen($serv, $port, $errno, $errstr, 30);
if (!$fp) {
echo "Impossible de se connecter au serveur du Club Info :-(\n<br/>$errstr ($errno)<br />\n";
echo "Couldn't connect to server\n<br/>$errstr ($errno)<br />\n";
} else {
// Sending request
fwrite($fp, $reqHeds);
@ -81,4 +92,4 @@ if (!$fp) {
fclose($fp);
}
?>
?>