--- /dev/null
+#!/bin/sh
+# getnetwork.cgi
+# Ian Roberts 19 March 2012
+#
+# CGI to return network connection 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
+
+internet=`fping google.com`;
+#packet_loss=`fping google.com -c 1 -q | sed -n 's/.*received, \(.*\)%.*/\1/p'`
+#if [ $packet_loss = "0" ]; then
+# internet="yes";
+#fi
+
+echo INTERNET=\"$internet\"
+#echo PACKETLOSS=\"$packet_loss\"
+
+cat <<EOF
+</body>
+</html>
+EOF
var ip_ext = [];
+var network = "no";
+
function loadExtensions() {
/*
}
);
+ // we get Network connection details
+
+ downloadUrl("/cgi-bin/getnetwork.cgi?cli=", loadNetwork);
+ // initialisePage();
+}
+
+// creates a network connection
+
+function loadNetwork(doc,status) {
+ loadHtmlTextFile(doc, function(line) {
+ //parseSipShowPeers(line);
+ if (line.indexOf("alive") != -1) {
+ network = "yes";
+ }
+ }
+ );
+
+ //
+
+ //downloadUrl("/cgi-bin/getnetwork.cgi?cli=", loadNetwork);
initialisePage();
}
html += '<tr><td colspan="4" align="left" valign="top"><h2>Phones</h2></td></tr>';
for(var i=0; i<zap.length; i++) {
if (zap[i] == 'FXS') {
- html += "<tr><td>" + analog_ext[i] + "</td>" + "<td>" + "Analog Phone" + "</td>";
- html += "<td>Port" + i + "</td></tr>";
+ html += "<tr>";
+ html += "<td>" + analog_ext[i] + "</td>" + "<td>" + "Analog Phone" + "</td>";
+// html += "<td>Port" + i + "<td>" +" <img src=" + "tick.png" + " />"+"</td>" + "</td></tr>";
+// html += "<td>Port" + i + "<td>" + '<img src="tick.png" />' + "</td>" + "</td></tr>";
+ html += "<td>Port" + i + "</td>";
+ html += "<td>" + '<img src="tick.png" />' + "</td>";
+ html += "</tr>";
}
}
for (j in ip_ext) {
if (ip_ext[j] != '') {
- html += "<tr><td>" + j + "</td>" + "<td>" + "IP Phone" + "</td>";
- html += "<td>" + ip_ext[j] + "</td></tr>";
+ html += "<tr>";
+ html += "<td>" + j + "</td>" + "<td>" + "IP Phone" + "</td>";
+ html += "<td>" + ip_ext[j] + "</td>";
+ html += "<td>" + '<img src="tick.png" />' + "</td>";
+ html += "</tr>";
}
}
html += '<tr><td colspan="4" align="left" valign="top"><h2>Phone Lines</h2></td></tr>';
for(var i=0; i<zap.length; i++) {
if (zap[i] == 'FXO') {
- html += "<tr><td>" + "0" + "</td>" + "<td>" + "Analog Phone" + "</td>";
- html += "<td>Port" + i + "</td></tr>";
+ html += "<tr>";
+ html += "<td>" + "0" + "</td>" + "<td>" + "Analog Phone" + "</td>";
+ html += "<td>Port" + i + "</td>";
+ html += "<td>" + '<img src="tick.png" />' + "</td>";
+ html += "</tr>";
}
}
// fire off Ifconfig IP address to get IP Address
- downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth0", processIfconfig);
+// downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth0", processIfconfig);
+ downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth1", processIfconfig);
}