#!/bin/sh
# setring.cgi
-# David Rowe 9 March 2011
+#
+# Ian Roberts 30 August 2012
#
# CGI to set extension to ring on an incoming call
#
EOF
-# extract extensions to ring
+# extract extensions to ring
+# must replace underscores with forward slash
+
#echo "Input $QUERY_STRING\n"
a=`echo "$QUERY_STRING" | sed -n "s/=on*//pg" | sed -n 's,_,/,pg'`
var network = "no";
-// incomming calls are routed to these extensions
+// incomming calls are routed to these extensions ie (6003, ZAP/3)
+var number='';
+var code='';
-var reception = [];
+
+var reception[] = {number, code};
+
+
+
+// these are the selections for the new reception numbers
+
+var selected = [];
function loadExtensions() {
if(line.indexOf("exten => s,1,Dial") != -1) {
i=0;
- // for each Zap/ read in a single digit and convert to extension
- while((ret = line.indexOf("Zap/"))!=-1) {
- reception [i++] = analog_ext[line.substr(ret+4,1)];
+ // for each Zap/ read in a single digit and convert to extension
+ while((ret = line.indexOf("Zap/"))!=-1) {
+ reception[i].code = line.substr(ret,5);
+ reception[i].number = analog_ext[line.substr(ret+4,1)];
line = line.substr(ret+6,line.length);
+ i++;
}
// for each SIP/ read in four digits
while ((ret = line.indexOf("SIP/")) != -1) {
- reception [i++] = line.substr(ret+4,4);
+ reception[i].code = line.substr(ret,8);
+ reception[i].number = line.substr(ret+4,4);
line = line.substr(ret+9,line.length);
+ i++;
}
}
//html += "<td>(Reception)</td>";
// the reception checkbox code
- html += "<td>" + '<input type="checkbox" name="ZAP_' + i ;
+ html += "<td>" + '<input name="selected[]" type="checkbox" ' ;
// Underscore used instead of forward slash to pass thru html request
if (reception.indexOf(analog_ext[i]) != -1) {
html += "<td>" + ip_ext[j] + "</td>";
// the reception checkbox code
- html += "<td>" + '<input type="checkbox" name="SIP_' + ip_ext[j] ;
+ html += "<td>" + '<input name="selected[]" type="checkbox" ' ;
// Underscore used instead of forward slash to pass thru html request
function onClickApply(e) {
-// firmwareurl=document.firmwareurl.value;
- // get the arguments from the form
- arg1=document.phones.submit();
-// downloadUrl("/cgi-bin/setring.cgi?"+arg1,null);
-
+ // get the arguments from the form selected[]
+///document.myform.elements['fav[]'].checked
+var arg ='';
+var total = document.getElementByName('selected[]');
+ for (i=0;i<total; i++) {
+// in document.phones.elements['selected[]'] {
+ if (selected[x]<6010)
+ arg = arg + 'ZAP_'+i;
+ // construct new arg from selected
+ //downloadUrl("/cgi-bin/setring.cgi?"+arg1,null);
+ }
}