55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
class Billissuelog extends MY_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
function show($logfile) {
|
|
$fp = file_get_contents("/xtmp/{$logfile}.log");
|
|
$arr = explode("\n", $fp);
|
|
$arr = array_slice($arr, -1000);
|
|
$arr = array_reverse($arr);
|
|
$msg = implode("\n", $arr);
|
|
echo "<pre>$msg</pre>";
|
|
}
|
|
function read_log($logfile)
|
|
{
|
|
$fp = fopen("/xtmp/{$logfile}.log", 'r');
|
|
$pos = -1; // Skip final new line character (Set to -1 if not present)
|
|
|
|
$lines = array();
|
|
$currentLine = '';
|
|
$idx = 0;
|
|
$msg = "<pre>";
|
|
while (-1 !== fseek($fp, $pos, SEEK_END)) {
|
|
$char = fgetc($fp);
|
|
if (PHP_EOL == $char) {
|
|
$msg .= $currentLine;
|
|
echo $msg;
|
|
$currentLine = '';
|
|
} else {
|
|
$currentLine = $char . $currentLine;
|
|
}
|
|
$pos--;
|
|
$idx++;
|
|
if ($idx > 1000) {
|
|
break;
|
|
}
|
|
}
|
|
$msg .= "</pre>";
|
|
return $msg;
|
|
}
|
|
function index()
|
|
{
|
|
|
|
$fp = file_get_contents("/xtmp/aging_on_hold.log");
|
|
$arr = explode("\n", $fp);
|
|
$arr = array_slice($arr, -500);
|
|
$arr = array_reverse($arr);
|
|
$msg = implode("\n", $arr);
|
|
echo "<pre>$msg</pre>";
|
|
}
|
|
}
|