--- /dev/null
+#!/bin/sh
+# getemergency.cgi
+# David Rowe 8 March 2011
+#
+# CGI to return emergency IP details
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1">
+</head>
+<body>
+EOF
+
+if [ -f /etc/rc.d/S05network-backdoor ]; then
+ backdoor=`sed -n 's/IPADDRESS="\(.*\)"/\1/p' /etc/init.d/network-backdoor`
+ echo BACKDOOR=\"$backdoor\"
+fi
+
+cat <<EOF
+</body>
+</html>
+EOF
*/
var menuItems = [
- '<a href="phones.sh">Phone System</a>',
+ '<a href="phones.html">Phone System</a>',
'<a href="about.sh">About</a>',
'<a href="admin.sh">Admin</a>',
'<a href="faq.sh">FAQ</a>',
'<a href="ipphones.sh">IP Phones</a>',
'<a href="logout.sh">Logout</a>',
- '<a href="network.sh">Network</a>',
+ '<a href="network.html">Network</a>',
'<a href="voiplines.sh">VOIP Line</a>'
];
}
+// called when Fping CGI returns
+
+function processFping(doc, status) {
+
+ // Change icon based on ping results
+
+ var icon;
+
+ if (doc.indexOf("google.com") != -1)
+ icon = '<img src="tick.png" />';
+ else
+ icon = '<img src="cross.png" />';
+
+ document.getElementById('internet').innerHTML = icon;
+}
+
+
/**
* Returns an XMLHttp instance to use for asynchronous
* downloading. This method will never throw an exception, but will
<table align="center" width=600 border=0>
<tr><td colspan="2" align="left" valign="top"><h2>Network</h2></td></tr>
<tr>
- <td><input type="radio" id="static" name="dhcp" value="no" onClick="doStatic()">Static</td>
- <td><input type="radio" id="dhcp" name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
+ <td><input type="radio" name="static" value="no" onClick="doStatic()">Static</td>
+ <td><input type="radio" name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
</tr>
<tr><td>IP Address:</td><td><input type="text" name="ipaddress" onBlur="isIP(this)"></td></tr>
<tr><td>Netmask:</td><td><input type="text" name="netmask" onBlur="isIP(this)"></td></tr>
<tr><td>Gateway:</td><td><input type="text" name="gateway" onBlur="isIP(this)"></td></tr>
<tr><td>DNS:</td><td><input type="text" name="dns" onBlur="isIP(this)"></td></tr>
<tr onMouseOver="popUp(event,'network_backdoor')" onmouseout="popUp(event,'network_backdoor')">
- <td>Emergency IP:</td><td><input type="text" name="backdoor" id="backdoor" onBlur="isIP(this)"></td>
+ <td>Emergency IP:</td><td><input type="text" name="backdoor" onBlur="isIP(this)"></td>
</tr>
<tr onMouseOver="popUp(event,'network_internet')" onmouseout="popUp(event,'network_internet')">
<td>Internet Connection:</td>
}
+function greyout(dhcp) {
+
+ if (dhcp == "yes") {
+ document.network.static.checked = 0;
+ document.network.dhcp.checked = 1;
+ document.network.ipaddress.disabled = 1;
+ document.network.netmask.disabled = 1;
+ document.network.gateway.disabled = 1;
+ document.network.dns.disabled = 1;
+ }
+ else {
+ document.network.static.checked = 1;
+ document.network.dhcp.checked = 0;
+ document.network.ipaddress.disabled = 0;
+ document.network.netmask.disabled = 0;
+ document.network.gateway.disabled = 0;
+ document.network.dns.disabled = 0;
+ }
+}
+
// called when DHCP CGI returns
function processDhcp(doc,status) {
}
);
+ greyout(dhcp);
+
if (dhcp == "no") {
- downloadUrl("/cgi-bin/getconf.cgi?file=../init.d/network-static", processStatic);
- }
- else {
- // grey out fields
+ downloadUrl("/cgi-bin/getconf.cgi?file=../init.d/network-static", processStatic);
}
}
parseNetwork(line);
}
);
-
+
+ downloadUrl("/cgi-bin/getemergencyip.cgi", processEmergencyIp);
}
+// called when Emergency CGI returns
+
+function processEmergencyIp(doc,status) {
+ loadHtmlTextFile(doc, function(line) {
+ parseNetwork(line);
+ }
+ );
+
+ // fire off fping CGI
+
+ downloadUrl("/cgi-bin/fpingnodes.cgi?ip=google.com", processFping);
+}
function parseNetwork(line) {
document.network.dns.value = dns;
}
+ if (line.indexOf("BACKDOOR=") != -1) {
+ var s = line.split('"');
+ var backdoor = s[1];
+ document.network.backdoor.value = backdoor;
+ }
}
}
-// called when Fping CGI returns
-
-function processFping(doc, status) {
-
- // Change icon based on ping results
-
- var icon;
-
- if (doc.indexOf("google.com") != -1)
- icon = '<img src="tick.png" />';
- else
- icon = '<img src="cross.png" />';
-
- document.getElementById('internet').innerHTML = icon;
-}
-
// called when ifconfig CGI returns
function processIfconfig(doc, status) {