adding tail log view + order by DATE last files before in logs
This commit is contained in:
parent
d8868ba541
commit
616306ecc6
|
@ -62,7 +62,11 @@ while (list($key,$val)=each($list)){
|
|||
<td><?php echo $v['name']; ?></td>
|
||||
<td><?php echo $v['creation_date']; ?></td>
|
||||
<td><?php echo format_size($v['filesize']); ?></td>
|
||||
<td><?php echo "<a href=\"".$v['downlink']."\">"._("Download")."</a>";?></td>
|
||||
<td><?php echo "<a href=\"logs_download.php?file=".$v['downlink']."\">"._("Download")."</a>";
|
||||
if ((time()-14400)<$v['mtime']) {
|
||||
echo " <a href=\"logs_tail.php?file=".$v['downlink']."\">"._("Follow")."</a>";
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<?php
|
||||
} //foreach
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/*
|
||||
$Id: logs_download.php,v 1.2 2004/09/06 18:14:36 anonymous Exp $
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
Copyright (C) 2002 by the AlternC Development Team.
|
||||
http://alternc.org/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License (GPL)
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file: Sonntag Benjamin
|
||||
Purpose of file: Return the current folder in a compressed file
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
require_once("../class/config.php");
|
||||
|
||||
$fields = array (
|
||||
"file" => array ("request", "string", ""),
|
||||
"autoreload" => array ("request", "integer", "1"),
|
||||
"lines" => array ("request", "integer", "20"),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
if (empty($file)) {
|
||||
$error="";
|
||||
}
|
||||
|
||||
include_once("head.php");
|
||||
|
||||
$string=$log->tail($file,$lines);
|
||||
if (!$string) {
|
||||
$file=_("unknown");
|
||||
}
|
||||
?>
|
||||
<h3><?php __("Follow a recent log"); ?></h3>
|
||||
<p><?php printf(_("Please find below the last lines of file <b>%s</b>"),$file); ?></p>
|
||||
<form method="get" action="logs_tail.php" name="update" id="update">
|
||||
<input type="hidden" name="file" value="<?php echo $file; ?>" />
|
||||
<input type="hidden" name="autoreload" value="<?php echo $autoreload; ?>" />
|
||||
<?php if ($autoreload) {
|
||||
?>
|
||||
<input type="button" class="inb" name="autoreload" value="<?php __("Stop Auto Reload"); ?>" onclick="document.location='logs_tail.php?file=<?php echo $file; ?>&autoreload=0'"/>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="button" class="inb" name="autoreload" value="<?php __("Auto Reload"); ?>" onclick="document.location='logs_tail.php?file=<?php echo $file; ?>'"/>
|
||||
<?php
|
||||
} ?>
|
||||
<select id="lines" name="lines" onchange="document.forms['update'].submit()">
|
||||
<?php
|
||||
$alines=array(10=>10, 20=>20, 30=>30, 50=>50, 100=>100, 200=>200, 500=>500, 1000=>1000, 5000=>5000);
|
||||
eoption($alines,$lines);
|
||||
?>
|
||||
</select> <?php __("Last lines shown"); ?>
|
||||
|
||||
<?php echo "<a class=\"inb\" href=\"logs_download.php?file=".$file."\">"._("Download")."</a>"; ?>
|
||||
<a class="inb" href="logs_list.php" ><?php __("Back to the logs list"); ?></a>
|
||||
<hr id="topbar"/>
|
||||
<br />
|
||||
<?php
|
||||
if (isset($error) && $error) {
|
||||
echo "<p class=\"alert alert-danger\">$error</p>";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<pre style=" white-space: pre-wrap; /* CSS 3 */
|
||||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
word-wrap: break-word; /* Internet Explorer 5.5+ */" >
|
||||
<?php echo $string; ?>
|
||||
</pre>
|
||||
<?php
|
||||
if ($autoreload) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
window.setTimeout("document.location=document.location",5000);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
require_once("foot.php");
|
||||
?>
|
|
@ -38,12 +38,13 @@ class m_log {
|
|||
$c=array();
|
||||
foreach( glob("${dir}/*log*") as $absfile) {
|
||||
$c[]=array("name"=>basename($absfile),
|
||||
"creation_date"=>date("F d Y H:i:s.", filectime($absfile)),
|
||||
"creation_date"=>date("F d Y H:i:s", filectime($absfile)),
|
||||
"mtime" => filemtime($absfile),
|
||||
"filesize"=>filesize($absfile),
|
||||
"downlink"=>"logs_download.php?file=".urlencode(basename($absfile)),
|
||||
"downlink"=>urlencode(basename($absfile)),
|
||||
);
|
||||
}
|
||||
usort($c,"m_log::compare_logname");
|
||||
usort($c,"m_log::compare_logtime");
|
||||
return $c;
|
||||
|
||||
}//list_logs
|
||||
|
@ -53,6 +54,11 @@ class m_log {
|
|||
return strcmp($a['name'],$b['name']);
|
||||
}
|
||||
|
||||
// Used by list_logs_directory to sort
|
||||
private function compare_logtime($a, $b) {
|
||||
return $b['mtime']-$a['mtime'];
|
||||
}
|
||||
|
||||
|
||||
function hook_menu() {
|
||||
$obj = array(
|
||||
|
@ -91,7 +97,7 @@ class m_log {
|
|||
function download_link($file){
|
||||
global $err,$mem;
|
||||
$err->log("log","download_link");
|
||||
header("Content-Disposition: attachment; filename=".$file);
|
||||
header("Content-Disposition: attachment; filename=".$file."");
|
||||
header("Content-Type: application/force-download");
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
$f=$this->get_logs_directory();
|
||||
|
@ -100,6 +106,17 @@ class m_log {
|
|||
readfile($ff);
|
||||
}
|
||||
|
||||
function tail($file,$lines=20) {
|
||||
global $err,$mem;
|
||||
$err->log("log","tail");
|
||||
$lines=intval($lines); if ($lines<=0) $lines=20;
|
||||
$f=$this->get_logs_directory();
|
||||
$ff=$f['dir']."/".basename($file);
|
||||
unset($out);
|
||||
exec("tail -".$lines." ".escapeshellarg($ff),$out);
|
||||
return implode("\n",$out);
|
||||
}
|
||||
|
||||
|
||||
} // end class
|
||||
|
||||
|
|
|
@ -13,5 +13,10 @@
|
|||
AllowOverride AuthConfig FileInfo Limit Options Indexes
|
||||
</Directory>
|
||||
|
||||
# If you want to log the errors also in /var/log/alternc/sites/
|
||||
# WARNING: this WILL FORK a vlogger for EACH VHOST havingg this !!! the load on the machine may be high
|
||||
# on hosting with many vhosts. as a consequence, this is disabled by default
|
||||
# ErrorLog "|| /usr/sbin/vlogger -e -u alterncpanel -g alterncpanel -s error.log -t \"error-%Y%m%d.log\" /var/log/alternc/sites/%%UID%%-%%LOGIN%%/"
|
||||
|
||||
</VirtualHost>
|
||||
|
||||
|
|
Loading…
Reference in New Issue