#!/usr/local/bin/perl # index.cgi # Display ADSL configuration options # XXX new-style ADSL config in redhat 7.2 and above! # XXX effects start/stop and bootup as well require './adsl-client-lib.pl'; $vers = &get_pppoe_version(\$out); &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0, &help_search_link("pppoe", "man", "doc"), undef, undef, $vers ? &text('index_version', $vers) : undef); if (!$vers) { # Not installed print "

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

\n"; } elsif (!($conf = &get_config())) { # Missing config file if ($config{'conf_style'} == 0) { # Just give up print "

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

\n"; } else { # On redhat systems, the file needs to be created by this # module :-( print "

",&text('index_esetup', "$config{'pppoe_conf'}"),"

\n"; print "

\n"; print "\n"; print "
\n"; } } elsif (&find("TYPE", $conf) =~ /modem/i) { # For a modem on a redhat system $config{'pppoe_conf'} =~ /^(.*)\//; print "

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

\n"; } else { # Show configuration form $conf = &get_config(); print "$text{'index_desc'}

\n"; print "

\n"; print "\n"; print "\n"; print "
$text{'index_header'}
\n"; # Show network interface field &foreign_require("net", "net-lib.pl"); $eth = &find("ETH", $conf); print "\n"; @ifcs = &net::active_interfaces(1); print "\n", $found ? "" : $eth; # Show on-demand field $demand = &find("DEMAND", $conf); print "\n"; printf "\n", $demand !~ /^\d+$/i ? "checked" : "", $text{'no'}; # Show username field $user = &find("USER", $conf); print "\n"; printf "\n", $user; # Show password field (from pap-secrets) ($sec) = grep { $_->{'client'} eq $user } &list_secrets(); print "\n"; printf "\n", $sec->{'secret'}; # Show DNS config buttons $dns = &find("USEPEERDNS", $conf) || &find("PEERDNS", $conf); print "\n"; printf "\n", $dns =~ /yes/i ? "" : "checked", $text{'no'}; # Show connect timeout field $connect = &find("CONNECT_TIMEOUT", $conf); print "\n"; printf "\n", $connect == 0 ? "" : $connect, $text{'index_secs'}; # Show MSS field $mss = &find("CLAMPMSS", $conf); print "\n"; printf "\n", $mss =~ /no/i ? "checked" : "", $text{'no'}; # Show firewall menu $fw = &find("FIREWALL", $conf); $fw ||= "NONE"; if ($fw ne "NONE") { print "\n"; print "\n"; } else { print "\n"; } print "
",&hlink($text{'index_eth'}, "eth"),"\n"; printf "",&hlink($text{'index_demand'},"demand")," %s\n", $demand !~ /^\d+$/i ? "" : "checked", $text{'index_timeout'}; printf "\n", $demand !~ /^\d+$/i ? "" : $demand; printf " %s
",&hlink($text{'index_user'},"user"),"",&hlink($text{'index_sec'},"sec"),"
",&hlink($text{'index_dns'}, "dns")," %s\n", $dns =~ /yes/i ? "checked" : "", $text{'yes'}; printf " %s",&hlink($text{'index_connect'},"connect")," %s\n", $connect == 0 ? "checked" : "", $text{'index_forever'}; printf "\n", $connect == 0 ? "" : "checked"; printf " %s
",&hlink($text{'index_mss'},"mss")," %s\n", $mss =~ /no/i ? "" : "checked", $text{'index_psize'}; printf " %s\n", $mss =~ /no/i ? "" : $mss, $text{'index_bytes'}; printf " %s",&hlink($text{'index_fw'},"fw"),"
\n"; print "
\n"; # Show connected/disconnect buttons print &ui_hr(); print &ui_buttons_start(); local ($dev, $ip) = &get_adsl_ip(); if ($ip) { # Offer to shut down print &ui_buttons_row("stop.cgi", $text{'index_stop'}, &text('index_stopdesc', "$ip", "$config{'stop_cmd'}")); } elsif ($dev eq "demand") { # Offer to cancel on-demand connection print &ui_buttons_row("stop.cgi", $text{'index_cdemand'}, &text('index_cdemanddesc', "$config{'stop_cmd'}")); } elsif ($dev) { # Offer to cancel connect print &ui_buttons_row("stop.cgi", $text{'index_cancel'}, &text('index_canceldesc', "$config{'stop_cmd'}")); } else { # Offer to start up print &ui_buttons_row("start.cgi", $text{'index_start'}, &text('index_startdesc', "$config{'start_cmd'}")); } # Show boot-time button if ($config{'conf_style'} == 1 && ($onboot = find("ONBOOT", $conf))) { # Offer to turn on/off starting at boot print &ui_buttons_row("rbootup.cgi", $text{'index_boot'}, $text{'index_bootdesc'}, undef, &ui_yesno_radio("onboot", $onboot =~ /yes/i ? 1 : 0)); } elsif (&foreign_check("init")) { # Offer to enable/disable init script &foreign_require("init", "init-lib.pl"); $boot = &init::action_status("adsl"); if ($boot > 0) { print &ui_buttons_row("bootup.cgi", $text{'index_boot'}, $text{'index_bootdesc'}, undef, &ui_yesno_radio("boot", $boot == 2 ? 1 : 0)); } } print &ui_buttons_end(); } &ui_print_footer("/", $text{'index'});