Skip to content

Instantly share code, notes, and snippets.

@Firefishy
Forked from deizel/tail.php
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Firefishy/6597db104d4095c8e79a to your computer and use it in GitHub Desktop.
Save Firefishy/6597db104d4095c8e79a to your computer and use it in GitHub Desktop.
<?php
if (isset($_GET['ajax'])) {
$sessionID = 'log'.$_GET['s'];
session_id($sessionID);
session_start();
$handle = fopen('/private/var/log/system.log', 'r');
if (isset($_SESSION['offset'])) {
$data = stream_get_contents($handle, -1, $_SESSION['offset']);
echo nl2br($data);
} else {
fseek($handle, 0, SEEK_END);
}
$_SESSION['offset'] = ftell($handle);
exit();
}
$randomSession = rand();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://creativecouple.github.com/jquery-timing/jquery-timing.min.js"></script>
<script>
$(function() {
$.repeat(1000, function() {
$.get('tail.php?ajax&s=<?=$randomSession;?>', function(data) {
$('#tail').append(data);
});
});
});
</script>
</head>
<body>
<div id="tail">Starting up...</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment