restructure webif similar to x-wrt
authorFelix Fietkau <nbd@openwrt.org>
Fri, 6 Oct 2006 20:10:37 +0000 (20:10 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 6 Oct 2006 20:10:37 +0000 (20:10 +0000)
SVN-Revision: 4938

27 files changed:
openwrt/package/webif/files/etc/httpd.conf
openwrt/package/webif/files/www/cgi-bin/webif/about.sh
openwrt/package/webif/files/www/cgi-bin/webif/connection.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/info.sh
openwrt/package/webif/files/www/cgi-bin/webif/ipkg.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/lan.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/leases.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/network-hosts.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/network-lan.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/network-wan.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/network-wlan-advanced.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/network-wlan.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/password.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/status-connection.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/status-dhcp.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/status-wireless.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/system-ipkg.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/system-password.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/system-settings.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/system-upgrade.sh [new file with mode: 0755]
openwrt/package/webif/files/www/cgi-bin/webif/system.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/upgrade.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/wan.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh [deleted file]
openwrt/package/webif/files/www/cgi-bin/webif/wireless-status.sh [deleted file]

index 29bafa926b0e74c831da0b27cb603c54b94fc852..5197b883781409de4d6687c51106ea748ab9b03e 100644 (file)
@@ -1,4 +1,8 @@
 .asp:text/html
 /cgi-bin/webif:root:$p$root
 /cgi-bin/webif:admin:$p$root
+.svg:image/svg+xml
+.png:image/png
+.gif:image/gif
+.jpg:image/jpg
 
index abaf27b435791cc8a8191d53290ef248653c51dd..0d7416a6919f28b811a6c6e5c5e03cb1f6be548a 100755 (executable)
@@ -8,17 +8,24 @@ header "Info" "About" "@TR<<About>>..."
 <br />
 @TR<<GPL_Text|This program is free software; you can redistribute it and/or <br />modify it under the terms of the GNU General Public License <br />as published by the Free Software Foundation; either version 2 <br />of the License, or (at your option) any later version. <br /> >>
 <br />
-@TR<<Copyright>> &copy; 2005 Felix Fietkau &lt;<a href="mailto:openwrt@nbd.name">openwrt@nbd.name</a>&gt;<br />
+@TR<<Copyright>> &copy; 2005-2006 OpenWrt.org <br />
 <br />
 @TR<<Contributions by>>:
 <ul class="about">
        <li class="about">Philipp Kewisch &lt;<a href="mailto:openwrt@kewis.ch">openwrt@kewis.ch</a>&gt;</li>
        <li class="about">Spectra &lt;<a href="mailto:spectra@gmx.ch">spectra@gmx.ch</a>&gt;</li>
+       <li class="about">Jeremy Collake &lt;<a href="mailto:jeremy.collake@gmail.com">jeremy.collake@gmail.com</a>&gt;</li>
+       <li class="about">Travis Kemen &lt;<a href="mailto:kemen04@gmail.com">kemen04@gmail.com</a>&gt;</li>
+       <li class="about">Markus Wigge</li>
+       <li class="about">SeDkY</li>
+       <li class="about">Ivoshiee</li>
+       <li class="about">arteqw</li>
+       <li class="about">silver71<li>
        <li class="about">@TR<<Layout based on>> <a href="http://www.openwebdesign.org/design/1773/prosimii/">&quot;Prosimii&quot;</a> @TR<<by>> haran</li>
 </ul>
 
 
 <? footer ?>
 <!--
-##WEBIF:name:Info:1:About
+##WEBIF:name:Info:20:About
 -->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/connection.sh b/openwrt/package/webif/files/www/cgi-bin/webif/connection.sh
deleted file mode 100755 (executable)
index cab7ebd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-header "Status" "Connections" "@TR<<Connection Status>>"
-?>
-<table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
-<tbody>
-       <tr>
-               <th><b>@TR<<Physical Connections|Ethernet/Wireless Physical Connections>></b></th>
-       </tr>
-       <tr>
-               <td><pre><? cat /proc/net/arp ?></pre></td>
-       </tr>
-       
-       <tr><td><br /><br /></td></tr>
-
-       <tr>
-               <th><b>@TR<<Router Connections|Connections to the Router>></b></th>
-       </tr>
-       <tr>
-               <td><pre><? netstat -n 2>&- | awk '$0 ~ /^Active UNIX/ {ignore = 1}; ignore != 1 { print $0 }' ?></pre></td>
-       </tr>
-</tbody>
-</table>
-
-<? footer ?>
-<!--
-##WEBIF:name:Status:1:Connections
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh b/openwrt/package/webif/files/www/cgi-bin/webif/hosts.sh
deleted file mode 100755 (executable)
index 22c8fe2..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-
-exists /tmp/.webif/file-hosts  && HOSTS_FILE=/tmp/.webif/file-hosts || HOSTS_FILE=/etc/hosts
-exists /tmp/.webif/file-ethers  && ETHERS_FILE=/tmp/.webif/file-ethers || ETHERS_FILE=/etc/ethers
-exists $HOSTS_FILE || touch $HOSTS_FILE >&- 2>&-
-exists $ETHERS_FILE || touch $ETHERS_FILE >&- 2>&-
-
-update_hosts() {
-       exists /tmp/.webif/* || mkdir -p /tmp/.webif
-       awk -v "mode=$1" -v "ip=$2" -v "name=$3" '
-BEGIN {
-       FS="[ \t]"
-       host_added = 0
-}
-{ processed = 0 }
-(mode == "del") && (ip == $1) {
-       names_found = 0
-       n = split($0, names, "[ \t]")
-       output = $1 "   "
-       for (i = 2; i <= n; i++) {
-               if ((names[i] != "") && (names[i] != name)) {
-                       output = output names[i] " "
-                       names_found++
-               }
-       }
-       if (names_found > 0) print output
-       processed = 1
-}
-(mode == "add") && (ip == $1) {
-       print $0 " " name
-       host_added = 1
-       processed = 1
-}
-processed == 0 {
-       print $0
-}
-END {
-       if ((mode == "add") && (host_added == 0)) print ip "    " name
-}' "$HOSTS_FILE" > /tmp/.webif/file-hosts-new
-       mv "/tmp/.webif/file-hosts-new" "/tmp/.webif/file-hosts"
-       HOSTS_FILE=/tmp/.webif/file-hosts
-}
-
-update_ethers() {
-       exists /tmp/.webif/* || mkdir -p /tmp/.webif
-       case "$1" in
-               add)
-                       grep -E -v "^[ \t]*$2" $ETHERS_FILE > /tmp/.webif/file-ethers-new
-                       echo "$2        $3" >> /tmp/.webif/file-ethers-new
-                       mv /tmp/.webif/file-ethers-new  /tmp/.webif/file-ethers
-               ;;
-               del)
-                       grep -E -v "^[ \t]*$2" $ETHERS_FILE > /tmp/.webif/file-ethers-new
-                       mv /tmp/.webif/file-ethers-new  /tmp/.webif/file-ethers
-               ;;      
-       esac
-       ETHERS_FILE=/tmp/.webif/file-ethers
-}
-
-empty "$FORM_add_host" || {
-       # add a host to /etc/hosts
-       validate <<EOF
-ip|FORM_host_ip|@TR<<IP Address>>|required|$FORM_host_ip
-hostname|FORM_host_name|@TR<<Host Name>>|required|$FORM_host_name
-EOF
-       equal "$?" 0 && update_hosts add "$FORM_host_ip" "$FORM_host_name"
-}
-empty "$FORM_add_dhcp" || {
-       # add a host to /etc/ethers
-       validate <<EOF
-mac|FORM_dhcp_mac|@TR<<MAC Address>>|required|$FORM_dhcp_mac
-ip|FORM_dhcp_ip|@TR<<IP Address>>|required|$FORM_dhcp_ip
-EOF
-       equal "$?" 0 && update_ethers add "$FORM_dhcp_mac" "$FORM_dhcp_ip"
-}
-
-empty "$FORM_remove_host" || update_hosts del "$FORM_remove_ip" "$FORM_remove_name"
-empty "$FORM_remove_dhcp" || update_ethers del "$FORM_remove_mac"
-
-header "Network" "Hosts" "@TR<<Configured Hosts>>" ''
-
-# Hosts in /etc/hosts
-awk -v "url=$SCRIPT_NAME" \
-       -v "ip=$FORM_host_ip" \
-       -v "name=$FORM_host_name" \
-       -f /usr/lib/webif/common.awk \
-       -f - $HOSTS_FILE <<EOF
-BEGIN {
-       FS="[ \t]"
-       start_form("@TR<<Host Names>>")
-       print "<table width=\"70%\" summary=\"Settings\">"
-       print "<tr><th>@TR<<IP Address>></th><th>@TR<<Host Name>></th><th></th></tr>"
-       print "<tr><td colspan=\"3\"><hr class=\"separator\" /></td></tr>"
-}
-
-# only for valid IPv4 addresses
-(\$1 ~ /^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/) {
-       gsub(/#.*$/, "");
-       output = ""
-       names_found = 0
-       n = split(\$0, names, "[ \\t]")
-       first = 1
-       for (i = 2; i <= n; i++) {
-               if (names[i] != "") {
-                       if (first != 1) output = output "<tr>"
-                       output = output "<td>" names[i] "</td><td align=\\"right\\" width=\\"10%\\"><a href=\\"" url "?remove_host=1&remove_ip=" \$1 "&remove_name=" names[i] "\\">@TR<<Remove>></a></td></tr>"
-                       first = 0
-                       names_found++
-               }
-       }
-       if (names_found > 0) {
-               print "<tr><td rowspan=\\"" names_found "\\">" \$1 "</td>" output
-               print "<tr><td colspan=\\"3\\"><hr class=\\"separator\\" /></td></tr>"
-       }
-}
-
-END {
-       print "<form enctype=\\"multipart/form-data\\" method=\\"post\\">"
-       print "<tr><td>" textinput("host_ip", ip) "</td><td>" textinput("host_name", name) "</td><td style=\\"width: 10em\\">" button("add_host", "Add") "</td></tr>"
-       print "</form>"
-       print "</table>"
-       end_form()
-}
-EOF
-
-# Static DHCP mappings (/etc/ethers)
-awk -v "url=$SCRIPT_NAME" \
-       -v "mac=$FORM_dhcp_mac" \
-       -v "ip=$FORM_dhcp_ip" -f /usr/lib/webif/common.awk -f - $ETHERS_FILE <<EOF
-       
-BEGIN {
-       FS="[ \\t]"
-       print "<form enctype=\\"multipart/form-data\\" method=\\"post\\">"
-       start_form("@TR<<DHCP Static|Static IP addresses (for DHCP)>>")
-       print "<table width=\\"70%\\" summary=\\"Settings\\">"
-       print "<tr><th>@TR<<MAC Address>></th><th>@TR<<IP Address>></th><th></th></tr>"
-}
-
-# only for valid MAC addresses
-(\$1 ~ /^[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]$/) {
-       gsub(/#.*$/, "");
-       print "<tr><td>" \$1 "</td><td>" \$2 "</td><td align=\\"right\\" width=\\"10%\\"><a href=\\"" url "?remove_dhcp=1&remove_mac=" \$1 "\\">@TR<<Remove>></a></td></tr>"
-}
-
-END {
-       print "<tr><td>" textinput("dhcp_mac", mac) "</td><td>" textinput("dhcp_ip", ip) "</td><td style=\\"width: 10em\\">" button("add_dhcp", "Add") "</td></tr>"
-       print "</table>"
-       print "</form>"
-       end_form();
-}
-EOF
-
-footer ?>
-<!--
-##WEBIF:name:Network:5:Hosts
--->
index 1eee7f68080ed73c7c92130656e9c8dfcc9f4877..cc7639702c40805581eab81e5670c17d1faf72c8 100755 (executable)
@@ -40,5 +40,5 @@ EOF
 footer
 ?>
 <!--
-##WEBIF:name:Info:2:Router Info
+##WEBIF:name:Info:10:Router Info
 -->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/ipkg.sh b/openwrt/package/webif/files/www/cgi-bin/webif/ipkg.sh
deleted file mode 100755 (executable)
index 4c68297..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-header "System" "Installed Software" "@TR<<Installed Software>>"
-?>
-<p style="position: absolute; right: 1em; top: 10.5em"><a href="ipkg.sh?action=update">@TR<<Update package lists>></a></p>
-<pre><?
-if [ "$FORM_action" = "update" ]; then
-       ipkg update
-elif [ "$FORM_action" = "install" ]; then
-       yes n | ipkg install `echo "$FORM_pkg" | sed -e 's, ,+,g'`
-elif [ "$FORM_action" = "remove" ]; then
-       ipkg remove `echo "$FORM_pkg" | sed -e 's, ,+,g'`
-fi
-?></pre>
-<div class="half noBorderOnLeft">
-  <h3>@TR<<Installed Packages>></h3>
-  <table style="width: 90%">
-<?
-ipkg list_installed | awk -F ' ' '
-$2 !~ /terminated/ {
-       link=$1
-       gsub(/\+/,"%2B",link)
-       print "<tr><td>" $1 "</td><td><a href=\"ipkg.sh?action=remove&pkg=" link "\" style=\"color: red\">@TR<<Uninstall>></a></td></tr>"
-}
-'
-?>
-  </table>
-</div>
-<div class="half noBorderOnLeft">
-  <h3>@TR<<Available packages>></h3>
-  <table style="width: 90%">
-<?
-grep Package: /usr/lib/ipkg/status /usr/lib/ipkg/lists/* 2>&- | sed -e 's, ,,' -e 's,/usr/lib/ipkg/lists/,,' | awk -F: '
-$1 ~ /status/ {
-       installed[$3]++;
-}
-($1 !~ /terminated/) && ($1 !~ /\/status/) && (!installed[$3]) {
-       if (current != $1) print "<tr><th>" $1 "</th><td></td></tr>"
-       link=$3
-       gsub(/\+/,"%2B",link)
-       print "<tr><td>" $3 "</td><td><a href=\"ipkg.sh?action=install&pkg=" link "\" style=\"color: green\">@TR<<Install>></a></td></tr>"
-       current=$1
-}
-'
-?>
-  </table>
-</div>
-
-<div class="rowOfBoxes"></div>
-         
-<? footer ?>
-<!--
-##WEBIF:name:System:3:Installed Software
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/lan.sh b/openwrt/package/webif/files/www/cgi-bin/webif/lan.sh
deleted file mode 100755 (executable)
index 3ed6a52..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-load_settings network
-
-FORM_dns="${lan_dns:-$(nvram get lan_dns)}"
-LISTVAL="$FORM_dns"
-handle_list "$FORM_dnsremove" "$FORM_dnsadd" "$FORM_dnssubmit" 'ip|FORM_dnsadd|@TR<<DNS Address>>|required' && {
-       FORM_dns="$LISTVAL"
-       save_setting network lan_dns "$FORM_dns"
-}
-FORM_dnsadd=${FORM_dnsadd:-192.168.1.1}
-
-if empty "$FORM_submit"; then 
-       FORM_lan_ipaddr=${lan_ipaddr:-$(nvram get lan_ipaddr)}
-       FORM_lan_netmask=${lan_netmask:-$(nvram get lan_netmask)}
-       FORM_lan_gateway=${lan_gateway:-$(nvram get lan_gateway)}
-else 
-       SAVED=1
-       validate <<EOF
-ip|FORM_lan_ipaddr|@TR<<IP Address>>|required|$FORM_lan_ipaddr
-netmask|FORM_lan_netmask|@TR<<Netmask>>|required|$FORM_lan_netmask
-ip|FORM_lan_gateway|@TR<<Gateway>>||$FORM_lan_gateway
-EOF
-       equal "$?" 0 && {
-               save_setting network lan_ipaddr $FORM_lan_ipaddr
-               save_setting network lan_netmask $FORM_lan_netmask
-               save_setting network lan_gateway $FORM_lan_gateway
-       }
-fi
-
-header "Network" "LAN" "@TR<<LAN Configuration>>" '' "$SCRIPT_NAME"
-
-display_form <<EOF
-start_form|@TR<<LAN Configuration>>
-field|@TR<<IP Address>>
-text|lan_ipaddr|$FORM_lan_ipaddr
-field|@TR<<Netmask>>
-text|lan_netmask|$FORM_lan_netmask
-field|@TR<<Default Gateway>>
-text|lan_gateway|$FORM_lan_gateway
-end_form
-start_form|@TR<<DNS Servers>>
-listedit|dns|$SCRIPT_NAME?|$FORM_dns|$FORM_dnsadd
-helpitem|Note
-helptext|Helptext DNS save#You need save your settings on this page before adding/removing DNS servers
-end_form
-EOF
-
-footer ?>
-<!--
-##WEBIF:name:Network:1:LAN
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/leases.sh b/openwrt/package/webif/files/www/cgi-bin/webif/leases.sh
deleted file mode 100755 (executable)
index 48364f3..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-header "Status" "DHCP" "@TR<<DHCP leases>>"
-?>
-<table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
-<tbody>
-       <tr>
-               <th>@TR<<MAC Address>></th>
-               <th>@TR<<IP Address>></th>
-               <th>@TR<<Name>></th>
-               <th>@TR<<Expires in>></th>
-       </tr>
-<? [ -e /tmp/dhcp.leases ] && awk -vdate="$(date +%s)" '
-$1 > 0 {
-       print "<tr>"
-       print "<td>" $2 "</td>"
-       print "<td>" $3 "</td>"
-       print "<td>" $4 "</td>"
-       print "<td>"
-       t = $1 - date
-       h = int(t / 60 / 60)
-       if (h > 0) printf h "h "
-       m = int(t / 60 % 60)
-       if (m > 0) printf m "min "
-       s = int(t % 60)
-       printf s "sec "
-       printf "</td>"
-       print "</tr>"
-}
-' /tmp/dhcp.leases ?>
-</tbody>
-</table>
-
-<? footer ?>
-<!--
-##WEBIF:name:Status:2:DHCP
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/network-hosts.sh b/openwrt/package/webif/files/www/cgi-bin/webif/network-hosts.sh
new file mode 100755 (executable)
index 0000000..aeb58e1
--- /dev/null
@@ -0,0 +1,158 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+
+exists /tmp/.webif/file-hosts  && HOSTS_FILE=/tmp/.webif/file-hosts || HOSTS_FILE=/etc/hosts
+exists /tmp/.webif/file-ethers  && ETHERS_FILE=/tmp/.webif/file-ethers || ETHERS_FILE=/etc/ethers
+exists $HOSTS_FILE || touch $HOSTS_FILE >&- 2>&-
+exists $ETHERS_FILE || touch $ETHERS_FILE >&- 2>&-
+
+update_hosts() {
+       exists /tmp/.webif/* || mkdir -p /tmp/.webif
+       awk -v "mode=$1" -v "ip=$2" -v "name=$3" '
+BEGIN {
+       FS="[ \t]"
+       host_added = 0
+}
+{ processed = 0 }
+(mode == "del") && (ip == $1) {
+       names_found = 0
+       n = split($0, names, "[ \t]")
+       output = $1 "   "
+       for (i = 2; i <= n; i++) {
+               if ((names[i] != "") && (names[i] != name)) {
+                       output = output names[i] " "
+                       names_found++
+               }
+       }
+       if (names_found > 0) print output
+       processed = 1
+}
+(mode == "add") && (ip == $1) {
+       print $0 " " name
+       host_added = 1
+       processed = 1
+}
+processed == 0 {
+       print $0
+}
+END {
+       if ((mode == "add") && (host_added == 0)) print ip "    " name
+}' "$HOSTS_FILE" > /tmp/.webif/file-hosts-new
+       mv "/tmp/.webif/file-hosts-new" "/tmp/.webif/file-hosts"
+       HOSTS_FILE=/tmp/.webif/file-hosts
+}
+
+update_ethers() {
+       exists /tmp/.webif/* || mkdir -p /tmp/.webif
+       case "$1" in
+               add)
+                       grep -E -v "^[ \t]*$2" $ETHERS_FILE > /tmp/.webif/file-ethers-new
+                       echo "$2        $3" >> /tmp/.webif/file-ethers-new
+                       mv /tmp/.webif/file-ethers-new  /tmp/.webif/file-ethers
+               ;;
+               del)
+                       grep -E -v "^[ \t]*$2" $ETHERS_FILE > /tmp/.webif/file-ethers-new
+                       mv /tmp/.webif/file-ethers-new  /tmp/.webif/file-ethers
+               ;;      
+       esac
+       ETHERS_FILE=/tmp/.webif/file-ethers
+}
+
+empty "$FORM_add_host" || {
+       # add a host to /etc/hosts
+       validate <<EOF
+ip|FORM_host_ip|@TR<<IP Address>>|required|$FORM_host_ip
+hostname|FORM_host_name|@TR<<Host Name>>|required|$FORM_host_name
+EOF
+       equal "$?" 0 && update_hosts add "$FORM_host_ip" "$FORM_host_name"
+}
+empty "$FORM_add_dhcp" || {
+       # add a host to /etc/ethers
+       validate <<EOF
+mac|FORM_dhcp_mac|@TR<<MAC Address>>|required|$FORM_dhcp_mac
+ip|FORM_dhcp_ip|@TR<<IP Address>>|required|$FORM_dhcp_ip
+EOF
+       equal "$?" 0 && update_ethers add "$FORM_dhcp_mac" "$FORM_dhcp_ip"
+}
+
+empty "$FORM_remove_host" || update_hosts del "$FORM_remove_ip" "$FORM_remove_name"
+empty "$FORM_remove_dhcp" || update_ethers del "$FORM_remove_mac"
+
+header "Network" "Hosts" "@TR<<Configured Hosts>>" ''
+
+# Hosts in /etc/hosts
+awk -v "url=$SCRIPT_NAME" \
+       -v "ip=$FORM_host_ip" \
+       -v "name=$FORM_host_name" \
+       -f /usr/lib/webif/common.awk \
+       -f - $HOSTS_FILE <<EOF
+BEGIN {
+       FS="[ \t]"
+       start_form("@TR<<Host Names>>")
+       print "<table width=\"70%\" summary=\"Settings\">"
+       print "<tr><th>@TR<<IP Address>></th><th>@TR<<Host Name>></th><th></th></tr>"
+       print "<tr><td colspan=\"3\"><hr class=\"separator\" /></td></tr>"
+}
+
+# only for valid IPv4 addresses
+(\$1 ~ /^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/) {
+       gsub(/#.*$/, "");
+       output = ""
+       names_found = 0
+       n = split(\$0, names, "[ \\t]")
+       first = 1
+       for (i = 2; i <= n; i++) {
+               if (names[i] != "") {
+                       if (first != 1) output = output "<tr>"
+                       output = output "<td>" names[i] "</td><td align=\\"right\\" width=\\"10%\\"><a href=\\"" url "?remove_host=1&remove_ip=" \$1 "&remove_name=" names[i] "\\">@TR<<Remove>></a></td></tr>"
+                       first = 0
+                       names_found++
+               }
+       }
+       if (names_found > 0) {
+               print "<tr><td rowspan=\\"" names_found "\\">" \$1 "</td>" output
+               print "<tr><td colspan=\\"3\\"><hr class=\\"separator\\" /></td></tr>"
+       }
+}
+
+END {
+       print "<form enctype=\\"multipart/form-data\\" method=\\"post\\">"
+       print "<tr><td>" textinput("host_ip", ip) "</td><td>" textinput("host_name", name) "</td><td style=\\"width: 10em\\">" button("add_host", "Add") "</td></tr>"
+       print "</form>"
+       print "</table>"
+       end_form()
+}
+EOF
+
+# Static DHCP mappings (/etc/ethers)
+awk -v "url=$SCRIPT_NAME" \
+       -v "mac=$FORM_dhcp_mac" \
+       -v "ip=$FORM_dhcp_ip" -f /usr/lib/webif/common.awk -f - $ETHERS_FILE <<EOF
+       
+BEGIN {
+       FS="[ \\t]"
+       print "<form enctype=\\"multipart/form-data\\" method=\\"post\\">"
+       start_form("@TR<<DHCP Static|Static IP addresses (for DHCP)>>")
+       print "<table width=\\"70%\\" summary=\\"Settings\\">"
+       print "<tr><th>@TR<<MAC Address>></th><th>@TR<<IP Address>></th><th></th></tr>"
+}
+
+# only for valid MAC addresses
+(\$1 ~ /^[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]$/) {
+       gsub(/#.*$/, "");
+       print "<tr><td>" \$1 "</td><td>" \$2 "</td><td align=\\"right\\" width=\\"10%\\"><a href=\\"" url "?remove_dhcp=1&remove_mac=" \$1 "\\">@TR<<Remove>></a></td></tr>"
+}
+
+END {
+       print "<tr><td>" textinput("dhcp_mac", mac) "</td><td>" textinput("dhcp_ip", ip) "</td><td style=\\"width: 10em\\">" button("add_dhcp", "Add") "</td></tr>"
+       print "</table>"
+       print "</form>"
+       end_form();
+}
+EOF
+
+footer ?>
+<!--
+##WEBIF:name:Network:300:Hosts
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/network-lan.sh b/openwrt/package/webif/files/www/cgi-bin/webif/network-lan.sh
new file mode 100755 (executable)
index 0000000..84137b6
--- /dev/null
@@ -0,0 +1,53 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+load_settings network
+
+FORM_dns="${lan_dns:-$(nvram get lan_dns)}"
+LISTVAL="$FORM_dns"
+handle_list "$FORM_dnsremove" "$FORM_dnsadd" "$FORM_dnssubmit" 'ip|FORM_dnsadd|@TR<<DNS Address>>|required' && {
+       FORM_dns="$LISTVAL"
+       save_setting network lan_dns "$FORM_dns"
+}
+FORM_dnsadd=${FORM_dnsadd:-192.168.1.1}
+
+if empty "$FORM_submit"; then 
+       FORM_lan_ipaddr=${lan_ipaddr:-$(nvram get lan_ipaddr)}
+       FORM_lan_netmask=${lan_netmask:-$(nvram get lan_netmask)}
+       FORM_lan_gateway=${lan_gateway:-$(nvram get lan_gateway)}
+else 
+       SAVED=1
+       validate <<EOF
+ip|FORM_lan_ipaddr|@TR<<IP Address>>|required|$FORM_lan_ipaddr
+netmask|FORM_lan_netmask|@TR<<Netmask>>|required|$FORM_lan_netmask
+ip|FORM_lan_gateway|@TR<<Gateway>>||$FORM_lan_gateway
+EOF
+       equal "$?" 0 && {
+               save_setting network lan_ipaddr $FORM_lan_ipaddr
+               save_setting network lan_netmask $FORM_lan_netmask
+               save_setting network lan_gateway $FORM_lan_gateway
+       }
+fi
+
+header "Network" "LAN" "@TR<<LAN Configuration>>" '' "$SCRIPT_NAME"
+
+display_form <<EOF
+start_form|@TR<<LAN Configuration>>
+field|@TR<<IP Address>>
+text|lan_ipaddr|$FORM_lan_ipaddr
+field|@TR<<Netmask>>
+text|lan_netmask|$FORM_lan_netmask
+field|@TR<<Default Gateway>>
+text|lan_gateway|$FORM_lan_gateway
+end_form
+start_form|@TR<<DNS Servers>>
+listedit|dns|$SCRIPT_NAME?|$FORM_dns|$FORM_dnsadd
+helpitem|Note
+helptext|Helptext DNS save#You need save your settings on this page before adding/removing DNS servers
+end_form
+EOF
+
+footer ?>
+<!--
+##WEBIF:name:Network:100:LAN
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/network-wan.sh b/openwrt/package/webif/files/www/cgi-bin/webif/network-wan.sh
new file mode 100755 (executable)
index 0000000..3156265
--- /dev/null
@@ -0,0 +1,220 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+
+load_settings network
+
+FORM_dns="${wan_dns:-$(nvram get wan_dns)}"
+LISTVAL="$FORM_dns"
+handle_list "$FORM_dnsremove" "$FORM_dnsadd" "$FORM_dnssubmit" 'ip|FORM_dnsadd|@TR<<DNS Address>>|required' && {
+       FORM_dns="$LISTVAL"
+       save_setting network wan_dns "$FORM_dns"
+}
+FORM_dnsadd=${FORM_dnsadd:-192.168.1.1}
+
+if empty "$FORM_submit"; then
+       FORM_wan_proto=${wan_proto:-$(nvram get wan_proto)}
+       case "$FORM_wan_proto" in
+               # supported types
+               static|dhcp|pptp|pppoe) ;;
+               # otherwise select "none"
+               *) FORM_wan_proto="none";;
+       esac
+       
+       # pptp, dhcp and static common
+       FORM_wan_ipaddr=${wan_ipaddr:-$(nvram get wan_ipaddr)}
+       FORM_wan_netmask=${wan_netmask:-$(nvram get wan_netmask)}
+       FORM_wan_gateway=${wan_gateway:-$(nvram get wan_gateway)}
+       
+       # ppp common
+       FORM_ppp_username=${ppp_username:-$(nvram get ppp_username)}
+       FORM_ppp_passwd=${ppp_passwd:-$(nvram get ppp_passwd)}
+       FORM_ppp_idletime=${ppp_idletime:-$(nvram get ppp_idletime)}
+       FORM_ppp_redialperiod=${ppp_redialperiod:-$(nvram get ppp_redialperiod)}
+       FORM_ppp_mtu=${ppp_mtu:-$(nvram get ppp_mtu)}
+
+       redial=${ppp_demand:-$(nvram get ppp_demand)}
+       case "$redial" in
+               1|enabled|on) FORM_ppp_redial="demand";;        
+               *) FORM_ppp_redial="persist";;  
+       esac
+       
+       FORM_pptp_server_ip=${pptp_server_ip:-$(nvram get pptp_server_ip)}
+else
+       SAVED=1
+
+       empty "$FORM_wan_proto" && {
+               ERROR="@TR<<No WAN Proto|No WAN protocol has been selected>>" 
+               return 255
+       }
+
+       case "$FORM_wan_proto" in
+               static)
+                       V_IP="required"
+                       V_NM="required"
+                       ;;
+               pptp)
+                       V_PPTP="required"
+                       ;;
+       esac
+
+validate <<EOF
+ip|FORM_wan_ipaddr|@TR<<IP Address>>|$V_IP|$FORM_wan_ipaddr
+netmask|FORM_wan_netmask|@TR<<Netmask>>|$V_NM|$FORM_wan_netmask
+ip|FORM_wan_gateway|@TR<<Default Gateway>>||$FORM_wan_gateway
+ip|FORM_pptp_server_ip|@TR<<PPTP Server IP>>|$V_PPTP|$FORM_pptp_server_ip
+EOF
+       equal "$?" 0 && {
+               save_setting network wan_proto $FORM_wan_proto
+               
+               # Settings specific to one protocol type
+               case "$FORM_wan_proto" in
+                       static) save_setting network wan_gateway $FORM_wan_gateway ;;
+                       pptp) save_setting network pptp_server_ip "$FORM_pptp_server_ip" ;;
+               esac
+               
+               # Common settings for PPTP, Static and DHCP 
+               case "$FORM_wan_proto" in
+                       pptp|static|dhcp)
+                               save_setting network wan_ipaddr $FORM_wan_ipaddr
+                               save_setting network wan_netmask $FORM_wan_netmask 
+                       ;;
+               esac
+               
+               # Common PPP settings
+               case "$FORM_wan_proto" in
+                       pppoe|pptp)
+                               empty "$FORM_ppp_username" || save_setting network ppp_username $FORM_ppp_username
+                               empty "$FORM_ppp_passwd" || save_setting network ppp_passwd $FORM_ppp_passwd
+               
+                               # These can be blank
+                               save_setting network ppp_idletime "$FORM_ppp_idletime"
+                               save_setting network ppp_redialperiod "$FORM_ppp_redialperiod"
+                               save_setting network ppp_mtu "$FORM_ppp_mtu"
+
+                               save_setting network wan_ifname "ppp0"
+               
+                               case "$FORM_ppp_redial" in
+                                       demand)
+                                               save_setting network ppp_demand 1
+                                               ;;
+                                       persist)
+                                               save_setting network ppp_demand ""
+                                               ;;
+                               esac    
+                       ;;
+                       *)
+                               wan_ifname=${wan_ifname:-$(nvram get wan_ifname)}
+                               [ -z "$wan_ifname" -o "${wan_ifname%%[0-9]*}" = "ppp" ] && {
+                                       wan_device=${wan_device:-$(nvram get wan_device)}
+                                       wan_device=${wan_device:-vlan1}
+                                       save_setting network wan_ifname "$wan_device"
+                               }
+                       ;;
+               esac
+       }
+fi
+
+# detect pptp package and compile option
+[ -x /sbin/ifup.pptp ] && {
+       PPTP_OPTION="option|pptp|PPTP"
+       PPTP_SERVER_OPTION="field|PPTP Server IP|pptp_server|hidden
+text|pptp_server_ip|$FORM_pptp_server_ip"
+}
+[ -x /sbin/ifup.pppoe ] && {
+       PPPOE_OPTION="option|pppoe|PPPoE"
+}
+
+
+header "Network" "WAN" "@TR<<WAN Configuration>>" ' onLoad="modechange()" ' "$SCRIPT_NAME"
+
+cat <<EOF
+<script type="text/javascript" src="/webif.js "></script>
+<script type="text/javascript">
+<!--
+function modechange()
+{
+       var v;
+       v = (isset('wan_proto', 'pppoe') || isset('wan_proto', 'pptp'));
+       set_visible('ppp_settings', v);
+       set_visible('username', v);
+       set_visible('passwd', v);
+       set_visible('redial', v);
+       set_visible('mtu', v);
+       set_visible('demand_idletime', v && isset('ppp_redial', 'demand'));
+       set_visible('persist_redialperiod', v && !isset('ppp_redial', 'demand'));
+       
+       v = (isset('wan_proto', 'static') || isset('wan_proto', 'pptp') || isset('wan_proto', 'dhcp'));
+       set_visible('ip_settings', v);
+       set_visible('ipaddr', v);
+       set_visible('netmask', v);
+       
+       v = isset('wan_proto', 'static');
+       set_visible('gateway', v);
+       set_visible('dns', v);
+
+       v = isset('wan_proto', 'pptp');
+       set_visible('pptp_server',v);
+
+       hide('save');
+       show('save');
+}
+-->
+</script>
+EOF
+
+display_form <<EOF
+onchange|modechange
+start_form|@TR<<WAN Configuration>>
+field|@TR<<Connection Type>>
+select|wan_proto|$FORM_wan_proto
+option|none|@TR<<No WAN#None>>
+option|dhcp|@TR<<DHCP>>
+option|static|@TR<<Static IP>>
+$PPPOE_OPTION
+$PPTP_OPTION
+helplink|http://wiki.openwrt.org/OpenWrtDocs/Configuration#head-b62c144b9886b221e0c4b870edb0dd23a7b6acab
+end_form
+start_form|@TR<<IP Settings>>|ip_settings|hidden
+field|@TR<<IP Address>>|ipaddr|hidden
+text|wan_ipaddr|$FORM_wan_ipaddr
+field|@TR<<Netmask>>|netmask|hidden
+text|wan_netmask|$FORM_wan_netmask
+field|@TR<<Default Gateway>>|gateway|hidden
+text|wan_gateway|$FORM_wan_gateway
+$PPTP_SERVER_OPTION
+helpitem|IP Settings
+helptext|Helptext IP Settings#IP Settings are optional for DHCP and PPTP. If you set them, they are used as defaults in case the DHCP server is unavailable.
+end_form
+start_form|@TR<<DNS Servers>>|dns|hidden
+listedit|dns|$SCRIPT_NAME?wan_proto=static&|$FORM_dns|$FORM_dnsadd
+helpitem|Note
+helptext|Helptext DNS save#You should save your settings on this page before adding/removing DNS servers
+end_form
+
+start_form|@TR<<PPP Settings>>|ppp_settings|hidden
+field|@TR<<Redial Policy>>|redial|hidden
+select|ppp_redial|$FORM_ppp_redial
+option|demand|@TR<<Connect on Demand>>
+option|persist|@TR<<Keep Alive>>
+field|@TR<<Maximum Idle Time>>|demand_idletime|hidden
+text|ppp_idletime|$FORM_ppp_idletime
+helpitem|Maximum Idle Time
+helptext|Helptext Idle Time#The number of seconds without internet traffic that the router should wait before disconnecting from the Internet (Connect on Demand only)
+field|@TR<<Redial Timeout>>|persist_redialperiod|hidden
+text|ppp_redialperiod|$FORM_ppp_redialperiod
+helpitem|Redial Timeout
+helptext|Helptext Redial Timeout#The number of seconds to wait after receiving no response from the provider before trying to reconnect
+field|@TR<<Username>>|username|hidden
+text|ppp_username|$FORM_ppp_username
+field|@TR<<Password>>|passwd|hidden
+password|ppp_passwd|$FORM_ppp_passwd
+field|@TR<<MTU>>|mtu|hidden
+text|ppp_mtu|$FORM_ppp_mtu
+end_form
+EOF
+
+footer ?>
+<!--
+##WEBIF:name:Network:150:WAN
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/network-wlan-advanced.sh b/openwrt/package/webif/files/www/cgi-bin/webif/network-wlan-advanced.sh
new file mode 100755 (executable)
index 0000000..2d8caf4
--- /dev/null
@@ -0,0 +1,104 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+load_settings "wireless"
+
+FORM_wds="${wl0_wds:-$(nvram get wl0_wds)}"
+LISTVAL="$FORM_wds"
+handle_list "$FORM_wdsremove" "$FORM_wdsadd" "$FORM_wdssubmit" 'mac|FORM_wdsadd|WDS MAC address|required' && {
+       FORM_wds="$LISTVAL"
+       save_setting wireless wl0_wds "$FORM_wds"
+}
+FORM_wdsadd=${FORM_wdsadd:-00:00:00:00:00:00}
+
+FORM_maclist="${wl0_maclist:-$(nvram get wl0_maclist)}"
+LISTVAL="$FORM_maclist"
+handle_list "$FORM_maclistremove" "$FORM_maclistadd" "$FORM_maclistsubmit" 'mac|FORM_maclistadd|WDS MAC address|required' && {
+       FORM_maclist="$LISTVAL"
+       save_setting wireless wl0_maclist "$FORM_maclist"
+}
+FORM_maclistadd=${FORM_maclistadd:-00:00:00:00:00:00}
+
+if empty "$FORM_submit"; then
+       FORM_macmode="${wl0_macmode:-$(nvram get wl0_macmode)}"
+       FORM_lazywds=${wl0_lazywds:-$(nvram get wl0_lazywds)}
+       case "$FORM_lazywds" in
+               1|on|enabled) FORM_lazywds=1;;
+               *) FORM_lazywds=0;;
+       esac
+       FORM_wdstimeout=${wl0_wdstimeout:-$(nvram get wl0_wdstimeout)}
+       FORM_antdiv="${wl0_antdiv:-$(nvram get wl0_antdiv)}"
+       case "$FORM_antdiv" in
+               -1|auto) FORM_antdiv=-1;;
+               0|main|left) FORM_antdiv=0;;
+               1|aux|right) FORM_antdiv=1;;
+               3|diversity) FORM_antdiv=3;;
+               *) FORM_antdiv=-1;;
+       esac
+       FORM_distance="${wl0_distance:-$(nvram get wl0_distance)}"
+else
+       SAVED=1
+
+       validate <<EOF
+int|FORM_lazywds|Lazy WDS On/Off|required min=0 max=1|$FORM_lazywds
+int|FORM_wdstimeout|WDS watchdog timeout|optional min=0 max=3600|$FORM_wdstimeout
+int|FORM_distance|Distance|optional min=1|$FORM_distance
+EOF
+       equal "$?" 0 && {
+               save_setting wireless wl0_lazywds "$FORM_lazywds"
+               save_setting wireless wl0_wdstimeout "$FORM_wdstimeout"
+               save_setting wireless wl0_macmode "$FORM_macmode"
+               save_setting wireless wl0_antdiv "$FORM_antdiv"
+               save_setting wireless wl0_distance "$FORM_distance"
+       }
+fi
+
+header "Network" "Advanced Wireless" "@TR<<Advanced Wireless Configuration>>" ' onLoad="modechange()"' "$SCRIPT_NAME"
+
+cat <<EOF
+<script type="text/javascript" src="/webif.js"></script>
+<script type="text/javascript">
+
+function modechange() {
+       var v = (value("macmode") == "allow") || (value("macmode") == "deny");
+       set_visible('mac_list', v);
+}
+
+</script>
+EOF
+
+display_form <<EOF
+onchange|modechange
+start_form|@TR<<WDS Connections>>
+listedit|wds|$SCRIPT_NAME?|$FORM_wds|$FORM_wdsadd
+end_form
+start_form|@TR<<MAC Filter List>>
+listedit|maclist|$SCRIPT_NAME?|$FORM_maclist|$FORM_maclistadd
+end_form
+start_form|@TR<<Settings>>
+field|@TR<<Automatic WDS>>
+select|lazywds|$FORM_lazywds
+option|1|@TR<<Enabled>>
+option|0|@TR<<Disabled>>
+field|@TR<<WDS watchdog timeout>>
+text|wdstimeout|$FORM_wdstimeout
+field|@TR<<Filter Mode>>:
+select|macmode|$FORM_macmode
+option|disabled|@TR<<Disabled>>
+option|allow|@TR<<Allow>>
+option|deny|@TR<<Deny>>
+field|@TR<<Antenna selection>>:
+select|antdiv|$FORM_antdiv
+option|-1|@TR<<Automatic>>
+option|0|@TR<<Left>>
+option|1|@TR<<Right>>
+option|3|@TR<<Diversity>>
+field|@TR<<Distance>>
+text|distance|$FORM_distance
+end_form
+EOF
+
+footer ?>
+<!--
+##WEBIF:name:Network:250:Advanced Wireless
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/network-wlan.sh b/openwrt/package/webif/files/www/cgi-bin/webif/network-wlan.sh
new file mode 100755 (executable)
index 0000000..fee14b9
--- /dev/null
@@ -0,0 +1,290 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+load_settings "wireless"
+
+CC=${wl0_country_code:-$(nvram get wl0_country_code)}
+case "$CC" in
+       All|all|ALL) CHANNELS="1 2 3 4 5 6 7 8 9 10 11 12 13 14"; CHANNEL_MAX=14 ;;
+       *) CHANNELS="1 2 3 4 5 6 7 8 9 10 11"; CHANNEL_MAX=11 ;;
+esac
+F_CHANNELS="option|0|@TR<<Auto>>"
+for ch in $CHANNELS; do
+       F_CHANNELS="${F_CHANNELS}
+option|$ch"
+done
+
+if empty "$FORM_submit"; then
+       FORM_mode=${wl0_mode:-$(nvram get wl0_mode)}
+       infra=${wl0_infra:-$(nvram get wl0_infra)}
+       case "$infra" in
+               0|off|disabled) FORM_mode=adhoc;;
+       esac
+       FORM_radio=${wl0_radio:-$(nvram get wl0_radio)}
+       case "$FORM_radio" in
+               0|off|diabled) FORM_radio=0;;
+               *) FORM_radio=1;;
+       esac
+                       
+       FORM_ssid=${wl0_ssid:-$(nvram get wl0_ssid)}
+       FORM_broadcast=${wl0_closed:-$(nvram get wl0_closed)}
+       case "$FORM_broadcast" in
+               1|off|disabled) FORM_broadcast=1;;
+               *) FORM_broadcast=0;;
+       esac
+       FORM_channel=${wl0_channel:-$(nvram get wl0_channel)}
+       FORM_encryption=off
+       akm=${wl0_akm:-$(nvram get wl0_akm)}
+       case "$akm" in
+               psk)
+                       FORM_encryption=psk
+                       FORM_wpa1=wpa1
+                       ;;
+               psk2)
+                       FORM_encryption=psk
+                       FORM_wpa2=wpa2
+                       ;;
+               'psk psk2')
+                       FORM_encryption=psk
+                       FORM_wpa1=wpa1
+                       FORM_wpa2=wpa2
+                       ;;
+               wpa)
+                       FORM_encryption=wpa
+                       FORM_wpa1=wpa1
+                       ;;
+               wpa2)
+                       FORM_encryption=wpa
+                       FORM_wpa2=wpa2
+                       ;;
+               'wpa wpa2')
+                       FORM_encryption=wpa
+                       FORM_wpa1=wpa1
+                       FORM_wpa2=wpa2
+                       ;;
+               *)
+                       FORM_wpa1=wpa1
+                       ;;
+       esac
+       FORM_wpa_psk=${wl0_wpa_psk:-$(nvram get wl0_wpa_psk)}
+       FORM_radius_key=${wl0_radius_key:-$(nvram get wl0_radius_key)}
+       FORM_radius_ipaddr=${wl0_radius_ipaddr:-$(nvram get wl0_radius_ipaddr)}
+       crypto=${wl0_crypto:-$(nvram get wl0_crypto)}
+       case "$crypto" in
+               tkip)
+                       FORM_tkip=tkip
+                       ;;
+               aes)
+                       FORM_aes=aes
+                       ;;
+               'tkip+aes'|'aes+tkip')
+                       FORM_aes=aes
+                       FORM_tkip=tkip
+                       ;;
+               *)
+                       FORM_tkip=tkip
+                       ;;
+       esac
+       equal "$FORM_encryption" "off" && {
+               wep=${wl0_wep:-$(nvram get wl0_wep)}
+               case "$wep" in
+                       1|enabled|on) FORM_encryption=wep;;
+                       *) FORM_encryption=off;;
+               esac
+       }
+       FORM_key1=${wl0_key1:-$(nvram get wl0_key1)}
+       FORM_key2=${wl0_key2:-$(nvram get wl0_key2)}
+       FORM_key3=${wl0_key3:-$(nvram get wl0_key3)}
+       FORM_key4=${wl0_key4:-$(nvram get wl0_key4)}
+       key=${wl0_key:-$(nvram get wl0_key)}
+       FORM_key=${key:-1}
+else
+       SAVED=1
+       case "$FORM_encryption" in
+               wpa) V_RADIUS="
+string|FORM_radius_key|@TR<<RADIUS Server Key>>|min=4 max=63 required|$FORM_radius_key
+ip|FORM_radius_ipaddr|@TR<<RADIUS IP Address>>|required|$FORM_radius_ipaddr";;
+               psk) V_PSK="wpapsk|FORM_wpa_psk|@TR<<WPA PSK#WPA Pre-Shared Key>>|required|$FORM_wpa_psk";;
+               wep) V_WEP="
+int|FORM_key|@TR<<Selected WEP Key>>|min=1 max=4|$FORM_key
+wep|FORM_key1|@TR<<WEP Key>> 1||$FORM_key1
+wep|FORM_key2|@TR<<WEP Key>> 2||$FORM_key2
+wep|FORM_key3|@TR<<WEP Key>> 3||$FORM_key3
+wep|FORM_key4|@TR<<WEP Key>> 4||$FORM_key4";;
+       esac
+
+       validate <<EOF
+int|FORM_radio|wl0_radio|required min=0 max=1|$FORM_radio
+int|FORM_broadcast|wl0_closed|required min=0 max=1|$FORM_broadcast
+string|FORM_ssid|@TR<<ESSID>>|required|$FORM_ssid
+int|FORM_channel|@TR<<Channel>>|required min=0 max=$CHANNEL_MAX|$FORM_channel
+$V_WEP
+$V_RADIUS
+$V_PSK
+EOF
+       equal "$?" 0 && {
+               save_setting wireless wl0_radio "$FORM_radio"
+
+               if equal "$FORM_mode" adhoc; then
+                       FORM_mode=sta
+                       infra="0"
+               fi
+               save_setting wireless wl0_mode "$FORM_mode"
+               save_setting wireless wl0_infra ${infra:-1}
+                       
+               save_setting wireless wl0_ssid "$FORM_ssid"
+               save_setting wireless wl0_closed "$FORM_broadcast"
+               save_setting wireless wl0_channel "$FORM_channel"
+       
+               crypto=""
+               equal "$FORM_aes" aes && crypto="aes"
+               equal "$FORM_tkip" tkip && crypto="tkip${crypto:++$crypto}"
+               save_setting wireless wl0_crypto "$crypto"
+
+               case "$FORM_encryption" in
+                       psk)
+                               case "${FORM_wpa1}${FORM_wpa2}" in
+                                       wpa1) save_setting wireless wl0_akm "psk";;
+                                       wpa2) save_setting wireless wl0_akm "psk2";;
+                                       wpa1wpa2) save_setting wireless wl0_akm "psk psk2";;
+                               esac
+                               save_setting wireless wl0_wpa_psk "$FORM_wpa_psk"
+                               save_setting wireless wl0_wep "disabled"
+                               ;;
+                       wpa)
+                               case "${FORM_wpa1}${FORM_wpa2}" in
+                                       wpa1) save_setting wireless wl0_akm "wpa";;
+                                       wpa2) save_setting wireless wl0_akm "wpa2";;
+                                       wpa1wpa2) save_setting wireless wl0_akm "wpa wpa2";;
+                               esac
+                               save_setting wireless wl0_radius_ipaddr "$FORM_radius_ipaddr"
+                               save_setting wireless wl0_radius_key "$FORM_radius_key"
+                               save_setting wireless wl0_wep "disabled"
+                               ;;
+                       wep)
+                               save_setting wireless wl0_wep enabled
+                               save_setting wireless wl0_akm "none"
+                               save_setting wireless wl0_key1 "$FORM_key1"
+                               save_setting wireless wl0_key2 "$FORM_key2"
+                               save_setting wireless wl0_key3 "$FORM_key3"
+                               save_setting wireless wl0_key4 "$FORM_key4"
+                               save_setting wireless wl0_key "$FORM_key"
+                               ;;
+                       off)
+                               save_setting wireless wl0_akm "none"
+                               save_setting wireless wl0_wep disabled
+                               ;;
+               esac
+       }
+fi
+
+header "Network" "Wireless" "@TR<<Wireless Configuration>>" ' onLoad="modechange()" ' "$SCRIPT_NAME"
+
+cat <<EOF
+<script type="text/javascript" src="/webif.js"></script>
+<script type="text/javascript">
+<!--
+function modechange()
+{
+       if (isset('mode','adhoc')) {
+               document.getElementById('encryption_psk').disabled = true;
+               if (isset('encryption','psk')) {
+                               document.getElementById('encryption').value = 'off';
+               }
+       } else {
+               document.getElementById('encryption_psk').disabled = false;
+       }
+       
+       if (!isset('mode','ap')) {
+               document.getElementById('encryption_wpa').disabled = true;
+               if (value('encryption') == 'wpa') {
+                               document.getElementById('encryption').value = 'off';
+               }
+       } else {
+               document.getElementById('encryption_wpa').disabled = false;
+       }
+
+       var v = (isset('encryption','wpa') || isset('encryption','psk'));
+       set_visible('wpa_support', v);
+       set_visible('wpa_crypto', v);
+       
+       set_visible('wpapsk', isset('encryption','psk'));
+       set_visible('wep_keys', isset('encryption','wep'));
+
+       v = isset('encryption','wpa');
+       set_visible('radiuskey', v);
+       set_visible('radius_ip', v);
+
+       hide('save');
+       show('save');
+}
+-->
+</script>
+
+EOF
+
+display_form <<EOF
+onchange|modechange
+start_form|@TR<<Wireless Configuration>>
+field|@TR<<Wireless Interface>>
+select|radio|$FORM_radio
+option|1|@TR<<Enabled>>
+option|0|@TR<<Disabled>>
+field|@TR<<ESSID Broadcast>>
+select|broadcast|$FORM_broadcast
+option|0|@TR<<Show>>
+option|1|@TR<<Hide>>
+field|@TR<<ESSID>>
+text|ssid|$FORM_ssid
+helpitem|ESSID
+helptext|Helptext ESSID#Name of your Wireless Network
+field|@TR<<Channel>>
+select|channel|$FORM_channel
+$F_CHANNELS
+field|@TR<<WLAN Mode#Mode>>
+select|mode|$FORM_mode
+option|ap|@TR<<Access Point>>
+option|sta|@TR<<Client>>
+option|wet|@TR<<Client>> (@TR<<Bridge>>)
+option|adhoc|@TR<<Ad-Hoc>>
+helpitem|WLAN Mode#Mode
+helptext|Helptext Operation mode#This sets the operation mode of your wireless network. Selecting 'Client (Bridge)' will not change your network interface settings. It will only set some parameters in the wireless driver that allow for limited bridging of the interface.
+helplink|http://wiki.openwrt.org/OpenWrtDocs/Configuration#head-7126c5958e237d603674b3a9739c9d23bdfdb293
+end_form
+start_form|@TR<<Encryption Settings>>
+field|@TR<<Encryption Type>>
+select|encryption|$FORM_encryption
+option|off|@TR<<Disabled>>
+option|wep|WEP
+option|psk|WPA (@TR<<PSK>>)
+option|wpa|WPA (RADIUS)
+helpitem|Encryption Type
+helptext|Helptext Encryption Type#'WPA (RADIUS)' is only supported in Access Point mode. <br /> 'WPA (PSK)' doesn't work in Ad-Hoc mode.
+field|@TR<<WPA Mode>>|wpa_support|hidden
+checkbox|wpa1|$FORM_wpa1|wpa1|WPA1
+checkbox|wpa2|$FORM_wpa2|wpa2|WPA2
+field|@TR<<WPA Algorithms>>|wpa_crypto|hidden
+checkbox|tkip|$FORM_tkip|tkip|RC4 (TKIP)
+checkbox|aes|$FORM_aes|aes|AES
+field|WPA @TR<<PSK>>|wpapsk|hidden
+text|wpa_psk|$FORM_wpa_psk
+field|@TR<<RADIUS IP Address>>|radius_ip|hidden
+text|radius_ipaddr|$FORM_radius_ipaddr
+field|@TR<<RADIUS Server Key>>|radiuskey|hidden
+text|radius_key|$FORM_radius_key
+field|@TR<<WEP Keys>>|wep_keys|hidden
+radio|key|$FORM_key|1
+text|key1|$FORM_key1|<br />
+radio|key|$FORM_key|2
+text|key2|$FORM_key2|<br />
+radio|key|$FORM_key|3
+text|key3|$FORM_key3|<br />
+radio|key|$FORM_key|4
+text|key4|$FORM_key4|<br />
+end_form
+EOF
+
+footer ?>
+<!--
+##WEBIF:name:Network:200:Wireless
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/password.sh b/openwrt/package/webif/files/www/cgi-bin/webif/password.sh
deleted file mode 100755 (executable)
index f8618d8..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-
-empty "$FORM_submit" || {
-       SAVED=1
-       validate <<EOF
-string|FORM_pw1|Password|required min=5|$FORM_pw1
-EOF
-       equal "$FORM_pw1" "$FORM_pw2" || {
-               ERROR="$ERROR Passwords do not match<br />"
-       }
-       empty "$ERROR" && {
-               RES=$(
-                       (
-                               echo "$FORM_pw1"
-                               sleep 1
-                               echo "$FORM_pw2"
-                       ) | passwd root 2>&1
-               )
-               equal "$?" 0 || ERROR="<pre>$RES</pre>"
-       }
-}
-
-header "System" "Password Change" "@TR<<Password Change>>" '' "$SCRIPT_NAME"
-
-display_form <<EOF
-start_form|@TR<<Password Change>>
-field|@TR<<New Password>>:
-password|pw1
-field|@TR<<Confirm Password>>:
-password|pw2
-end_form
-EOF
-
-footer ?>
-
-<!--
-##WEBIF:name:System:2:Password Change
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/status-connection.sh b/openwrt/package/webif/files/www/cgi-bin/webif/status-connection.sh
new file mode 100755 (executable)
index 0000000..fbf329b
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+header "Status" "Connections" "@TR<<Connection Status>>"
+?>
+<table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
+<tbody>
+       <tr>
+               <th><b>@TR<<Physical Connections|Ethernet/Wireless Physical Connections>></b></th>
+       </tr>
+       <tr>
+               <td><pre><? cat /proc/net/arp ?></pre></td>
+       </tr>
+       
+       <tr><td><br /><br /></td></tr>
+
+       <tr>
+               <th><b>@TR<<Router Connections|Connections to the Router>></b></th>
+       </tr>
+       <tr>
+               <td><pre><? netstat -n 2>&- | awk '$0 ~ /^Active UNIX/ {ignore = 1}; ignore != 1 { print $0 }' ?></pre></td>
+       </tr>
+</tbody>
+</table>
+
+<? footer ?>
+<!--
+##WEBIF:name:Status:100:Connections
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/status-dhcp.sh b/openwrt/package/webif/files/www/cgi-bin/webif/status-dhcp.sh
new file mode 100755 (executable)
index 0000000..5517b78
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+header "Status" "DHCP" "@TR<<DHCP leases>>"
+?>
+<table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
+<tbody>
+       <tr>
+               <th>@TR<<MAC Address>></th>
+               <th>@TR<<IP Address>></th>
+               <th>@TR<<Name>></th>
+               <th>@TR<<Expires in>></th>
+       </tr>
+<? [ -e /tmp/dhcp.leases ] && awk -vdate="$(date +%s)" '
+$1 > 0 {
+       print "<tr>"
+       print "<td>" $2 "</td>"
+       print "<td>" $3 "</td>"
+       print "<td>" $4 "</td>"
+       print "<td>"
+       t = $1 - date
+       h = int(t / 60 / 60)
+       if (h > 0) printf h "h "
+       m = int(t / 60 % 60)
+       if (m > 0) printf m "min "
+       s = int(t % 60)
+       printf s "sec "
+       printf "</td>"
+       print "</tr>"
+}
+' /tmp/dhcp.leases ?>
+</tbody>
+</table>
+
+<? footer ?>
+<!--
+##WEBIF:name:Status:150:DHCP
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/status-wireless.sh b/openwrt/package/webif/files/www/cgi-bin/webif/status-wireless.sh
new file mode 100755 (executable)
index 0000000..c7ad0a3
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+header "Status" "Wireless" "@TR<<Wireless Status>>"
+?>
+
+<pre><? iwconfig 2>&1 | grep -v 'no wireless' | grep '\w' ?></pre>
+
+<? footer ?>
+<!--
+##WEBIF:name:Status:200:Wireless
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/system-ipkg.sh b/openwrt/package/webif/files/www/cgi-bin/webif/system-ipkg.sh
new file mode 100755 (executable)
index 0000000..b21918d
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+header "System" "Installed Software" "@TR<<Installed Software>>"
+?>
+<p style="position: absolute; right: 1em; top: 10.5em"><a href="ipkg.sh?action=update">@TR<<Update package lists>></a></p>
+<pre><?
+if [ "$FORM_action" = "update" ]; then
+       ipkg update
+elif [ "$FORM_action" = "install" ]; then
+       yes n | ipkg install `echo "$FORM_pkg" | sed -e 's, ,+,g'`
+elif [ "$FORM_action" = "remove" ]; then
+       ipkg remove `echo "$FORM_pkg" | sed -e 's, ,+,g'`
+fi
+?></pre>
+<div class="half noBorderOnLeft">
+  <h3>@TR<<Installed Packages>></h3>
+  <table style="width: 90%">
+<?
+ipkg list_installed | awk -F ' ' '
+$2 !~ /terminated/ {
+       link=$1
+       gsub(/\+/,"%2B",link)
+       print "<tr><td>" $1 "</td><td><a href=\"ipkg.sh?action=remove&pkg=" link "\" style=\"color: red\">@TR<<Uninstall>></a></td></tr>"
+}
+'
+?>
+  </table>
+</div>
+<div class="half noBorderOnLeft">
+  <h3>@TR<<Available packages>></h3>
+  <table style="width: 90%">
+<?
+grep Package: /usr/lib/ipkg/status /usr/lib/ipkg/lists/* 2>&- | sed -e 's, ,,' -e 's,/usr/lib/ipkg/lists/,,' | awk -F: '
+$1 ~ /status/ {
+       installed[$3]++;
+}
+($1 !~ /terminated/) && ($1 !~ /\/status/) && (!installed[$3]) {
+       if (current != $1) print "<tr><th>" $1 "</th><td></td></tr>"
+       link=$3
+       gsub(/\+/,"%2B",link)
+       print "<tr><td>" $3 "</td><td><a href=\"ipkg.sh?action=install&pkg=" link "\" style=\"color: green\">@TR<<Install>></a></td></tr>"
+       current=$1
+}
+'
+?>
+  </table>
+</div>
+
+<div class="rowOfBoxes"></div>
+         
+<? footer ?>
+<!--
+##WEBIF:name:System:300:Installed Software
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/system-password.sh b/openwrt/package/webif/files/www/cgi-bin/webif/system-password.sh
new file mode 100755 (executable)
index 0000000..87a768a
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+
+empty "$FORM_submit" || {
+       SAVED=1
+       validate <<EOF
+string|FORM_pw1|Password|required min=5|$FORM_pw1
+EOF
+       equal "$FORM_pw1" "$FORM_pw2" || {
+               ERROR="$ERROR Passwords do not match<br />"
+       }
+       empty "$ERROR" && {
+               RES=$(
+                       (
+                               echo "$FORM_pw1"
+                               sleep 1
+                               echo "$FORM_pw2"
+                       ) | passwd root 2>&1
+               )
+               equal "$?" 0 || ERROR="<pre>$RES</pre>"
+       }
+}
+
+header "System" "Password Change" "@TR<<Password Change>>" '' "$SCRIPT_NAME"
+
+display_form <<EOF
+start_form|@TR<<Password Change>>
+field|@TR<<New Password>>:
+password|pw1
+field|@TR<<Confirm Password>>:
+password|pw2
+end_form
+EOF
+
+footer ?>
+
+<!--
+##WEBIF:name:System:200:Password Change
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/system-settings.sh b/openwrt/package/webif/files/www/cgi-bin/webif/system-settings.sh
new file mode 100755 (executable)
index 0000000..cbb7f5a
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/webif-page
+<? 
+. /usr/lib/webif/webif.sh
+load_settings system
+load_settings nvram
+load_settings webif
+
+if empty "$FORM_submit"; then
+       FORM_hostname="${wan_hostname:-$(nvram get wan_hostname)}"
+       FORM_hostname="${FORM_hostname:-OpenWrt}"
+       FORM_language="${language:-$(nvram get language)}"
+       FORM_language="${FORM_language:-default}"
+       is_bcm947xx && {
+               FORM_boot_wait="${boot_wait:-$(nvram get boot_wait)}"
+               FORM_boot_wait="${FORM_boot_wait:-off}"
+       }
+else
+       SAVED=1
+       validate <<EOF
+hostname|FORM_hostname|Hostname|nodots required|$FORM_hostname
+EOF
+       equal "$?" 0 && {
+               save_setting system wan_hostname "$FORM_hostname"
+               save_setting webif language "$FORM_language"
+               is_bcm947xx && {
+                       case "$FORM_boot_wait" in
+                               on|off) save_setting nvram boot_wait "$FORM_boot_wait";;
+                       esac
+               }
+       }
+fi
+
+LANGUAGES="$(grep -H '^[\t ]*lang[\t ]*=>' /usr/lib/webif/lang/*/*.txt 2>/dev/null | awk -f /usr/lib/webif/languages.awk)"
+
+header "System" "Settings" "@TR<<System Settings>>" '' "$SCRIPT_NAME"
+
+is_bcm947xx && bootwait_form="field|boot_wait
+select|boot_wait|$FORM_boot_wait
+option|on|@TR<<Enabled>>
+option|off|@TR<<Disabled>>"
+
+display_form <<EOF
+start_form|@TR<<System Settings>>
+field|@TR<<Host Name>>
+text|hostname|$FORM_hostname
+$bootwait_form
+field|@TR<<Language>>
+select|language|$FORM_language
+$LANGUAGES
+end_form
+EOF
+
+footer ?>
+
+<!--
+##WEBIF:name:System:100:Settings
+-->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/system-upgrade.sh b/openwrt/package/webif/files/www/cgi-bin/webif/system-upgrade.sh
new file mode 100755 (executable)
index 0000000..5bdd2f1
--- /dev/null
@@ -0,0 +1,113 @@
+#!/usr/bin/webif-page -p /bin/sh
+. /usr/lib/webif/webif.sh
+
+do_upgrade() {
+       # free some memory :)
+       ps | grep -vE 'Command|init|\[[kbmj]|httpd|haserl|bin/sh|awk|kill|ps|webif' | awk '{ print $1 }' | xargs kill -KILL
+       MEMFREE="$(awk 'BEGIN{ mem = 0 } ($1 == "MemFree:") || ($1 == "Cached:") {mem += int($2)} END{print mem}' /proc/meminfo)"
+       empty "$ERASE_FS" || MTD_OPT="-e linux"
+       if [ $(($MEMFREE)) -ge 4096 ]; then
+               bstrip "$BOUNDARY" > /tmp/firmware.bin
+               mtd $MTD_OPT -q -r write /tmp/firmware.bin linux
+       else
+               # Not enough memory for storing the firmware on tmpfs
+               bstrip "$BOUNDARY" | mtd $MTD_OPT -q -q -r write - linux
+       fi
+       echo "@TR<<done>>."
+}
+
+read_var() {
+       NAME=""
+       while :; do
+               read LINE
+               LINE="${LINE%%[^0-9A-Za-z]}"
+               equal "$LINE" "$BOUNDARY" && read LINE
+               empty "$NAME$LINE" && exit
+               case "${LINE%%:*}" in
+                       Content-Disposition)
+                               NAME="${LINE##*; name=\"}"
+                               NAME="${NAME%%\"*}"
+                       ;;
+               esac
+               empty "$LINE" && return
+       done
+}
+
+
+NOINPUT=1
+header "System" "Firmware Upgrade" "@TR<<Firmware Upgrade>>"
+
+equal "$REQUEST_METHOD" "GET" && {
+       cat <<EOF
+       <script type="text/javascript">
+       
+function statusupdate() {
+       document.getElementById("form_submit").style.display = "none";
+       document.getElementById("status_text").style.display = "inline";
+
+       return true;
+}
+function printStatus() {
+       document.write('<div style="display: none; font-size: 14pt; font-weight: bold;" id="status_text" />@TR<<Upgrading...>>&nbsp;</div>');
+}
+       </script>
+       <form method="POST" name="upgrade" action="$SCRIPT_NAME" enctype="multipart/form-data" onSubmit="statusupdate()">
+       <table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
+       <tbody>
+               <tr>
+                       <td>@TR<<Options>>:</td>
+                       <td>
+                               <input type="checkbox" name="erase_fs" value="1" />@TR<<Erase_JFFS2|Erase JFFS2 partition>>
+                       </td>
+               </tr>
+               <tr>
+                       <td>@TR<<Firmware_image|Firmware image to upload:>></td>
+                       <td>
+                               <input type="file" name="firmware" />
+                       </td>
+               </tr>
+               <tr>
+                       <td />
+                       <td>
+                               <script type="text/javascript">printStatus()</script>
+                               <input id="form_submit" type="submit" name="submit" value="@TR<<Upgrade>>" onClick="statusupdate()" />
+                       </td>
+               </tr>
+       </tbody>
+       </table>
+       </form>
+EOF
+}
+equal "$REQUEST_METHOD" "POST" && {
+       equal "${CONTENT_TYPE%%;*}" "multipart/form-data" || ERR=1
+       BOUNDARY="${CONTENT_TYPE##*boundary=}"
+       empty "$BOUNDARY" && ERR=1
+
+       empty "$ERR" || {
+               echo "Wrong data format"
+               footer
+               exit
+       }
+cat <<EOF
+       <div style="margin: auto; text-align: left">
+<pre>
+EOF
+       while :; do
+               read_var
+               empty "$NAME" && exit
+               case "$NAME" in
+                       erase_fs)
+                               ERASE_FS=1
+                               bstrip "$BOUNDARY" > /dev/null
+                       ;;
+                       firmware) do_upgrade;;
+               esac
+       done
+cat <<EOF
+       </div>
+EOF
+}
+
+footer
+
+##WEBIF:name:System:400:Firmware Upgrade
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/system.sh b/openwrt/package/webif/files/www/cgi-bin/webif/system.sh
deleted file mode 100755 (executable)
index e21f8d7..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-load_settings system
-load_settings nvram
-load_settings webif
-
-if empty "$FORM_submit"; then
-       FORM_hostname="${wan_hostname:-$(nvram get wan_hostname)}"
-       FORM_hostname="${FORM_hostname:-OpenWrt}"
-       FORM_language="${language:-$(nvram get language)}"
-       FORM_language="${FORM_language:-default}"
-       is_bcm947xx && {
-               FORM_boot_wait="${boot_wait:-$(nvram get boot_wait)}"
-               FORM_boot_wait="${FORM_boot_wait:-off}"
-       }
-else
-       SAVED=1
-       validate <<EOF
-hostname|FORM_hostname|Hostname|nodots required|$FORM_hostname
-EOF
-       equal "$?" 0 && {
-               save_setting system wan_hostname "$FORM_hostname"
-               save_setting webif language "$FORM_language"
-               is_bcm947xx && {
-                       case "$FORM_boot_wait" in
-                               on|off) save_setting nvram boot_wait "$FORM_boot_wait";;
-                       esac
-               }
-       }
-fi
-
-LANGUAGES="$(grep -H '^[\t ]*lang[\t ]*=>' /usr/lib/webif/lang/*/*.txt 2>/dev/null | awk -f /usr/lib/webif/languages.awk)"
-
-header "System" "Settings" "@TR<<System Settings>>" '' "$SCRIPT_NAME"
-
-is_bcm947xx && bootwait_form="field|boot_wait
-select|boot_wait|$FORM_boot_wait
-option|on|@TR<<Enabled>>
-option|off|@TR<<Disabled>>"
-
-display_form <<EOF
-start_form|@TR<<System Settings>>
-field|@TR<<Host Name>>
-text|hostname|$FORM_hostname
-$bootwait_form
-field|@TR<<Language>>
-select|language|$FORM_language
-$LANGUAGES
-end_form
-EOF
-
-footer ?>
-
-<!--
-##WEBIF:name:System:1:Settings
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/upgrade.sh b/openwrt/package/webif/files/www/cgi-bin/webif/upgrade.sh
deleted file mode 100755 (executable)
index c5750fa..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/webif-page -p /bin/sh
-. /usr/lib/webif/webif.sh
-
-do_upgrade() {
-       # free some memory :)
-       ps | grep -vE 'Command|init|\[[kbmj]|httpd|haserl|bin/sh|awk|kill|ps|webif' | awk '{ print $1 }' | xargs kill -KILL
-       MEMFREE="$(awk 'BEGIN{ mem = 0 } ($1 == "MemFree:") || ($1 == "Cached:") {mem += int($2)} END{print mem}' /proc/meminfo)"
-       empty "$ERASE_FS" || MTD_OPT="-e linux"
-       if [ $(($MEMFREE)) -ge 4096 ]; then
-               bstrip "$BOUNDARY" > /tmp/firmware.bin
-               mtd $MTD_OPT -q -r write /tmp/firmware.bin linux
-       else
-               # Not enough memory for storing the firmware on tmpfs
-               bstrip "$BOUNDARY" | mtd $MTD_OPT -q -q -r write - linux
-       fi
-       echo "@TR<<done>>."
-}
-
-read_var() {
-       NAME=""
-       while :; do
-               read LINE
-               LINE="${LINE%%[^0-9A-Za-z]}"
-               equal "$LINE" "$BOUNDARY" && read LINE
-               empty "$NAME$LINE" && exit
-               case "${LINE%%:*}" in
-                       Content-Disposition)
-                               NAME="${LINE##*; name=\"}"
-                               NAME="${NAME%%\"*}"
-                       ;;
-               esac
-               empty "$LINE" && return
-       done
-}
-
-
-NOINPUT=1
-header "System" "Firmware Upgrade" "@TR<<Firmware Upgrade>>"
-
-equal "$REQUEST_METHOD" "GET" && {
-       cat <<EOF
-       <script type="text/javascript">
-       
-function statusupdate() {
-       document.getElementById("form_submit").style.display = "none";
-       document.getElementById("status_text").style.display = "inline";
-
-       return true;
-}
-function printStatus() {
-       document.write('<div style="display: none; font-size: 14pt; font-weight: bold;" id="status_text" />@TR<<Upgrading...>>&nbsp;</div>');
-}
-       </script>
-       <form method="POST" name="upgrade" action="$SCRIPT_NAME" enctype="multipart/form-data" onSubmit="statusupdate()">
-       <table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
-       <tbody>
-               <tr>
-                       <td>@TR<<Options>>:</td>
-                       <td>
-                               <input type="checkbox" name="erase_fs" value="1" />@TR<<Erase_JFFS2|Erase JFFS2 partition>>
-                       </td>
-               </tr>
-               <tr>
-                       <td>@TR<<Firmware_image|Firmware image to upload:>></td>
-                       <td>
-                               <input type="file" name="firmware" />
-                       </td>
-               </tr>
-               <tr>
-                       <td />
-                       <td>
-                               <script type="text/javascript">printStatus()</script>
-                               <input id="form_submit" type="submit" name="submit" value="@TR<<Upgrade>>" onClick="statusupdate()" />
-                       </td>
-               </tr>
-       </tbody>
-       </table>
-       </form>
-EOF
-}
-equal "$REQUEST_METHOD" "POST" && {
-       equal "${CONTENT_TYPE%%;*}" "multipart/form-data" || ERR=1
-       BOUNDARY="${CONTENT_TYPE##*boundary=}"
-       empty "$BOUNDARY" && ERR=1
-
-       empty "$ERR" || {
-               echo "Wrong data format"
-               footer
-               exit
-       }
-cat <<EOF
-       <div style="margin: auto; text-align: left">
-<pre>
-EOF
-       while :; do
-               read_var
-               empty "$NAME" && exit
-               case "$NAME" in
-                       erase_fs)
-                               ERASE_FS=1
-                               bstrip "$BOUNDARY" > /dev/null
-                       ;;
-                       firmware) do_upgrade;;
-               esac
-       done
-cat <<EOF
-       </div>
-EOF
-}
-
-footer
-
-##WEBIF:name:System:4:Firmware Upgrade
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/wan.sh b/openwrt/package/webif/files/www/cgi-bin/webif/wan.sh
deleted file mode 100755 (executable)
index e172c56..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-
-load_settings network
-
-FORM_dns="${wan_dns:-$(nvram get wan_dns)}"
-LISTVAL="$FORM_dns"
-handle_list "$FORM_dnsremove" "$FORM_dnsadd" "$FORM_dnssubmit" 'ip|FORM_dnsadd|@TR<<DNS Address>>|required' && {
-       FORM_dns="$LISTVAL"
-       save_setting network wan_dns "$FORM_dns"
-}
-FORM_dnsadd=${FORM_dnsadd:-192.168.1.1}
-
-if empty "$FORM_submit"; then
-       FORM_wan_proto=${wan_proto:-$(nvram get wan_proto)}
-       case "$FORM_wan_proto" in
-               # supported types
-               static|dhcp|pptp|pppoe) ;;
-               # otherwise select "none"
-               *) FORM_wan_proto="none";;
-       esac
-       
-       # pptp, dhcp and static common
-       FORM_wan_ipaddr=${wan_ipaddr:-$(nvram get wan_ipaddr)}
-       FORM_wan_netmask=${wan_netmask:-$(nvram get wan_netmask)}
-       FORM_wan_gateway=${wan_gateway:-$(nvram get wan_gateway)}
-       
-       # ppp common
-       FORM_ppp_username=${ppp_username:-$(nvram get ppp_username)}
-       FORM_ppp_passwd=${ppp_passwd:-$(nvram get ppp_passwd)}
-       FORM_ppp_idletime=${ppp_idletime:-$(nvram get ppp_idletime)}
-       FORM_ppp_redialperiod=${ppp_redialperiod:-$(nvram get ppp_redialperiod)}
-       FORM_ppp_mtu=${ppp_mtu:-$(nvram get ppp_mtu)}
-
-       redial=${ppp_demand:-$(nvram get ppp_demand)}
-       case "$redial" in
-               1|enabled|on) FORM_ppp_redial="demand";;        
-               *) FORM_ppp_redial="persist";;  
-       esac
-       
-       FORM_pptp_server_ip=${pptp_server_ip:-$(nvram get pptp_server_ip)}
-else
-       SAVED=1
-
-       empty "$FORM_wan_proto" && {
-               ERROR="@TR<<No WAN Proto|No WAN protocol has been selected>>" 
-               return 255
-       }
-
-       case "$FORM_wan_proto" in
-               static)
-                       V_IP="required"
-                       V_NM="required"
-                       ;;
-               pptp)
-                       V_PPTP="required"
-                       ;;
-       esac
-
-validate <<EOF
-ip|FORM_wan_ipaddr|@TR<<IP Address>>|$V_IP|$FORM_wan_ipaddr
-netmask|FORM_wan_netmask|@TR<<Netmask>>|$V_NM|$FORM_wan_netmask
-ip|FORM_wan_gateway|@TR<<Default Gateway>>||$FORM_wan_gateway
-ip|FORM_pptp_server_ip|@TR<<PPTP Server IP>>|$V_PPTP|$FORM_pptp_server_ip
-EOF
-       equal "$?" 0 && {
-               save_setting network wan_proto $FORM_wan_proto
-               
-               # Settings specific to one protocol type
-               case "$FORM_wan_proto" in
-                       static) save_setting network wan_gateway $FORM_wan_gateway ;;
-                       pptp) save_setting network pptp_server_ip "$FORM_pptp_server_ip" ;;
-               esac
-               
-               # Common settings for PPTP, Static and DHCP 
-               case "$FORM_wan_proto" in
-                       pptp|static|dhcp)
-                               save_setting network wan_ipaddr $FORM_wan_ipaddr
-                               save_setting network wan_netmask $FORM_wan_netmask 
-                       ;;
-               esac
-               
-               # Common PPP settings
-               case "$FORM_wan_proto" in
-                       pppoe|pptp)
-                               empty "$FORM_ppp_username" || save_setting network ppp_username $FORM_ppp_username
-                               empty "$FORM_ppp_passwd" || save_setting network ppp_passwd $FORM_ppp_passwd
-               
-                               # These can be blank
-                               save_setting network ppp_idletime "$FORM_ppp_idletime"
-                               save_setting network ppp_redialperiod "$FORM_ppp_redialperiod"
-                               save_setting network ppp_mtu "$FORM_ppp_mtu"
-
-                               save_setting network wan_ifname "ppp0"
-               
-                               case "$FORM_ppp_redial" in
-                                       demand)
-                                               save_setting network ppp_demand 1
-                                               ;;
-                                       persist)
-                                               save_setting network ppp_demand ""
-                                               ;;
-                               esac    
-                       ;;
-                       *)
-                               wan_ifname=${wan_ifname:-$(nvram get wan_ifname)}
-                               [ -z "$wan_ifname" -o "${wan_ifname%%[0-9]*}" = "ppp" ] && {
-                                       wan_device=${wan_device:-$(nvram get wan_device)}
-                                       wan_device=${wan_device:-vlan1}
-                                       save_setting network wan_ifname "$wan_device"
-                               }
-                       ;;
-               esac
-       }
-fi
-
-# detect pptp package and compile option
-[ -x /sbin/ifup.pptp ] && {
-       PPTP_OPTION="option|pptp|PPTP"
-       PPTP_SERVER_OPTION="field|PPTP Server IP|pptp_server|hidden
-text|pptp_server_ip|$FORM_pptp_server_ip"
-}
-[ -x /sbin/ifup.pppoe ] && {
-       PPPOE_OPTION="option|pppoe|PPPoE"
-}
-
-
-header "Network" "WAN" "@TR<<WAN Configuration>>" ' onLoad="modechange()" ' "$SCRIPT_NAME"
-
-cat <<EOF
-<script type="text/javascript" src="/webif.js "></script>
-<script type="text/javascript">
-<!--
-function modechange()
-{
-       var v;
-       v = (isset('wan_proto', 'pppoe') || isset('wan_proto', 'pptp'));
-       set_visible('ppp_settings', v);
-       set_visible('username', v);
-       set_visible('passwd', v);
-       set_visible('redial', v);
-       set_visible('mtu', v);
-       set_visible('demand_idletime', v && isset('ppp_redial', 'demand'));
-       set_visible('persist_redialperiod', v && !isset('ppp_redial', 'demand'));
-       
-       v = (isset('wan_proto', 'static') || isset('wan_proto', 'pptp') || isset('wan_proto', 'dhcp'));
-       set_visible('ip_settings', v);
-       set_visible('ipaddr', v);
-       set_visible('netmask', v);
-       
-       v = isset('wan_proto', 'static');
-       set_visible('gateway', v);
-       set_visible('dns', v);
-
-       v = isset('wan_proto', 'pptp');
-       set_visible('pptp_server',v);
-
-       hide('save');
-       show('save');
-}
--->
-</script>
-EOF
-
-display_form <<EOF
-onchange|modechange
-start_form|@TR<<WAN Configuration>>
-field|@TR<<Connection Type>>
-select|wan_proto|$FORM_wan_proto
-option|none|@TR<<No WAN#None>>
-option|dhcp|@TR<<DHCP>>
-option|static|@TR<<Static IP>>
-$PPPOE_OPTION
-$PPTP_OPTION
-helplink|http://wiki.openwrt.org/OpenWrtDocs/Configuration#head-b62c144b9886b221e0c4b870edb0dd23a7b6acab
-end_form
-start_form|@TR<<IP Settings>>|ip_settings|hidden
-field|@TR<<IP Address>>|ipaddr|hidden
-text|wan_ipaddr|$FORM_wan_ipaddr
-field|@TR<<Netmask>>|netmask|hidden
-text|wan_netmask|$FORM_wan_netmask
-field|@TR<<Default Gateway>>|gateway|hidden
-text|wan_gateway|$FORM_wan_gateway
-$PPTP_SERVER_OPTION
-helpitem|IP Settings
-helptext|Helptext IP Settings#IP Settings are optional for DHCP and PPTP. If you set them, they are used as defaults in case the DHCP server is unavailable.
-end_form
-start_form|@TR<<DNS Servers>>|dns|hidden
-listedit|dns|$SCRIPT_NAME?wan_proto=static&|$FORM_dns|$FORM_dnsadd
-helpitem|Note
-helptext|Helptext DNS save#You should save your settings on this page before adding/removing DNS servers
-end_form
-
-start_form|@TR<<PPP Settings>>|ppp_settings|hidden
-field|@TR<<Redial Policy>>|redial|hidden
-select|ppp_redial|$FORM_ppp_redial
-option|demand|@TR<<Connect on Demand>>
-option|persist|@TR<<Keep Alive>>
-field|@TR<<Maximum Idle Time>>|demand_idletime|hidden
-text|ppp_idletime|$FORM_ppp_idletime
-helpitem|Maximum Idle Time
-helptext|Helptext Idle Time#The number of seconds without internet traffic that the router should wait before disconnecting from the Internet (Connect on Demand only)
-field|@TR<<Redial Timeout>>|persist_redialperiod|hidden
-text|ppp_redialperiod|$FORM_ppp_redialperiod
-helpitem|Redial Timeout
-helptext|Helptext Redial Timeout#The number of seconds to wait after receiving no response from the provider before trying to reconnect
-field|@TR<<Username>>|username|hidden
-text|ppp_username|$FORM_ppp_username
-field|@TR<<Password>>|passwd|hidden
-password|ppp_passwd|$FORM_ppp_passwd
-field|@TR<<MTU>>|mtu|hidden
-text|ppp_mtu|$FORM_ppp_mtu
-end_form
-EOF
-
-footer ?>
-<!--
-##WEBIF:name:Network:2:WAN
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-advanced.sh
deleted file mode 100755 (executable)
index 7a096c8..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-load_settings "wireless"
-
-FORM_wds="${wl0_wds:-$(nvram get wl0_wds)}"
-LISTVAL="$FORM_wds"
-handle_list "$FORM_wdsremove" "$FORM_wdsadd" "$FORM_wdssubmit" 'mac|FORM_wdsadd|WDS MAC address|required' && {
-       FORM_wds="$LISTVAL"
-       save_setting wireless wl0_wds "$FORM_wds"
-}
-FORM_wdsadd=${FORM_wdsadd:-00:00:00:00:00:00}
-
-FORM_maclist="${wl0_maclist:-$(nvram get wl0_maclist)}"
-LISTVAL="$FORM_maclist"
-handle_list "$FORM_maclistremove" "$FORM_maclistadd" "$FORM_maclistsubmit" 'mac|FORM_maclistadd|WDS MAC address|required' && {
-       FORM_maclist="$LISTVAL"
-       save_setting wireless wl0_maclist "$FORM_maclist"
-}
-FORM_maclistadd=${FORM_maclistadd:-00:00:00:00:00:00}
-
-if empty "$FORM_submit"; then
-       FORM_macmode="${wl0_macmode:-$(nvram get wl0_macmode)}"
-       FORM_lazywds=${wl0_lazywds:-$(nvram get wl0_lazywds)}
-       case "$FORM_lazywds" in
-               1|on|enabled) FORM_lazywds=1;;
-               *) FORM_lazywds=0;;
-       esac
-       FORM_wdstimeout=${wl0_wdstimeout:-$(nvram get wl0_wdstimeout)}
-       FORM_antdiv="${wl0_antdiv:-$(nvram get wl0_antdiv)}"
-       case "$FORM_antdiv" in
-               -1|auto) FORM_antdiv=-1;;
-               0|main|left) FORM_antdiv=0;;
-               1|aux|right) FORM_antdiv=1;;
-               3|diversity) FORM_antdiv=3;;
-               *) FORM_antdiv=-1;;
-       esac
-       FORM_distance="${wl0_distance:-$(nvram get wl0_distance)}"
-else
-       SAVED=1
-
-       validate <<EOF
-int|FORM_lazywds|Lazy WDS On/Off|required min=0 max=1|$FORM_lazywds
-int|FORM_wdstimeout|WDS watchdog timeout|optional min=0 max=3600|$FORM_wdstimeout
-int|FORM_distance|Distance|optional min=1|$FORM_distance
-EOF
-       equal "$?" 0 && {
-               save_setting wireless wl0_lazywds "$FORM_lazywds"
-               save_setting wireless wl0_wdstimeout "$FORM_wdstimeout"
-               save_setting wireless wl0_macmode "$FORM_macmode"
-               save_setting wireless wl0_antdiv "$FORM_antdiv"
-               save_setting wireless wl0_distance "$FORM_distance"
-       }
-fi
-
-header "Network" "Advanced Wireless" "@TR<<Advanced Wireless Configuration>>" ' onLoad="modechange()"' "$SCRIPT_NAME"
-
-cat <<EOF
-<script type="text/javascript" src="/webif.js"></script>
-<script type="text/javascript">
-
-function modechange() {
-       var v = (value("macmode") == "allow") || (value("macmode") == "deny");
-       set_visible('mac_list', v);
-}
-
-</script>
-EOF
-
-display_form <<EOF
-onchange|modechange
-start_form|@TR<<WDS Connections>>
-listedit|wds|$SCRIPT_NAME?|$FORM_wds|$FORM_wdsadd
-end_form
-start_form|@TR<<MAC Filter List>>
-listedit|maclist|$SCRIPT_NAME?|$FORM_maclist|$FORM_maclistadd
-end_form
-start_form|@TR<<Settings>>
-field|@TR<<Automatic WDS>>
-select|lazywds|$FORM_lazywds
-option|1|@TR<<Enabled>>
-option|0|@TR<<Disabled>>
-field|@TR<<WDS watchdog timeout>>
-text|wdstimeout|$FORM_wdstimeout
-field|@TR<<Filter Mode>>:
-select|macmode|$FORM_macmode
-option|disabled|@TR<<Disabled>>
-option|allow|@TR<<Allow>>
-option|deny|@TR<<Deny>>
-field|@TR<<Antenna selection>>:
-select|antdiv|$FORM_antdiv
-option|-1|@TR<<Automatic>>
-option|0|@TR<<Left>>
-option|1|@TR<<Right>>
-option|3|@TR<<Diversity>>
-field|@TR<<Distance>>
-text|distance|$FORM_distance
-end_form
-EOF
-
-footer ?>
-<!--
-##WEBIF:name:Network:4:Advanced Wireless
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-config.sh
deleted file mode 100755 (executable)
index 6709098..0000000
+++ /dev/null
@@ -1,290 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-load_settings "wireless"
-
-CC=${wl0_country_code:-$(nvram get wl0_country_code)}
-case "$CC" in
-       All|all|ALL) CHANNELS="1 2 3 4 5 6 7 8 9 10 11 12 13 14"; CHANNEL_MAX=14 ;;
-       *) CHANNELS="1 2 3 4 5 6 7 8 9 10 11"; CHANNEL_MAX=11 ;;
-esac
-F_CHANNELS="option|0|@TR<<Auto>>"
-for ch in $CHANNELS; do
-       F_CHANNELS="${F_CHANNELS}
-option|$ch"
-done
-
-if empty "$FORM_submit"; then
-       FORM_mode=${wl0_mode:-$(nvram get wl0_mode)}
-       infra=${wl0_infra:-$(nvram get wl0_infra)}
-       case "$infra" in
-               0|off|disabled) FORM_mode=adhoc;;
-       esac
-       FORM_radio=${wl0_radio:-$(nvram get wl0_radio)}
-       case "$FORM_radio" in
-               0|off|diabled) FORM_radio=0;;
-               *) FORM_radio=1;;
-       esac
-                       
-       FORM_ssid=${wl0_ssid:-$(nvram get wl0_ssid)}
-       FORM_broadcast=${wl0_closed:-$(nvram get wl0_closed)}
-       case "$FORM_broadcast" in
-               1|off|disabled) FORM_broadcast=1;;
-               *) FORM_broadcast=0;;
-       esac
-       FORM_channel=${wl0_channel:-$(nvram get wl0_channel)}
-       FORM_encryption=off
-       akm=${wl0_akm:-$(nvram get wl0_akm)}
-       case "$akm" in
-               psk)
-                       FORM_encryption=psk
-                       FORM_wpa1=wpa1
-                       ;;
-               psk2)
-                       FORM_encryption=psk
-                       FORM_wpa2=wpa2
-                       ;;
-               'psk psk2')
-                       FORM_encryption=psk
-                       FORM_wpa1=wpa1
-                       FORM_wpa2=wpa2
-                       ;;
-               wpa)
-                       FORM_encryption=wpa
-                       FORM_wpa1=wpa1
-                       ;;
-               wpa2)
-                       FORM_encryption=wpa
-                       FORM_wpa2=wpa2
-                       ;;
-               'wpa wpa2')
-                       FORM_encryption=wpa
-                       FORM_wpa1=wpa1
-                       FORM_wpa2=wpa2
-                       ;;
-               *)
-                       FORM_wpa1=wpa1
-                       ;;
-       esac
-       FORM_wpa_psk=${wl0_wpa_psk:-$(nvram get wl0_wpa_psk)}
-       FORM_radius_key=${wl0_radius_key:-$(nvram get wl0_radius_key)}
-       FORM_radius_ipaddr=${wl0_radius_ipaddr:-$(nvram get wl0_radius_ipaddr)}
-       crypto=${wl0_crypto:-$(nvram get wl0_crypto)}
-       case "$crypto" in
-               tkip)
-                       FORM_tkip=tkip
-                       ;;
-               aes)
-                       FORM_aes=aes
-                       ;;
-               'tkip+aes'|'aes+tkip')
-                       FORM_aes=aes
-                       FORM_tkip=tkip
-                       ;;
-               *)
-                       FORM_tkip=tkip
-                       ;;
-       esac
-       equal "$FORM_encryption" "off" && {
-               wep=${wl0_wep:-$(nvram get wl0_wep)}
-               case "$wep" in
-                       1|enabled|on) FORM_encryption=wep;;
-                       *) FORM_encryption=off;;
-               esac
-       }
-       FORM_key1=${wl0_key1:-$(nvram get wl0_key1)}
-       FORM_key2=${wl0_key2:-$(nvram get wl0_key2)}
-       FORM_key3=${wl0_key3:-$(nvram get wl0_key3)}
-       FORM_key4=${wl0_key4:-$(nvram get wl0_key4)}
-       key=${wl0_key:-$(nvram get wl0_key)}
-       FORM_key=${key:-1}
-else
-       SAVED=1
-       case "$FORM_encryption" in
-               wpa) V_RADIUS="
-string|FORM_radius_key|@TR<<RADIUS Server Key>>|min=4 max=63 required|$FORM_radius_key
-ip|FORM_radius_ipaddr|@TR<<RADIUS IP Address>>|required|$FORM_radius_ipaddr";;
-               psk) V_PSK="wpapsk|FORM_wpa_psk|@TR<<WPA PSK#WPA Pre-Shared Key>>|required|$FORM_wpa_psk";;
-               wep) V_WEP="
-int|FORM_key|@TR<<Selected WEP Key>>|min=1 max=4|$FORM_key
-wep|FORM_key1|@TR<<WEP Key>> 1||$FORM_key1
-wep|FORM_key2|@TR<<WEP Key>> 2||$FORM_key2
-wep|FORM_key3|@TR<<WEP Key>> 3||$FORM_key3
-wep|FORM_key4|@TR<<WEP Key>> 4||$FORM_key4";;
-       esac
-
-       validate <<EOF
-int|FORM_radio|wl0_radio|required min=0 max=1|$FORM_radio
-int|FORM_broadcast|wl0_closed|required min=0 max=1|$FORM_broadcast
-string|FORM_ssid|@TR<<ESSID>>|required|$FORM_ssid
-int|FORM_channel|@TR<<Channel>>|required min=0 max=$CHANNEL_MAX|$FORM_channel
-$V_WEP
-$V_RADIUS
-$V_PSK
-EOF
-       equal "$?" 0 && {
-               save_setting wireless wl0_radio "$FORM_radio"
-
-               if equal "$FORM_mode" adhoc; then
-                       FORM_mode=sta
-                       infra="0"
-               fi
-               save_setting wireless wl0_mode "$FORM_mode"
-               save_setting wireless wl0_infra ${infra:-1}
-                       
-               save_setting wireless wl0_ssid "$FORM_ssid"
-               save_setting wireless wl0_closed "$FORM_broadcast"
-               save_setting wireless wl0_channel "$FORM_channel"
-       
-               crypto=""
-               equal "$FORM_aes" aes && crypto="aes"
-               equal "$FORM_tkip" tkip && crypto="tkip${crypto:++$crypto}"
-               save_setting wireless wl0_crypto "$crypto"
-
-               case "$FORM_encryption" in
-                       psk)
-                               case "${FORM_wpa1}${FORM_wpa2}" in
-                                       wpa1) save_setting wireless wl0_akm "psk";;
-                                       wpa2) save_setting wireless wl0_akm "psk2";;
-                                       wpa1wpa2) save_setting wireless wl0_akm "psk psk2";;
-                               esac
-                               save_setting wireless wl0_wpa_psk "$FORM_wpa_psk"
-                               save_setting wireless wl0_wep "disabled"
-                               ;;
-                       wpa)
-                               case "${FORM_wpa1}${FORM_wpa2}" in
-                                       wpa1) save_setting wireless wl0_akm "wpa";;
-                                       wpa2) save_setting wireless wl0_akm "wpa2";;
-                                       wpa1wpa2) save_setting wireless wl0_akm "wpa wpa2";;
-                               esac
-                               save_setting wireless wl0_radius_ipaddr "$FORM_radius_ipaddr"
-                               save_setting wireless wl0_radius_key "$FORM_radius_key"
-                               save_setting wireless wl0_wep "disabled"
-                               ;;
-                       wep)
-                               save_setting wireless wl0_wep enabled
-                               save_setting wireless wl0_akm "none"
-                               save_setting wireless wl0_key1 "$FORM_key1"
-                               save_setting wireless wl0_key2 "$FORM_key2"
-                               save_setting wireless wl0_key3 "$FORM_key3"
-                               save_setting wireless wl0_key4 "$FORM_key4"
-                               save_setting wireless wl0_key "$FORM_key"
-                               ;;
-                       off)
-                               save_setting wireless wl0_akm "none"
-                               save_setting wireless wl0_wep disabled
-                               ;;
-               esac
-       }
-fi
-
-header "Network" "Wireless" "@TR<<Wireless Configuration>>" ' onLoad="modechange()" ' "$SCRIPT_NAME"
-
-cat <<EOF
-<script type="text/javascript" src="/webif.js"></script>
-<script type="text/javascript">
-<!--
-function modechange()
-{
-       if (isset('mode','adhoc')) {
-               document.getElementById('encryption_psk').disabled = true;
-               if (isset('encryption','psk')) {
-                               document.getElementById('encryption').value = 'off';
-               }
-       } else {
-               document.getElementById('encryption_psk').disabled = false;
-       }
-       
-       if (!isset('mode','ap')) {
-               document.getElementById('encryption_wpa').disabled = true;
-               if (value('encryption') == 'wpa') {
-                               document.getElementById('encryption').value = 'off';
-               }
-       } else {
-               document.getElementById('encryption_wpa').disabled = false;
-       }
-
-       var v = (isset('encryption','wpa') || isset('encryption','psk'));
-       set_visible('wpa_support', v);
-       set_visible('wpa_crypto', v);
-       
-       set_visible('wpapsk', isset('encryption','psk'));
-       set_visible('wep_keys', isset('encryption','wep'));
-
-       v = isset('encryption','wpa');
-       set_visible('radiuskey', v);
-       set_visible('radius_ip', v);
-
-       hide('save');
-       show('save');
-}
--->
-</script>
-
-EOF
-
-display_form <<EOF
-onchange|modechange
-start_form|@TR<<Wireless Configuration>>
-field|@TR<<Wireless Interface>>
-select|radio|$FORM_radio
-option|1|@TR<<Enabled>>
-option|0|@TR<<Disabled>>
-field|@TR<<ESSID Broadcast>>
-select|broadcast|$FORM_broadcast
-option|0|@TR<<Show>>
-option|1|@TR<<Hide>>
-field|@TR<<ESSID>>
-text|ssid|$FORM_ssid
-helpitem|ESSID
-helptext|Helptext ESSID#Name of your Wireless Network
-field|@TR<<Channel>>
-select|channel|$FORM_channel
-$F_CHANNELS
-field|@TR<<WLAN Mode#Mode>>
-select|mode|$FORM_mode
-option|ap|@TR<<Access Point>>
-option|sta|@TR<<Client>>
-option|wet|@TR<<Client>> (@TR<<Bridge>>)
-option|adhoc|@TR<<Ad-Hoc>>
-helpitem|WLAN Mode#Mode
-helptext|Helptext Operation mode#This sets the operation mode of your wireless network. Selecting 'Client (Bridge)' will not change your network interface settings. It will only set some parameters in the wireless driver that allow for limited bridging of the interface.
-helplink|http://wiki.openwrt.org/OpenWrtDocs/Configuration#head-7126c5958e237d603674b3a9739c9d23bdfdb293
-end_form
-start_form|@TR<<Encryption Settings>>
-field|@TR<<Encryption Type>>
-select|encryption|$FORM_encryption
-option|off|@TR<<Disabled>>
-option|wep|WEP
-option|psk|WPA (@TR<<PSK>>)
-option|wpa|WPA (RADIUS)
-helpitem|Encryption Type
-helptext|Helptext Encryption Type#'WPA (RADIUS)' is only supported in Access Point mode. <br /> 'WPA (PSK)' doesn't work in Ad-Hoc mode.
-field|@TR<<WPA Mode>>|wpa_support|hidden
-checkbox|wpa1|$FORM_wpa1|wpa1|WPA1
-checkbox|wpa2|$FORM_wpa2|wpa2|WPA2
-field|@TR<<WPA Algorithms>>|wpa_crypto|hidden
-checkbox|tkip|$FORM_tkip|tkip|RC4 (TKIP)
-checkbox|aes|$FORM_aes|aes|AES
-field|WPA @TR<<PSK>>|wpapsk|hidden
-text|wpa_psk|$FORM_wpa_psk
-field|@TR<<RADIUS IP Address>>|radius_ip|hidden
-text|radius_ipaddr|$FORM_radius_ipaddr
-field|@TR<<RADIUS Server Key>>|radiuskey|hidden
-text|radius_key|$FORM_radius_key
-field|@TR<<WEP Keys>>|wep_keys|hidden
-radio|key|$FORM_key|1
-text|key1|$FORM_key1|<br />
-radio|key|$FORM_key|2
-text|key2|$FORM_key2|<br />
-radio|key|$FORM_key|3
-text|key3|$FORM_key3|<br />
-radio|key|$FORM_key|4
-text|key4|$FORM_key4|<br />
-end_form
-EOF
-
-footer ?>
-<!--
-##WEBIF:name:Network:3:Wireless
--->
diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/wireless-status.sh b/openwrt/package/webif/files/www/cgi-bin/webif/wireless-status.sh
deleted file mode 100755 (executable)
index 47c044e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/webif-page
-<? 
-. /usr/lib/webif/webif.sh
-header "Status" "Wireless" "@TR<<Wireless Status>>"
-?>
-
-<pre><? iwconfig 2>&1 | grep -v 'no wireless' | grep '\w' ?></pre>
-
-<? footer ?>
-<!--
-##WEBIF:name:Status:2:Wireless
--->