69 lines
3.0 KiB
Plaintext
69 lines
3.0 KiB
Plaintext
<?php
|
|
|
|
$module = array("help" => "watchdog_help",
|
|
"cron" => "watchdog_cron",
|
|
"admin" => "watchdog_admin");
|
|
|
|
function watchdog_help() {
|
|
?>
|
|
<P>The watchdog module monitors your website, captures system events in a log and records them to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of events recorded during operation and contains usage data, performance data, errors, warnings and operational information. It is vital to check the watchdog report on a regular basis as it is often the only way to tell what is going on.</P>
|
|
<P>To ease administration, the watchdog will automatically remove old logs.</P>
|
|
<?php
|
|
}
|
|
|
|
function watchdog_cron() {
|
|
db_query("DELETE FROM watchdog WHERE ". time() ." - timestamp > ". variable_get(watchdog_clear, "302400"));
|
|
}
|
|
|
|
function watchdog_overview() {
|
|
$colors = array(message => "#FFFFFF", special => "#836FFF", warning => "#FFAA22", error => "#EE2C2C");
|
|
|
|
$result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id ORDER BY timestamp DESC LIMIT 1000");
|
|
|
|
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
|
|
$output .= " <TR><TH>date</TH><TH>type</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n";
|
|
while ($watchdog = db_fetch_object($result)) {
|
|
if ($color = $colors[$watchdog->type]) {
|
|
$output .= " <TR BGCOLOR=\"$color\"><TD>". format_date($watchdog->timestamp) ."</TD><TD ALIGN=\"center\">$watchdog->link</TD><TD>". substr(check_output($watchdog->message), 0, 50) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
|
|
}
|
|
}
|
|
$output .= "</TABLE>\n";
|
|
|
|
return $output;
|
|
}
|
|
|
|
function watchdog_view($id) {
|
|
$result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'");
|
|
|
|
if ($watchdog = db_fetch_object($result)) {
|
|
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
|
|
$output .= " <TR><TH>Type:</TH><TD>". check_output($watchdog->type) ."</TD></TR>\n";
|
|
$output .= " <TR><TH>Date:</TH><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n";
|
|
$output .= " <TR><TH>User:</TH><TD>". format_username($watchdog->userid) ."</TD></TR>\n";
|
|
$output .= " <TR><TH>Location:</TH><TD>". check_output($watchdog->location). "</TD></TR>\n";
|
|
$output .= " <TR><TH>Message:</TH><TD>". check_output($watchdog->message) ."</TD></TR>\n";
|
|
$output .= " <TR><TH>Hostname:</TH><TD>". check_output($watchdog->hostname) ."</TD></TR>\n";
|
|
$output .= "</TABLE>\n";
|
|
|
|
return $output;
|
|
}
|
|
}
|
|
|
|
function watchdog_admin() {
|
|
global $op, $id, $order;
|
|
|
|
print "<SMALL><A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n";
|
|
|
|
switch ($op) {
|
|
case "help":
|
|
watchdog_help();
|
|
break;
|
|
case "view":
|
|
print watchdog_view(check_input($id));
|
|
break;
|
|
default:
|
|
print watchdog_overview();
|
|
}
|
|
}
|
|
|
|
?> |