Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Live File Viewer?

Elite Diviner
Joined
Mar 30, 2013
Messages
456
Reaction score
42
So I have this server.log file on my desktop, and its essentially just a long list of logs in text. I need someway to upload this and allow someone to view it from a webpage. It essentially would need to be live, so if a new line gets added into the logs, then it updates on the webpage automatically.
 
Custom Title Activated
Loyal Member
Joined
Mar 26, 2012
Messages
1,465
Reaction score
131
Here is a demo setup so that you can see a constantly updating file. Very simply done in php.
PHP:
<!--Meta Refresh to update the page constantly-->
<meta http-equiv="refresh" content="2;url=YOUR URL">
<!--Example of YOUR URL: http://current page.com-->
<?php
/* This can be changed to the location of your file. Make sure you have set the correct permissions in your web server to edit and read */
$fn = "./server.log";
if (isset($_POST['content'])) {
    $content = stripslashes($_POST['content']);
    $fp = fopen($fn, "w") or die("Error opening file in write mode!");
    fputs($fp, $content);
    fclose($fp) or die("Error closing file!");
}
?>
<h4>SERVER LOG</h4>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
    <textarea class="note" name="content" rows="15" cols="30"><?php readfile($fn); ?></textarea>
	<!--Uncomment the line below to edit the log file. Remember that you need to adjust the refesh time of the meta tag so that it will allow you enough time to edit it.-->
    <!--<input type="submit" value="Save">-->
</form>



On another note if you need to host this so that it can be seen and don't have a web server here is a simple suggestion that will help if you think this is viable. Register at no-ip.com and download the DUC client.(This will allow you to host it as a website) Then download a webserver such as xampp or wampserver or if you are using Windows 7 you can setup IIS with php but, it is simpler to setup xampp. This is the closest idea to allowing someone to constantly view a file live that is being updated constantly. Other options would be to use Dropbox and share with this other person however they will have to constantly update it on their computer and this may be time consuming. I hope that one of these ideas are what you are looking for. Good luck.



Better yet. I feel like a Special person. Here is a better way to view the log without all the extra stuff involved.
PHP:
<!--Meta Refresh to update the page constantly-->
<meta http-equiv="refresh" content="2;url=YOUR URL">
<!--Example of YOUR URL: http://current page.com-->
<?php
/* This can be changed to the location of your file. Make sure you have set the correct permissions in your web server to edit and read */
$data = file_get_contents( "./server.log" );
?>
<h4>SERVER LOG</h4>
<?php echo nl2br($data); ?>
 
Elite Diviner
Joined
Mar 30, 2013
Messages
456
Reaction score
42
Here is a demo setup so that you can see a constantly updating file. Very simply done in php.
PHP:
<!--Meta Refresh to update the page constantly-->
<meta http-equiv="refresh" content="2;url=YOUR URL">
<!--Example of YOUR URL: http://current page.com-->
<?php
/* This can be changed to the location of your file. Make sure you have set the correct permissions in your web server to edit and read */
$fn = "./server.log";
if (isset($_POST['content'])) {
    $content = stripslashes($_POST['content']);
    $fp = fopen($fn, "w") or die("Error opening file in write mode!");
    fputs($fp, $content);
    fclose($fp) or die("Error closing file!");
}
?>
<h4>SERVER LOG</h4>
<form action="https://forum.ragezone.com/<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
    <textarea class="note" name="content" rows="15" cols="30"><?php readfile($fn); ?></textarea>
	<!--Uncomment the line below to edit the log file. Remember that you need to adjust the refesh time of the meta tag so that it will allow you enough time to edit it.-->
    <!--<input type="submit" value="Save">-->
</form>



On another note if you need to host this so that it can be seen and don't have a web server here is a simple suggestion that will help if you think this is viable. Register at no-ip.com and download the DUC client.(This will allow you to host it as a website) Then download a webserver such as xampp or wampserver or if you are using Windows 7 you can setup IIS with php but, it is simpler to setup xampp. This is the closest idea to allowing someone to constantly view a file live that is being updated constantly. Other options would be to use Dropbox and share with this other person however they will have to constantly update it on their computer and this may be time consuming. I hope that one of these ideas are what you are looking for. Good luck.



Better yet. I feel like a Special person. Here is a better way to view the log without all the extra stuff involved.
PHP:
<!--Meta Refresh to update the page constantly-->
<meta http-equiv="refresh" content="2;url=YOUR URL">
<!--Example of YOUR URL: http://current page.com-->
<?php
/* This can be changed to the location of your file. Make sure you have set the correct permissions in your web server to edit and read */
$data = file_get_contents( "./server.log" );
?>
<h4>SERVER LOG</h4>
<?php echo nl2br($data); ?>

Ill take a look at these. As is, it will just be hosted on a Wamp Server and the IP given out to select people.
 
Joined
Dec 15, 2009
Messages
1,387
Reaction score
236
Here is a demo setup so that you can see a constantly updating file. Very simply done in php.
PHP:
<!--Meta Refresh to update the page constantly-->
<meta http-equiv="refresh" content="2;url=YOUR URL">
<!--Example of YOUR URL: http://current page.com-->
<?php
/* This can be changed to the location of your file. Make sure you have set the correct permissions in your web server to edit and read */
$fn = "./server.log";
if (isset($_POST['content'])) {
    $content = stripslashes($_POST['content']);
    $fp = fopen($fn, "w") or die("Error opening file in write mode!");
    fputs($fp, $content);
    fclose($fp) or die("Error closing file!");
}
?>
<h4>SERVER LOG</h4>
<form action="https://forum.ragezone.com/<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
    <textarea class="note" name="content" rows="15" cols="30"><?php readfile($fn); ?></textarea>
	<!--Uncomment the line below to edit the log file. Remember that you need to adjust the refesh time of the meta tag so that it will allow you enough time to edit it.-->
    <!--<input type="submit" value="Save">-->
</form>



On another note if you need to host this so that it can be seen and don't have a web server here is a simple suggestion that will help if you think this is viable. Register at no-ip.com and download the DUC client.(This will allow you to host it as a website) Then download a webserver such as xampp or wampserver or if you are using Windows 7 you can setup IIS with php but, it is simpler to setup xampp. This is the closest idea to allowing someone to constantly view a file live that is being updated constantly. Other options would be to use Dropbox and share with this other person however they will have to constantly update it on their computer and this may be time consuming. I hope that one of these ideas are what you are looking for. Good luck.



Better yet. I feel like a Special person. Here is a better way to view the log without all the extra stuff involved.
PHP:
<!--Meta Refresh to update the page constantly-->
<meta http-equiv="refresh" content="2;url=YOUR URL">
<!--Example of YOUR URL: http://current page.com-->
<?php
/* This can be changed to the location of your file. Make sure you have set the correct permissions in your web server to edit and read */
$data = file_get_contents( "./server.log" );
?>
<h4>SERVER LOG</h4>
<?php echo nl2br($data); ?>

No, it should not be done natively with PHP and refresh intervals.
I would recommend web sockets.
 
Divine Celestial
Joined
Feb 25, 2013
Messages
808
Reaction score
343
He ment live update.

And NubPro sockets here are definitely not needed. You can just use AJAX or jQuery

Ajax:
Code:
function updateFeed(){
$.ajax({ 
url: 'mylog.log', 
data: my_data, 
type: 'GET', success: 
function(response){ 
$('#LiveFeed').html(response);
 setTimeout(updateFeed,1000); // 1 second
} 
}); 
}

HTML:
Code:
<body onLoad="updateFeed();">
<div id="LiveFeed"></div>
</body>

Something like this should do!

Good luck!
 
Joined
Dec 15, 2009
Messages
1,387
Reaction score
236
He ment live update.

And NubPro sockets here are definitely not needed. You can just use AJAX or jQuery

Ajax:
Code:
function updateFeed(){
$.ajax({ 
url: 'mylog.log', 
data: my_data, 
type: 'GET', success: 
function(response){ 
$('#LiveFeed').html(response);
 setTimeout(updateFeed,1000); // 1 second
} 
}); 
}

HTML:
Code:
<body onLoad="updateFeed();">
<div id="LiveFeed"></div>
</body>

Something like this should do!

Good luck!
Web sockets are closest to being real-time.

Methods stated above by them are not wrong, but I think it could have been better.
Syncing with the server every X seconds, while there aren't any actual changes to the server, will be a resource waster. In contrast, with websockets, client and server can interact under low latency without using substantial bandwidth and similarly publish updates almost immediately when changes are been made.
AJAX ain't going to play cool if your clients are requesting to the server incessantly, resulting the server to possibly crashes or degrade your server bandwidth and speed.
 
Divine Celestial
Joined
Feb 25, 2013
Messages
808
Reaction score
343
That is what cache is for though.
 
Back
Top