3 # Display available apache or squid logfiles
5 require './webalizer-lib.pl';
6 &foreign_require("cron", "cron-lib.pl");
8 # Check if webalizer is actually installed
9 if (!&has_command($config{'webalizer'})) {
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
11 &help_search_link("webalizer", "man", "doc", "google"));
12 print &text('index_ewebalizer', "<tt>$config{'webalizer'}</tt>",
13 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
15 &foreign_require("software", "software-lib.pl");
16 $lnk = &software::missing_install_link(
17 "webalizer", $text{'index_webalizer'},
18 "../$module_name/", $text{'index_title'});
19 print $lnk,"<p>\n" if ($lnk);
21 &ui_print_footer("/", $text{'index'});
25 # Get the version number
26 $webalizer_version = &get_webalizer_version(\$out);
27 if (!$webalizer_version) {
28 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
29 &help_search_link("webalizer", "man", "doc", "google"));
30 print &text('index_egetversion',
31 "<tt>$config{'webalizer'} -v</tt>",
32 "<pre>$out</pre>"),"<p>\n";
33 &ui_print_footer("/", $text{'index'});
37 if ($webalizer_version < 2) {
39 print &text('index_eversion', "<tt>$config{'webalizer'}</tt>",
40 "$webalizer_version", "2.0"),"<p>\n";
41 &ui_print_footer("/", $text{'index'});
45 # Check if the config file exists
46 if (!-r $config{'webalizer_conf'}) {
48 print &text('index_econf', "<tt>$config{'webalizer_conf'}</tt>",
49 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
50 &ui_print_footer("/", $text{'index'});
54 # Query apache and squid for their logfiles
55 @logs = &get_all_logs();
57 # Remove in-accessible logs, and redirect if only one
58 @logs = grep { &can_edit_log($_->{'file'}) } @logs;
59 if (@logs == 1 && -r $logs[0]->{'file'} &&
60 $access{'noconfig'} && !$access{'add'} && !$access{'global'}) {
61 # User can only edit/view one log file ..
63 if ($access{'view'}) {
64 &redirect("view_log.cgi/".&urlize(&urlize($l->{'file'})).
68 &redirect("edit_log.cgi?file=".&urlize($l->{'file'}).
69 "&type=$l->{'type'}&custom=$l->{'custom'}");
77 if (!$access{'view'}) {
78 print &ui_form_start("mass.cgi", "post");
79 push(@links, &select_all_link("d"),
80 &select_invert_link("d"));
82 push(@links, "<a href='edit_log.cgi?new=1'>$text{'index_add'}</a>")
83 if (!$access{'view'} && $access{'add'});
84 print &ui_links_row(\@links);
85 local @tds = ( "width=5" );
86 print &ui_columns_start([ $access{'view'} ? ( ) : ( "" ),
91 $text{'index_rep'} ], 100, 0, \@tds);
93 next if ($done{$l->{'file'}}++);
94 local @files = &all_log_files($l->{'file'});
96 local $lconf = &get_log_config($l->{'file'});
98 local $short = $l->{'file'};
99 if (length($short) > 40) {
100 $short = "...".substr($short, -40);
102 if ($access{'view'}) {
106 push(@cols, "<a href='edit_log.cgi?file=".
107 &urlize($l->{'file'}).
108 "&type=$l->{'type'}&custom=$l->{'custom'}'>".
111 push(@cols, &text('index_type'.$l->{'type'}));
112 local ($size, $latest);
113 foreach $f (@files) {
114 local @st = stat($f);
116 $latest = $st[9] if ($st[9] > $latest);
118 $latest = $latest ? localtime($latest) : "<br>";
119 push(@cols, $size ? &nice_size($size) : $text{'index_empty'});
120 push(@cols, $lconf->{'sched'} ?
121 &text('index_when', &cron::when_text($lconf)) :
123 if ($lconf->{'dir'} && -r "$lconf->{'dir'}/index.html") {
124 push(@cols, "<a href='view_log.cgi/".
125 &urlize(&urlize($l->{'file'})).
126 "/index.html'>$text{'index_view'}</a>");
131 if ($access{'view'}) {
132 print &ui_columns_row(\@cols);
135 print &ui_columns_row([ "<img src=images/empty.gif>",
139 print &ui_checked_columns_row(\@cols, \@tds, "d",
143 print &ui_columns_end();
146 print "<p><b>$text{'index_nologs'}</b><p>\n";
147 push(@links, "<a href='edit_log.cgi?new=1'>$text{'index_add'}</a>")
148 if (!$access{'view'} && $access{'add'});
150 print &ui_links_row(\@links);
151 if (@logs && !$access{'view'}) {
152 print &ui_form_end([ [ "enable", $text{'index_enable'} ],
153 [ "disable", $text{'index_disable'} ] ]);
156 if (!$access{'view'} && $access{'global'}) {
158 print "<form action=edit_global.cgi>\n";
159 print "<table width=100%><tr>\n";
160 print "<td><input type=submit value='$text{'index_global'}'></td>\n";
161 print "<td>$text{'index_globaldesc'}</td>\n";
162 print "</tr></table></form>\n";
165 &ui_print_footer("/", $text{'index'});
169 local $prog = &get_webalizer_prog();
170 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
171 &help_search_link($prog, "man", "doc", "google"),
172 undef, undef, &text('index_version_'.$prog, $webalizer_version));