3 # Display a form for adding a new logfile or editing an existing one.
4 # Allows you to set the schedule on which the log is analysed
6 require './webalizer-lib.pl';
7 &foreign_require("cron", "cron-lib.pl");
9 $access{'view'} && &error($text{'edit_ecannot'});
11 $access{'add'} || &error($text{'edit_ecannot'});
12 &ui_print_header(undef, $text{'edit_title1'}, "");
15 &can_edit_log($in{'file'}) || &error($text{'edit_ecannot'});
16 &ui_print_header(undef, $text{'edit_title2'}, "");
17 $lconf = &get_log_config($in{'file'});
20 print "<form action=save_log.cgi>\n";
21 print "<input type=hidden name=new value='$in{'new'}'>\n";
22 print "<input type=hidden name=oldfile value='$in{'file'}'>\n";
24 print "<table border width=100% class='ui_table'>\n";
25 print "<tr $tb> <td><b>$text{'edit_header'}</b></td> </tr>\n";
26 print "<tr $cb> <td><table width=100%>\n";
28 print "<tr> <td><b>$text{'edit_file'}</b></td> <td colspan=3>\n";
30 print "<input name=file size=50> ",&file_chooser_button("file");
33 print "<input type=hidden name=file value='$in{'file'}'>\n";
34 print "<tt>$in{'file'}</tt>";
36 print "</td> </tr>\n";
39 @all = &all_log_files($in{'file'});
41 print "<tr> <td valign=top><b>$text{'edit_files'}</b></td> ",
42 "<td colspan=3><font size=-1>\n";
46 print "</font></td> </tr>\n";
50 print "<tr> <td><b>$text{'edit_type'}</b></td> <td>\n";
52 print "<select name=type>\n";
53 for($i=1; defined($t = $text{'index_type'.$i}); $i++) {
54 print "<option value=$i>$t\n";
59 print "<input type=hidden name=type value='$in{'type'}'>\n";
60 print $text{'index_type'.$in{'type'}};
64 print "<tr> <td><b>$text{'edit_dir'}</b></td> <td colspan=3>\n";
65 printf "<input name=dir size=50 value='%s'> %s</td> </tr>\n",
66 $lconf->{'dir'}, &file_chooser_button("dir", 1);
68 print "<tr> <td><b>$text{'edit_user'}</b></td>\n";
69 if ($access{'user'} eq '*') {
70 # User that webalizer runs as can be chosen
71 printf "<td><input name=user size=13 value='%s'> %s</td> </tr>\n",
72 $lconf->{'user'} || "root";
76 printf "<td><tt>%s</tt></td> </tr>\n",
77 !$in{'new'} && $lconf->{'dir'} ? $lconf->{'user'} || "root" :
78 $access{'user'} eq "" ? $remote_user : $access{'user'};
81 print "<tr> <td><b>$text{'edit_over'}</b></td>\n";
82 printf "<td><input type=radio name=over value=1 %s> %s\n",
83 $lconf->{'over'} ? "checked" : "", $text{'yes'};
84 printf "<input type=radio name=over value=0 %s> %s</td> </tr>\n",
85 $lconf->{'over'} ? "" : "checked", $text{'no'};
87 $cfile = &config_file_name($in{'file'});
88 $cmode = -l $cfile ? 2 : -r $cfile ? 1 : 0;
89 print "<tr> <td><b>$text{'edit_conf'}</b></td> <td nowrap>\n";
90 printf "<input type=radio name=cmode value=0 %s> %s\n",
91 $cmode == 0 ? "checked" : "", $text{'edit_cmode0'};
92 printf "<input type=radio name=cmode value=1 %s> %s\n",
93 $cmode == 1 ? "checked" : "", $text{'edit_cmode1'};
94 printf "<input type=radio name=cmode value=2 %s> %s\n",
95 $cmode == 2 ? "checked" : "", $text{'edit_cmode2'};
96 printf "<input name=cfile size=20 value='%s'> %s</td> </tr>\n",
97 $cmode == 2 ? readlink($cfile) : "", &file_chooser_button("cfile");
99 print "<tr> <td><b>$text{'edit_sched'}</b></td> <td colspan=3>\n";
100 printf "<input type=radio name=sched value=0 %s> %s\n",
101 $lconf->{'sched'} ? "" : "checked", $text{'edit_sched0'};
102 printf "<input type=radio name=sched value=1 %s> %s</td> </tr>\n",
103 $lconf->{'sched'} ? "checked" : "", $text{'edit_sched1'};
105 print "<tr> <td><b>$text{'edit_clear'}</b></td>\n";
106 printf "<td><input type=radio name=clear value=1 %s> %s\n",
107 $lconf->{'clear'} ? "checked" : "", $text{'yes'};
108 printf "<input type=radio name=clear value=0 %s> %s</td> </tr>\n",
109 $lconf->{'clear'} ? "" : "checked", $text{'no'};
113 print "<table border width=100%>\n";
114 if ($lconf->{'mins'} eq '') {
115 $lconf->{'mins'} = $lconf->{'hours'} = 0;
116 $lconf->{'days'} = $lconf->{'months'} = $lconf->{'weekdays'} = '*';
118 &foreign_call("cron", "show_times_input", $lconf);
121 print "</td></tr></table>\n";
124 push(@b, "<input type=submit value='$text{'create'}'>");
127 push(@b, "<input type=submit value='$text{'save'}'>");
128 push(@b, "<input type=submit name=global value='$text{'edit_global'}'>")
130 if ($lconf->{'dir'}) {
131 push(@b, "<input type=submit name=run value='$text{'edit_run'}'>");
133 if ($lconf->{'dir'} && -r "$lconf->{'dir'}/index.html") {
134 push(@b, "<input type=submit name=view value='$text{'edit_view'}'>");
137 push(@b, "<input type=submit name=delete value='$text{'delete'}'>");
143 &ui_print_footer("", $text{'index_return'});