freeswitch xml_curl模块使用
2015-11-26 16:06
246 查看
freeswitch xml_curl模块使用
替换掉directory,ivr,dialplan,等各种本地配置xml文件
freeswitch 数据库生成xml文件
部分代码
<?php
/**
* @package FS_CURL
*/
/**
* define for the time that execution of the script started
*/
define('START_TIME', ereg_replace('^0\.([0-9]+) ([0-9]+)$', '\2.\1', microtime()));
/**
* Pre-Class initialization die function
* This function should be called on any
* critical error condition before the fs_curl
* class is successfully instantiated.
* @return void
*/
function file_not_found($no=false, $str=false, $file=false, $line=false) {
if ($no == E_STRICT) {
return;
}
header('Content-Type: text/xml');
printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
printf("<document type=\"freeswitch/xml\">\n");
printf(" <section name=\"result\">\n");
printf(" <result status=\"not found\"/>\n");
printf(" </section>\n");
if (!empty($no) && !empty($str) && !empty($file) &&!empty($line)) {
printf(" <!-- ERROR: $no - ($str) on line $line of $file -->\n");
}
printf("</document>\n");
exit();
}
error_reporting(E_ALL);
set_error_handler('file_not_found');
if (!class_exists('XMLWriter')) {
trigger_error(
"XMLWriter Class NOT Found... You Must install it before using this package"
, E_USER_ERROR
);
}
if (!(@include_once('fs_curl.php'))
|| !(@include_once('global_defines.php'))) {
trigger_error(
'could not include fs_curl.php or global_defines.php', E_USER_ERROR
);
}
if (!is_array($_REQUEST)) {
trigger_error('$_REQUEST is not an array');
}
if (array_key_exists('cdr', $_REQUEST)) {
$section = 'cdr';
} else {
$section = $_REQUEST['section'];
}
$section_file = sprintf('fs_%s.php', $section);
/**
* this include will differ based on the section that's passed
*/
if (!(@include_once($section_file))) {
trigger_error("unable to include $section_file");
}
switch ($section) {
case 'configuration':
if (!array_key_exists('key_value', $_REQUEST)) {
trigger_error('key_value does not exist in $_REQUEST');
}
$config = $_REQUEST['key_value'];
$processor = sprintf('configuration/%s.php', $config);
$class = str_replace('.', '_', $config);
if (!(@include_once($processor))) {
trigger_error("unable to include $processor");
}
$conf = new $class;
$conf -> comment("class name is $class");
break;
case 'dialplan':
$conf = new fs_dialplan();
break;
case 'directory':
$conf = new fs_directory();
break;
case 'cdr':
$conf = new fs_cdr();
break;
case 'chatplan':
$conf = new fs_chatplan();
break;
case 'phrases':
$conf = new fs_phrases();
break;
}
$conf -> debug('---- Start _REQUEST ----');
$conf -> debug($_REQUEST);
$conf -> debug('---- End _REQUEST ----');
$conf -> main();
$conf -> output_xml();
?>
详细代码,请下载http://download.csdn.net/detail/coolyqq/9302651
替换掉directory,ivr,dialplan,等各种本地配置xml文件
freeswitch 数据库生成xml文件
部分代码
<?php
/**
* @package FS_CURL
*/
/**
* define for the time that execution of the script started
*/
define('START_TIME', ereg_replace('^0\.([0-9]+) ([0-9]+)$', '\2.\1', microtime()));
/**
* Pre-Class initialization die function
* This function should be called on any
* critical error condition before the fs_curl
* class is successfully instantiated.
* @return void
*/
function file_not_found($no=false, $str=false, $file=false, $line=false) {
if ($no == E_STRICT) {
return;
}
header('Content-Type: text/xml');
printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
printf("<document type=\"freeswitch/xml\">\n");
printf(" <section name=\"result\">\n");
printf(" <result status=\"not found\"/>\n");
printf(" </section>\n");
if (!empty($no) && !empty($str) && !empty($file) &&!empty($line)) {
printf(" <!-- ERROR: $no - ($str) on line $line of $file -->\n");
}
printf("</document>\n");
exit();
}
error_reporting(E_ALL);
set_error_handler('file_not_found');
if (!class_exists('XMLWriter')) {
trigger_error(
"XMLWriter Class NOT Found... You Must install it before using this package"
, E_USER_ERROR
);
}
if (!(@include_once('fs_curl.php'))
|| !(@include_once('global_defines.php'))) {
trigger_error(
'could not include fs_curl.php or global_defines.php', E_USER_ERROR
);
}
if (!is_array($_REQUEST)) {
trigger_error('$_REQUEST is not an array');
}
if (array_key_exists('cdr', $_REQUEST)) {
$section = 'cdr';
} else {
$section = $_REQUEST['section'];
}
$section_file = sprintf('fs_%s.php', $section);
/**
* this include will differ based on the section that's passed
*/
if (!(@include_once($section_file))) {
trigger_error("unable to include $section_file");
}
switch ($section) {
case 'configuration':
if (!array_key_exists('key_value', $_REQUEST)) {
trigger_error('key_value does not exist in $_REQUEST');
}
$config = $_REQUEST['key_value'];
$processor = sprintf('configuration/%s.php', $config);
$class = str_replace('.', '_', $config);
if (!(@include_once($processor))) {
trigger_error("unable to include $processor");
}
$conf = new $class;
$conf -> comment("class name is $class");
break;
case 'dialplan':
$conf = new fs_dialplan();
break;
case 'directory':
$conf = new fs_directory();
break;
case 'cdr':
$conf = new fs_cdr();
break;
case 'chatplan':
$conf = new fs_chatplan();
break;
case 'phrases':
$conf = new fs_phrases();
break;
}
$conf -> debug('---- Start _REQUEST ----');
$conf -> debug($_REQUEST);
$conf -> debug('---- End _REQUEST ----');
$conf -> main();
$conf -> output_xml();
?>
详细代码,请下载http://download.csdn.net/detail/coolyqq/9302651
相关文章推荐
- 用redis实现支持优先级的消息队列
- Failed to create keys in the OLR, rc = 127, Message:
- IOS 常用第三方类整理
- ***CSS里有哪些常见的块级元素和行内元素以及其区别?
- 初试cmake
- PHP获取昨天时间戳,当前时间信息数组,上周与上周所在的年份,上月与上月所在的年份
- redis-3.0集群安装
- sp_who
- Android编译过程详解(一)
- 中央经济工作会仅剩一月 经济冲刺年末考
- 问题
- php客户端neoclient遍历neo4j中的节点和关系及其属性等
- java连接Oracle数据库详细代码,jdbc
- vim重复操作的宏录制
- ztree
- 安卓虚拟机启动后报错: 类似 SDK Manager] Error: Error parsing .....devices.xml 解决方案
- 状态开关按钮(ToggleButton)和开关(Switch)的功能与用法
- Unix(include vim)常用命令
- JavaEE项目在WEB-INF目录下的jsp页面如何访问WebRoot中的CSS和JS文
- j2ee常用知识