1
0
Fork 0
mirror of https://github.com/GeoffreyFrogeye/phroxyp.git synced 2024-11-23 19:56:02 +01: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 // PROXY
// Config // Config
$serv = 'servclubinfo.insecure.deule.net'; $serv = 'google.com';
$port = 33736; $port = 80;
$root = '/ci_website'; $root = '';
$localRoot = '';
// Functions // 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')) { if (!function_exists('getallheaders')) {
function getallheaders() { function getallheaders() {
if (!is_array($_SERVER)) { if (!is_array($_SERVER)) {
return array(); return array();
} }
$headers = array(); $headers = array();
foreach ($_SERVER as $name => $value) { foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') { if (substr($name, 0, 5) == 'HTTP_') {
@ -26,6 +36,7 @@ if (!function_exists('getallheaders')) {
// Target determination // Target determination
$metd = $_SERVER['REQUEST_METHOD']; $metd = $_SERVER['REQUEST_METHOD'];
$reqp = $_SERVER['REQUEST_URI']; $reqp = $_SERVER['REQUEST_URI'];
// $reqp = str_replace_once($localRoot, '', $reqp);
// Preparing request headers // Preparing request headers
$reqHeds = "$metd $root$reqp HTTP/1.1\r\n"; $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); $fp = fsockopen($serv, $port, $errno, $errstr, 30);
if (!$fp) { 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 { } else {
// Sending request // Sending request
fwrite($fp, $reqHeds); fwrite($fp, $reqHeds);
@ -81,4 +92,4 @@ if (!$fp) {
fclose($fp); fclose($fp);
} }
?> ?>