-
Notifications
You must be signed in to change notification settings - Fork 1
/
logfile.php
executable file
·44 lines (35 loc) · 1.12 KB
/
logfile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php require_once("../includes/initialize.php"); ?>
<?php if (!$session->is_logged_in()) { redirect_to("login.php"); } ?>
<?php
$logfile = SITE_ROOT.DS.'logs'.DS.'log.txt';
if($_GET['clear'] == 'true') {
file_put_contents($logfile, '');
// Add the first log entry
log_action('Logs Cleared', "by {$session->uname} with User ID : {$session->user_id}");
// redirect to this same page so that the URL won't
// have "clear=true" anymore
redirect_to('logfile.php');
}
?>
<?php include_layout_template('admin_header.php'); ?>
<a href="index.php">« Back</a><br />
<br />
<h2>Log File</h2>
<p><a href="logfile.php?clear=true">Clear log file</a><p>
<?php
if( file_exists($logfile) && is_readable($logfile) &&
$handle = fopen($logfile, 'r')) { // read
echo "<ul class=\"log-entries\">";
while(!feof($handle)) {
$entry = fgets($handle);
if(trim($entry) != "") {
echo "<li>{$entry}</li>";
}
}
echo "</ul>";
fclose($handle);
} else {
echo "Could not read from {$logfile}.";
}
?>
<?php include_layout_template('admin_footer.php'); ?>