Page 1 of 1

Xampp for Windows can't read files? can't post to web server

PostPosted: 26. January 2007 23:04
by albatroz
I have this script whose purpose is extract data from the last line of a log file, build an URL and then submit it to a webserver.

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>";
}
?>



PostPosted: 26. January 2007 23:11
by Wiedmann
It seems that it can open the log file,

You have an error message?

PostPosted: 26. January 2007 23:13
by albatroz
Nope.
No error message, at all...
Actually. It seems that it can open the file, but can't read anything in it.

PostPosted: 26. January 2007 23:16
by Wiedmann
No error message, at all...

Well, why did you think PHP can't read the file, if there is no error message in the fopen() / fread() function?

PostPosted: 26. January 2007 23:34
by albatroz
Because I can run the same exactly file in a Linux box,
without problems...

PostPosted: 26. January 2007 23:39
by Wiedmann
Because I can run the same exactly file in a Linux box,
without problems...

This doesn't matter... ;-)

You should do a normal debugging, and find out in which line an error occur (or a not aspected program behaviour).