the code i'm doing is to allow people to read log files from a game server (just something to help develop PHP skills)
the link to the page is readlogs.php?page=list so by default it will list all files in the folder and for each file in the folder it will create a link to that file (not directly but through php). when the file is clicked it should fopen then fgets the log file then display it but it only displays 1 line for some reason
<?php
//assign the folder of the logs
$folder = "C:/HLServer/tfc/logs";
$page = $_GET['page'];
//if the page is list, it will list all files in the folder
if ($page == "list")
{
//set the variable to open the specified folder
$dir_open = opendir($folder);
//while the function to read the directory returns true......
while (($read_dir = readdir($dir_open)) !== FALSE)
{
//if the file or folder in question is a file and not a directory....
if (is_file($folder."/".$read_dir))
{
//output a link to the page as being this page but with the
echo "<a href=\"readlogs.php?page=$read_dir\">".$read_dir."</a>"."<br>";
}
}
}
///////////PROBLEM AREA STARTS HERE////////
else
{
//get the complete path of the file into 1 variable
$file_path = $folder."/".$page;
//open $file_path with read access
$file_open = fopen("$file_path","r");
//set the size of the buffer
$buffer_size = filesize($file_path);
//load the file into a buffer
$display_file = fgets($file_open,$buffer_size);
//display the log file
echo $display_file;
//close the file
fclose($file_open);
}
?>
any ideas what i did wrong? you can view the page here to see what i mean:
http://shawnserver.cjb.net/readlogs.php?page=list