However although this script works fine in a Linux installed Apache + PHP (from CentOS) it seems to be not working with the PHP included with the latest version of Xampp (for Windows). It seems that it can open the log file, but can't read anything and also can't post info to the web server.
Are there any limitations on the PHP version installed by Xampp?
<?php
$date = date("Y-m-d");
$ip = "127.0.0.1"; // Server Address
$port = "9638"; // Server Port
$pass = "Password"; // Admin Password
$file = $date . "-playlog.txt"; // Archivo Log
$fp = fopen($file , "r");
while (!feof($fp))
{
$song .= fread($fp, 1024);
}
fclose($fp);
$songs = explode ("\n",$song);
$x = sizeof($songs)-1;
$song = $songs[$x];
$songs = explode (" ",$song);
$song = "";
for ($i=2;$i<sizeof($songs);$i++)
{
$song .= $songs[$i] . " ";
}
$song = urlencode($song);
$song = str_replace("+", "%20", $song);
$fp = @fsockopen($ip,$port,$errno,$errstr,4);
if (!$fp)
{
print "Error: cant get server, please check that server is online";
}
else
{
fputs($fp, "GET /admin.cgi?pass=" . $pass . "&mode=updinfo&song=" . $song . " HTTP/1.0\r\n");
fputs($fp, "User-Agent: Mozilla\r\n\r\n");
fclose($fp);
$song = str_replace("%20", "+", $song);
$song = urldecode($song);
print "Titulo Adicionado: <b>$song</b>";
}
?>