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); }
function trunk_edit_iax2($trunkid, $devdata) { global $freeiris_conf; global $dbcon; //------------------------------------------------------修改trunk记录 $result = mysql_query("update trunk set " . "trunkprototype='" . $devdata['trunkprototype'] . "'," . "trunkremark='" . $devdata['trunkremark'] . "' where id = '" . $trunkid . "'"); if (!$result) { return rpcreturn(500, mysql_error(), 100, null); } //------------------------------------------------------取得trunk记录 $result = mysql_query("select * from trunk where id = '{$trunkid}'"); if (!$result) { return rpcreturn(500, mysql_error(), 100, null); } $resdata = mysql_fetch_array($result); mysql_free_result($result); if (!$resdata) { return rpcreturn(500, "can't find trunk", 143, null); } //------------------------------------------------------取得旧trunk $trunk_conf = new asteriskconf(); if ($trunk_conf->parse_in_file($freeiris_conf->get('general', 'asterisketc') . '/iax_trunk.conf') == false) { return rpcreturn(500, "can't open " . $freeiris_conf->get('general', 'asterisketc') . '/iax_trunk.conf', 100, null); } //------------------------------------------------------删除旧registery if ($trunk_conf->get($resdata['trunkdevice'], 'register') != '') { $regmatch = 'register=' . $trunk_conf->get($resdata['trunkdevice'], 'register'); //打开regfile文件 $regfile_array = file($freeiris_conf->get('general', 'asterisketc') . '/iax_regfile.conf'); $regfile_string = null; foreach ($regfile_array as $line) { //如果在文件中找到对应的register if (trim($line) != $regmatch) { $regfile_string = $regfile_string . trim($line) . "\n"; } } //写文件 $fhandle = fopen($freeiris_conf->get('general', 'asterisketc') . '/iax_regfile.conf', 'w'); fwrite($fhandle, $regfile_string); fclose($fhandle); } //------------------------------------------------------增加新的sipregistery if (trim($devdata['register']) != '') { $reg_conf = new asteriskconf(); if ($reg_conf->parse_in_file($freeiris_conf->get('general', 'asterisketc') . '/iax_regfile.conf') == false) { return rpcreturn(500, "can't open " . $freeiris_conf->get('general', 'asterisketc') . '/sip_regfile.conf', 100, null); } $reg_conf->assign_append('foot', null, 'register=' . $devdata['register'], null); $reg_conf->save_file(); } //------------------------------------------------------编辑siptrunk $trunk_conf->assign_editkey($resdata['trunkdevice'], 'username', $devdata['username']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'secret', $devdata['secret']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'host', $devdata['host']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'port', $devdata['port']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'register', $devdata['register']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'callerid', $devdata['callerid']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'qualify', $devdata['qualify']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'transfer', $devdata['transfer']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'jitterbuffer', $devdata['jitterbuffer']); $trunk_conf->assign_editkey($resdata['trunkdevice'], 'allow', $devdata['allow']); //如果执行成功 $trunk_conf->save_file(); //必须执行sip reload return rpcreturn(200, null, null, null, true); }
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); }
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); }