3 # Display icons for defined PPTP tunnels
5 require './pptp-client-lib.pl';
7 $vers = &get_pppd_version(\$out);
8 &ui_print_header(undef, $text{'index_title'}, undef, "intro", 1, 1, 0, undef, undef, undef,
9 $vers ? &text('index_version', $vers) : undef);
11 # Create the PPTP options file if non-existent. This ensures that it can be
12 # used in the peer scripts, even if it is empty
13 if (!-r $config{'pptp_options'} && $config{'pptp_options'}) {
14 &open_tempfile(OPTS, ">>$config{'pptp_options'}");
15 &close_tempfile(OPTS);
18 if (!&has_command($config{'pptp'})) {
19 # The PPTP command is not installed
20 print "<p>",&text('index_epptp', "<tt>$config{'pptp'}</tt>",
21 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
24 # The PPP daemon is not installed
25 print "<p>",&text('index_epppd', "<tt>pppd</tt>"),"<p>\n";
29 @tunnels = &list_tunnels();
30 %tunnels = map { $_->{'name'}, 1 } @tunnels;
31 print &ui_subheading($text{'index_header'});
33 @links = map { "edit.cgi?tunnel=$_->{'name'}" } @tunnels;
34 @titles = map { $_->{'name'} } @tunnels;
35 @icons = map { "images/tunnel.gif" } @tunnels;
36 &icons_table(\@links, \@titles, \@icons);
39 print "<b>$text{'index_none'}</b><p>\n";
41 print "<a href='edit.cgi?new=1'>$text{'index_add'}</a><p>\n";
44 print "<table width=100%>\n";
45 print "<tr><form action=edit_opts.cgi>\n";
46 print "<td><input type=submit ",
47 "value='$text{'index_opts'}'></td>\n";
48 print "<td>$text{'index_optsdesc'}</td>\n";
49 print "</form></tr>\n";
51 @conns = grep { $tunnels{$_->[0]} } &list_connected();
52 %conns = map { @$_ } @conns;
53 @notconns = grep { !$conns{$_->{'name'}} } @tunnels;
56 # Show connect button, if any are disconnected
57 print "<tr><form action=conn.cgi><td nowrap>\n";
58 print "<input type=submit value='$text{'index_conn'}'>\n";
59 print "<select name=tunnel>\n";
60 foreach $t (@notconns) {
61 printf "<option %s>%s\n",
62 $config{'tunnel'} eq $t->{'name'} ? "selected" : "",
66 print $text{'index_pass'}," ",&ui_password("cpass", undef, 10);
68 print "<td>$text{'index_conndesc'}</td> </form></tr>\n";
72 # If any tunnels appear to be active, show disconnect button
73 print "<tr><form action=disc.cgi><td nowrap>\n";
74 print "<input type=submit value='$text{'index_disc'}'>\n";
75 print "<select name=tunnel>\n";
77 printf "<option %s>%s\n",
78 $config{'tunnel'} eq $t->[0] ? "selected" : "",
81 print "</select></td>\n";
82 print "<td>$text{'index_discdesc'}</td> </form></tr>\n";
86 if (&foreign_check("init") && @tunnels) {
88 &foreign_require("init", "init-lib.pl");
89 $starting = &init::action_status($module_name);
90 $config{'boot'} = undef if ($starting != 2);
91 print "<form action=bootup.cgi>\n";
92 print "<input type=hidden name=starting value='$starting'>\n";
93 print "<td nowrap><input type=submit value='$text{'index_boot'}'>\n";
94 print "<select name=tunnel>\n";
95 printf "<option value='' %s>%s\n",
96 $config{'boot'} ? "" : "selected",
97 $text{'index_noboot'};
98 foreach $t (@tunnels) {
99 printf "<option value='%s' %s>%s\n",
101 $t->{'name'} eq $config{'boot'} ?
105 print "</select></td>\n";
106 print "<td>$text{'index_bootdesc'}</td>\n";
107 print "</form></tr>\n";
113 &ui_print_footer("/", $text{'index'});