17.09.2011, 12:46
I have a problem. I successfuly connect to FTP, but why it reads file from web host not VPS (I connect to VPS FTP)
PHP код:
<?php
$ip = "ip"; // your server's IP-address (not checked anywhere)
$host = "host"; // your server's FTP's host
$user = "user"; // your server's FTP's username
$pass = "pass"; // your server's FTP's user's password
$file = "OnlinePlayers.txt"; // modify only if your host's FTP doesn't go to the server's dir on connect
$lang = "en"; // choose your preferred language here; supported: en, hu, sr
// DON'T CHANGE ANYTHING AFTER THIS LINE!!!
$conn = ftp_connect($host);
if (!$conn)
{
echo "Error: Could not connect to ftp server<br>";
exit;
}
ftp_login($conn, $user, $pass);
$myFile = "OnlinePlayers.txt";
if(!is_readable($myFile)) {
echo "ERROR";
exit;
}
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
//echo $theData;
echo '<div align="center">
<table border="0" width="84%" id="table1">
<tr>
<td width="250">
<p align="center">Name</td>
<td width="149">
<p align="center">Score</td>
<td>
<p align="center">Kills</td>
<td>
<p align="center">Deaths</td>
<td width="238">
<p align="center">Level</td>
</tr>';
$handle = @fopen("OnlinePlayers.txt", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle);
$exploded_data = explode("=",$buffer);
echo "<tr>
<td width='250'>
<p align='center'><a href='http://sf-streets.com/sign.php?name=[_FFG_]BuLLeT'>
<span style='text-decoration: none'><font color='#000000'>$exploded_data[0]</font></span></a></td>
<td width='149'>
<p align='center'>$exploded_data[1]</td>
<td>
<p align='center'>$exploded_data[2]</td>
<td>
<p align='center'>$exploded_data[3]</td>
<td width='238'>
<p align='center'>$exploded_data[4]</td>
</tr>";
//}
}
fclose($handle);
echo '</table>
</div>';
}
ftp_close($conn);
exit ;
?>