#!/bin/sh . /www/cgi-bin/functions.sh internet_type=$($nvram get internet_type) internet_ppp_type=$($nvram get internet_ppp_type) ether_get_wan_assign=$($nvram get wan_ether_wan_assign) ether_get_dns_assign=$($nvram get wan_ether_dns_assign) #wan parameters info_get_wanproto=$($nvram get wan_proto) wan_if=$(get_wanif $info_get_wanproto) info_get_wanmac=$($ifconfig eth1 | grep ^$wan_if | sed 's/.*HWaddr//') if [ "$info_get_wanproto" = "dhcp" ];then info_get_wanip=$($nvram get wan_dhcp_ipaddr) info_get_wanmask=$($nvram get wan_dhcp_netmask) info_get_gateway=$($nvram get wan_dhcp_gateway) if [ "x$info_get_wanip" = "x" -o "$info_get_wanip" = "0.0.0.0" ];then info_get_wanmask="0.0.0.0" info_get_gateway="0.0.0.0" fi dhcpc_lease_obtain=$($nvram get dhcpc_lease_obtain) dhcpc_lease_time=$($nvram get dhcpc_lease_time) wan_dhcp_server=`[ -f /tmp/configs/wan_dhcp_server ] && cat /tmp/configs/wan_dhcp_server || echo ""` if [ "x$wan_dhcp_server" = "x" ];then wan_dhcp_server="0.0.0.0" fi info_get_wanproto="DHCP" info_get_dns_assign=$($nvram get wan_ether_dns_assign) elif [ "$info_get_wanproto" = "static" ];then info_get_wanip=$($nvram get wan_ipaddr) info_get_wanmask=$($nvram get wan_netmask) info_get_gateway=$($nvram get wan_gateway) info_get_wanproto="Static" info_get_dns_assign=$($nvram get wan_ether_dns_assign) elif [ "$info_get_wanproto" = "pppoe" ];then info_get_wanproto="PPPoE" info_get_dns_assign=$($nvram get wan_pppoe_dns_assign) pppoe_status=/tmp/ppp/ppp0-status pppoe_get_wan_assign=$($nvram get wan_pppoe_wan_assign) pppoe_alive=0 pppoe_uptime=0 if [ -f $pppoe_status ]; then status=$(cat $pppoe_status) if [ "x$status" = "x1" ]; then pppoe_alive=1 fi fi if [ "$pppoe_alive" = "1" ];then ppp0_value=`ifconfig | grep ^ppp0` if [ "x$ppp0_value" != "x" ];then info_get_wanip=`ifconfig ppp0 | sed 2p -n | awk '/inet/{print $2}' | awk -F: '{print $2}'` info_get_wanmask="255.255.255.255" info_get_gateway=$info_get_wanip elif [ "$pppoe_get_wan_assign" = "0" ];then info_get_wanip="0.0.0.0" info_get_wanmask="0.0.0.0" info_get_gateway="0.0.0.0" else info_get_wanip=$($nvram get wan_pppoe_ip) info_get_wanmask="0.0.0.0" info_get_gateway="0.0.0.0" fi if [ "x$ppp0_value" != "x" ];then ori_uptime=`cat /tmp/ppp/ppp_conn_time | awk -F. '{print$1}'` now_uptime=`cat /proc/uptime | awk -F. '{print$1}'` pppoe_uptime=$(($now_uptime-$ori_uptime)) fi else info_get_wanip="0.0.0.0" info_get_wanmask="0.0.0.0" info_get_gateway="0.0.0.0" fi elif [ "$info_get_wanproto" = "pptp" ];then info_get_wanproto="PPTP" info_get_dns_assign=$($nvram get wan_pptp_dns_assign) tunnel_ip="0.0.0.0" pptp_get_wan_assign=$($nvram get wan_pptp_wan_assign) pptp_status=/tmp/ppp/ppp0-status pptp_alive=0 pptp_uptime=0 if [ -f $pptp_status ]; then status=$(cat $pptp_status) if [ "x$status" = "x1" ]; then pptp_alive=1 fi fi if [ "$pptp_alive" = "1" ];then ppp0_value=`ifconfig | grep ^ppp0` if [ "x$ppp0_value" != "x" ];then info_get_wanip=`ifconfig ppp0 | sed 2p -n | awk '/inet/{print $2}' | awk -F: '{print $2}'` info_get_wanmask="255.255.255.255" info_get_gateway=$info_get_wanip tunnel_ip=$(ifconfig ppp0 | sed -n 2p | awk '{print $3}' | awk -F: '{ print $2 }') elif [ "$pptp_get_wan_assign" = "0" ];then info_get_wanip="0.0.0.0" info_get_wanmask="0.0.0.0" info_get_gateway="0.0.0.0" else info_get_wanip=$($nvram get wan_pptp_local_ip) info_get_wanmask="0.0.0.0" info_get_gateway="0.0.0.0" fi if [ "x$ppp0_value" != "x" ];then ori_uptime=`cat /tmp/ppp/ppp_conn_time | awk -F. '{print$1}'` now_uptime=`cat /proc/uptime | awk -F. '{print$1}'` pptp_uptime=$(($now_uptime-$ori_uptime)) fi else info_get_wanip="0.0.0.0" info_get_wanmask="0.0.0.0" info_get_gateway="0.0.0.0" fi elif [ "$info_get_wanproto" = "bigpond" ];then info_get_wanproto="Telstra Bigpond" info_get_bpa_status=$(cat /tmp/bpa_info | awk '{print $1}') info_get_dns_assign=$($nvram get wan_bpa_dns_assign) info_get_wanip=$($nvram get wan_dhcp_ipaddr) info_get_wanmask=$($nvram get wan_dhcp_netmask) info_get_gateway=$($nvram get wan_dhcp_gateway) elif [ "$info_get_wanproto" = "mulpppoe1" ];then info_get_dns_assign=$($nvram get wan_mulpppoe1_dns_assign) #ppp1 IP_FILE0=/etc/ppp/pppoe1-ip PPP0_STATUS=/etc/ppp/pppoe1-status info_get_wanip="0.0.0.0" if [ -f $PPP0_STATUS ]; then status=$(cat $PPP0_STATUS) if [ "x$status" = "x1" -a -f $IP_FILE0 ]; then info_get_wanip=$(cat $IP_FILE0) fi fi info_get_wanmask="0.0.0.0" if [ -f $PPP0_STATUS ]; then status=$(cat $PPP0_STATUS) if [ "x$status" = "x1" ]; then info_get_wanmask="255.255.255.255" fi fi info_get_gateway=$info_get_wanip DNS_FIEL0=/etc/ppp/pppoe1-dns.conf info_get_dns1="0.0.0.0" if [ -f $PPP0_STATUS ]; then status=$(cat $PPP0_STATUS) if [ "x$status" = "x1" -a -f $DNS_FIEL0 ]; then mulppp_get_dns1=`sed -n '1p' $DNS_FIEL0` fi fi if [ "x$mulppp_get_dns1" = "x" ];then mulppp_get_dns1="0.0.0.0" fi #ppp2 IP_FILE1=/etc/ppp/pppoe2-ip PPP1_STATUS=/etc/ppp/pppoe2-status info_get_wanip2="0.0.0.0" if [ -f $PPP1_STATUS ]; then status=$(cat $PPP1_STATUS) if [ "x$status" = "x1" -a -f $IP_FILE1 ]; then info_get_wanip2=$(cat $IP_FILE1) fi fi info_get_wanmask2="0.0.0.0" if [ -f $PPP1_STATUS ]; then status=$(cat $PPP1_STATUS) if [ "x$status" = "x1" ]; then info_get_wanmask2="255.255.255.255" fi fi info_get_gateway2=$info_get_wanip DNS_FIEL1=/etc/ppp/pppoe2-dns.conf mulppp_get_dns2="0.0.0.0" if [ -f $PPP1_STATUS ]; then status=$(cat $PPP1_STATUS) if [ "x$status" = "x1" -a -f $DNS_FIEL1 ]; then mulppp_get_dns2=`sed -n '1p' $DNS_FIEL1` fi fi if [ "x$mulppp_get_dns2" = "x" ];then mulppp_get_dns2="0.0.0.0" fi #uptime UP_TIME_FILE0=/etc/ppp/pppoe1-dial-up-time ppp0_uptime=0 if [ -f $PPP0_STATUS ]; then status=$(cat $PPP0_STATUS) if [ "x$status" = "x1" -a -f $UP_TIME_FILE0 ]; then ori_uptime=`cat $UP_TIME_FILE0 | awk -F. '{print$1}'` now_uptime=`cat /proc/uptime | awk -F. '{print$1}'` ppp0_uptime=$(($now_uptime-$ori_uptime)) fi fi UP_TIME_FILE1=/etc/ppp/pppoe2-dial-up-time ppp2_uptime=0 if [ -f $PPP1_STATUS ]; then status=$(cat $PPP1_STATUS) if [ "x$status" = "x1" -a -f $UP_TIME_FILE1 ]; then ori_uptime=`cat $UP_TIME_FILE1 | awk -F. '{print$1}'` now_uptime=`cat /proc/uptime | awk -F. '{print$1}'` ppp2_uptime=$(($now_uptime-$ori_uptime)) fi fi fi if [ -f /tmp/resolv.conf ];then info_get_dns1=$(cat /tmp/resolv.conf | awk '/nameserver/{printf $2 "\n"}' | sed -n 1p) info_get_dns2=$(cat /tmp/resolv.conf | awk '/nameserver/{printf $2 "\n"}' | sed -n 2p) else info_get_dns1="0.0.0.0" info_get_dns2="0.0.0.0" fi if [ "x$info_get_wanip" = "x" ];then info_get_wanip="0.0.0.0" fi if [ "x$info_get_wanip2" = "x" ];then info_get_wanip2="0.0.0.0" fi if [ "$info_get_wanip" = "0.0.0.0" ];then wan_dhcp_server="0.0.0.0" if [ "$info_get_dns_assign" = "0" ];then info_get_dns1="0.0.0.0" info_get_dns2="0.0.0.0" fi fi if [ "$info_get_dns1" = "$info_get_dns2" ];then info_get_dns2="" fi print_cgi_header print_http_header "/funcs.js" echo "" print_table_header "" cat < var info_get_wanip="$info_get_wanip"; function changepage() { var cf = document.forms[0]; if( "$info_get_wanproto" != "Telstra Bigpond" ) { if (info_get_wanip != "0.0.0.0" && info_get_wanip!="10.64.64.64") setTimeout("window.location.replace('http://www.netgear.com')",5000); else setTimeout("window.location.replace('testpage.html')",2500); } else { if("$info_get_wanip" !="0.0.0.0" && "$info_get_bpa_status" == "up") setTimeout("window.location.replace('http://www.netgear.com')",5000); else setTimeout("window.location.replace('testpage.html')",2500); } } changepage(); EOF print_http_footer