Beispiel #1
0
function option_confkey_edit($folder, $type, $section, $key, $newvalue)
{
    global $freeiris_conf;
    global $dbcon;
    if ($folder == 'freeiris') {
        if ($type == 'freeiris.conf') {
            //取得配置
            $confile = new asteriskconf();
            if ($confile->parse_in_file('/etc/freeiris2/freeiris.conf') == false) {
                return rpcreturn(500, '/etc/freeiris2/freeiris.conf', 100, null);
            }
            $confile->assign_editkey($section, $key, $newvalue);
            //如果执行成功
            $confile->save_file();
        } else {
            $confile = new asteriskconf();
            if ($confile->parse_in_file('/etc/freeiris2/' . $type) == false) {
                return rpcreturn(500, "can't open " . '/etc/freeiris2/' . $type, 100, null);
            }
            $confile->assign_editkey($section, $key, $newvalue);
            //如果执行成功
            $confile->save_file();
        }
    } elseif ($folder == 'asterisk') {
        $confile = new asteriskconf();
        if ($confile->parse_in_file($freeiris_conf->get('general', 'asterisketc') . '/' . $type) == false) {
            return rpcreturn(500, "can't open " . $freeiris_conf->get('general', 'asterisketc') . '/' . $type, 100, null);
        }
        $confile->assign_editkey($section, $key, $newvalue);
        //如果执行成功
        $confile->save_file();
    }
    return rpcreturn(200, null, null, null, null);
}
Beispiel #2
0
<?php

include 'asteriskconf.inc.php';
$sip = new asteriskconf();
$sip->parse_in_file('delfrom.conf');
$sip->assign_delsection('1000');
//	$sip->debug();
$sip->keep_resource_array = false;
$sip->save_file('output.conf');
print $sip->errstr;
Beispiel #3
0
function features_hotkey_set($key, $hotkey)
{
    global $freeiris_conf;
    global $dbcon;
    //取得配置
    $features_conf = new asteriskconf();
    //#在这里不再是注释符号
    $features_conf->comments_flags = '\\;';
    if ($features_conf->parse_in_file($freeiris_conf->get('general', 'asterisketc') . '/features.conf') == false) {
        return rpcreturn(500, "can't open " . $freeiris_conf->get('general', 'asterisketc') . '/features.conf', 100, null);
    }
    if ($features_conf->get('featuremap', $key)) {
        $features_conf->assign_editkey('featuremap', $key, $hotkey);
    } elseif ($features_conf->get('general', $key)) {
        $features_conf->assign_editkey('general', $key, $hotkey);
    } elseif ($features_conf->get('applicationmap', $key)) {
        $fullvalues = $features_conf->get('applicationmap', $key);
        $allarray = preg_split("/\\,/", $fullvalues);
        $newvalue = preg_replace('/^' . preg_quote($allarray[0], '\\') . '/', $hotkey, $fullvalues);
        $features_conf->assign_editkey('applicationmap', $key, $newvalue);
    }
    //如果执行成功
    $features_conf->save_file();
    return rpcreturn(200, null, null, null, true);
}
Beispiel #4
0
function queue_delete($queuenumber)
{
    global $freeiris_conf;
    global $dbcon;
    //------------------------------------------------------删除localnumber表记录
    $result = mysql_query("delete from localnumber where number = '" . $queuenumber . "'");
    if (!$result) {
        return rpcreturn(500, mysql_error(), 100, null);
    }
    //------------------------------------------------------删除基本数据
    $dores = mysql_query("delete from queue where queuenumber = '" . $queuenumber . "'");
    if (!$dores) {
        return rpcreturn(500, mysql_error(), 100, null);
    }
    //------------------------------------------------------删除配置数据
    $queues_list_conf = new asteriskconf();
    if ($queues_list_conf->parse_in_file($freeiris_conf->get('general', 'asterisketc') . '/queues_list.conf') == false) {
        return rpcreturn(500, "can't open " . $freeiris_conf->get('general', 'asterisketc') . '/queues_list.conf', 100, null);
    }
    $queues_list_conf->assign_delsection($queuenumber);
    //如果执行成功
    if ($queues_list_conf->save_file() && $queues_list_conf->last_changed_file == $freeiris_conf->get('general', 'asterisketc') . '/queues_list.conf') {
        return rpcreturn(200, null, null, null, true);
    } else {
        return rpcreturn(200, null, null, null);
    }
}
Beispiel #5
0
function extension_add_fxs($exten)
{
    global $freeiris_conf;
    global $dbcon;
    //------------------------------------------------------创建localnumber表记录
    $result = mysql_query("insert into localnumber set number = '" . $exten['devicenumber'] . "',typeof = 'extension',assign = '" . $exten['accountcode'] . "'");
    if (!$result) {
        return rpcreturn(500, mysql_error(), 100, null);
    }
    //------------------------------------------------------创建extension表记录
    $result = mysql_query("insert into extension set accountcode = '" . $exten['accountcode'] . "',cretime=now()," . "password='******'password'] . "'," . "deviceproto='fxs'," . "devicenumber='" . $exten['devicenumber'] . "'," . "devicestring='" . $exten['devicestring'] . "'," . "fristchecked=0," . "transfernumber='" . $exten['transfernumber'] . "'," . "diallocal_failed='" . $exten['diallocal_failed'] . "'," . "info_name='" . $exten['info_name'] . "'," . "info_email='" . $exten['info_email'] . "'," . "info_detail='" . $exten['info_detail'] . "'," . "info_remark='" . $exten['info_remark'] . "'");
    if (!$result) {
        return rpcreturn(500, mysql_error(), 100, null);
    }
    //------------------------------------------------------生成分组数据
    foreach (split('[\\,|\\s|\\ ]', $exten['extengroup']) as $value) {
        $groupnames = $groupnames . " groupname = '{$value}' OR ";
    }
    $groupnames = rtrim($groupnames, 'OR ');
    $exten['callgroup'] = null;
    $exten['pickupgroup'] = null;
    $result = mysql_query("select * from extengroup where {$groupnames}");
    if (!$result) {
        return rpcreturn(500, mysql_error(), 100, null);
    }
    while ($each = mysql_fetch_array($result)) {
        //创建分组
        $dores = mysql_query("insert into extengroup_assign set groupid = '" . $each['groupid'] . "' , accountcode = '" . $exten['accountcode'] . "'");
        if (!$dores) {
            return rpcreturn(500, mysql_error(), 100, null);
        }
        //补充sip template所需数据
        $exten['callgroup'] = $exten['callgroup'] . $each['groupid'] . ',';
        $exten['pickupgroup'] = $exten['pickupgroup'] . $each['groupid'] . ',';
    }
    mysql_free_result($result);
    //------------------------------------------------------hints的数据处理
    extension_hints_add($exten['devicenumber'], 'DAHDI', $exten['devicestring']);
    //------------------------------------------------------生成template数据格式
    $tplcontents = conftpl_replace('/etc/freeiris2/chan_dahdi_fxs.conf.tpl', $exten);
    //存储到配置文件中
    $fxs_conf = new asteriskconf();
    if ($fxs_conf->parse_in_file($freeiris_conf->get('general', 'asterisketc') . '/chan_dahdi_fxs.conf') == false) {
        return rpcreturn(500, "can't open " . $freeiris_conf->get('general', 'asterisketc') . '/chan_dahdi_fxs.conf', 100, null);
    }
    $fxs_conf->assign_append('foot', null, $tplcontents, null);
    $fxs_conf->save_file();
    return rpcreturn(200, null, null, null, true);
}
Beispiel #6
0
function trunk_add_fxo($devdata)
{
    global $freeiris_conf;
    global $dbcon;
    //------------------------------------------------------创建trunk记录
    $result = mysql_query("insert into trunk set trunkname = '" . $devdata['trunkname'] . "',cretime=now()," . "trunkproto='" . $devdata['trunkproto'] . "'," . "trunkprototype='" . $devdata['trunkprototype'] . "'," . "trunkdevice='" . $devdata['trunkdevice'] . "'," . "trunkremark='" . $devdata['trunkremark'] . "'");
    if (!$result) {
        return rpcreturn(500, mysql_error(), 100, null);
    }
    //------------------------------------------------------创建trunk记录的id
    $result = mysql_query("select last_insert_id()");
    $lastid = mysql_fetch_array($result);
    mysql_free_result($result);
    $lastid = $lastid[0];
    //------------------------------------------------------创建localnumber表记录
    $result = mysql_query("insert into localnumber set number = '" . $devdata['trunkdevice'] . "',typeof = 'trunk',assign = '" . $lastid . "'");
    if (!$result) {
        return rpcreturn(500, mysql_error(), 100, null);
    }
    //------------------------------------------------------生成template数据格式
    $devdata['channel'] = chanpacker($devdata['channel_array']);
    $tplcontents = conftpl_replace('/etc/freeiris2/chan_dahdi_fxo.conf.tpl', $devdata);
    //存储到配置文件中
    $fxo_conf = new asteriskconf();
    if ($fxo_conf->parse_in_file($freeiris_conf->get('general', 'asterisketc') . '/chan_dahdi_fxo.conf') == false) {
        return rpcreturn(500, "can't open " . $freeiris_conf->get('general', 'asterisketc') . '/chan_dahdi_fxo.conf', 100, null);
    }
    $fxo_conf->assign_append('foot', null, $tplcontents, null);
    $fxo_conf->save_file();
    return rpcreturn(200, null, null, null, true);
}
Beispiel #7
0
function base_registration_set($systemid, $register_name)
{
    global $freeiris_conf;
    global $dbcon;
    $confile = new asteriskconf();
    if ($confile->parse_in_file('/etc/freeiris2/freeiris.conf') == false) {
        return rpcreturn(500, "can't open " . '/etc/freeiris2/freeiris.conf', 100, null);
    }
    $confile->assign_editkey('registration', 'register_name', $register_name);
    $confile->assign_editkey('registration', 'systemid', $systemid);
    //如果执行成功
    $confile->save_file();
    return rpcreturn(200, null, null, null, null);
}