[Freeswitch-svn] [commit] r7158 - in freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl: . configuration
Freeswitch SVN
intralanman at freeswitch.org
Wed Jan 9 18:15:20 EST 2008
Author: intralanman
Date: Wed Jan 9 18:15:19 2008
New Revision: 7158
Added:
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/conference.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/console.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/dingaling.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/iax.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/ivr.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/limit.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/local_stream.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/post_load_modules.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/rss.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/sofia.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/spidermonkey.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/voicemail.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/xml_cdr.conf.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php
freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/index.php
Log:
Initial check-in of fs_curl stuff.... this will pull configurations for the modules, directory, dialplan, and eventually take xml_cdr POSTs
the dialplan_importer will take a current xml file and import it to the db so that it's correctly returned as xml in the webpage exactly the same way it went in [ideally]
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/conference.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/conference.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,185 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * conference.conf.php
+ */
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Write XML for conference.conf
+*/
+class conference_conf extends fs_configuration {
+ /**
+ * Initializer method
+ * This method calls fs_configuration to initialize all of the
+ * objects and variables that we want to inherit
+ * @return void
+ */
+ public function conference_conf() {
+ $this -> fs_configuration();
+ }
+
+ /**
+ * Main sub-routine
+ * This method will call all of the other methods necessary
+ * to write out the XML for the conference.conf
+ * @return void
+ */
+ public function main() {
+ $this -> write_advertises();
+ $this -> write_controls();
+ $this -> write_profiles();
+ }
+
+ /**
+ * Write XML for <advertises>
+ * This method will write the elements and attributes for the
+ * conferences that are to be advertised
+ * @return void
+ */
+ private function write_advertises() {
+ $query = "SELECT * FROM conference_advertise ORDER BY room";
+ $advertises = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ if (MDB2::isError($advertises)) {
+ $this -> comment($query);
+ $this -> comment($advertises -> getMessage());
+ return ;
+ }
+ $advertise_count = count($advertises);
+ if ($advertise_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('advertise');
+ for ($i=0; $i<$advertise_count; $i++) {
+ //$this -> comment_array($advertises[$i]);
+ $this -> xmlw -> startElement('room');
+ $this -> xmlw -> writeAttribute('name', $advertises[$i]['room']);
+ $this -> xmlw -> writeAttribute('status', $advertises[$i]['status']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+
+
+ /**
+ * Pull conference profiles from the database
+ * This method will pull the conference profiles
+ * from the database using the PEAR MDB2 extension
+ * @return array
+ */
+ private function get_profiles_array() {
+ $query = sprintf('%s %s;'
+ , "SELECT * FROM conference_profiles"
+ , "ORDER BY profile_name"
+ );
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ return array();
+ }
+ while ($row = $res -> fetchRow()) {
+ $pn = $row['profile_name'];
+ $profiles[$pn][] = $row;
+ }
+ return $profiles;
+ }
+
+ /**
+ * Write XML for <profiles>
+ * This method will write the XML of the array
+ * from get_profiles_array
+ * @return void
+ */
+ private function write_profiles() {
+ $profiles_array = $this -> get_profiles_array();
+ $profiles_count = count($profiles_array);
+ if ($profiles_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('profiles');
+
+ foreach ($profiles_array as $profile_name => $profile_data) {
+ $this -> xmlw -> startElement('profile');
+ $this -> xmlw -> writeAttribute('name', $profile_name);
+ foreach ($profile_data as $params) {
+ //$this -> comment_array($profiles_array[$i]);
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $params['param_name']);
+ $this -> xmlw -> writeAttribute('value', $params['param_value']);
+ $this -> xmlw -> endElement();//</param>
+
+ }
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Pull caller-controls from database via MDB2
+ * This method will pull the conference caller-controls from
+ * the database using the PEAR MDB2 extension
+ * @return array
+ */
+ private function get_controls_array() {
+ $query = sprintf(
+ "SELECT * FROM conference_controls ORDER BY conf_group"
+ );
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ return array();
+ }
+ while ($row = $res -> fetchRow()) {
+ $cg = $row['conf_group'];
+ $profiles[$cg][] = $row;
+ }
+ return $profiles;
+ }
+
+ /**
+ * Write XML for <caller-controls>
+ * This method will write the XML of the array
+ * from get_controls_array
+ * @return void
+ */
+ private function write_controls() {
+ $controls_array = $this -> get_controls_array();
+ $controls_count = count($controls_array);
+ if (MDB2::isError($controls_array)) {
+ $this -> comment($query);
+ $this -> comment($controls_array -> getMessage());
+ return ;
+ }
+ if ($controls_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('caller-controls');
+
+ foreach ($controls_array as $group_name => $control_data) {
+ $this -> xmlw -> startElement('group');
+ $this -> xmlw -> writeAttribute('name', $group_name);
+ foreach ($control_data as $controls) {
+
+ //$this -> comment_array($controls_array[$i]);
+ $this -> xmlw -> startElement('control');
+ $this -> xmlw -> writeAttribute('action', $controls['action']);
+ $this -> xmlw -> writeAttribute('digits', $controls['digits']);
+ $this -> xmlw -> endElement();
+
+ }
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/console.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/console.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,50 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ * console.conf.php
+ */
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * @todo make this configurable via db rather than hardcoded.
+ * File containing the base class for all curl XML output
+*/
+class console_conf extends fs_configuration {
+ function console_conf() {
+ $this -> fs_configuration();
+ }
+
+ /**
+ * Currently this method does pretty much everything
+ */
+ function main() {
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'Console configuration');
+
+ $this -> xmlw -> startElement('settings');
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', 'colorize');
+ $this -> xmlw -> writeAttribute('value', 'true');
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+
+ $this -> xmlw -> startElement('mappings');
+ $this -> xmlw -> startElement('map');
+ $this -> xmlw -> writeAttribute('name', 'all');
+ $this -> xmlw -> writeAttribute('value', 'notice,warning,error,crit,alert');
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+
+ $this -> xmlw -> endElement();
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/dingaling.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/dingaling.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,142 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * dingaling.conf.php
+ */
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Write XML for dingaling.conf
+*/
+class dingaling_conf extends fs_configuration {
+ /**
+ * Initializer method
+ * This method calls fs_configuration to initialize all of the
+ * objects and variables that we want to inherit
+ * @return void
+ */
+ public function dingaling_conf() {
+ $this -> fs_configuration();
+ }
+
+ /**
+ * Main sub-routine
+ * This method will call all of the other methods necessary
+ * to write out the XML for the dingaling.conf
+ * @return void
+ */
+ public function main() {
+ $this -> write_settings();
+ $this -> write_profiles();
+ }
+
+ /**
+ * Pull dingaling profiles from the database
+ * @return array
+ */
+ private function get_params_array() {
+ $query = sprintf('%s %s;'
+ , "SELECT * FROM dingaling_profile_params"
+ , "ORDER BY dingaling_id"
+ );
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ return array();
+ }
+ while ($row = $res -> fetchRow()) {
+ $id = $row['dingaling_id'];
+ $profiles[$id][] = $row;
+ }
+ return $profiles;
+ }
+
+ /**
+ * get dingaling profile names, types, and ids
+ * @return array
+ */
+ private function get_profile_array() {
+ $query = sprintf('SELECT * FROM dingaling_profiles');
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ while ($row = $res -> fetchRow()) {
+ $id = $row['id'];
+ $profiles[$id] = $row['type'];
+ }
+ return $profiles;
+ }
+
+
+ /**
+ * Write XML for <profile>s
+ * This method will write the XML of the array
+ * from get_profiles_array
+ * @return void
+ */
+ private function write_profiles() {
+ $profile_array = $this -> get_profile_array();
+ $params_array = $this -> get_params_array();
+ $params_count = count($params_array);
+ if ($params_count < 1) {
+ return ;
+ }
+ while (list($id, $type) = each($profile_array)) {
+ $this -> xmlw -> startElement('profile');
+ $this -> xmlw -> writeAttribute('type', $type);
+ if (!empty($params_array[$id])) {
+ $this_param_count = count($params_array[$id]);
+ for ($i=0; $i<$this_param_count; $i++) {
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute(
+ 'name', $params_array[$id][$i]['param_name']
+ );
+ $this -> xmlw -> writeAttribute(
+ 'value', $params_array[$id][$i]['param_value']
+ );
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> xmlw -> endElement();
+ }
+ }
+ }
+
+
+ /**
+ * Write out the XML for the dingaling <settings>
+ *@return void
+ */
+ private function write_settings() {
+ $query = sprintf('SELECT * FROM dingaling_settings');
+ $res = $this -> db -> queryAll($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ $setting_count = count($res);
+ if ($setting_count > 0) {
+ $this -> xmlw -> startElement('settings');
+ for ($i=0; $i<$setting_count; $i++) {
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $res[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $res[$i]['param_value']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/iax.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/iax.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,172 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ * iax.conf.php
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * @todo add gateways, aliases, etc when support is added into FS
+ * Class to write XML for iax.conf
+*/
+class iax_conf extends fs_configuration {
+ public function iax_conf() {
+ $this -> fs_configuration();
+ }
+
+ public function main() {
+ $profiles = $this -> get_profiles();
+ $this -> write_config($profiles);
+ }
+
+ private function get_profiles() {
+ $query = "SELECT * FROM iax_conf ORDER BY id LIMIT 1";
+ $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ return $profiles;
+ }
+
+ private function write_aliases($profile_id) {
+ $query = "SELECT * FROM iax_aliases WHERE iax_id=$profile_id ";
+ $aliases_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $aliases_count = count($aliases_array);
+ if (MDB2::isError($aliases_array)) {
+ $this -> comment($query);
+ $this -> comment($aliases_array -> getMessage());
+ return ;
+ }
+ if ($aliases_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('aliases');
+
+ for ($i=0; $i<$aliases_count; $i++) {
+ //$this -> comment_array($aliases_array[$i]);
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $aliases_array[$i]['alias_name']);
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ private function write_settings($profile_id) {
+ $query = "SELECT * FROM iax_settings WHERE iax_id=$profile_id "
+ . "ORDER BY iax_id, param_name";
+ $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $settings_count = count($settings_array);
+ if (MDB2::isError($settings_array)) {
+ $this -> comment($query);
+ $this -> comment($settings_array -> getMessage());
+ return ;
+ }
+ if ($settings_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('settings');
+
+ for ($i=0; $i<$settings_count; $i++) {
+ //$this -> comment_array($settings_array[$i]);
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $settings_array[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $settings_array[$i]['param_value']);
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ private function write_gateways($profile_id) {
+ $query = "SELECT * FROM iax_gateways WHERE iax_id=$profile_id "
+ . "ORDER BY gateway_name, gateway_param";
+ $gateway_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $gateway_count = count($gateway_array);
+ //$this -> comment_array($gateway_array);
+ if (MDB2::isError($gateway_array)) {
+ $this -> comment($query);
+ $this -> comment($gateway_array -> getMessage());
+ return ;
+ }
+ if ($gateway_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('gateways');
+ for ($i=0; $i<$gateway_count; $i++) {
+ $this_gateway = $gateway_array[$i]['gateway_name'];
+ if ($this_gateway != $gateway_array[$i-1]['gateway_name']) {
+ $this -> xmlw -> startElement('gateway');
+ $this -> xmlw -> writeAttribute('name', $this_gateway);
+ }
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $gateway_array[$i]['gateway_param']);
+ $this -> xmlw -> writeAttribute('value', $gateway_array[$i]['gateway_value']);
+ $this -> xmlw -> endElement();
+ if (!array_key_exists($i+1, $gateway_array)
+ || $this_gateway != $gateway_array[$i+1]['gateway_name']) {
+ $this -> xmlw -> endElement();
+ }
+ $last_gateway = $this_gateway;
+ }
+ $this -> xmlw -> endElement(); //</gateways>
+ }
+
+ private function write_domains($profile_id) {
+ $query = "SELECT * FROM iax_domains WHERE iax_id=$profile_id";
+ $domain_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $domain_count = count($domain_array);
+ if (MDB2::isError($domain_array)) {
+ $this -> comment($query);
+ $this -> comment($domain_array -> getMessage());
+ return ;
+ }
+ if ($domain_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('domains');
+ for ($i=0; $i<$domain_count; $i++) {
+ $this -> xmlw -> startElement('domain');
+ $this -> xmlw -> writeAttribute('name', $domain_array[$i]['domain_name']);
+ $this -> xmlw -> writeAttribute(
+ 'parse', ($domain_array[$i]['parse'] == 1 ? 'true' : 'false')
+ );
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ private function write_single_profile($profile) {
+ /* //reserved for multi-profile
+ $this -> xmlw -> startElement('profile');
+ $this -> xmlw -> writeAttribute('name', $profile['profile_name']);
+ */
+ //$this -> write_aliases($profile['id']);
+ //$this -> write_domains($profile['id']);
+ //$this -> write_gateways($profile['id']);
+ $this -> write_settings($profile['id']);
+ //$this -> xmlw -> endElement(); //reserved for multi-profile
+ }
+
+ /**
+ * Write XML for iax.conf profiles
+ *
+ * @param unknown_type $profiles
+ */
+ private function write_config($profiles) {
+ $profile_count = count($profiles);
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'IAX Endpoint');
+ /*
+ $this -> xmlw -> startElement('profiles');
+ //we'll add this back if ever multiple iax profiles are supported
+ */
+ for ($i=0; $i<$profile_count; $i++) {
+ $this -> write_single_profile($profiles[$i]);
+ }
+ //$this -> xmlw -> endElement(); //this too
+ $this -> xmlw -> endElement();
+ }
+}
+
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/ivr.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/ivr.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,117 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * ivr.conf.php
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Write XML for ivr.conf
+*/
+class ivr_conf extends fs_configuration {
+ public function ivr_conf() {
+ $this -> fs_configuration();
+ }
+
+ /**
+ * This method will run all of the methods necessary to return
+ * the XML for the ivr.conf
+ * @return void
+ */
+ public function main() {
+ $ivrs = $this -> get_ivr_array();
+ $this -> write_config($ivrs);
+ }
+
+ /**
+ * This method will fetch all of the ivr menus from the database
+ * using the MDB2 pear class
+ * @return array
+ */
+ private function get_ivr_array() {
+ $query = "SELECT * FROM ivr_conf";
+ $menus = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ return $menus;
+ }
+
+ /**
+ * This method will write all of the entry elements with
+ * their corresponding attributes
+ * @return void
+ */
+ private function write_entries($ivr_id) {
+ $query = sprintf(
+ "SELECT * FROM ivr_entries WHERE ivr_id=$ivr_id ORDER BY digits"
+ );
+ $entries_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ if (MDB2::isError($entries_array)) {
+ $this -> comment($query);
+ $this -> comment($entries_array -> getMessage());
+ return ;
+ }
+ $entries_count = count($entries_array);
+ if ($entries_count < 1) {
+ return ;
+ }
+ $entries_count = count($entries_array);
+ for ($i=0; $i<$entries_count; $i++) {
+ //$this -> comment_array($entries_array[$i]);
+ $this -> xmlw -> startElement('entry');
+ $this -> xmlw -> writeAttribute('action', $entries_array[$i]['action']);
+ $this -> xmlw -> writeAttribute('digits', $entries_array[$i]['digits']);
+ if (!empty($entries_array[$i]['params'])) {
+ $this -> xmlw -> writeAttribute('params', $entries_array[$i]['params']);
+ }
+ $this -> xmlw -> endElement();//</param>
+ }
+ }
+
+ /**
+ * This method will evaluate the data from the db and
+ * write attributes that need written
+ * @return void
+ */
+ private function write_menu_attributes($menu_data) {
+ $this -> xmlw -> writeAttribute('name', $menu_data['name']);
+ $this -> xmlw -> writeAttribute('greet-long', $menu_data['greet_long']);
+ $this -> xmlw -> writeAttribute('greet-short', $menu_data['greet_short']);
+ $this -> xmlw -> writeAttribute('invalid-sound', $menu_data['invalid_sound']);
+ $this -> xmlw -> writeAttribute('exit-sound', $menu_data['exit_sound']);
+ $this -> xmlw -> writeAttribute('timeout', $menu_data['timeout']);
+ $this -> xmlw -> writeAttribute('max-failures', $menu_data['max_failures']);
+ if (!empty($menu_data['tts_engine'])) {
+ $this -> xmlw -> writeAttribute('tts-engine', $menu_data['tts_engine']);
+ }
+ if (!empty($menu_data['tts_voice'])) {
+ $this -> xmlw -> writeAttribute('tts-voice', $menu_data['tts_voice']);
+ }
+ //$this -> xmlw -> writeAttribute('', $menu_data['']);
+ }
+
+ /**
+ * This method will do the writing of the "menu" elements
+ * and call the write_entries method to do the writing of
+ * individual menu's "entry" elements
+ * @return void
+ */
+ private function write_config($menus) {
+ $menu_count = count($menus);
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'Sofia SIP Endpoint');
+ $this -> xmlw -> startElement('menus');
+ for ($i=0; $i<$menu_count; $i++) {
+ $this -> xmlw -> startElement('menu');
+ $this -> write_menu_attributes($menus[$i]);
+ $this -> write_entries($menus[$i]['id']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/limit.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/limit.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,74 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * limit.conf.php
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Write XML for limit.conf
+*/
+class limit_conf extends fs_configuration {
+
+ public function limit_conf() {
+ $this -> fs_configuration();
+ }
+
+ public function main() {
+ $params = $this -> get_params_array($this -> db);
+ $this -> write_params_array($params);
+ $this -> output_xml();
+
+ }
+
+ /**
+ * Pull limit params from the db
+ * @return array
+ */
+ private function get_params_array() {
+ $query = sprintf('SELECT * FROM limit_conf;');
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ return array();
+ }
+ $this -> comment($res -> numRows() . 'rows');
+ if ($res -> numRows() == 0) {
+ return array();
+ }
+ while ($row = $res -> fetchRow(MDB2_FETCHMODE_ASSOC)) {
+ $feeds_array[] = $row;
+ }
+ return $feeds_array;
+ }
+
+ /**
+ * Write out the XML of params retreived from get_params_array
+ * @see get_params_array
+ * @param unknown_type $params
+ */
+ private function write_params_array($params) {
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'Call Limiter');
+ $this -> xmlw -> startElement('settings');
+
+ $param_count = count($params);
+ for ($i=0; $i<$param_count; $i++) {
+ $this -> comment("$param_count/$i");
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $params[$i]['name']);
+ $this -> xmlw -> writeAttribute('value', $params[$i]['value']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+
+}
+?>
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/local_stream.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/local_stream.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,73 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * local_stream.conf.php
+ */
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Class to write the XML for local_stream.conf
+ */
+class local_stream_conf extends fs_configuration {
+
+ public function local_stream_conf() {
+ $this -> fs_configuration();
+ }
+
+ public function main() {
+ $directories = $this -> get_directories();
+ $this -> write_directories($directories);
+ }
+
+ private function write_settings($profile_id) {
+ $query = sprintf('%s %s %s;'
+ , "SELECT * FROM local_stream_settings "
+ , "WHERE stream_id=$profile_id "
+ , "ORDER BY stream_id, param_name"
+ );
+ $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $settings_count = count($settings_array);
+ if (MDB2::isError($settings_array)) {
+ $this -> comment($query);
+ $this -> comment($settings_array -> getMessage());
+ return ;
+ }
+ if ($settings_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('settings');
+
+ for ($i=0; $i<$settings_count; $i++) {
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $settings_array[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $settings_array[$i]['param_value']);
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> write_email($profile_id);
+ $this -> xmlw -> endElement();
+ }
+
+ private function get_directories() {
+ $query = sprintf('SELECT * FROM local_stream_conf;');
+ $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ if (MDB2::isError($profiles)) {
+ $this -> comment($query);
+ $this -> comment($profiles -> getMessage());
+ return array();
+ }
+ return $profiles;
+ }
+
+ private function write_directories($directories) {
+ $directory_count = count($directories);
+ for ($i=0; $i<$directory_count; $i++) {
+ $this -> write_settings($directories[$i]);
+ }
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/post_load_modules.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/post_load_modules.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,77 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * post_load_modules.conf.php
+ */
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Class to write the post_load_modules.conf XML for FreeSWITCH
+*/
+class post_load_modules_conf extends fs_configuration {
+
+ public function post_load_modules_conf() {
+ $this -> fs_configuration();
+ }
+
+ public function main() {
+ $params = $this -> get_modules_array($this -> db);
+ $this -> write_modules_array($params);
+ $this -> output_xml();
+
+ }
+
+ /**
+ * This method will pull the postloaded modules from the database
+ * @return array
+ */
+ function get_modules_array() {
+ $query = sprintf(
+ 'SELECT * FROM post_load_modules_conf WHERE load_module=1 ORDER BY priority;'
+ );
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ return array();
+ }
+ $this -> comment($res -> numRows() . 'rows');
+ if ($res -> numRows() == 0) {
+ return array();
+ }
+ while ($row = $res -> fetchRow(MDB2_FETCHMODE_ASSOC)) {
+ $feeds_array[] = $row;
+ }
+ return $feeds_array;
+ }
+
+ /**
+ * This method will write the XML from the array returned by get_modules_array
+ * @see post_load_modules_conf::get_modules_array
+ * @param array $params array of modules to load
+ */
+ function write_modules_array($params) {
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute(
+ 'description', 'Load All External Modules'
+ );
+ $this -> xmlw -> startElement('modules');
+
+ $param_count = count($params);
+ for ($i=0; $i<$param_count; $i++) {
+ $this -> xmlw -> startElement('load');
+ $this -> xmlw -> writeAttribute('module', $params[$i]['module_name']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+
+}
+?>
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/rss.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/rss.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,70 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ *
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * class to write XML for rss.conf
+*/
+class rss_conf extends fs_configuration {
+
+ function rss_conf() {
+ $this -> fs_configuration();
+ }
+
+ function main() {
+ $feeds_array = $this -> get_feeds_array();
+ $this -> xmlw -> startElement('feeds');
+ $this -> xmlw -> endElement();
+ $this -> write_xml($feeds_array);
+ }
+
+ /**
+ * Get RSS feed info from DB
+ *
+ * @return array
+ */
+ function get_feeds_array() {
+ $query = sprintf(
+ 'SELECT * FROM rss_conf ORDER BY priority, local_file;'
+ );
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ return false;
+ }
+ while ($row = $res -> fetchRow(MDB2_FETCHMODE_ASSOC)) {
+ $feeds_array[] = $row;
+ }
+ return $feeds_array;
+ }
+
+ /**
+ * Write XML for RSS feeds that were pulled by get_feeds_arrray
+ * @see get_feeds_array
+ * @param unknown_type $feeds_in
+ */
+ function write_xml($feeds_in) {
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'RSS Parser');
+ $this -> xmlw -> startElement('feeds');
+ $feed_count = count($feeds_in);
+ for ($i=0; $i<$feed_count; $i++) {
+ $this -> xmlw -> startElement('feed');
+ $this -> xmlw -> writeAttribute(
+ 'name', $feeds_in[$i]['description']
+ );
+ $this -> xmlw -> text($feeds_in[$i]['local_file']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+}
+
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/sofia.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/sofia.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,196 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * sofia.conf.php
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Write XML for sofia.conf
+*/
+class sofia_conf extends fs_configuration {
+ public function sofia_conf() {
+ $this -> fs_configuration();
+ }
+
+ public function main() {
+ $profiles = $this -> get_profiles();
+ $this -> write_config($profiles);
+ }
+
+ /**
+ * Pull the sofia profiles from the db
+ * @return array
+ */
+ private function get_profiles() {
+ $query = "SELECT * FROM sofia_conf";
+ $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ if (MDB2::isError($profiles)) {
+ $this -> comment($query);
+ $this -> comment($profiles -> getMessage());
+ $this -> file_not_found();
+ }
+ return $profiles;
+ }
+
+ /**
+ * Write aliases for current sofia <profile>
+ * @param integer $profile_id id of the sofia profile in sofia_conf
+ */
+ private function write_aliases($profile_id) {
+ $query = "SELECT * FROM sofia_aliases WHERE sofia_id=$profile_id ";
+ $aliases_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $aliases_count = count($aliases_array);
+ if (MDB2::isError($aliases_array)) {
+ $this -> comment($query);
+ $this -> comment($aliases_array -> getMessage());
+ return ;
+ }
+ if ($aliases_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('aliases');
+
+ for ($i=0; $i<$aliases_count; $i++) {
+ //$this -> comment_array($aliases_array[$i]);
+ $this -> xmlw -> startElement('alias');
+ $this -> xmlw -> writeAttribute('name', $aliases_array[$i]['alias_name']);
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Write the <settings> for the current profile
+ * @param integer $profile_id id of the sofia profile in sofia_conf
+ */
+ private function write_settings($profile_id) {
+ $query = "SELECT * FROM sofia_settings WHERE sofia_id=$profile_id "
+ . "ORDER BY sofia_id, param_name";
+ $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $settings_count = count($settings_array);
+ if (MDB2::isError($settings_array)) {
+ $this -> comment($query);
+ $this -> comment($settings_array -> getMessage());
+ return ;
+ }
+ if ($settings_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('settings');
+
+ for ($i=0; $i<$settings_count; $i++) {
+ //$this -> comment_array($settings_array[$i]);
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $settings_array[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $settings_array[$i]['param_value']);
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Write <gateways> XML for current profile
+ * @param integer $profile_id id of the sofia profile in sofia_conf
+ */
+ private function write_gateways($profile_id) {
+ $query = "SELECT * FROM sofia_gateways WHERE sofia_id=$profile_id "
+ . "ORDER BY gateway_name, gateway_param";
+ $gateway_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $gateway_count = count($gateway_array);
+ //$this -> comment_array($gateway_array);
+ if (MDB2::isError($gateway_array)) {
+ $this -> comment($query);
+ $this -> comment($gateway_array -> getMessage());
+ return ;
+ }
+ if ($gateway_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('gateways');
+ for ($i=0; $i<$gateway_count; $i++) {
+ $this_gateway = $gateway_array[$i]['gateway_name'];
+ if ($this_gateway != $gateway_array[$i-1]['gateway_name']) {
+ $this -> xmlw -> startElement('gateway');
+ $this -> xmlw -> writeAttribute('name', $this_gateway);
+ }
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $gateway_array[$i]['gateway_param']);
+ $this -> xmlw -> writeAttribute('value', $gateway_array[$i]['gateway_value']);
+ $this -> xmlw -> endElement();
+ if (!array_key_exists($i+1, $gateway_array)
+ || $this_gateway != $gateway_array[$i+1]['gateway_name']) {
+ $this -> xmlw -> endElement();
+ }
+ $last_gateway = $this_gateway;
+ }
+ $this -> xmlw -> endElement(); //</gateways>
+ }
+
+ /**
+ * Write <domains> XML for current sofia profile
+ * @param integer $profile_id id of sofia profile in sofia_conf
+ */
+ private function write_domains($profile_id) {
+ $query = "SELECT * FROM sofia_domains WHERE sofia_id=$profile_id";
+ $domain_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $domain_count = count($domain_array);
+ if (MDB2::isError($domain_array)) {
+ $this -> comment($query);
+ $this -> comment($domain_array -> getMessage());
+ return ;
+ }
+ if ($domain_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('domains');
+ for ($i=0; $i<$domain_count; $i++) {
+ $this -> xmlw -> startElement('domain');
+ $this -> xmlw -> writeAttribute('name', $domain_array[$i]['domain_name']);
+ $this -> xmlw -> writeAttribute(
+ 'parse', ($domain_array[$i]['parse'] == 1 ? 'true' : 'false')
+ );
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Write XML for single sofia profile (including all subsections)
+ * This method opens and closes the <profile> as well as calling
+ * other methods to complete the other subsections of the XML
+ * @param array $profile array of the current profile
+ */
+ private function write_single_profile($profile) {
+ $this -> xmlw -> startElement('profile');
+ $this -> xmlw -> writeAttribute('name', $profile['profile_name']);
+ $this -> write_aliases($profile['id']);
+ $this -> write_domains($profile['id']);
+ $this -> write_gateways($profile['id']);
+ $this -> write_settings($profile['id']);
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Iterate over the profiles and write the corresponding XML via other methods
+ * @param array $profiles multi-dimentional array from get_profiles
+ */
+ private function write_config($profiles) {
+ $profile_count = count($profiles);
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'Sofia SIP Endpoint');
+ $this -> xmlw -> startElement('profiles');
+ for ($i=0; $i<$profile_count; $i++) {
+ $this -> write_single_profile($profiles[$i]);
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+}
+
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/spidermonkey.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/spidermonkey.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,51 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ * spidermonkey.conf.php
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * @todo make configuration get pulled from db? maybe just use defines if there's not evern gonna be too many options
+ * Class for writing spidermonkey.conf XML
+*/
+class spidermonkey_conf extends fs_configuration {
+
+ function spidermonkey_conf() {
+ $this -> fs_configuration();
+ }
+
+ function main() {
+ $params = $this -> get_params();
+ $this -> write_params($params);
+ }
+
+ private function get_params() {
+ return array(
+ 'mod_spidermonkey_teleone',
+ 'mod_spidermonkey_odbc',
+ 'mod_spidermonkey_core_db'
+ );
+ }
+
+ private function write_params($modules) {
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'JavaScript Plug-In Configuration');
+ $this -> xmlw -> startElement('modules');
+ $module_count = count($modules);
+ for ($i=0; $i<$module_count; $i++) {
+ $this -> xmlw -> startElement('load');
+ $this -> xmlw -> writeAttribute('module', $modules[$i]);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+}
+
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/voicemail.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/voicemail.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,132 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ * voicemail.conf.php
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Writes out voicemail.conf XML
+ * @see fs_configuration
+*/
+class voicemail_conf extends fs_configuration {
+
+ public function voicemail_conf() {
+ $this -> fs_configuration();
+ }
+
+ public function main() {
+ $profiles = $this -> get_profiles();
+ $this -> write_config($profiles);
+ }
+
+ /**
+ * Get voicemail profiles from db
+ * @return array
+ */
+ private function get_profiles() {
+ $query = "SELECT * FROM voicemail_conf ORDER BY id";
+ $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ return $profiles;
+ }
+
+ /**
+ * Write XML for voicemail <settings>
+ * @return void
+ */
+ private function write_settings($profile_id) {
+ $query = sprintf('%s %s %s;'
+ , "SELECT * FROM voicemail_settings "
+ , "WHERE voicemail_id=$profile_id "
+ , "ORDER BY voicemail_id, param_name"
+ );
+ $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $settings_count = count($settings_array);
+ if (MDB2::isError($settings_array)) {
+ $this -> comment($query);
+ $this -> comment($settings_array -> getMessage());
+ return ;
+ }
+ if ($settings_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('settings');
+
+ for ($i=0; $i<$settings_count; $i++) {
+ //$this -> comment_array($settings_array[$i]);
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $settings_array[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $settings_array[$i]['param_value']);
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> write_email($profile_id);
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Write XML for voicemail email settings
+ * @return void
+ */
+ private function write_email($profile_id) {
+ $query = sprintf('%s %s %s;'
+ , "SELECT * FROM voicemail_email "
+ , "WHERE voicemail_id=$profile_id "
+ , "ORDER BY voicemail_id, param_name"
+ );
+ $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+ $settings_count = count($settings_array);
+ if (MDB2::isError($settings_array)) {
+ $this -> comment($query);
+ $this -> comment($settings_array -> getMessage());
+ return ;
+ }
+ if ($settings_count < 1) {
+ return ;
+ }
+ $this -> xmlw -> startElement('email');
+
+ for ($i=0; $i<$settings_count; $i++) {
+ //$this -> comment_array($settings_array[$i]);
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $settings_array[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $settings_array[$i]['param_value']);
+ $this -> xmlw -> endElement();//</param>
+ }
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Write the XML for the current profile in write_profiles
+ * @return void
+ */
+ private function write_single_profile($profile) {
+ $this -> xmlw -> startElement('profile');
+ $this -> xmlw -> writeAttribute('name', $profile['vm_profile']);
+ $this -> write_settings($profile['id']);
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Write the entire XML config for the voicemail module
+ * Write XML by calling other methods to do specific areas of config
+ * @return void
+ */
+ private function write_config($profiles) {
+ $profile_count = count($profiles);
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'voicemail Endpoint');
+ $this -> xmlw -> startElement('profiles');
+ for ($i=0; $i<$profile_count; $i++) {
+ $this -> write_single_profile($profiles[$i]);
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+}
+
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/xml_cdr.conf.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/xml_cdr.conf.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,49 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ * xml_cdr.conf.php
+ */
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Class for writing xml_cdr.conf XML
+*/
+class xml_cdr_conf extends fs_configuration {
+ function xml_cdr_conf() {
+ $this -> fs_configuration();
+ }
+
+ function main() {
+ $params = $this -> get_settings();
+ $this -> write_settings($params);
+ }
+
+ function get_settings() {
+ return array('url'=>'http://localhost/fs_curl/index_test.php', 'encode'=>'true');
+ return array(
+ 'url'=>'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']
+ , 'encode'=>'true'
+ );
+ }
+
+ function write_settings($params) {
+ $this -> xmlw -> startElement('configuration');
+ $this -> xmlw -> writeAttribute('name', basename(__FILE__, '.php'));
+ $this -> xmlw -> writeAttribute('description', 'CDRs via XML Post');
+ $this -> xmlw -> startElement('settings');
+ while (list($name, $value) = each($params)) {
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $name);
+ $this -> xmlw -> writeAttribute('value', $value);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+}
+
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,147 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Dialplan
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+*/
+
+/**
+ * include MDB2 PEAR Extension
+ */
+require_once('MDB2.php');
+/**
+ * require global definitions for FS_CURL
+ */
+require_once('global_defines.php');
+
+/**
+ * Output the upload form
+ * echo out the HTML for the upload form.
+ * @return null
+*/
+function upload_form() {
+ echo '<html>';
+ echo '<h1>Select A File To Import</h1>';
+ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data">';
+ echo '<input type="file" name="file">';
+ echo '<input type="submit" name="confirmed">';
+ echo '</form>';
+ echo '</html>';
+}
+
+/**
+ * Perform Insert Query
+ * take MDB2 object and query as params and
+ * perform query, setting error flag in the event
+ * of a db error.
+ * @return null
+*/
+function run_query($db, $query) {
+ $affected = $db -> exec($query);
+ if (MDB2::isError($affected)) {
+ if (!defined('UNSUCCESSFUL_QUERY')) {
+ define('UNSUCCESSFUL_QUERY', true);
+ }
+ echo "$query\n";
+ echo $affected -> getMessage() . "\n";
+ }
+}
+
+/**
+ * Check uploaded file for obvious problems
+ * This function checks the uploaded file's
+ * size, type, length, etc to make sure it's
+ * worth continuing with processing
+ * @return bool
+*/
+function check_uploaded_file($file_array) {
+ if (!is_uploaded_file($file_array['tmp_name'])) {
+ echo "File NOT uploaded OK<br>";
+ die(upload_form());
+ } elseif ($file_array['size'] < 1) {
+ echo "File was empty";
+ die(upload_form());
+ } elseif ($file_array['error'] > 0) {
+ echo "Uploading file encountered error #" . $file_array['error'];
+ die(upload_form());
+ } elseif ($file_array['type'] != 'text/xml') {
+ echo "Expected file of type 'text/xml', but got " . $file_array['type'];
+ die(upload_form());
+ } else {
+ //echo "File seems uploaded OK<br>";
+ return true;
+ }
+}
+
+
+if (!array_key_exists('confirmed', $_REQUEST)) {
+ die(upload_form());
+}
+
+/*
+foreach ($_REQUEST as $key => $val) {
+echo "$key => $val <br>\n";
+}
+if (is_array($_FILES) && count($_FILES)>0) {
+echo "<h2>FILES is an array</h2>";
+print_r($_FILES);
+}
+*/
+
+
+// no need to do anything till we check that the file's ok
+if (check_uploaded_file($_FILES['file'])) {
+ $xml_file = $_FILES['file']['tmp_name'];
+ move_uploaded_file($tmp_file, $xml_file);
+ //echo $xml_file . "\n<br>";
+ $xml_str = sprintf('<?xml version="1.0" encoding="UTF-8" standalone="no"?>%s', file_get_contents($xml_file));
+ //echo $xml_str;
+}
+
+$db = MDB2::connect(DEFAULT_DSN);
+if (MDB2::isError($db)) {
+ echo $db -> getMessage() . "\n";
+}
+
+$xml_obj = new SimpleXMLElement($xml_str);
+foreach ($xml_obj -> context as $context) {
+ $cn = $context['name'];
+ $global_weight = 100;
+ foreach ($context -> extension as $extension) {
+ $en = $extension['name'];
+ $ec = is_numeric($extension['continue']) ? $extension['continue'] : '0';
+ $global_weight+=100;
+ foreach ($extension -> condition as $condition) {
+ //print_r($condition);
+ $cf = $condition['field'];
+ $ce = $condition['expression'];
+ $cc = $condition['continue'];
+ $weight = 0;
+ foreach ($condition as $type => $action) {
+ //echo "-------------------$type-----------------------------\n";
+ $app_name = $action['application'];
+ $app_data = $action['data'];
+ $weight++;
+ //echo "$cn\t$en\t$cf\t$ce\t$cc\t$app_name\t$app_data\t$ec\t$global_weight\t$weight\n";
+ $query = sprintf('%s %s %s %s %s %s;',
+ "INSERT INTO curl_dialplan SET",
+ "context='$cn', extension='$en', condition_field='$cf',",
+ "condition_expression='$ce', application_name='$app_name',",
+ "application_data='$app_data', weight='$weight', type='$type',",
+ "ext_continue='$ec', global_weight='$global_weight',",
+ "condition_continue='$cc'"
+ );
+ run_query($db, $query);
+ }
+ }
+ }
+}
+if (defined(UNSUCCESSFUL_QUERY) && UNSUCCESSFUL_QUERY == true) {
+ echo "<h2>Some Queries Were Not Successful</h2>";
+} else {
+ echo "<h2>File Successfully Imported</h2>";
+}
+upload_form();
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,72 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * fs_configuration.php
+ */
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Class for all module configurations
+ * @return object
+*/
+class fs_configuration extends fs_curl {
+ /**
+ * Class Instantiation
+ * This method will instantiate all other objects upon which it relies.
+ * @return void
+ */
+ function fs_configuration() {
+ $this -> fs_curl();
+ $mod_name = sprintf('mod_%s', str_replace('.conf', '', $this -> request['key_value']));
+ $this -> comment("module name is $mod_name");
+ if (!$this -> is_mod_enabled($mod_name)) {
+ $this -> comment('module not enabled');
+ $this -> file_not_found();
+ }
+ $this -> xmlw -> startElement('section');
+ $this -> xmlw -> writeAttribute('name', 'configuration');
+ $this -> xmlw -> writeAttribute(
+ 'description', 'FreeSWITCH Configuration'
+ );
+ }
+
+ /**
+ * Enabled module checker
+ * This method will check if a module is enabled before
+ * returning the XML for the module. If the module's not
+ * enabled, the file_not_found method will be called.
+ * @param string $mod_name name of module to check
+ * @return bool
+ */
+ function is_mod_enabled($mod_name) {
+ if ($mod_name == 'mod_post_load_modules') {
+ return true;
+ }
+ $query = sprintf('%s %s'
+ , "SELECT * FROM post_load_modules_conf"
+ , "WHERE module_name='$mod_name' AND load_module=1"
+ );
+ $res = $this -> db -> query($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ return true; //default allow policy
+ return false; //comment previous line to default deny
+ $this -> file_not_found();
+ } elseif ($res -> numRows() == 1) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
+
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,290 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Configuration
+ * fs_curl.php
+ */
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * FreeSWITCH CURL base class
+ * Base class for all curl XML output, contains methods for XML output and
+ * connecting to a database
+ * @return void
+*/
+class fs_curl {
+ /**
+ * MDB2 Object
+ * @link http://pear.php.net/MDB2
+ * @var $db MDB2
+ */
+ public $db;
+ /**
+ * Array of _REQUEST parameters passed
+ *
+ * @var array
+ */
+ public $request;
+ /**
+ * XMLWriter object
+ * @link http://php.net/XMLWriter
+ * @var object
+ */
+ public $xmlw;
+ /**
+ * Array of comments to be output in the XML
+ * @see fs_curl::comment
+ * @var array
+ */
+ private $comments;
+
+ /**
+ * Instantiation of XMLWriter and MDB2
+ * This method will instantiate the MDB2 and XMLWriter classes for use
+ * in child classes
+ * @return void
+ */
+ public function fs_curl() {
+ header('Content-Type: text/xml');
+ $this -> open_xml();
+ $this -> generate_request_array();
+ $inc = array('required'=>'MDB2.php');
+ $this -> include_files($inc);
+ $this -> connect_db(DEFAULT_DSN);
+ set_error_handler(array($this, 'error_handler'));
+ //trigger_error('blah', E_USER_ERROR);
+ }
+
+ /**
+ * Connect to a database via MDB2
+ * @param mixed $dsn data source for database connection (array or string)
+ * @return void
+ */
+ public function connect_db($dsn) {
+ $this -> db = MDB2::connect($dsn);
+ if (MDB2::isError($this -> db)) {
+ $this -> comment($this -> db -> getMessage());
+ $this -> file_not_found();
+ }
+ $this -> db -> setFetchMode(MDB2_FETCHMODE_ASSOC);
+ }
+
+ /**
+ * Method to add comments to XML
+ * Adds a comment to be displayed in the final XML
+ * @param string $comment comment string to be output in XML
+ * @return void
+ */
+ public function comment($comment) {
+ $this -> comments[] = $comment;
+ }
+
+ /**
+ * Generate a globally accesible array of the _REQUEST parameters passed
+ * Generates an array from the _REQUEST parameters that were passed, keeping
+ * all key => value combinations intact
+ * @return void
+ */
+ private function generate_request_array() {
+ while (list($req_key, $req_val) = each($_REQUEST)) {
+ //$this -> comment("$req_key => $req_val");
+ $this -> request[$req_key] = $req_val;
+ }
+ }
+
+ /**
+ * Actual Instantiation of XMLWriter Object
+ * This method creates an XMLWriter Object and sets some needed options
+ * @return void
+ */
+ private function open_xml() {
+ $this -> xmlw = new XMLWriter();
+ $this -> xmlw -> openMemory();
+ $this -> xmlw -> setIndent(true);
+ $this -> xmlw -> setIndentString(' ');
+ $this -> xmlw -> startDocument('1.0', 'UTF-8', 'no');
+ //set the freeswitch document type
+ $this -> xmlw -> startElement('document');
+ $this -> xmlw -> writeAttribute('type', 'freeswitch/xml');
+ }
+
+ /**
+ * Method to call on any error that can not be revovered from
+ * This method was written to return a valid XML response to FreeSWITCH
+ * in the event that we are unable to generate a valid configuration file
+ * from the passed information
+ * @return void
+ */
+ public function file_not_found() {
+ $this -> comment('Include Path = ' . ini_get('include_path'));
+ $not_found = new XMLWriter();
+ $not_found -> openMemory();
+ $not_found -> setIndent(true);
+ $not_found -> setIndentString(' ');
+ $not_found -> startDocument('1.0', 'UTF-8', 'no');
+ //set the freeswitch document type
+ $not_found -> startElement('document');
+ $not_found -> writeAttribute('type', 'freeswitch/xml');
+ $not_found -> startElement('section');
+ $not_found -> writeAttribute('name', 'result');
+ $not_found -> startElement('result');
+ $not_found -> writeAttribute('status', 'not found');
+ $not_found -> endElement();
+ $not_found -> endElement();
+ $not_found -> endElement();
+ $this -> comments2xml($not_found, $this -> comments);
+ echo $not_found -> outputMemory();
+ exit();
+ }
+
+ /**
+ * Generate XML comments from comments array
+ * This [recursive] method will iterate over the passed array, writing XML
+ * comments and calling itself in the event that the "comment" is an array
+ * @param object $xml_obj Already instantiated XMLWriter object
+ * @param array $comments [Multi-dementional] Array of comments to be added
+ * @param integer $space_pad Number of spaces to indent the comments
+ * @return void
+ */
+ private function comments2xml($xml_obj, $comments, $space_pad=0) {
+ $comment_count = count($comments);
+ for ($i = 0; $i < $comment_count; $i++) {
+ if (!is_array($comments[$i])) {
+ $xml_obj -> writeComment($comments[$i]);
+ } else {
+ $this -> comments2xml($xml_obj, $comments[$i], $space_pad + 2);
+ }
+ }
+ }
+
+ /**
+ * End open XML elments in XMLWriter object
+ * @return void
+ */
+ private function close_xml() {
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+
+ /**
+ * Close and Output XML and stop script execution
+ * @return void
+ */
+ public function output_xml() {
+ $this -> close_xml();
+ $comment_count = count($this -> comments);
+ for ($i = 0; $i < $comment_count; $i++) {
+ $this -> xmlw -> writeComment($this -> comments[$i]);
+ }
+ echo $this -> xmlw -> outputMemory();
+ exit();
+ }
+
+ /**
+ * Recursive method to add an array of comments
+ * @return void
+ */
+ public function comment_array($array, $spacepad=0) {
+ $spaces = str_repeat(' ', $spacepad);
+ foreach ($array as $key => $val) {
+ if (is_array($val)) {
+ $this -> comment("$spaces$key => Array");
+ $this -> comment_array($val, $spacepad+2);
+ } else {
+ $this -> comment("$spaces$key => $val");
+ }
+ }
+ }
+
+ /**
+ * Include files for child classes
+ * This method will include the files needed by child classes.
+ * Expects an associative array of type => path
+ * where type = [required|any other string]
+ * @param array $file_array associative array of files to include
+ * @return void
+ * @todo add other types for different levels of errors
+ */
+ public function include_files($file_array) {
+ $return = FS_CURL_SUCCESS;
+ while (list($type, $file) = each($file_array)) {
+ $inc = @include_once($file);
+ if (!$inc) {
+ $comment = sprintf(
+ 'Unable To Include %s File %s', $type, $file
+ );
+ $this -> comment($comment);
+ if ($type == 'required') {
+ $return = FS_CURL_CRITICAL;
+ } else {
+ if ($return != FS_CURL_CRITICAL) {
+ $return = FS_CURL_WARNING;
+ }
+ }
+ }
+ }
+ if ($return == FS_CURL_CRITICAL) {
+ $this -> file_not_found();
+ }
+ return $return;
+ }
+
+ /**
+ * Class-wide error handler
+ * This method should be called whenever there is an error in any child
+ * classes, script execution and returning is pariatlly determined by
+ * defines
+ * @see RETURN_ON_WARN
+ * @return void
+ * @todo add other defines that control what, if any, comments gets output
+ */
+ public function error_handler($no, $str, $file, $line) {
+ /*
+ $this -> comment("USER_ERROR " . E_USER_ERROR);
+ $this -> comment("USER_NOTICE " . E_USER_NOTICE);
+ $this -> comment("USER_WARNING " . E_USER_WARNING);
+ $this -> comment("ALL " . E_ALL);
+ $this -> comment("COMPILE_ERROR " . E_COMPILE_ERROR);
+ $this -> comment("COMPILE_WARNING " . E_COMPILE_WARNING);
+ $this -> comment("CORE_ERROR " . E_CORE_ERROR);
+ $this -> comment("CORE_WARNING " . E_CORE_WARNING);
+ $this -> comment("ERROR " . E_ERROR);
+ $this -> comment("NOTICE " . E_NOTICE);
+ $this -> comment("WARNING " . E_WARNING);
+ $this -> comment("PARSE " . E_PARSE);
+ $this -> comment("RECOVERABLE_ERROR " . E_RECOVERABLE_ERROR);
+ $this -> comment("STRICT " . E_STRICT);
+ //$this -> comment(E);
+ */
+ if ($no == E_STRICT) {
+ return true;
+ }
+
+ $file = ereg_replace('\.(inc|php)$', '', $file);
+ $this -> comment(basename($file) . ":$line - $no:$str");
+
+ switch ($no) {
+ case E_USER_NOTICE:
+ case E_NOTICE:
+ break;
+ case E_USER_WARNING:
+ case E_WARNING:
+ if (defined('RETURN_ON_WARN') && RETURN_ON_WARN == true) {
+ break;
+ }
+ case E_ERROR:
+ case E_USER_ERROR:
+ default:
+ $this -> file_not_found();
+ }
+ return true;
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,127 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Dialplan
+ * @todo i should probably add a condition_weight to order the conditions inside a given extension
+ * fs_dialplan.php
+ */
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Dialplan
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Class for XML dialplan
+*/
+class fs_dialplan extends fs_curl {
+ public function fs_dialplan() {
+ $this -> fs_curl();
+ }
+
+ public function main() {
+ $this -> comment($this -> request);
+ $context = $this -> request['context'];
+ $dp_array = $this -> get_dialplan($context);
+ $this -> writeDialplan($dp_array);
+ $this -> output_xml();
+ }
+
+ /**
+ * This method will pull dialplan from database
+ *
+ * @param string $context context name for XML dialplan
+ * @return array
+ */
+ private function get_dialplan($context) {
+ $dp_array = array();
+ $dpQuery = sprintf("%s %s;"
+ , "SELECT * FROM dialplan WHERE context='$context' ORDER BY"
+ , "global_weight, context, extension, weight"
+ );
+ $res = $this -> db -> query($dpQuery);
+ if (MDB2::isError($res)) {
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ $condition_number = 0;
+ while ($row = $res -> fetchRow()) {
+ $ct = $row['context'];
+ $et = $row['extension'];
+ $ec = $row['ext_continue'];
+ $app = $row['application_name'];
+ $data = $row['application_data'];
+ $type = $row['type'];
+ $cf = $row['condition_field'];
+ $ce = $row['condition_expression'];
+ $cc = empty($row['condition_continue']) ? '0' : $row['condition_continue'];
+ $dp_array[$ct]["$et;$ec"]["$cf;$ce;$cc"][] = array(
+ 'type'=>$type,
+ 'application'=>$app,
+ 'data'=>$data
+ );
+ }
+ return $dp_array;
+ }
+
+ /**
+ * Write XML dialplan from the array returned by get_dialplan
+ * @see fs_dialplan::get_dialplan
+ * @param array $dpArray Multi-dimentional array from which we write the XML
+ */
+ private function writeDialplan($dpArray) {
+ //print_r($dpArray);
+ if (is_array($dpArray)) {
+ //$this -> comment('dpArray is an array');
+ foreach ($dpArray as $context => $extensions_array) {
+ //$this -> comment($context);
+ //start the context
+ $this -> xmlw -> startElement('context');
+ $this -> xmlw -> writeAttribute('name', $context);
+ if (is_array($extensions_array)) {
+ foreach ($extensions_array as $extension => $conditions) {
+ //start an extension
+ $ex_split = split(';', $extension);
+ $this -> xmlw -> startElement('extension');
+ $this -> xmlw -> writeAttribute('name', $ex_split[0]);
+ if ($ex_split[1] > 0) {
+ $this -> xmlw -> writeAttribute('continue', $ex_split[1]);
+ }
+ foreach ($conditions as $condition => $app_array) {
+ $c_split = split(';', $condition);
+ $this -> xmlw -> startElement('condition');
+ if (!empty($c_split[0])) {
+ $this -> xmlw -> writeAttribute('field', $c_split[0]);
+ }
+ if (!empty($c_split[1])) {
+ $this -> xmlw -> writeAttribute('expression', $c_split[1]);
+ }
+ //$this -> comment($c_split[2]);
+ if ($c_split[2] != '0') {
+ $this -> xmlw -> writeAttribute('continue', $c_split[2]);
+ }
+ foreach ($app_array as $app) {
+ $this -> xmlw -> startElement($app['type']);
+ $this -> xmlw -> writeAttribute('application', $app['application']);
+ if (!empty($app['data'])) {
+ $this -> xmlw -> writeAttribute('data', $app['data']);
+ }
+ $this -> xmlw -> endElement();
+ }
+ //</condition>
+ $this -> xmlw -> endElement();
+ }
+ // </extension>
+ $this -> xmlw -> endElement();
+ }
+ }
+ // </context>
+ $this -> xmlw -> endElement();
+ }
+ }
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,214 @@
+<?php
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ * fs_directory.php
+*/
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * @package FS_CURL
+ * @subpackage FS_CURL_Directory
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * Class for XML directory
+*/
+class fs_directory extends fs_curl {
+ public function fs_directory() {
+ $this -> fs_curl();
+ }
+
+ public function main() {
+ $this -> comment($this -> request);
+ $directory_array = $this -> get_directory();
+ $this -> writedirectory($directory_array);
+ $this -> output_xml();
+ }
+
+ /**
+ * This method will pull directory from database
+ * @return array
+ * @todo add GROUP BY to query to make sure we don't get duplicate users
+ */
+ private function get_directory() {
+ $directory_array = array();
+ if (!array_key_exists('domain', $this -> request)) {
+ $this -> comment('domain not passed');
+ $this -> file_not_found();
+ }
+ if (GLOBAL_USERS != true) {
+ $where_array[] = sprintf("domain='%s'", $this -> request['domain']);
+ }
+ if (array_key_exists('user', $this -> request)) {
+ $where_array[] = sprintf("username='%s'", $this -> request['user']);
+ }
+ if (!empty($where_array)) {
+ $this -> comment('where array has contents');
+ if (count($where_array) > 1) {
+ $where_clause = sprintf('WHERE ', implode(' AND ', $where_array));
+ } else {
+ $where_clause = sprintf('WHERE %s', $where_array[0]);
+ }
+ } else {
+ $where_clause = '';
+ }
+ $query = sprintf(
+ "SELECT * FROM directory %s ORDER BY username"
+ , $where_clause
+ );
+ $res = $this -> db -> queryAll($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ return $res;
+ }
+
+ /**
+ * Writes XML for directory user's <params>
+ * This method will pull all of the user params based on the passed user_id
+ * @param integer $user_id
+ * @return void
+ */
+ private function write_params($user_id) {
+ $query = sprintf(
+ "SELECT * FROM directory_params WHERE directory_id='$user_id';"
+ );
+ $res = $this -> db -> queryAll($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($query);
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ $param_count = count($res);
+ if ($param_count > 0) {
+ $this -> xmlw -> startElement('params');
+ for ($i=0; $i<$param_count; $i++) {
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $res[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $res[$i]['param_value']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+ }
+
+ /**
+ * Write all the <variables> for a given user
+ *
+ * @param integer $user_id
+ * @return void
+ */
+ private function write_variables($user_id) {
+ $query = sprintf(
+ "SELECT * FROM directory_vars WHERE directory_id='$user_id';"
+ );
+ $res = $this -> db -> queryAll($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ $var_count = count($res);
+ if ($var_count > 0) {
+ $this -> xmlw -> startElement('variables');
+ for ($i=0; $i<$var_count; $i++) {
+ $this -> xmlw -> startElement('variable');
+ $this -> xmlw -> writeAttribute('name', $res[$i]['var_name']);
+ $this -> xmlw -> writeAttribute('value', $res[$i]['var_value']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+ }
+
+ /**
+ * Write all of the XML for the user's <gateways>
+ * This method takes the id of the user from the directory table and pulls
+ * all of the user's gateways. It then calls write_single_gateway for
+ * each of them to write out all of the params
+ * @param integer $user_id
+ * @return void
+ */
+ private function write_gateways($user_id) {
+ $query = sprintf(
+ "SELECT * FROM directory_gateways WHERE directory_id='$user_id';"
+ );
+ $res = $this -> db -> queryAll($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ $gw_count = count($res);
+ if ($gw_count > 0) {
+ $this -> xmlw -> startElement('gateways');
+ for ($i=0; $i<$gw_count; $i++) {
+ $this -> xmlw -> startElement('gateway');
+ $this -> xmlw -> writeAttribute('name', $res[$i]['gateway_name']);
+ $this -> write_single_gateway($res[$i]['id']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ }
+ }
+
+ /**
+ * Write out the <params> XML for each user-specific gateway
+ *
+ * @param integer $d_gw_id id from directory_gateways
+ * @return void
+ */
+ private function write_single_gateway($d_gw_id) {
+ $query = sprintf(
+ "SELECT * FROM directory_gateway_params WHERE d_gw_id='%s';", $d_gw_id
+ );
+ $res = $this -> db -> queryAll($query);
+ if (MDB2::isError($res)) {
+ $this -> comment($res -> getMessage());
+ $this -> file_not_found();
+ }
+ $param_count = count($res);
+ if ($param_count > 0) {
+ for ($i=0; $i<$param_count; $i++) {
+ $this -> xmlw -> startElement('param');
+ $this -> xmlw -> writeAttribute('name', $res[$i]['param_name']);
+ $this -> xmlw -> writeAttribute('value', $res[$i]['param_value']);
+ $this -> xmlw -> endElement();
+ }
+ }
+ }
+
+ /**
+ * Write XML directory from the array returned by get_directory
+ * @see fs_directory::get_directory
+ * @param array $directory Multi-dimentional array from which we write the XML
+ * @return void
+ */
+ private function writedirectory($directory) {
+ if (empty($directory)) {
+ $this -> comment('no users found');
+ $this -> file_not_found();
+ }
+ $directory_count = count($directory);
+ $this -> xmlw -> startElement('section');
+ $this -> xmlw -> writeAttribute('name', 'directory');
+ $this -> xmlw -> writeAttribute('description', 'FreeSWITCH Dialplan');
+ $this -> xmlw -> startElement('domain');
+ $this -> xmlw -> writeAttribute('name', $this -> request['domain']);
+ for ($i=0; $i<$directory_count; $i++) {
+ $this -> xmlw -> startElement('user');
+ $this -> xmlw -> writeAttribute('id', $directory[$i]['username']);
+ $this -> write_params($directory[$i]['id']);
+ $this -> write_variables($directory[$i]['id']);
+ $this -> write_gateways($directory[$i]['id']);
+ $this -> xmlw -> endElement();
+ }
+ $this -> xmlw -> endElement();
+ $this -> xmlw -> endElement();
+ }
+}
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @package FS_CURL
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ */
+
+if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
+ header('Location: index.php');
+}
+
+/**
+ * Defines the default dsn for the MDB2 PEAR class
+ */
+define('DEFAULT_DSN', 'mysql://freeswitch:Fr33Sw1tch@localhost/freeswitch');
+/**
+ * Generic return success
+ */
+define('FS_CURL_SUCCESS', 0);
+/**
+ * Generic return warning
+ */
+define('FS_CURL_WARNING', 1);
+/**
+ * Generic return critical
+ */
+define('FS_CURL_CRITICAL', 2);
+
+/**
+ * determines how the error handler handles warnings
+ */
+define('RETURN_ON_WARN', true);
+
+/**
+ * Determines whether or not users should be domain specific
+ * If GLOBAL_USERS is true, user info will be returned for whatever
+ * domain is passed.....
+ * NOTE: using a1 hashes will NOT work with this setting
+ */
+define('GLOBAL_USERS', true);
+
+
+
+//define('', '');
+?>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/index.php
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/index.php Wed Jan 9 18:15:19 2008
@@ -0,0 +1,71 @@
+<?php
+/**
+ * @package FS_CURL
+ * @license
+ * @author Raymond Chandler (intralanman) <intralanman at gmail.com>
+ * @version 0.1
+ * initial page hit in all curl requests
+ */
+
+/**
+ * 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) {
+ header('Content-Type: text/xml');
+ $xmlw = new XMLWriter();
+ $xmlw -> openMemory();
+ $xmlw -> setIndent(true);
+ $xmlw -> setIndentString(' ');
+ $xmlw -> startDocument('1.0', 'UTF-8', 'no');
+ //set the freeswitch document type
+ $xmlw -> startElement('document');
+ $xmlw -> writeAttribute('type', 'freeswitch/xml');
+ $xmlw -> startElement('section');
+ $xmlw -> writeAttribute('name', 'result');
+ $xmlw -> startElement('result');
+ $xmlw -> writeAttribute('status', 'not found');
+ $xmlw -> endElement();
+ $xmlw -> endElement();
+ $xmlw -> endElement();
+ echo $xmlw -> outputMemory();
+ exit();
+}
+
+if (!(@include_once('fs_curl.php'))
+|| !(@include_once('global_defines.php'))) {
+ file_not_found();
+}
+$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))) {
+ file_not_found();
+}
+switch ($section) {
+ case 'configuration':
+ $config = $_REQUEST['key_value'];
+ $processor = sprintf('configuration/%s.php', $config);
+ $class = str_replace('.', '_', $config);
+ if (!(@include_once($processor))) {
+ file_not_found();
+ exit();
+ }
+ $conf = new $class;
+ $conf -> comment("class name is $class");
+ break;
+ case 'dialplan':
+ $conf = new fs_dialplan();
+ break;
+ case 'directory':
+ $conf = new fs_directory();
+ break;
+}
+$conf -> main();
+$conf -> output_xml();
+?>
\ No newline at end of file
More information about the Freeswitch-svn
mailing list