This repository has been archived by the owner on Jun 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
archived.php
149 lines (121 loc) · 4.1 KB
/
archived.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
require 'inc/pre.inc.php';
define('TITLE', _('Archived'));
require 'tpl/head.inc.php';
define('INC_FOOTER', 'tpl/foot.inc.php');
$l = null;
try {
$l = new Lggr($state, $config);
}
catch (LggrException $e) {
echo '<div class="container"><div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div></div>';
require INC_FOOTER;
exit();
}
$page = $state->getPage();
try {
$aEvents = $l->getArchived($page * LggrState::PAGELEN, LggrState::PAGELEN);
$searchvalue = '';
$searchvalueprog = '';
$isSearch = false;
}
catch (LggrException $e) {
echo '<div class="container"><div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div></div>';
require INC_FOOTER;
exit();
}
if (version_compare(phpversion(), '5.4', '<')) {
echo '<div class="container"><div class="alert alert-danger" role="alert">Your PHP version ' .
phpversion() . ' might be too old, expecting at least 5.4</div></div>';
} // if
require 'tpl/nav.inc.php';
?>
<div class="container" id="infoheader">
<?= _('Archived') ?>, <a href="./do.php?a=exportarchive"
target="_blank">export</a> to csv.
</div>
<div class="container">
<?php
if (0 == count($aEvents)) {
echo '<div class="alert alert-danger" role="alert">' . _('empty result') .
'</div>';
} // if
?>
</div>
<!-- class container for fixed max width, or container-fluid for maximum width -->
<div class="container-fluid datablock">
<?php
if (! $isSearch) {
include 'tpl/paginate.inc.php';
} // if
include 'tpl/containerhead.inc.php';
$i = 0;
foreach ($aEvents as $event) {
$i ++;
if (0 == $i % 2) {
$rowclass = 'even';
} else {
$rowclass = 'odd';
} // if
switch ($event->level) {
case 'emerg':
$label = '<span class="label label-danger">Emergency</span>';
break;
case 'crit':
$label = '<span class="label label-danger">Critical</span>';
break;
case 'err':
$label = '<span class="label label-danger">Error</span>';
break;
case 'warning':
$label = '<span class="label label-warning">Warning</span>';
break;
case 'notice':
$label = '<span class="label label-primary">Notice</span>';
break;
case 'info':
$label = '<span class="label label-success">Info</span>';
break;
default:
$label = '<span class="label label-default">' . $event->level .
'</span>';
} // switch
switch ($event->archived) {
case 'Y':
$archived = '<span id="arch' . $event->id .
'" class="lggr-archived glyphicon glyphicon-warning-sign" aria-hidden="true" title="archived"></span>';
break;
case 'N':
$archived = '<span id="arch' . $event->id .
'" class="lggr-notarchived glyphicon glyphicon-pushpin" aria-hidden="true" title=""></span>';
break;
default:
$archived = '?';
} // switch
$host = htmlentities($event->host, ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES);
$program = htmlentities($event->program,
ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES);
$msg = htmlentities($event->message, ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES);
echo <<<EOL
<div class="row datarow $rowclass" data-id="{$event->id}">
<div class="col-md-2 col-xs-6 newlog-date">{$event->date}</div>
<div class="col-md-1 col-xs-2">{$event->facility}</div>
<div class="col-md-1 col-xs-2">$archived $label</div>
<div class="col-md-1 col-xs-2">$host</div>
<div class="col-md-2 col-xs-12">$program</div>
<div class="col-md-5 col-xs-12 newlog-msg" title="$msg"><tt>{$msg}</tt></div>
</div><!-- row -->
EOL;
} // foreach
?>
<div id="dialog" title="Details">I'm a dialog</div>
<?php
if (! $isSearch) {
include 'tpl/paginate.inc.php';
} // if
?>
</div>
<?php
$aPerf = $l->getPerf();
require INC_FOOTER;
?>