Reading from latest.log, display to latest.php. HTTP 500 error.

Hello! I am trying to work on a small minecraft panel for me and a few friends. Right now, I’m trying to make a PHP page that shows all data from /home/minecraft/1.8server/logs/latest.log and display it on latest.php. However, whenever I try and launch latest.php ([vps].com/latest.php) I get an HTTP 500 error. Can anyone help?
This is my latest.php: [php]<?php
$myfile = file_get_contents(DIR . ‘/home/minecraft/1.8server/logs/latest.log’);
echo fread($myfile,"/home/minecraft/1.8server/logs/latest.log"));
fclose($myfile); ?>
[/php]
Apache is being run under the root user. My minecraft server is running under the user minecraft

It is likely because the apache user does not have access to log files, so it can’t read them or the file doesn’t exist. I may be wrong, but that would be my guess.

Apache doesn’t run under the root user, it would be a huge security risk if it did.

[php]

if ( !is_readable(DIR . ‘/home/minecraft/1.8server/logs/latest.log’) )
throw new Exception(“File cannot be read.”);

$myfile = file_get_contents(DIR . ‘/home/minecraft/1.8server/logs/latest.log’);
echo fread($myfile,"/home/minecraft/1.8server/logs/latest.log");
fclose($myfile);

[/php]

You have added an extra closing parentheses to the fread() function.

Sponsor our Newsletter | Privacy Policy | Terms of Service