提交 43579303 authored 作者: Ken Rice's avatar Ken Rice

fix a few little issues and dont connect to ESL when we dont need to

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk/scripts/contrib@12707 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 699b1646
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
require_once "ESL.php"; require_once "ESL.php";
class FreeSWITCH { class FreeSWITCH {
var $esl;
var $dbh;
private function getDbh(){ private function getDbh(){
$dbtype='mysql'; /* Set the Database type */ $dbtype='mysql'; /* Set the Database type */
...@@ -56,23 +54,26 @@ class FreeSWITCH { ...@@ -56,23 +54,26 @@ class FreeSWITCH {
return $dbh; return $dbh;
} }
public function __construct() { private function getEsl(){
$esl_server = "127.0.0.1"; /* ESL Server */ $esl_server = "127.0.0.1"; /* ESL Server */
$esl_port = "8021"; /* ESL Port */ $esl_port = "8021"; /* ESL Port */
$esl_secret = "ClueCon"; /* ESL Secret */ $esl_secret = "ClueCon"; /* ESL Secret */
$this->esl = new eslConnection($esl_server, $esl_port, $esl_secret); $esl = new eslConnection($esl_server, $esl_port, $esl_secret);
return $esl;
} }
/*** General Whats happening Methods ***/ /*** General Whats happening Methods ***/
public function getStatus() { public function getStatus() {
$e = $this->esl->sendRecv("api status"); $esl = getEsl();
$e = $esl->sendRecv("api status");
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
public function getChannels() { public function getChannels() {
$e = $this->esl->sendRecv("api show channels"); $esl = getEsl();
$e = $esl->sendRecv("api show channels");
$body = $e->getBody(); $body = $e->getBody();
$temp = explode ("\n", $body); $temp = explode ("\n", $body);
$total_count = sizeof($temp); $total_count = sizeof($temp);
...@@ -101,7 +102,8 @@ class FreeSWITCH { ...@@ -101,7 +102,8 @@ class FreeSWITCH {
} }
public function getCalls() { public function getCalls() {
$e = $this->esl->sendRecv("api show calls"); $esl = getEsl();
$e = $esl->sendRecv("api show calls");
$body = $e->getBody(); $body = $e->getBody();
$temp = explode ("\n", $body); $temp = explode ("\n", $body);
$total_count = sizeof($temp); $total_count = sizeof($temp);
...@@ -129,13 +131,15 @@ class FreeSWITCH { ...@@ -129,13 +131,15 @@ class FreeSWITCH {
public function originate($call_url, $exten, $dialplan = "XML", $context= "default", $cid_name = "amf_php", $cid_number = "888", $timeout="30"){ public function originate($call_url, $exten, $dialplan = "XML", $context= "default", $cid_name = "amf_php", $cid_number = "888", $timeout="30"){
$dialstring = "api originate $call_url $exten $dialplan $context $cid_name $cid_number $timeout"; $dialstring = "api originate $call_url $exten $dialplan $context $cid_name $cid_number $timeout";
$e = $this->esl->sendRecv($dialstring); $esl = getEsl();
$e = $esl->sendRecv($dialstring);
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
public function killUuid($uuid) { public function killUuid($uuid) {
$e = $this->esl->sendRecv("api uuid_kill $uuid"); $esl = getEsl();
$e = $esl->sendRecv("api uuid_kill $uuid");
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
...@@ -143,13 +147,15 @@ class FreeSWITCH { ...@@ -143,13 +147,15 @@ class FreeSWITCH {
/*** Conference Methods ***/ /*** Conference Methods ***/
public function kickConferenceUser($conference, $member) { public function kickConferenceUser($conference, $member) {
$e = $this->esl->sendRecv("api conference $conference kick $member"); $esl = getEsl();
$e = $esl->sendRecv("api conference $conference kick $member");
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
public function getConferenceList() { public function getConferenceList() {
$e = $this->esl->sendRecv("api conference list"); $esl = getEsl();
$e = $esl->sendRecv("api conference list");
$body = $e->getBody(); $body = $e->getBody();
$data=explode("\n", $body); $data=explode("\n", $body);
$y=0; $y=0;
...@@ -164,7 +170,8 @@ class FreeSWITCH { ...@@ -164,7 +170,8 @@ class FreeSWITCH {
} }
public function getConferenceUsers($conference_name) { public function getConferenceUsers($conference_name) {
$e = $this->esl->sendRecv("api conference $conference_name list"); $esl = getEsl();
$e = $esl->sendRecv("api conference $conference_name list");
$body = $e->getBody(); $body = $e->getBody();
$data=explode("\n", $body); $data=explode("\n", $body);
$y=0; $y=0;
...@@ -218,35 +225,40 @@ class FreeSWITCH { ...@@ -218,35 +225,40 @@ class FreeSWITCH {
public function confPlayfile($conference, $file_path){ public function confPlayfile($conference, $file_path){
$playfile = "api conference $conference play " . $file_path; $playfile = "api conference $conference play " . $file_path;
$e = $this->esl->sendRecv($playfile); $esl = getEsl();
$e = $esl->sendRecv($playfile);
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
public function confLock($conference){ public function confLock($conference){
$playfile = "api conference $conference lock"; $playfile = "api conference $conference lock";
$e = $this->esl->sendRecv($playfile); $esl = getEsl();
$e = $esl->sendRecv($playfile);
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
public function confUnlock($conference){ public function confUnlock($conference){
$playfile = "api conference $conference unlock"; $playfile = "api conference $conference unlock";
$e = $this->esl->sendRecv($playfile); $esl = getEsl();
$e = $esl->sendRecv($playfile);
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
public function confMute($conference, $member){ public function confMute($conference, $member){
$playfile = "api conference $conference mute $member"; $playfile = "api conference $conference mute $member";
$e = $this->esl->sendRecv($playfile); $esl = getEsl();
$e = $esl->sendRecv($playfile);
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
public function confUnmute($conference, $member){ public function confUnmute($conference, $member){
$playfile = "api conference $conference unmute $member"; $playfile = "api conference $conference unmute $member";
$e = $this->esl->sendRecv($playfile); $esl = getEsl();
$e = $esl->sendRecv($playfile);
$body = $e->getBody(); $body = $e->getBody();
return $body; return $body;
} }
......
...@@ -20,7 +20,7 @@ $key_value="192.168.1.140"; ...@@ -20,7 +20,7 @@ $key_value="192.168.1.140";
$user="1000"; $user="1000";
*/ */
if ($section == "directory" && $tag_name == "domain" && $key_name == "name") { if ($section == "directory" && $tag_name == "domain" && $key_name == "name" && $user != "" ) {
$db_domain = $fsd->getDirDomainbyName($key_value); $db_domain = $fsd->getDirDomainbyName($key_value);
} else { } else {
printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"freeswitch/xml\">\n<section name=\"result\">\n". printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"freeswitch/xml\">\n<section name=\"result\">\n".
...@@ -28,16 +28,29 @@ if ($section == "directory" && $tag_name == "domain" && $key_name == "name") { ...@@ -28,16 +28,29 @@ if ($section == "directory" && $tag_name == "domain" && $key_name == "name") {
die(); die();
} }
$db_user = $fsd->getDirUsersByDomainUidByUsername($db_domain['uid'], $user);
$db_user_settings = $fsd->getDirUser($db_user['uid']);
$db_domain_settings = $fsd->getDirDomain($db_domain['uid']);
$db_user = $fsd->getDirUsersByDomainUidByUsername($db_domain['uid'], $user);
$db_user_settings = $fsd->getDirUser($db_user['uid']);
$db_groups = $fsd->getDirGroupsByDomianUidByUserUid($db_domain['uid'], $db_user['uid']); $db_groups = $fsd->getDirGroupsByDomianUidByUserUid($db_domain['uid'], $db_user['uid']);
printf(" <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); printf(" <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
printf(" <document type=\"freeswitch/xml\">\n"); printf(" <document type=\"freeswitch/xml\">\n");
printf(" <section name=\"directory\" description=\"Codename: Shipment Directory\">\n"); printf(" <section name=\"directory\" description=\"Codename: Shipment Directory\">\n");
printf(" <domain name=\"%s\">\n", $db_domain['name']); printf(" <domain name=\"%s\">\n", $db_domain['name']);
printf(" <params>\n");
foreach($db_domain_settings['params'] as $db_params) {
printf(" <param name=\"%s\" value=\"%s\"/>\n", $db_params['name'], $db_params['value']);
}
printf(" </params>\n");
printf(" <variables>\n");
foreach($db_domain_settings['variables'] as $db_variables) {
printf(" <variable name=\"%s\" value=\"%s\"/>\n", $db_variables['name'], $db_variables['value']);
}
printf(" </variables>\n");
printf(" <groups>\n"); printf(" <groups>\n");
printf(" <group name=\"default\">\n"); printf(" <group name=\"default\">\n");
printf(" <users>\n"); printf(" <users>\n");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论