$cwcolor = "#FFFFFF"; } } $record_out_db = checkRecordingOUTManager($extdisplay); if ($record_out != $record_out_db and $record_out != "") { $record_out_color = "#FF0000"; $record_out = $record_out_db; } else { if ($record_out == "") { $cwcolor = "#FFFFFF"; $record_out = $record_out_db; } else { $cwcolor = "#FFFFFF"; } } $cw_db = setcwstatus($extdisplay, null, 'read'); if ($cw != $cw_db and $cw != "") { $cwcolor = "#FF0000"; $cw = $cw_db; } else { if ($cw == "") { $cwcolor = "#FFFFFF"; $cw = $cw_db; } else { $cwcolor = "#FFFFFF"; } } $rob_db = setrobstatus($extdisplay, null, 'read'); if ($rob != $rob_db and $rob != "") { $robcolor = "#FF0000"; $rob = $rob_db;
function updatesipauto($account_start, $account_end) { sipexists(); global $db; for ($i = $account_start; $i <= $account_end; $i++) { $sipext_array[] = $i; } foreach (extension_list() as $row) { $extension_list[] = $row[0]; } $diff_extensions = array_diff($sipext_array, $extension_list); if (count($diff_extensions) != 0) { echo "<script>javascript:alert('" . _("One or more SIP Extension in your range do not exist, please check your range!") . "');</script>"; return false; } $sipfields = array(array($_REQUEST['accountcode'], 'accountcode'), array($_REQUEST['secret'], 'secret'), array($_REQUEST['canreinvite'], 'canreinvite'), array($_REQUEST['context'], 'context'), array($_REQUEST['dtmfmode'], 'dtmfmode'), array($_REQUEST['host'], 'host'), array($_REQUEST['type'], 'type'), array($_REQUEST['mailbox'], 'mailbox'), array($_REQUEST['nat'], 'nat'), array($_REQUEST['port'], 'port'), array($_REQUEST['qualify'], 'qualify'), array($_REQUEST['callgroup'], 'callgroup'), array($_REQUEST['pickupgroup'], 'pickupgroup'), array($_REQUEST['disallow'], 'disallow'), array($_REQUEST['allow'], 'allow'), array($_REQUEST['record_in'], 'record_in'), array($_REQUEST['record_out'], 'record_out'), array($_REQUEST['nocall'], 'nocall'), array($_REQUEST['allowcall'], 'allowcall'), array($_REQUEST['rob'], 'rob'), array($_REQUEST['cw'], 'cw'), array($_REQUEST['allowsubscribe'], 'allowsubscribe'), array($_REQUEST['calllimit'], 'call-limit'), array($_REQUEST['videosupport'], 'videosupport'), array($_REQUEST['t38pt_udptl'], 't38pt_udptl'), array($_REQUEST['language'], 'language'), array($_REQUEST['subscribecontext'], 'subscribecontext')); $cidnuminc = $_REQUEST['cidnuminc']; $outcidname = $_REQUEST['outcidname']; $outcidnum = $_REQUEST['outcidnum']; $directdid = $_REQUEST['directdid']; $ringtime = $_REQUEST['ringtime']; if ($cidnuminc != "") { settype($cidnuminc, "integer"); } else { $cidnuminc = ""; } $name = $_REQUEST['name']; foreach ($sipfields as $row) { if ($row[0] != '') { $sipfields_cleaned[] = array($row[0], $row[1]); } } for ($accountX = $account_start;; $accountX++) { if ($accountX == $account_end + 1) { break; } $outcid = '' . $outcidname . ' ' . '<' . $outcidnum . $cidnuminc . '>'; $callerid = '"' . $name . '" ' . '<' . $accountX . '>'; $compiled = $db->prepare("UPDATE `sip` SET `data` = ? WHERE `id` = {$accountX} AND `keyword` = ? LIMIT 1"); $result = $db->executeMultiple($compiled, $sipfields_cleaned); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Updating SIP table'); } if ($name != "") { $sql = "UPDATE `sip` SET `data` = '{$callerid}' WHERE `id` = {$accountX} AND `keyword` = 'callerid' LIMIT 1"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Updating SIP table'); } } if ($outcid != " <>") { $sql = "UPDATE `globals` SET `value` = '{$outcid}' WHERE `variable` = 'ECID{$accountX}' LIMIT 1"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Updating Globals table'); } } if ($directdid != "") { $sql = "DELETE FROM extensions WHERE context = 'ext-did' AND descr = '{$accountX}'"; $results = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Deleting Extensions table'); } $sql = "DELETE FROM incoming WHERE destination = 'ext-local,{$accountX},1'"; $results = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Deleting Incoming table'); } $sql = "INSERT INTO extensions (context, extension, priority, application, args, descr, flags) VALUES ('ext-did', '{$directdid}{$accountX}', '01', 'Set', 'FROM_DID={$directdid}{$accountX}', '{$accountX}' , '0')"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Updating Extensions table'); } $sql = "INSERT INTO extensions (context, extension, priority, application, args, descr, flags) VALUES ('ext-did', '{$directdid}{$accountX}', '02', 'Set', 'FAX_RX=disabled', '{$accountX}' , '0')"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Updating Extensions table'); } $sql = "INSERT INTO extensions (context, extension, priority, application, args, descr, flags) VALUES ('ext-did', '{$directdid}{$accountX}', '03', 'Goto', 'ext-local,{$accountX},1', '{$accountX}' , '0')"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Updating Extensions table'); } $sql = "INSERT INTO incoming (cidnum,extension,destination,faxexten,faxemail,faxemail2,answer,wait,CIDName,privacyman,alertinfo,channel,ringing) values ('','{$directdid}{$accountX}','ext-local,{$accountX},1','disabled','','','0','0','','0','','','')"; $results = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Updating Incoming table'); } } if ($ringtime != "") { if ($ringtime == "default") { $sql = "DELETE FROM globals WHERE variable = 'RINGTIME{$accountX}'"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Delete GLOBALS table'); } } else { $sql = "DELETE FROM globals WHERE variable = 'RINGTIME{$accountX}'"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'Error to Delete GLOBALS table'); } $sql = "INSERT INTO globals VALUES ('RINGTIME{$accountX}', '{$ringtime}')"; $result = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage() . "<br><br>" . 'error adding to Globals table'); } } } setrecordingstatus($accountX, "In", $_REQUEST['record_in']); setrecordingstatus($accountX, "Out", $_REQUEST['record_out']); setnocallstatus($accountX, $_REQUEST['nocall'], 'NOCALL'); setnocallstatus($accountX, $_REQUEST['allowcall'], 'ALLOWCALL'); setrobstatus($accountX, $_REQUEST['rob'], 'write'); setcwstatus($accountX, $_REQUEST['cw'], 'write'); if ($outcid != " <>") { $cidnuminc = $cidnuminc + 1; } } return true; }