A lot of game server hosts don't give you access to a console log, especially ones that use TCAdmin. I was fed up with it, so I wrote a simple PHP script that connects to your server via FTP and downloads the console.log file. To use this, you need to add -condebug to your server's command line. In addition, make sure your web host allows FTP connections through PHP. READ BELOW FOR INSTALLATION INSTRUCTIONS
INSTALLATION
Put this into a .php file, for example, console.php, and upload it to your web server. In the same directory, upload a text file named consolelog.txt, and chmod it to 777. You can name this text file something else if you want, just change the $txt_filename value in the PHP script. Also change the settings with your FTP connection information. MAKE SURE WHEN YOU UPLOAD THE PHP SCRIPT THERE ARE NO BLANK LINES BEFORE THE <?php LINE!
If you get a PHP Warning of "Length parameter must be greater than 0", don't worry about it. All it means is that your console.log file is blank, and PHP doesn't like that.
If you want to donate, please feel free. Just send me a PM.
PHP Code:
<?php
/**************************
* SRCDS PHP console viewer
* Written by abcorn - http://goo.gl/hlIZL
**************************/
/***********
* SETTINGS
***********/
$ftp_server = 'ftp server'; // PUT YOUR FTP SERVER ADDRESS HERE
$ftp_user_name = 'ftp user'; // PUT YOUR FTP USERNAME HERE
$ftp_user_pass = 'ftp password'; // PUT YOUR FTP PASSWORD HERE
$ftp_directory = 'ftp directory'; // PUT YOUR DIRECTORY TO console.log HERE, FOR EXAMPLE '/123.456.789.012 port 27015/tf' IF console.log IS LOCATED IN '/123.456.789.012 port 27015/tf/console.log' IN YOUR FTP SERVER'S ROOT
$allow_clear = 0; // SET THIS TO 1 IF YOU WANT USERS TO BE ABLE TO CLEAR console.log FROM THIS SCRIPT. REQUIRES THE OPTION BELOW TO BE SET.
$filename = 'script filename'; // SET THIS TO THE FILENAME OF THIS SCRIPT, FOR EXAMPLE 'console.php' IF YOU SET THE ABOVE OPTION TO 1.
$txt_filename = 'consolelog.txt'; // ONLY CHANGE THIS IF YOU UPLOADED A .txt NAMED SOMETHING OTHER THAN 'consolelog.txt'. IT MUST BE CHMODDED TO 777.
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
// check connection
if ((!$conn_id) || (!$login_result)) {
die("<code>FTP connection has failed!</code>");
}
if (!ftp_chdir($conn_id, $ftp_directory)) {
die("<code>Couldn't change directory to ".$ftp_directory.".</code>");
}
if($_GET['clear'] && $allow_clear) {
if(!$file = fopen($txt_filename, 'w')) {
die("<code>Couldn't open ".$txt_filename."!");
}
if(!fwrite($file, ' ')) {
die("<code>Couldn't write to ".$txt_filename."!");
}
fclose($file);
if (!ftp_put($conn_id, "console.log", $txt_filename, FTP_ASCII)) {
die("<code>Couldn't upload blank file to console.log.</code>");
}
header("location: ".$filename);
exit(0);
}
if (!ftp_get($conn_id, $txt_filename, $ftp_directory."/console.log", FTP_ASCII)) {
die("<code>Couldn't get console log from server.</code>");
}
if(!$file = fopen($txt_filename, 'r')) {
die("<code>Couldn't open ".$txt_filename."!");
}
$text = fread($file, filesize($txt_filename));
fclose($file);
// close the connection
ftp_close($conn_id);
?>
<html>
<head>
<title>SRCDS Console Output</title>
</head>
<body>
<code>
<a href="javascript:location.reload(true)">Refresh</a><?php if($allow_clear) { ?> | <a href="<?php echo $filename; ?>?clear=1">Clear Console</a><?php } ?><br><hr>
<?php echo nl2br($text); ?><br>
<hr><a href="javascript:location.reload(true)">Refresh</a><?php if($allow_clear) { ?> | <a href="<?php echo $filename; ?>?clear=1">Clear Console</a><?php } ?>
</code>
</body>
</html>
INSTALLATION
Put this into a .php file, for example, console.php, and upload it to your web server. In the same directory, upload a text file named consolelog.txt, and chmod it to 777. You can name this text file something else if you want, just change the $txt_filename value in the PHP script. Also change the settings with your FTP connection information. MAKE SURE WHEN YOU UPLOAD THE PHP SCRIPT THERE ARE NO BLANK LINES BEFORE THE <?php LINE!
If you get a PHP Warning of "Length parameter must be greater than 0", don't worry about it. All it means is that your console.log file is blank, and PHP doesn't like that.
If you want to donate, please feel free. Just send me a PM.