-
Notifications
You must be signed in to change notification settings - Fork 7
/
reports-messages.php
84 lines (74 loc) · 2.62 KB
/
reports-messages.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once('db-open.php');
include('local-dls.php');
include('functions.php');
require_once('session.inc');
$subsys="reports";
if (!CheckAuthByLevel('reports', $_SESSION["access_level"])) {
header_html('Dispatch :: Access Restricted');
include('include-title.php');
print "Access level too low to access Reports page.";
exit;
}
// End subclass definition
// Begin main program
if (isset($_GET["message_type"]) && isset($_GET["selected-date"])) {
$message_type = MysqlClean($_GET,"message_type",20);
$optional_type_clause = "";
if ($message_type != "All Messages") {
$optional_type_clause = "message_type = '$message_type' AND";
}
$date = MysqlClean($_GET,"selected-date",20);
syslog(LOG_INFO, $_SESSION['username'] . " generated messages report");
$query = "SELECT * FROM messages WHERE $optional_type_clause DATE_FORMAT(ts, '%Y-%m-%d') LIKE '$date%'";
$result = mysql_query($query) or die("In query: $query<br>\nError: ".mysql_error());
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Dispatch :: Reports</title>
<meta http-equiv="content-language" content="en" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="StyleSheet"
href="style.css"
type="text/css"
media="screen, print" />
<link rel="shortcut icon"
href="favicon.ico"
type="image/x-icon" />
</head>
<body vlink="blue" link="blue" alink="cyan">
<div class="h1">Messages Report</div>
<font size="-1">
<div class="text"><ul>Message type: <?php print $message_type;?><br>
Selected date: <?php print $date ?><br>
Report written at: <?php print NOW ?> <br>
</ul><p></font>
<table><tr><td bgcolor="#aaaaaa">
<table cellspacing="1">
<tr>
<td class="th">Type</td>
<td class="th">Time Logged</td>
<td class="th">From</td>
<td class="th">Message</td>
<td class="th"><font size="-2">Logged By</font></td></tr>
<?php
while ($line = mysql_fetch_object($result)) {
print "<tr bgcolor=\"white\"><td class=\"text\">".$line->message_type."</td>\n";
print "<td class=\"text\">" .date('Y-m-d',strtotime($line->ts))." ".date('H:i:s',strtotime($line->ts))."</td\n";
print "<td class=\"text\">" .$line->unit."</td>\n";
print "<td class=\"text\">" . $line->message."</td>\n";
print "<td class=\"text\">" . $line->creator."</td>\n";
print "</tr>\n\n";
}
mysql_free_result($result);
mysql_close($link);
?>
</table>
</td></tr></table>
<?php
} else {
mysql_close($link);
die("Unit selection not set.");
}
?>