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
|
#!/usr/bin/perl
#
# This file is part of the exilog suite.
#
# http://duncanthrax.net/exilog/
#
# (c) Tom Kistner 2004
#
# See LICENSE for licensing information.
#
use strict;
use lib "/usr/lib/exilog";
use lib "/usr/lib/cgi-bin/exilog";
use exilog_config;
use exilog_util;
use exilog_cgi_html;
use exilog_cgi_param;
use exilog_sql;
# Put user name into global variable
my $user = $ENV{'REMOTE_USER'} || 'anonymous';
# XMLHTTP requests are handled here.
# We only return short result statements
# in text/plain format for those.
if ($param->{'xmlhttp'} == 1) {
print $q->header(-expires=>'Thursday, 01-Jan-1970 00:00:01 GMT',
-Expires=>'now',
-Content-Type=>'text/plain',
-Cache-Control=>'no-cache',
-Cache-Control=>'no-store',
-Pragma=>'no-cache');
print _do_xmlhttp_actions();
exit(0);
}
_print_cgi_headers();
_print_html_header();
_print_html_tabs();
print '<div class="display" align="center">';
if ($param->{tab} eq 'queues') {
use exilog_cgi_queues;
queues();
}
elsif ($param->{tab} eq 'messages') {
use exilog_cgi_messages;
messages();
}
elsif ($param->{tab} eq 'servers') {
use exilog_cgi_servers;
servers();
};
print '</div>';
_print_html_footer();
# -- Private functions ---------------------------------------------------------
sub _do_xmlhttp_actions {
# queue actions
my $valid_actions = [ 'deliver', 'cancel', 'delete' ];
my $restricted_actions = [ 'cancel', 'delete' ];
my $action_text = { 'deliver' => 'Forcing', 'cancel' => 'Cancelling', 'delete' => 'Deleting' };
if ( ina($valid_actions,$param->{'action'}) &&
!(ina($restricted_actions,$param->{'action'}) && ina($config->{web}->{restricted_users},$main::user)) ) {
sql_queue_set_action($param->{'server'},$param->{'message_id'},$param->{'action'});
return $action_text->{$param->{'action'}};
}
return 0;
};
sub _print_cgi_headers {
print $q->header(-expires=>'Thursday, 01-Jan-1970 00:00:01 GMT',
-Expires=>'now',
-Cache-Control=>'no-cache',
-Cache-Control=>'no-store',
-Pragma=>'no-cache');
};
sub _print_html_header {
print $q->start_html({-title=>"Exilog ".$version,
-style=>{-src=>$config->{web}->{webroot}."exilog_stylesheet.css"},
-script=>[
{-language=>'JAVASCRIPT',
-src=>$config->{web}->{webroot}."exilog_jscript.js"},
"document.write(getCalendarStyles());"
],
-meta=>{'http-equiv' => 'pragma', 'content' => 'no-cache'}});
# global "centering" div
print $q->start_form({-name=>"exilogform",-method=>"POST", enctype => "multipart/form-data"});
print '<div align="center">';
print '<div align="center" class="body">';
};
sub _print_html_tabs {
my $tabs = { 'servers' => "Servers",
'messages' => "Messages",
'queues' => "Queues",
'messages' => "Messages" };
my $html;
foreach my $tab (sort keys %{ $tabs }) {
$html .= $q->td({-class=>"tabs_spacer"}," ").
(($param->{"tab"} eq $tab) ?
$q->td({-class=>"tabs_active"},$tabs->{$tab})
:
$q->td({-class=>"tabs_click", -onClick=>"javascript:load_tab('$tab');"},$tabs->{$tab}));
};
print $q->table({-class=>"tabs",-cellpadding=>2,-cellspacing=>0},
$q->Tr(
$q->td({-align=>"center",-class=>"tabs_static",-style=>"font-size: 16px; font-weight: bold;" }, "Exilog").
$html.
$q->td({-class=>"tabs_spacer"}," ").
$q->td({-align=>"center",-class=>"tabs_static",-style=>"font-size: 12px; width: 240px; white-space: nowrap;" }, " Server time".(($config->{web}->{timestamps} eq 'gmt') ? " (GMT)":"").": ".stamp_to_date(time())." ")
)
);
print $q->input({-type=>"hidden",-name=>"tab",-id=>"tab",-override=>1,-value=>$param->{"tab"}});
};
sub _print_html_footer {
print '</div></div>';
print $q->end_form();
print $q->end_html();
};
|