2 # interface_chooser.cgi
4 # Based on user_chooser.cgi by Jamie Cameron
5 # (c) Tomas Pospisek <tpo_deb@sourcepole.ch>
6 # Licensed under the webmin license
9 # Sourcepole http://sourcepole.ch
10 # under contract from:
11 # AO Media Services http://www.ao-asif.ch/aoi/media/
15 # replace active_interfaces by a merged list from active_* and boot_interfaces
17 # This CGI generated the HTML for choosing an interface or a list of interfaces.
19 require './net-lib.pl';
22 %access = &get_module_acl();
25 # selecting multiple interfaces.
26 if ($in{'frame'} == 0) {
30 @il = split(/\s+/, $in{'interface'});
32 print "sel = new Array($len);\n";
33 for($i=0; $i<$len; $i++) {
34 print "sel[$i] = \"$il[$i]\";\n";
37 print "<title>$text{'interfaces_title1'}</title>\n";
38 print "<frameset cols='50%,50%'>\n";
39 print "<frame src=\"/net/interface_chooser.cgi?frame=1&multi=1\">\n";
40 print "<frameset rows='*,50' frameborder=no>\n";
41 print " <frame src=\"/net/interface_chooser.cgi?frame=2&multi=1\">\n";
42 print " <frame src=\"/net/interface_chooser.cgi?frame=3&multi=1\" scrolling=no>\n";
43 print "</frameset>\n";
44 print "</frameset>\n";
46 elsif ($in{'frame'} == 1) {
47 # list of all interfaces to choose from
48 &ui_print_header(undef, );
50 print "function addinterface(i)\n";
52 print "top.sel[top.sel.length] = i\n";
53 print "top.frames[1].location = top.frames[1].location\n";
54 print "return false;\n";
57 print "<font size=+1>$text{'interfaces_all'}</font>\n";
58 print "<table width=100%>\n";
59 foreach $if (&active_interfaces()) {
60 if ($in{'interface'} eq $if->{'fullname'}) { print "<tr $cb>\n"; }
61 else { print "<tr>\n"; }
62 print "<td width=20%><a href=\"\" onClick='return addinterface(\"$if->{'fullname'}\")'>$if->{'fullname'}</a></td>\n";
66 elsif ($in{'frame'} == 2) {
67 # show chosen interfaces
68 &ui_print_header(undef, );
69 print "<font size=+1>$text{'interfaces_sel'}</font>\n";
76 for(k=0,l=0; k<top.sel.length; k++) {
83 top.frames[1].location = top.frames[1].location;
86 for(i=0; i<top.sel.length; i++) {
87 document.write("<tr>\n");
88 document.write("<td><a href=\"\" onClick='return sub("+i+")'>"+top.sel[i]+"</a></td>\n");
94 elsif ($in{'frame'} == 3) {
95 # output OK and Cancel buttons
96 &ui_print_header(undef, );
98 print "<input type=button value=\"$text{'interfaces_ok'}\" ",
99 "onClick='top.ifield.value = top.sel.join(\" \"); ",
101 print "<input type=button value=\"$text{'interfaces_cancel'}\" ",
102 "onClick='top.close()'>\n";
103 print " <input type=button value=\"$text{'interfaces_clear'}\" onClick='top.sel = new Array(); top.selr = new Array(); top.frames[1].location = top.frames[1].location'>\n";
108 # selecting just one interface .. display a list of all interfaces to choose from
109 &ui_print_header(undef, );
111 print "function select(f)\n";
113 print "ifield.value = f;\n";
114 print "top.close();\n";
115 print "return false;\n";
118 print "<title>$text{'interfaces_title2'}</title>\n";
119 print "<table width=100%>\n";
120 foreach $if (&active_interfaces()) {
121 if ($in{'interface'} eq $if->{'fullname'}) { print "<tr $cb>\n"; }
122 else { print "<tr>\n"; }
123 print "<td width=20%><a href=\"\" onClick='return select(\"$if->{'fullname'}\")'>$if->{'fullname'}</a></td></tr>\n";