[Freeswitch-svn] [commit] r12707 - in freeswitch/trunk/scripts/contrib/swk/php: amfphp xml_curl

FreeSWITCH SVN silik0n at freeswitch.org
Sat Mar 21 21:59:54 PDT 2009


Author: silik0n
Date: Sat Mar 21 23:59:54 2009
New Revision: 12707

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

Modified:
   freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php
   freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php

Modified: freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php	(original)
+++ freeswitch/trunk/scripts/contrib/swk/php/amfphp/freeswitch.php	Sat Mar 21 23:59:54 2009
@@ -38,8 +38,6 @@
 require_once "ESL.php";
  
 class FreeSWITCH {
-	var $esl;
-	var $dbh;
 
 	private function getDbh(){
 		$dbtype='mysql'; 		/* Set the Database type */
@@ -56,23 +54,26 @@
 		return $dbh;
 	}
 
-        public function __construct() { 
+        private function getEsl(){
 		$esl_server = "127.0.0.1"; 	/* ESL Server */
 		$esl_port = "8021"; 		/* ESL Port */
 		$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 ***/
 
 	public function getStatus() {
-		$e = $this->esl->sendRecv("api status");
+		$esl = getEsl();
+		$e = $esl->sendRecv("api status");
 		$body = $e->getBody();
 		return $body;
 	}
 
 	public function getChannels() {
-		$e = $this->esl->sendRecv("api show channels");
+		$esl = getEsl();
+		$e = $esl->sendRecv("api show channels");
 		$body = $e->getBody();
 		$temp = explode  ("\n", $body);
 		$total_count = sizeof($temp);
@@ -101,7 +102,8 @@
 	}
 	
 	public function getCalls() {
-		$e = $this->esl->sendRecv("api show calls");
+		$esl = getEsl();
+		$e = $esl->sendRecv("api show calls");
 		$body = $e->getBody();
 		$temp = explode  ("\n", $body);
 		$total_count = sizeof($temp);
@@ -129,13 +131,15 @@
 
 	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";
-		$e = $this->esl->sendRecv($dialstring);
+		$esl = getEsl();
+		$e = $esl->sendRecv($dialstring);
 		$body = $e->getBody();
 		return $body;
 	}
 
 	public function killUuid($uuid) {
-		$e = $this->esl->sendRecv("api uuid_kill $uuid");
+		$esl = getEsl();
+		$e = $esl->sendRecv("api uuid_kill $uuid");
 		$body = $e->getBody();
 		return $body;
 	}
@@ -143,13 +147,15 @@
 	/*** Conference Methods ***/
 	
 	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();
 		return $body;
 	}
 
 	public function getConferenceList() {
-		$e = $this->esl->sendRecv("api conference list");
+		$esl = getEsl();
+		$e = $esl->sendRecv("api conference list");
 		$body = $e->getBody();
 		$data=explode("\n", $body);
 		$y=0;
@@ -164,7 +170,8 @@
 	}
 
 	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();
 		$data=explode("\n", $body);
 		$y=0;
@@ -218,35 +225,40 @@
 
 	public function confPlayfile($conference, $file_path){
 		$playfile = "api conference $conference play " . $file_path;
-		$e = $this->esl->sendRecv($playfile);
+		$esl = getEsl();
+		$e = $esl->sendRecv($playfile);
 		$body = $e->getBody();
 		return $body;
 	}
 
 	public function confLock($conference){
 		$playfile = "api conference $conference lock";
-		$e = $this->esl->sendRecv($playfile);
+		$esl = getEsl();
+		$e = $esl->sendRecv($playfile);
 		$body = $e->getBody();
 		return $body;
 	}
 
 	public function confUnlock($conference){
 		$playfile = "api conference $conference unlock";
-		$e = $this->esl->sendRecv($playfile);
+		$esl = getEsl();
+		$e = $esl->sendRecv($playfile);
 		$body = $e->getBody();
 		return $body;
 	}
 	
 	public function confMute($conference, $member){
 		$playfile = "api conference $conference mute $member";
-		$e = $this->esl->sendRecv($playfile);
+		$esl = getEsl();
+		$e = $esl->sendRecv($playfile);
 		$body = $e->getBody();
 		return $body;
 	}
 	
 	public function confUnmute($conference, $member){
 		$playfile = "api conference $conference unmute $member";
-		$e = $this->esl->sendRecv($playfile);
+		$esl = getEsl();
+		$e = $esl->sendRecv($playfile);
 		$body = $e->getBody();
 		return $body;
 	}

Modified: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php	(original)
+++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php	Sat Mar 21 23:59:54 2009
@@ -20,7 +20,7 @@
 $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);
 } else {
 	printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"freeswitch/xml\">\n<section name=\"result\">\n".
@@ -28,16 +28,29 @@
 	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']);
 
 printf(" <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
 printf("   <document type=\"freeswitch/xml\">\n");
 printf("      <section name=\"directory\" description=\"Codename: Shipment Directory\">\n");
 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("             <group name=\"default\">\n");
 printf("               <users>\n");



More information about the Freeswitch-svn mailing list