function do_login() { global $rpcpbx; global $smarty; global $friconf; //忘记填写参数 if (trim($_REQUEST['adminid']) == "") { error_popbox(103, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['passwd']) == "") { error_popbox(103, null, null, null, null, 'submit_failed'); } //修复可以利用输入用户为【admin' OR ''='】来扰乱SQL查询的安全漏洞 修复人员:Coco老爸 $adminid = str_replace(' ', null, str_replace(' ', null, addslashes($_REQUEST['adminid']))); //发送请求验证login // $rpcres = sendrequest($rpcpbx->base_clientlogin($_REQUEST['adminid'],md5($_REQUEST['passwd'])),1); //2015-01-10 22:08:24 修复安全漏洞 $rpcres = sendrequest($rpcpbx->base_clientlogin($adminid, md5($_REQUEST['passwd'])), 1); //成功(不会在这里出现失败) session_cache_expire($friconf['session_expiry']); session_start(); $_SESSION["admin"] = true; $_SESSION["res_admin"] = $rpcres['res_admin']; //回调地址 if (trim($_REQUEST['callback']) != "") { error_popbox(null, null, null, null, $_REQUEST['callback'], 'submit_successfuly'); } else { error_popbox(null, null, null, null, 'main.php', 'submit_successfuly'); } exit; }
function translatenew4($string, $fromlang = "auto", $tolang = "en") { //$url='http://translate.googleapis.com/translate_a/t?anno=3&client=te&format=html&v=2.0&logld=v8&ie=UTF-8&oe=UTF-8'; $url = 'http://translate.google.com/translate_a/t?client=json&js=n&hl=ru&ie=UTF-8&oe=UTF-8&sl=' . $fromlang . '&tl=' . $tolang . '&multires=1&prev=btn&ssel=0&tsel=0&sc=1&layout=1&eotf=1&c_ad=1'; $temp2 = ''; $query = ''; if (is_array($string)) { for ($i = 0; $i < count($string); $i++) { $query .= 'q=' . rawurlencode($string[$i]); if ($i < count($string) - 1) { $query .= '&'; } } } else { $query .= 'q=' . rawurlencode($string); } $query .= '&sl=' . $fromlang . '&tl=' . $tolang . '&tc=1'; $result = sendrequest($url, $query, "http://translate.google.com/#", '', '', 'POST'); $json = json_decode($result, true); if (is_array($string)) { for ($i = 0; $i < count($json['results']); $i++) { $thistemp = ''; if (isset($json['results'][$i]['sentences'])) { for ($t = 0; $t < count($json['results'][$i]['sentences']); $t++) { $thistemp .= trim($json['results'][$i]['sentences'][$t]['trans']); if ($t < count($json['results'][$i]['sentences']) - 1) { $thistemp .= "\n"; } } } $temp2[] = $thistemp; } } else { $thistemp = ''; for ($t = 0; $t < count($json['sentences']); $t++) { $thistemp .= trim($json['sentences'][$t]['trans']); if ($t < count($json['sentences']) - 1) { $thistemp .= "\n"; } } $temp2 = $thistemp; } if ($temp2 == '') { echo '<pre>'; print_r($result); echo '</pre>'; echo '<pre>'; print_r($json); echo '</pre>'; exit; return 'ERROR'; } else { return $temp2; } }
function do_admin_profile_edit() { global $rpcpbx; global $smarty; $changelist = array(); //忘记填写参数 if (trim($_REQUEST['curpasswd']) == "" || md5($_REQUEST['curpasswd']) != $_SESSION['res_admin']['passwd']) { error_popbox(104, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['newpasswd']) != "" && $_REQUEST['newpasswd'] != $_REQUEST['renewpasswd']) { error_popbox(105, null, null, null, null, 'submit_failed'); } //准备数据 if (trim($_REQUEST['newpasswd']) != "") { $changelist['passwd'] = md5($_REQUEST['newpasswd']); } //更新密码 $rpcres = sendrequest($rpcpbx->admin_profile_edit($_SESSION['res_admin']['adminid'], $changelist), 1); error_popbox(106, null, null, null, 'index.php?action=do_logout', 'submit_successfuly'); exit; }
function do_option_general_set() { global $smarty; global $rpcpbx; global $friconf; if ($_REQUEST['section'] == 'fastagi') { $section = 'fastagi'; if (trim($_REQUEST['dial_ringtime']) == "" || preg_match("/[^0-9]/", $_REQUEST['dial_ringtime'])) { error_popbox(501, null, null, null, null, 'submit_failed'); } sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'dial_ringtime', $_REQUEST['dial_ringtime']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'dial_addional', $_REQUEST['dial_addional']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'diallocal_failed', $_REQUEST['diallocal_failed']), 1); if ($_REQUEST['router_extenrule_default'] != 'enable') { sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'router_extenrule_default', 'disabled'), 1); } else { sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'router_extenrule_default', $_REQUEST['router_extenrule_default']), 1); } if ($_REQUEST['router_trunkrule_default'] != 'enable') { sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'router_trunkrule_default', 'disabled'), 1); } else { sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'router_trunkrule_default', $_REQUEST['router_trunkrule_default']), 1); } error_popbox(517, null, null, null, 'option_general.php', 'submit_confirm'); } elseif ($_REQUEST['section'] == 'voicemail') { $section = 'voicemail'; if (trim($_REQUEST['usermax']) == "" || preg_match("/[^0-9]/", $_REQUEST['usermax'])) { error_popbox(502, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['silence']) == "" || preg_match("/[^0-9]/", $_REQUEST['silence'])) { error_popbox(503, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['maxduration']) == "" || preg_match("/[^0-9]/", $_REQUEST['maxduration'])) { error_popbox(504, null, null, null, null, 'submit_failed'); } sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'enable', $_REQUEST['enable']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'usermax', $_REQUEST['usermax']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'silence', $_REQUEST['silence']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'maxduration', $_REQUEST['maxduration']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'vmmainsayinbox', $_REQUEST['vmmainsayinbox']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'uvmainsayheader', $_REQUEST['uvmainsayheader']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'mailer', $_REQUEST['mailer']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'mailer_attachvoice', $_REQUEST['mailer_attachvoice']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'mailer_from', $_REQUEST['mailer_from']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'smtp_host', $_REQUEST['smtp_host']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'smtp_port', $_REQUEST['smtp_port']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'smtp_auth', $_REQUEST['smtp_auth']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'smtp_username', $_REQUEST['smtp_username']), 1); sendrequest($rpcpbx->option_confkey_edit('freeiris', 'freeiris.conf', $section, 'smtp_password', $_REQUEST['smtp_password']), 1); error_popbox(null, null, null, null, 'option_general.php', 'submit_successfuly'); } else { error_popbox(113, null, null, null, null, 'submit_failed'); } exit; }
function do_invoice_download() { global $smarty; global $rpcpbx; global $friconf; $rpcres = sendrequest($rpcpbx->base_dbquery("select src,dst,calldate,billsec,cost from billinginvoice where calldate >= '" . $_REQUEST['year'] . "-" . $_REQUEST['month'] . "-01 00:00:00' and calldate <= '" . $_REQUEST['year'] . "-" . $_REQUEST['month'] . "-31 23:59:59' order by calldate desc"), 0); #CSV FORMAT if ($_REQUEST['format'] == 'csv') { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); Header("Content-Type: application/vnd.ms-excel"); Header("Content-Disposition: attachment; filename=billing_invoice.csv"); header("Content-Transfer-Encoding: binary "); echo "caller,called,calldate,billsec,cost\n"; foreach ($rpcres['result_array'] as $each) { echo $each['src'] . ',' . $each['dst'] . ',' . $each['calldate'] . ',' . $each['billsec'] . ',' . $each['cost'] . ',' . "\n"; } exit; } else { include "../include/exportxls.php"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); Header("Content-Type: application/vnd.ms-excel"); Header("Content-Disposition: attachment; filename=billing_invoice.xls"); header("Content-Transfer-Encoding: binary "); xlsBOF(); xlsWriteLabel(0, 0, "src"); xlsWriteLabel(0, 1, "dst"); xlsWriteLabel(0, 2, "calldate"); xlsWriteLabel(0, 3, "billsec"); xlsWriteLabel(0, 4, "cost"); $xlsRow = 1; foreach ($rpcres['result_array'] as $each) { xlsWriteLabel($xlsRow, 0, $each['src']); xlsWriteLabel($xlsRow, 1, $each['dst']); xlsWriteLabel($xlsRow, 2, $each['calldate']); xlsWriteLabel($xlsRow, 3, $each['billsec']); xlsWriteLabel($xlsRow, 4, $each['cost']); $xlsRow++; } xlsEOF(); exit; } exit; }
function do_queue_delete() { global $smarty; global $rpcpbx; global $friconf; //不填绝对不行的 if (trim($_REQUEST['queuenumber']) == "") { error_popbox(190, null, null, null, null, 'submit_failed'); } // $rpcres = sendrequest($rpcpbx->queue_delete($_REQUEST['queuenumber']), 1); //完成 if ($rpcres['response']['reload'] == true) { error_popbox(202, null, null, null, 'pbx_reload.php?action=reload&area=queue&return=' . urlencode('acd_queue.php'), 'submit_confirm'); } else { error_popbox(null, null, null, null, 'acd_queue.php', 'submit_successfuly'); } exit; }
function page_main() { global $smarty; global $rpcpbx; global $friconf; //version $rpcres = sendrequest($rpcpbx->base_version(), 0); $smarty->assign("rpcpbx_version", $rpcres['rpcpbx']); $smarty->assign("freeiris2_version", $rpcres['freeiris2']); $smarty->assign("buildver_version", $rpcres['buildver']); //cpu balance $rpcres = sendrequest($rpcpbx->stat_cpu_usage(), 0); $smarty->assign("cpu_usage", $rpcres['usage']); $smarty->assign("cpu_loadavg", $rpcres['loadavg']); //uptime $rpcres = sendrequest($rpcpbx->stat_system_uptime(), 0); $uptime = preg_split("/\\./", round($rpcres['uptime'] / 60 / 60, 1)); $smarty->assign("uptime_hour", $uptime[0]); $smarty->assign("uptime_min", round($uptime[1] * 6)); //memory $rpcres = sendrequest($rpcpbx->stat_memory_usage(), 0); $smarty->assign("memory_usage", $rpcres['percent']); // all extensions count $rpcres = sendrequest($rpcpbx->base_dbquery("select count(*) from extension "), 1); $smarty->assign("extensions_count", $rpcres['result_array'][0]['count(*)']); // all trunks count $rpcres = sendrequest($rpcpbx->base_dbquery("select count(*) from trunk "), 1); $smarty->assign("trunks_count", $rpcres['result_array'][0]['count(*)']); // call count $timestamp = time(); $timestamp -= 86400; $datetime = date('Y-m-d H:i:s', $timestamp); $rpcres = sendrequest($rpcpbx->base_dbquery("select count(*) from cdr where calldate >= '" . $datetime . "'"), 1); $smarty->assign("calls_in24", $rpcres['result_array'][0]['count(*)']); $rpcres = sendrequest($rpcpbx->base_dbquery("select count(*) from cdr"), 1); $smarty->assign("calls_all", $rpcres['result_array'][0]['count(*)']); $release = $rpcpbx->base_release(); $smarty->assign("release", $release['release']); $smarty->assign("res_admin", $_SESSION['res_admin']); smarty_output('cpanel/page_main.tpl'); exit; }
function do_ivruserinput_edit() { global $smarty; global $rpcpbx; global $friconf; $insert = array(); //不填绝对不行的 if (trim($_REQUEST['id']) == "" || preg_match("/[^0-9]/", $_REQUEST['id'])) { error_popbox(210, null, null, null, null, 'submit_failed'); } $insert['input'] = $_REQUEST['input']; $insert['gotoivrnumber'] = $_REQUEST['gotoivrnumber']; $insert['gotoivractid'] = $_REQUEST['gotoivractid']; $rpcres = sendrequest($rpcpbx->ivrmenu_edit_ivruserinput($_REQUEST['id'], $insert), 1); error_popbox(null, null, null, null, 'acd_ivrmenu.php?action=page_ivruserinput_list&ivrnumber=' . $_REQUEST['ivrnumber'], 'submit_successfuly'); exit; }
function do_soundmanager_delete() { global $smarty; global $rpcpbx; global $friconf; //不填绝对不行的 if (trim($_REQUEST['id']) == "") { error_popbox(113, null, null, null, null, 'submit_failed'); } $rpcres = sendrequest($rpcpbx->voicefiles_delete($_REQUEST['id']), 1); error_popbox(null, null, null, null, 'pbx_soundmanager.php', 'submit_successfuly'); exit; }
function do_router_recall() { global $rpcpbx; global $smarty; global $friconf; //剔除调整顺序 $source_all = array(); foreach ($_REQUEST['router'] as $value) { if (trim($value) == "") { continue; } array_push($source_all, $value); } $routerproi = array(); $maxdigit = count($source_all); foreach ($source_all as $value) { $routerproi[$maxdigit] = $value; $maxdigit--; } //根据新顺序调整优先关系 foreach ($routerproi as $proi => $routerid) { $rpcres = sendrequest($rpcpbx->router_recall($routerid, $proi), 1); } //完成 error_popbox(null, null, null, null, 'trunk_router.php', 'submit_successfuly'); exit; }
function do_chan_dahdi_set() { global $smarty; global $rpcpbx; global $friconf; sendrequest($rpcpbx->option_confkey_edit('asterisk', 'chan_dahdi.conf', 'channels', 'echocancel', $_REQUEST['echocancel']), 1); sendrequest($rpcpbx->option_confkey_edit('asterisk', 'chan_dahdi.conf', 'channels', 'cidsignalling', $_REQUEST['cidsignalling']), 1); sendrequest($rpcpbx->option_confkey_edit('asterisk', 'chan_dahdi.conf', 'channels', 'cidstart', $_REQUEST['cidstart']), 1); sendrequest($rpcpbx->option_confkey_edit('asterisk', 'chan_dahdi.conf', 'channels', 'rxgain', $_REQUEST['rxgain']), 1); sendrequest($rpcpbx->option_confkey_edit('asterisk', 'chan_dahdi.conf', 'channels', 'txgain', $_REQUEST['txgain']), 1); error_popbox(533, null, null, null, 'pbx_reload.php?action=reload&area=softrestart&return=' . urlencode('option_hardware.php'), 'submit_confirm'); exit; }
function func_sessionflow_list() { global $smarty; global $rpcpbx; $smarty->assign("cdruniqueid", $_REQUEST['cdruniqueid']); $rpcres = sendrequest($rpcpbx->base_dbquery("select * from callsession where id = '" . $_REQUEST['callsessionid'] . "' LIMIT 1"), 0); $smarty->assign("callsession", $rpcres['result_array'][0]); $rpcres = sendrequest($rpcpbx->base_dbquery("select disposition,duration,billsec from cdr where userfield = '" . $rpcres['result_array'][0]['id'] . "," . $rpcres['result_array'][0]['frist_cdruniqueid'] . "' LIMIT 1"), 0); $smarty->assign("cdr", $rpcres['result_array'][0]); //取出 $rpcres = sendrequest($rpcpbx->base_dbquery("select * from callsession_acts where callsessionid = '" . $_REQUEST['callsessionid'] . "' order by actid asc"), 0); $smarty->assign("sessionflow", $rpcres['result_array']); //基本 $smarty->assign("res_admin", $_SESSION['res_admin']); smarty_output('cpanel/func_sessionflow_list.tpl'); exit; }
function do_group_edit() { global $rpcpbx; global $smarty; global $friconf; //忘记填写参数 if (trim($_REQUEST['groupname']) == "") { error_popbox(131, null, null, null, null, 'submit_failed'); } //编辑分组 $rpcres = sendrequest($rpcpbx->extengroup_edit($_REQUEST['groupid'], array('groupname' => $_REQUEST['groupname'], 'remark' => $_REQUEST['remark'])), 1); error_popbox(null, null, null, null, 'exten_group.php', 'submit_successfuly'); exit; }
function do_ivrfiles_delete() { global $smarty; global $rpcpbx; global $friconf; //不填绝对不行的 if (trim($_REQUEST['id']) != "") { $rpcres = sendrequest($rpcpbx->voicefiles_delete($_REQUEST['id']), 1); } elseif (trim($_REQUEST['area']) == "all") { $rpcres = sendrequest($rpcpbx->voicefiles_list('ivrmenu', $limit_from, $friconf['cols_in_page'], $_REQUEST['ivrmenu_filter']), 0); foreach ($rpcres['resdata'] as $value) { sendrequest($rpcpbx->voicefiles_delete($value['id']), 1); } } header('Location: acd_record.php?action=func_ivrfiles_list&trigger_filter=' . $_REQUEST['ivrmenu_filter'] . "\n\n"); exit; }
function do_outgoing_add() { global $smarty; global $rpcpbx; global $friconf; $insert = array(); //不填绝对不行的 if (trim($_REQUEST['name']) == "") { error_popbox(401, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['concurrent']) == "" || preg_match("/[^0-9]/", $_REQUEST['concurrent'])) { error_popbox(402, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['startime_date']) == "") { error_popbox(403, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['members']) == "") { error_popbox(404, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['localnumber']) == "" || preg_match("/[^0-9]/", $_REQUEST['localnumber'])) { error_popbox(405, null, null, null, null, 'submit_failed'); } $insert['name'] = $_REQUEST['name']; $insert['concurrent'] = $_REQUEST['concurrent']; $insert['startime'] = $_REQUEST['startime_date'] . ' ' . $_REQUEST['startime_hour'] . ':' . $_REQUEST['startime_minute'] . ':00'; $insert['localnumber'] = $_REQUEST['localnumber']; $insert['outgoing_callerid'] = $_REQUEST['outgoing_callerid']; $insert['outgoing_waittime'] = $_REQUEST['outgoing_waittime']; $_REQUEST['members'] = preg_replace("/\r/", "", $_REQUEST['members']); $insert['members'] = array(); foreach (explode("\n", $_REQUEST['members']) as $value) { trim($value); if ($value != "") { array_push($insert['members'], $value); } } //创建计划 $rpcres = sendrequest($rpcpbx->outgoing_add($insert), 1); //完成 error_popbox(null, null, null, null, 'acd_outgoing.php', 'submit_successfuly'); exit; }
function do_features_key() { global $rpcpbx; global $smarty; global $friconf; //取出特殊featerus localnumber号码 $vmres = sendrequest($rpcpbx->base_readconf('freeiris', 'freeiris.conf'), 0); if ($vmres['resdata']['voicemail']['voicemailmain'] != $_REQUEST['voicemailmain']) { //检测这个名字是否已经使用过了 $rpcres = sendrequest($rpcpbx->localnumber_get($_REQUEST['voicemailmain']), 1); if ($rpcres['resdata']) { error_popbox(161, null, null, null, null, 'submit_failed'); } //写回特别features设置 sendrequest($rpcpbx->base_dbquery("update localnumber set number = '" . $_REQUEST['voicemailmain'] . "' where number = '" . $vmres['resdata']['voicemail']['voicemailmain'] . "'")); sendrequest($rpcpbx->base_updateconf('freeiris', 'freeiris.conf', 'voicemail', 'voicemailmain', $_REQUEST['voicemailmain']), 1); } //取出特殊features localnumber号码 $rpcres = sendrequest($rpcpbx->base_dbquery("select number from localnumber where assign like '" . 'agi://127.0.0.1/originate_diagnosis?%' . "'"), 1); if ($rpcres['result_array'][0]['number'] != $_REQUEST['originate_diagnosis']) { $newnumber = $rpcres['result_array'][0]['number']; //检测这个名字是否已经使用过了 $rpcres = sendrequest($rpcpbx->localnumber_get($_REQUEST['originate_diagnosis']), 1); if ($rpcres['resdata']) { error_popbox(161, null, null, null, null, 'submit_failed'); } sendrequest($rpcpbx->base_dbquery("update localnumber set number = '" . $_REQUEST['originate_diagnosis'] . "' where number = '" . $newnumber . "'")); } //编辑参数 $rpcres = sendrequest($rpcpbx->features_hotkey_set('pickupexten', $_REQUEST['pickupexten']), 1); $rpcres = sendrequest($rpcpbx->features_hotkey_set('blindxfer', $_REQUEST['blindxfer']), 1); $rpcres = sendrequest($rpcpbx->features_hotkey_set('atxfer', $_REQUEST['atxfer']), 1); $rpcres = sendrequest($rpcpbx->features_hotkey_set('parkcall', $_REQUEST['parkcall']), 1); $rpcres = sendrequest($rpcpbx->features_hotkey_set('parkpos', $_REQUEST['parkpos']), 1); $rpcres = sendrequest($rpcpbx->features_hotkey_set('fri2automon', $_REQUEST['fri2automon']), 1); $rpcres = sendrequest($rpcpbx->features_hotkey_set('nway-start', $_REQUEST['nwaystart']), 1); error_popbox(160, null, null, null, 'pbx_reload.php?action=reload&area=all&return=' . urlencode('pbx_features.php'), 'submit_confirm'); }
function do_admin_edit() { global $rpcpbx; global $smarty; global $friconf; $changelist = array(); //忘记填写参数 if (trim($_REQUEST['curpasswd']) == "" || md5($_REQUEST['curpasswd']) != $_SESSION['res_admin']['passwd']) { error_popbox(107, null, null, null, null, 'submit_failed'); exit; } if (trim($_REQUEST['newpasswd']) != "" && $_REQUEST['newpasswd'] != $_REQUEST['renewpasswd']) { error_popbox(105, null, null, null, null, 'submit_failed'); exit; } if (trim($_REQUEST['newpasswd']) == "") { error_popbox(111, null, null, null, null, 'submit_failed'); exit; } //更新密码 $rpcres = sendrequest($rpcpbx->base_dbquery("update admin set passwd=md5('" . $_REQUEST['newpasswd'] . "') where adminid = '" . $_REQUEST['adminid'] . "'"), 1); error_popbox(null, null, null, null, 'admin_manage.php', 'submit_successfuly'); exit; }
function do_trunk_edit_fxo() { global $rpcpbx; global $smarty; global $friconf; $trunk = array(); //不填绝对不行的 if (trim($_REQUEST['id']) == "") { error_popbox(143, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['trunkname']) == "") { error_popbox(140, null, null, null, null, 'submit_failed'); } if (count($_REQUEST['channel']) <= 0) { error_popbox(147, null, null, null, null, 'submit_failed'); } #other $trunk['trunkremark'] = $_REQUEST['trunkremark']; #array of channels selected $trunk['channel_array'] = $_REQUEST['channel']; //检测这个名字是否存在 sendrequest($rpcpbx->trunk_get_fxo($_REQUEST['id']), 1); //编辑 sendrequest($rpcpbx->trunk_edit_fxo($_REQUEST['id'], $trunk), 1); //完成 error_popbox(149, null, null, null, 'pbx_reload.php?action=reload&area=chan_dahdi&return=' . urlencode('trunk_manage.php'), 'submit_confirm'); exit; }
function do_confile_edit() { global $smarty; global $rpcpbx; global $friconf; //不填绝对不行的 if (trim($_REQUEST['folder']) == "") { error_popbox(113, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['filename']) == "") { error_popbox(113, null, null, null, null, 'submit_failed'); } //增加这个费率 sendrequest($rpcpbx->option_confile_puts($_REQUEST['folder'], $_REQUEST['filename'], $_REQUEST['filestream']), 1); header('Location: ' . 'option_advanced.php?action=func_confile_list&folder=' . $_REQUEST['folder'] . "\n\n"); exit; }
function do_faxfile_download() { global $smarty; global $rpcpbx; global $friconf; if ($_REQUEST['faxid'] == "") { exit; } $rpcres = sendrequest($rpcpbx->fax_faxfile_download($_REQUEST['faxid']), 1); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); Header("Content-Type: application/octet-stream"); Header("Content-Disposition: attachment; filename=" . $rpcres['filename']); header("Content-Transfer-Encoding: binary"); echo $rpcres['filestream']; exit; }
function do_restart() { global $smarty; global $rpcpbx; switch ($_REQUEST['area']) { case "fri2d": $rpcres = sendrequest($rpcpbx->system_restart('fri2d'), 0); break; case "all": $rpcres = sendrequest($rpcpbx->system_restart('reboot'), 0); break; } header("location: " . $_REQUEST['return'] . "\n\n"); exit; }
function do_exten_diagnosis() { global $smarty; global $rpcpbx; //取出 $rpcres = sendrequest($rpcpbx->extension_get($_REQUEST['accountcode']), 1); if (!$rpcres['extension']) { error_popbox(125, null, null, null, null, 'submit_failed'); } //设置目前为 ! 状态 sendrequest($rpcpbx->base_dbquery("update extension set fristchecked=1 where accountcode = '" . $_REQUEST['accountcode'] . "'"), 1); //设置好分机 if ($rpcres['extension']['deviceproto'] == 'custom') { $channel = $rpcres['extension']['devicestring']; } elseif ($rpcres['extension']['deviceproto'] == 'fxs') { $channel = 'DAHDI/' . $rpcres['extension']['devicestring']; } else { $channel = $rpcres['extension']['deviceproto'] . '/' . $rpcres['extension']['devicestring']; } //发起呼叫 $actionid = uniqid(); $rpcres = $rpcpbx->ami_originate($actionid, array('Channel' => $channel, 'CallerID' => 'Diagnosis Phone', 'MaxRetries' => 0, 'WaitTime' => 30, 'RetryTime' => 15, 'Application' => 'AGI', 'Data' => 'agi://127.0.0.1/originate_diagnosis?accountcode=' . $_REQUEST['accountcode'])); error_popbox(null, null, null, null, 'exten_manage.php', 'submit_successfuly'); exit; }
function do_uservoice_delete() { global $smarty; global $rpcpbx; global $friconf; $rpcres = sendrequest($rpcpbx->voicefiles_delete($_REQUEST['id']), 1); //完成 if ($_REQUEST['type'] == 'vm') { header('Location: pbx_uservoice.php?action=func_voicemail_list&accountcode=' . $_REQUEST['accountcode'] . "\n\n"); } elseif ($_REQUEST['type'] == 'ot') { header('Location: pbx_uservoice.php?action=func_onetouch_list&accountcode=' . $_REQUEST['accountcode'] . "\n\n"); } exit; }
function do_conference_kick() { global $smarty; global $rpcpbx; global $friconf; //不填绝对不行的 if (trim($_REQUEST['confno']) == "") { error_popbox(190, null, null, null, null, 'submit_failed'); } sendrequest($rpcpbx->ami_command(uniqid(), 'meetme kick ' . $_REQUEST['confno'] . ' all')); //完成 error_popbox(null, null, null, null, 'acd_conference.php', 'submit_successfuly'); exit; }
function do_record_download() { global $smarty; global $rpcpbx; global $friconf; //禁止使用因为某些条件 if (trim($_REQUEST['start_date']) == '' && trim($_REQUEST['end_date']) == '' && trim($_REQUEST['id']) == "") { error_popbox(601, null, null, null, null, 'submit_failed'); } //格式化条件 $sqlwhere = ''; //取出当前要显示的类型 if ($_REQUEST['dcontext'] == 'trunk') { $sqlwhere .= " and dcontext like 'from-trunk%'"; } elseif ($_REQUEST['dcontext'] == 'exten') { $sqlwhere .= " and dcontext like 'from-exten%'"; } //取出 if (trim($_REQUEST['start_date']) != '' && trim($_REQUEST['end_date']) != '') { $sqlwhere .= " and calldate >= '" . $_REQUEST['start_date'] . " 00:00:00' and calldate <= '" . $_REQUEST['end_date'] . " 23:59:59'"; } if (trim($_REQUEST['src']) != '') { $sqlwhere .= " and src like '" . preg_replace("/\\*/", "%", $_REQUEST['src']) . "'"; $smarty->assign("src", $_REQUEST['src']); } if (trim($_REQUEST['dst']) != '') { $sqlwhere .= " and dst like '" . preg_replace("/\\*/", "%", $_REQUEST['dst']) . "'"; $smarty->assign("dst", $_REQUEST['dst']); } //如果发现了ID覆盖其他参数 if (trim($_REQUEST['id']) != "") { $sqlwhere = "id = '" . $_REQUEST['id'] . "'"; $smarty->assign("id", $_REQUEST['id']); } //最后生成 $sqlwhere = preg_replace("/^ and/", "", $sqlwhere); if (trim($sqlwhere) != '') { $sqlwhere = 'where ' . $sqlwhere; } //取出所有数据 $rpcres = sendrequest($rpcpbx->base_dbquery("select * from cdr " . $sqlwhere . " order by calldate desc"), 0); //输出 include "../include/exportxls.php"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); Header("Content-Type: application/vnd.ms-excel"); Header("Content-Disposition: attachment; filename=record.xls"); header("Content-Transfer-Encoding: binary "); xlsBOF(); xlsWriteLabel(0, 0, "Calling Record Statistical"); xlsWriteLabel(1, 1, "calltype " . $_REQUEST['dcontext']); xlsWriteLabel(2, 0, "Date Range " . $_REQUEST['start_date'] . " To " . $_REQUEST['end_date']); xlsWriteLabel(3, 0, "Call From " . $_REQUEST['src'] . " To " . $_REQUEST['dst']); // xlsWriteLabel(4,0,"calltype"); xlsWriteLabel(4, 0, ""); xlsWriteLabel(4, 1, "src"); xlsWriteLabel(4, 2, "dst"); xlsWriteLabel(4, 3, "disposition"); xlsWriteLabel(4, 4, "duration"); xlsWriteLabel(4, 5, "billsec"); xlsWriteLabel(4, 6, "calldate"); $xlsRow = 5; foreach ($rpcres['result_array'] as $each) { // if (preg_match("/trunk/",$each['dcontext'])) { // xlsWriteLabel($xlsRow,0,'trunk'); // } elseif (preg_match("/exten/",$each['dcontext'])) { // xlsWriteLabel($xlsRow,0,'exten'); // } else { xlsWriteLabel($xlsRow, 0, ''); // } xlsWriteLabel($xlsRow, 1, $each['src']); xlsWriteLabel($xlsRow, 2, $each['dst']); xlsWriteLabel($xlsRow, 3, $each['disposition']); xlsWriteLabel($xlsRow, 4, $each['duration']); xlsWriteLabel($xlsRow, 5, $each['billsec']); xlsWriteLabel($xlsRow, 6, $each['calldate']); $xlsRow++; } xlsEOF(); exit; }
function do_option_voip_rtp_set() { global $smarty; global $rpcpbx; global $friconf; if (trim($_REQUEST['rtpstart']) == "" || preg_match("/[^0-9]/", $_REQUEST['rtpstart'])) { error_popbox(510, null, null, null, null, 'submit_failed'); } if (trim($_REQUEST['rtpend']) == "" || preg_match("/[^0-9]/", $_REQUEST['rtpend'])) { error_popbox(511, null, null, null, null, 'submit_failed'); } sendrequest($rpcpbx->option_confkey_edit('asterisk', 'rtp.conf', 'general', 'rtpstart', $_REQUEST['rtpstart']), 1); sendrequest($rpcpbx->option_confkey_edit('asterisk', 'rtp.conf', 'general', 'rtpend', $_REQUEST['rtpend']), 1); error_popbox(516, null, null, null, 'pbx_reload.php?action=reload&area=rtp&return=' . urlencode('option_voip.php'), 'submit_confirm'); exit; }
function do_musicmanager_delete() { global $smarty; global $rpcpbx; global $friconf; //不填绝对不行的 if (trim($_REQUEST['id']) == "") { error_popbox(113, null, null, null, null, 'submit_failed'); } $rpcres = sendrequest($rpcpbx->voicefiles_delete($_REQUEST['id']), 1); error_popbox(184, null, null, null, 'pbx_reload.php?action=reload&area=moh&return=' . urlencode('pbx_musicmanager.php'), 'submit_confirm'); exit; }