Exemple #1
0
     $vmoption = explode("=", $_REQUEST['delete']);
     $vmoptions[$vmoption[0]] = $vmoption[1];
     $vmoption = explode("=", $_REQUEST['nextaftercmd']);
     $vmoptions[$vmoption[0]] = $vmoption[1];
     $uservm[$vmcontext][$account] = array('mailbox' => $account, 'pwd' => $_REQUEST['vmpwd'], 'name' => $_REQUEST['name'], 'email' => $_REQUEST['email'], 'pager' => $_REQUEST['pager'], 'options' => $vmoptions);
     saveVoicemail($uservm);
     $mailb = $_REQUEST['vm'] == 'disabled' || $_REQUEST['mailbox'] == '' ? 'novm' : $_REQUEST['mailbox'];
     $sql = "UPDATE `extensions` SET `args` = 'exten-vm," . $mailb . "," . $account . "' WHERE `context` = 'ext-local' AND `extension` = '" . $account . "' AND `priority` = '1' LIMIT 1 ;";
     $result = $db->query($sql);
     if (DB::IsError($result)) {
         die($result->getMessage());
     }
 }
 if ($_REQUEST['vm'] == 'destination') {
     $mailb = "jump";
     $gotojumpto = setGotoJumpTo($goto, 0);
     $sql = "UPDATE `extensions` SET `args` = 'exten-vm," . $mailb . "," . $account . ',' . $gotojumpto . "' WHERE `context` = 'ext-local' AND `extension` = '" . $account . "' AND `priority` = '1' LIMIT 1 ;";
     $result = $db->query($sql);
     if (DB::IsError($result)) {
         die($result->getMessage());
     }
 }
 exec($wScript1);
 needreload();
 setrecordingstatus($account, "In", $_REQUEST['record_in']);
 setrecordingstatus($account, "Out", $_REQUEST['record_out']);
 setnocallstatus($account, $_REQUEST['nocall'], "NOCALL");
 setnocallstatus($account, $_REQUEST['allowcall'], "ALLOWCALL");
 setrobstatus($account, $_REQUEST['rob'], 'write');
 setcwstatus($account, $_REQUEST['cw'], 'write');
 $options = $options[0];
Exemple #2
0
function addsipauto($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];
    }
    $existant_extensions = array_intersect($sipext_array, $extension_list);
    if (count($existant_extensions) > 0) {
        echo "<script>javascript:alert('" . _("One or more SIP Extension in your range is already in use!") . "');</script>";
        return false;
    }
    $sipfields = array(array('accountcode', isset($_REQUEST['accountcode']) ? $_REQUEST['accountcode'] : ''), array('secret', isset($_REQUEST['secret']) ? $_REQUEST['secret'] : ''), array('canreinvite', isset($_REQUEST['canreinvite']) ? $_REQUEST['canreinvite'] : 'no'), array('context', isset($_REQUEST['context']) ? $_REQUEST['context'] : 'from-internal'), array('dtmfmode', isset($_REQUEST['dtmfmode']) ? $_REQUEST['dtmfmode'] : 'rfc2833'), array('host', isset($_REQUEST['host']) ? $_REQUEST['host'] : 'dynamic'), array('type', isset($_REQUEST['type']) ? $_REQUEST['type'] : 'friend'), array('mailbox', isset($_REQUEST['mailbox']) ? $_REQUEST['mailbox'] : ''), array('nat', isset($_REQUEST['nat']) ? $_REQUEST['nat'] : 'no'), array('port', isset($_REQUEST['port']) ? $_REQUEST['port'] : '5060'), array('qualify', !empty($_REQUEST['qualify']) ? $_REQUEST['qualify'] : 'no'), array('callgroup', isset($_REQUEST['callgroup']) ? $_REQUEST['callgroup'] : ''), array('pickupgroup', isset($_REQUEST['pickupgroup']) ? $_REQUEST['pickupgroup'] : ''), array('disallow', isset($_REQUEST['disallow']) ? $_REQUEST['disallow'] : ''), array('allow', isset($_REQUEST['allow']) ? $_REQUEST['allow'] : ''), array('record_in', isset($_REQUEST['record_in']) ? $_REQUEST['record_in'] : 'Never'), array('record_out', isset($_REQUEST['record_out']) ? $_REQUEST['record_out'] : 'Never'), array('nocall', isset($_REQUEST['nocall']) ? $_REQUEST['nocall'] : ''), array('allowcall', isset($_REQUEST['allowcall']) ? $_REQUEST['allowcall'] : ''), array('rob', isset($_REQUEST['rob']) ? $_REQUEST['rob'] : 'Never'), array('cw', isset($_REQUEST['cw']) ? $_REQUEST['cw'] : 'Never'), array('allowsubscribe', isset($_REQUEST['allowsubscribe']) ? $_REQUEST['allowsubscribe'] : ''), array('call-limit', !empty($_REQUEST['calllimit']) ? $_REQUEST['calllimit'] : '99'), array('videosupport', isset($_REQUEST['videosupport']) ? $_REQUEST['videosupport'] : ''), array('t38pt_udptl', isset($_REQUEST['t38pt_udptl']) ? $_REQUEST['t38pt_udptl'] : ''), array('language', isset($_REQUEST['language']) ? $_REQUEST['language'] : ''), array('subscribecontext', isset($_REQUEST['subscribecontext']) ? $_REQUEST['subscribecontext'] : 'ext-local'));
    $cidnuminc = $_REQUEST['cidnuminc'];
    $outcidname = $_REQUEST['outcidname'];
    $outcidnum = $_REQUEST['outcidnum'];
    $directdid = $_REQUEST['directdid'];
    $ringtime = $_REQUEST['ringtime'];
    $vm = $_REQUEST['vm'];
    $goto = isset($_REQUEST['goto0']) ? $_REQUEST['goto0'] : '';
    if ($cidnuminc != "") {
        settype($cidnuminc, "integer");
    } else {
        $cidnuminc = "";
    }
    $mailb = "novm";
    $name = $_REQUEST['name'];
    for ($accountX = $account_start;; $accountX++) {
        if ($accountX == $account_end + 1) {
            break;
        }
        if ($outcidname != "" && $outcidnum != "") {
            $outcid = '' . $outcidname . ' ' . '<' . $outcidnum . $cidnuminc . '>';
        } else {
            $outcid = "";
        }
        $hint = "SIP/" . $accountX;
        $callerid = '"' . $name . '" ' . '<' . $accountX . '>';
        $compiled = $db->prepare("INSERT INTO sip (id, keyword, data) VALUES ('{$accountX}',?,?)");
        $result = $db->executeMultiple($compiled, $sipfields);
        if (DB::IsError($result)) {
            die($result->getMessage() . "<br><br>" . 'Error to Adding to SIP table');
        }
        $sql = "INSERT INTO sip (id, keyword, data) VALUES ('{$accountX}', 'account', '{$accountX}')";
        $result = $db->query($sql);
        if (DB::IsError($result)) {
            die($result->getMessage() . "<br><br>" . 'Error to Adding to SIP table');
        }
        $sql = "INSERT INTO sip (id, keyword, data) VALUES ('{$accountX}', 'username', '{$accountX}')";
        $result = $db->query($sql);
        if (DB::IsError($result)) {
            die($result->getMessage() . "<br><br>" . 'Error to Adding to SIP table');
        }
        $sql = "INSERT INTO sip (id, keyword, data) VALUES ('{$accountX}', 'callerid', '{$callerid}')";
        $result = $db->query($sql);
        if (DB::IsError($result)) {
            die($result->getMessage() . "<br><br>" . 'Error to Adding to SIP table');
        }
        $sql = "INSERT INTO globals VALUES ('E{$accountX}', 'SIP')";
        $result = $db->query($sql);
        if (DB::IsError($result)) {
            die($result->getMessage() . "<br><br>" . 'Error to Adding to SIP table');
        }
        if ($outcidname != "" && $outcidnum != "") {
            $sql = "INSERT INTO globals VALUES ('ECID{$accountX}', '{$outcid}')";
            $result = $db->query($sql);
            if (DB::IsError($result)) {
                die($result->getMessage() . "<br><br>" . 'Error to Adding to Globals table');
            }
        }
        if ($vm == "destination") {
            $mailb = "jump";
            $gotojumpto = setGotoJumpTo($goto, 0);
            $sql = "INSERT INTO extensions (context, extension, priority, application, args, descr, flags) VALUES ('ext-local', '" . $accountX . "', '1', 'Macro', 'exten-vm," . $mailb . "," . $accountX . ',' . $gotojumpto . "', NULL , '0')";
            $result = $db->query($sql);
            if (DB::IsError($result)) {
                die($result->getMessage() . "<br><br>" . 'Error to Adding to Extensions table');
            }
            $sql = "INSERT INTO extensions (context, extension, priority, application) VALUES ('ext-local', '" . $accountX . "', 'hint', '" . $hint . "')";
            $result = $db->query($sql);
            if (DB::IsError($result)) {
                die($result->getMessage() . "<br><br>" . 'Error to Adding to Extensions 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');
            }
        } else {
            $sql = "INSERT INTO extensions (context, extension, priority, application, args, descr, flags) VALUES ('ext-local', '" . $accountX . "', '1', 'Macro', 'exten-vm," . $mailb . "," . $accountX . "', NULL , '0')";
            $result = $db->query($sql);
            if (DB::IsError($result)) {
                die($result->getMessage() . "<br><br>" . 'Error to Adding to Extensions table');
            }
            $sql = "INSERT INTO extensions (context, extension, priority, application) VALUES ('ext-local', '" . $accountX . "', 'hint', '" . $hint . "')";
            $result = $db->query($sql);
            if (DB::IsError($result)) {
                die($result->getMessage() . "<br><br>" . 'Error to Adding to Extensions table');
            }
        }
        if ($directdid != "") {
            $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 Adding to 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 Adding to 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 Adding to 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 Adding to Incoming 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 (isset($cidnuminc)) {
            $cidnuminc = $cidnuminc + 1;
        }
    }
    return true;
}