[Freeswitch-svn] [commit] r12726 - freeswitch/trunk/scripts/contrib/swk/php/xml_curl
FreeSWITCH SVN
silik0n at freeswitch.org
Tue Mar 24 01:41:09 PDT 2009
Author: silik0n
Date: Tue Mar 24 03:41:09 2009
New Revision: 12726
Log:
ok lets add a few more things in here for IVR stuff
Added:
freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php
freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php (contents, props changed)
freeswitch/trunk/scripts/contrib/swk/php/xml_curl/fs_curl.php
- copied, changed from r12725, /freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php
Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/FSConfig.php Tue Mar 24 03:41:09 2009
@@ -0,0 +1,74 @@
+<?php
+
+/*
+ * FreeSWITCH AMF-PHP ESL Client Library
+ * Copyright (C) 2009, Ken Rice <krice at tollfreegateway.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Ken Rice <krice at tollfreegateway.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Ken Rice <krice at tollfreegateway.com>
+ *
+ * freeswitch.php -- Initial Class file for XML_CURL responses for Codename: SHIPMENT
+ *
+ ***************************************************************************************************
+ *
+ * This Requires the FreeSWITCH ESL Extension to be installed properly on your system.
+ *
+ */
+
+// require_once "ESL.php";
+
+class FSConfig {
+ // var $esl;
+
+ var $dbh;
+
+ public function __construct(){
+ $dbtype='mysql'; /* Set the Database type */
+ // $db_hostname = 'localhost'; /* Database Server hostname */
+ $db_hostname = '192.168.1.140'; /* Database Server hostname */
+ $db_port = '3306'; /* Database Server Port */
+ $db_username = 'root'; /* Database Server username */
+ $db_password = 'password'; /* Database Server password */
+ $db_database = 'shipment'; /* DataBase Name */
+ if ($dbtype == 'mysql') {
+ $pdo_flags = array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,);
+ }
+ $this->dbh = new PDO("$dbtype:host=$db_hostname;port=$db_port;dbname=$db_database", $db_username, $db_password, $pdo_flags);
+
+ }
+
+ /*** IVR Methods Methods ***/
+ public function getConfigMenus(){
+ $query = sprintf("select * from menus");
+ $stmt = $this->dbh->query($query);
+ $results = $stmt->fetchAll();
+ return $results;
+ }
+
+ public function getConfigMenuOptions($menu_uid) {
+ $query = sprintf("select * from menu_entries where menu_uid = %s", $menu_uid);
+ $stmt = $this->dbh->query($query);
+ $results = $stmt->fetchAll();
+ return $results;
+ }
+}
Added: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/swk/php/xml_curl/directory.php Tue Mar 24 03:41:09 2009
@@ -0,0 +1 @@
+link fs_curl.php
\ No newline at end of file
Copied: freeswitch/trunk/scripts/contrib/swk/php/xml_curl/fs_curl.php (from r12725, /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/fs_curl.php Tue Mar 24 03:41:09 2009
@@ -1,6 +1,7 @@
<?
require_once "FSDirectory.php";
+require_once "FSConfig.php";
header ("content-type: text/xml");
@@ -9,9 +10,8 @@
$$key = $value;
}
-$fsd = new FSDirectory();
-/* Uncomment and edit for debugging */
+/* Uncomment and edit for debugging directory*/
/*
$section = "directory";
$tag_name= "domain";
@@ -20,64 +20,111 @@
$user="1000";
*/
-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".
- "<result status=\"not found\" />\n</section>\n</document>");
- die();
-}
-
-
+/* Uncomment and edit for debugging directory*/
+/*
+$section = "configuration";
+$tag_name= "configuration";
+$key_name ="name";
+$key_value="ivr.conf";
+*/
+/* section=configuration&tag_name=configuration&key_name=name&key_value=ivr.conf&Event-Name=REQUEST_PARAMS */
-$db_domain_settings = $fsd->getDirDomain($db_domain['uid']);
+if ($section == "configuration" && $tag_name == "configuration" && $key_name == "name" && $key_value == "ivr.conf" ) {
+
+ $fsc = new FSConfig();
+
+ printf(" <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
+ printf(" <document type=\"freeswitch/xml\">\n");
+ printf(" <section name=\"configuration\" description=\"Codename: Shipment IVR\">\n");
+ printf(" <configuration name=\"ivr.conf\" description=\"IVR menus\">\n");
+ printf(" <menus>\n");
+
+ $db_menus = $fsc->getConfigMenus();
+ foreach ($db_menus as $db_menu) {
+ printf(" <menu name=\"%s\"\n".
+ " greet-long=\"%s\"\n".
+ " greet-short=\"%s\"\n".
+ " invalid-sound=\"%s\"\n".
+ " exit-sound=\"%s\"\n".
+ " timeout=\"%s\"\n".
+ " inter-digit-timeout=\"%s\"\n".
+ " max-failures=\"%s\"\n".
+ " max-timeouts=\"%s\"\n".
+ " digit-len=\"%s\">\n",
+ $db_menu['name'], $db_menu['greet_long'], $db_menu['greet_short'], $db_menu['invalid_sound'],
+ $db_menu['exit_sound'], $db_menu['timeout'], $db_menu['inter_digit_timeout'], $db_menu['max_failures'],
+ $db_menu['max_timeouts'], $db_menu['digit_len']);
+
+ $db_menuopts = $fsc->getConfigMenuOptions($db_menu['uid']);
+
+ foreach ($db_menuopts as $db_menuopt) {
+ printf(" <entry action=\"%s\" digits=\"%s\" param=\"%s\"/>\n",
+ $db_menuopt['action'], $db_menuopt['digits'], $db_menuopt['param']);
+ }
+
+ printf(" </menu>\n");
+ }
+ printf(" </menus>\n");
+ printf(" </configuration>\n");
+ printf(" </section>\n");
+ printf(" </document>\n");
+} else if ($section == "directory" && $tag_name == "domain" && $key_name == "name" && $user != "" ) {
-$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");
-printf(" <user id=\"%s\" mailbox=\"%s\">\n", $db_user['username'], $db_user['mailbox']);
-printf(" <params>\n");
-foreach($db_user_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_user_settings['variables'] as $db_variables) {
- printf(" <variable name=\"%s\" value=\"%s\"/>\n", $db_variables['name'], $db_variables['value']);
-}
-printf(" </variables>\n");
-printf(" </user>\n");
-printf(" </users>\n");
-printf(" </group>\n");
-foreach($db_groups as $db_group){
- printf(" <group name=\"%s\">\n", $db_group['groupName']);
+ $fsd = new FSDirectory();
+ $db_domain = $fsd->getDirDomainbyName($key_value);
+ $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");
- printf(" <user id=\"%s\" type=\"pointer\"/>\n", $user);
+ printf(" <user id=\"%s\" mailbox=\"%s\">\n", $db_user['username'], $db_user['mailbox']);
+ printf(" <params>\n");
+ foreach($db_user_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_user_settings['variables'] as $db_variables) {
+ printf(" <variable name=\"%s\" value=\"%s\"/>\n", $db_variables['name'], $db_variables['value']);
+ }
+ printf(" </variables>\n");
+ printf(" </user>\n");
printf(" </users>\n");
printf(" </group>\n");
+ foreach($db_groups as $db_group){
+ printf(" <group name=\"%s\">\n", $db_group['groupName']);
+ printf(" <users>\n");
+ printf(" <user id=\"%s\" type=\"pointer\"/>\n", $user);
+ printf(" </users>\n");
+ printf(" </group>\n");
+ }
+
+ printf(" </groups>\n");
+ printf(" </domain>\n");
+ printf(" </section>\n");
+ printf(" </document>\n");
+
+} else {
+ printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"freeswitch/xml\">\n<section name=\"result\">\n".
+ "<result status=\"not found\" />\n</section>\n</document>");
+ die();
}
-
-printf(" </groups>\n");
-printf(" </domain>\n");
-printf(" </section>\n");
-printf(" </document>\n");
?>
More information about the Freeswitch-svn
mailing list