No, maybe i wasnt clear. This is the code that ive came up with:
<?php
//function returns a string containing cfg.txt from PBX or false if error occured
function getCfg($url,$host,$username,$password) {
$test = base64_encode("$username:$password");
$fp = fsockopen("$host", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
return 0;
} else {
$out = "GET $url HTTP/1.0\r\n";
$out .= "Host: $host\r\n";
$out .= "Accept-Encoding: identity\r\n";
$out .= "Host: $host\r\n";
$out .= "Content-Type: text/xml; charset=\"utf-8\"\r\n";
$out .= "Content-Length: 0\r\n";
$out .= "Authorization: Basic $test\r\n\r\n";
fwrite($fp, $out);
$cfg = "";
while (!feof($fp)) {
$cfg .= fgets($fp, 128);
}
fclose($fp);
return $cfg;
}
}
echo getCfg("/cfg.txt","193.xxx.xxx.xx","user","pass");
?>
Have fun!
🆒