2 # Show a form for editing or creating a log destination
4 require './syslog-ng-lib.pl';
7 # Show title and get the destination
10 &ui_print_header(undef, $text{'destination_title1'}, "");
13 &ui_print_header(undef, $text{'destination_title2'}, "");
14 @dests = &find("destination", $conf);
15 ($dest) = grep { $_->{'value'} eq $in{'name'} } @dests;
16 $dest || &error($text{'destination_egone'});
20 print &ui_form_start("save_destination.cgi", "post");
21 print &ui_hidden("new", $in{'new'}),"\n";
22 print &ui_hidden("old", $in{'name'}),"\n";
23 print &ui_table_start($text{'destination_header'}, undef, 2);
26 print &ui_table_row($text{'destination_name'},
27 &ui_textbox("name", $dest->{'value'}, 20));
30 $file = &find("file", $dest->{'members'});
31 $usertty = &find("usertty", $dest->{'members'});
32 $program = &find("program", $dest->{'members'});
33 $pipe = &find("pipe", $dest->{'members'});
34 $udp = &find("udp", $dest->{'members'});
35 $tcp = &find("tcp", $dest->{'members'});
36 $dgram = &find("unix-dgram", $dest->{'members'});
37 $stream = &find("unix-stream", $dest->{'members'});
47 $dtable = "<table>\n";
51 $file_name = $file->{'value'};
52 $file_owner = &find_value("owner", $file->{'members'});
53 $file_group = &find_value("group", $file->{'members'});
54 $file_perm = &find_value("perm", $file->{'members'});
55 $file_create_dirs = &find_value("create_dirs", $file->{'members'});
56 $file_dir_perm = &find_value("dir_perm", $file->{'members'});
57 $file_fsync = &find_value("fsync", $file->{'members'});
58 $file_sync_freq = &find_value("sync_freq", $file->{'members'});
60 $dtable .= "<tr> <td valign=top>".&ui_oneradio("type", 0, "<b>$text{'destinations_typef'}</b>", $type == 0)."</td> <td valign=top><table>\n";
61 $dtable .= "<tr> <td>$text{'destination_file'}</td> <td>".
62 &ui_textbox("file_name", $file_name, 35)." ".
63 &file_chooser_button("file_name")."</td> </tr>\n";
64 $dtable .= "<tr> <td>$text{'destination_owner'}</td> <td>".
65 &ui_opt_textbox("file_owner", $file_owner, 15, $text{'default'})." ".
66 &user_chooser_button("file_owner").
68 $dtable .= "<tr> <td>$text{'destination_group'}</td> <td>".
69 &ui_opt_textbox("file_group", $file_group, 15, $text{'default'})." ".
70 &group_chooser_button("file_owner").
72 $dtable .= "<tr> <td>$text{'destination_perm'}</td> <td>".
73 &ui_opt_textbox("file_perm", $file_perm, 5, $text{'default'}).
75 $dtable .= "<tr> <td>$text{'destination_create_dirs'}</td> <td>".
76 &ui_radio("file_create_dirs", $file_create_dirs,
77 [ [ 'yes', $text{'yes'} ],
78 [ 'no', $text{'no'} ],
79 [ '', $text{'default'} ] ]).
81 $dtable .= "<tr> <td>$text{'destination_dir_perm'}</td> <td>".
82 &ui_opt_textbox("file_dir_perm", $file_dir_perm, 5,$text{'default'}).
84 $dtable .= "<tr> <td>$text{'destination_fsync'}</td> <td>".
85 &ui_radio("file_fsync", $file_fsync,
86 [ [ 'yes', $text{'yes'} ],
87 [ 'no', $text{'no'} ],
88 [ '', $text{'default'} ] ]).
90 $dtable .= "<tr> <td>$text{'destination_sync_freq'}</td> <td>".
91 &ui_opt_textbox("file_sync_freq", $file_sync_freq, 5, $text{'default'}).
93 $dtable .= "</table></td> </tr>";
95 # User TTY destination
97 $usertty_user = $usertty->{'value'};
99 $dtable .= "<tr> <td valign=top>".&ui_oneradio("type", 1, "<b>$text{'destinations_typeu'}</b>", $type == 1)."</td> <td valign=top>\n";
100 $dtable .= &ui_opt_textbox("usertty_user", $usertty_user eq "*" ? undef : $usertty_user, 20, $text{'destinations_allusers'}, $text{'destination_users'})." ".&user_chooser_button("usertty_user", 1);
101 $table .= "</td> </tr>";
103 # Program destination
105 $program_prog = $program->{'value'};
107 $dtable .= "<tr> <td valign=top>".&ui_oneradio("type", 2, "<b>$text{'destinations_typep'}</b>", $type == 2)."</td> <td valign=top>\n";
108 $dtable .= &ui_textbox("program_prog", $program_prog, 50);
109 $table .= "</td> </tr>";
113 $pipe_name = $pipe->{'value'};
115 $dtable .= "<tr> <td valign=top>".&ui_oneradio("type", 3, "<b>$text{'destinations_typei'}</b>", $type == 3)."</td> <td valign=top>\n";
116 $dtable .= &ui_textbox("pipe_name", $pipe_name, 30)." ".
117 &file_chooser_button("pipe_name");
118 $dtable .= "</td> </tr>";
123 $net_host = $net->{'value'};
124 $net_port = &find_value("port", $net->{'members'});
125 $net_localip = &find_value("localip", $net->{'members'});
126 $net_localport = &find_value("localport", $net->{'members'});
128 $dtable .= "<tr> <td valign=top>".&ui_oneradio("type", 4, "<b>$text{'destination_net'}</b>", $type == 4 || $type == 5)."</td> <td valign=top><table>\n";
129 $dtable .= "<tr> <td>$text{'destination_proto'}</td> ".
130 "<td>".&ui_select("net_proto", $type == 5 ? "udp" : "tcp",
131 [ [ "tcp", "TCP" ], [ "udp", "UDP" ] ])."</td> </tr>\n";
132 $dtable .= "<tr> <td>$text{'destination_host'}</td> ".
133 "<td>".&ui_textbox("net_host", $net_host, 20)."</td> </tr>\n";
134 $dtable .= "<tr> <td>$text{'destination_port'}</td> ".
135 "<td>".&ui_opt_textbox("net_port", $net_port, 5, "$text{'default'} (514)")."</td> </tr>\n";
136 $dtable .= "<tr> <td>$text{'destination_localip'}</td> ".
137 "<td>".&ui_opt_textbox("net_localip", $net_localip, 15, $text{'default'})."</td> </tr>\n";
138 $dtable .= "<tr> <td>$text{'destination_localport'}</td> ".
139 "<td>".&ui_opt_textbox("net_localport", $net_localport, 5, $text{'default'})."</td> </tr>\n";
140 $dtable .= "</table></td> </tr>";
142 # Datagram or stream socket
143 $unix = $dgram || $stream;
145 $unix_name = $unix->{'value'};
147 $dtable .= "<tr> <td valign=top>".&ui_oneradio("type", 6, "<b>$text{'destination_unix'}</b>", $type == 6 || $type == 7)."</td> <td valign=top><table>\n";
148 $dtable .= "<tr> <td>$text{'destination_utype'}</td> ".
149 "<td>".&ui_select("unix_type",
150 $type == 6 ? "unix-dgram" : "unix-stream",
151 [ [ "unix-stream", $text{'destinations_types'} ],
152 [ "unix-dgram", $text{'destinations_typeg'} ] ]).
154 $dtable .= "<tr> <td>$text{'destination_socket'}</td> ".
155 "<td>".&ui_textbox("unix_name", $unix_name, 30)."\n".
156 &file_chooser_button("unix_name")."</td> </tr>\n";
157 $dtable .= "</table></td> </tr>";
159 # Actually show the destination
160 $dtable .= "</table>\n";
161 print &ui_table_row($text{'destination_type'}, $dtable);
163 # Form footer and buttons
164 print &ui_table_end();
166 print &ui_form_end([ [ "create", $text{'create'} ] ]);
169 print &ui_form_end([ [ "save", $text{'save'} ],
170 [ "delete", $text{'delete'} ] ]);
172 &ui_print_footer("list_destinations.cgi", $text{'destinations_return'});