I'm about to write an booking system for a game server. It (the gameserver) can be controled via an WebPage which is protected by HTTP Auth. I put together this small test scipt since i had no idea what the client's authorization header looks like (and still don't know) . does anyone know and could help me please? 🙂
thx Goldeneye
function fetchFile($user, $pass, $ip, $port){
$auth = base64_encode("$user:$pass\r\n");
$auth = "Authorization: basic $auth\r\n";
$fp = fsockopen($ip, $port, &$errno, &$errstr, 60);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "GET /ServerAdmin/ HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n$auth\r\n");
while (!feof($fp)) {
$file .= fgets($fp,128);
}
fclose($fp);
}
$file = explode("\n", $file);
foreach($file as $line){
$dateic .= $line."\n";
if($body){
$datei[] = $line."\n";
} elseif(trim($line)=="")$body=1;
}
$f=fopen(time().".txt", "w"); fwrite($f, $dateic); fclose($f);
return $datei;
}