#!/usr/local/bin/perl # index.cgi # Display a list of connections require './ppp-client-lib.pl'; &foreign_require("proc", "proc-lib.pl"); # Check if wvdial is installed if (!&has_command($config{'wvdial'}) || ($out = &proc::pty_backquote("$config{'wvdial'} --version")) !~ /WvDial\s+([^: \n\r]+)/i) { &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1); print "

",&text('index_ewvdial', "$config{'wvdial'}", "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; if ($out) { print &text('index_ver', "$config{'wvdial'} --version"),"\n"; print "

$out
\n"; } } else { # Get the version and show title waitpid(-1, 1); $vers = $1; &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, &help_search_link("wvdial", "man", "doc"), undef, undef, &text('index_version', $vers)); if ($vers < 1.53) { # This version not supported print "

",&text('index_eversion', $vers, 1.53),"

\n"; } elsif (!-r $config{'file'}) { # We need initialization print "

\n"; print "
",&text('index_init',"$config{'file'}"), "

\n"; print "\n"; print "

\n"; } else { # Show defined dialers and modems $conf = &get_config(); @links = map { "edit.cgi?idx=".$_->{'index'} } @$conf; @icons = map { "images/modem.gif" } @$conf; @titles = map { &dialer_name($_->{'name'}) } @$conf; print &ui_subheading($text{'index_header'}); if (@links) { &icons_table(\@links, \@titles, \@icons); } else { print "$text{'index_none'}

\n"; } print "$text{'index_dadd'}", "

\n"; # Show buttons for connect/disconnect and status local @dials = grep { $_->{'name'} =~ /^Dialer\s+/i } @$conf; print &ui_hr(); print "\n"; ($ip, $pid, $sect) = &get_connect_details(); if ($ip && kill(0, $pid)) { # Connected .. offer to disconnect print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } elsif ($pid = &get_wvdial_pid()) { # Running, but started elsewhere print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } else { # Not connected .. offer to dial up if (@dials) { print "\n"; print "\n"; print "\n"; print "\n"; } } # Show at-boot button if (&foreign_check("init") && @dials) { print "\n"; &foreign_require("init", "init-lib.pl"); $starting = &init::action_status($module_name); $config{'boot'} = undef if ($starting != 2); print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } # Show re-config button print "\n"; print "\n"; print "\n"; print "\n"; print "
",&text($ip eq "*" ? 'index_discdesc3' : 'index_discdesc1', "$ip", &dialer_name($sect)),"
",&text('index_discdesc2', $pid),"
\n"; print "$text{'index_connectdesc'}
\n"; print "$text{'index_bootdesc'}
$text{'index_refreshdesc'}
\n"; } } &ui_print_footer("/", $text{'index'});