[Freeswitch-svn] [commit] r12029 - in freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl: . configuration dialplans

FreeSWITCH SVN mphill at freeswitch.org
Sun Feb 15 10:22:15 PST 2009


Author: mphill
Date: Sun Feb 15 12:22:15 2009
New Revision: 12029

Log:
* Changed database library from MDB2 to PDO
* Added profiling information: excution time, number of queries 



Modified:
   freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/acl.conf.php
   freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/conference.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/voicemail.conf.php
   freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplans/lcr.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

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/acl.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/acl.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/acl.conf.php	Sun Feb 15 12:22:15 2009
@@ -45,10 +45,10 @@
         $query = sprintf(
         'SELECT * FROM acl_lists al JOIN acl_nodes an ON an.list_id=al.id;'
         );
-        $acl_data = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
-        if (MDB2::isError($profiles)) {
+        $acl_data = $this -> db -> queryAll($query);
+        if (FS_PDO::isError($profiles)) {
             $this -> comment($query);
-            $this -> comment($acl_data -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return array();
         }
         return $acl_data;
@@ -81,4 +81,4 @@
         $this -> xmlw -> endElement();
     }
 }
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/conference.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/conference.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/conference.conf.php	Sun Feb 15 12:22:15 2009
@@ -47,10 +47,10 @@
     */
     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)) {
+        $advertises = $this -> db -> queryAll($query);
+        if (FS_PDO::isError($advertises)) {
             $this -> comment($query);
-            $this -> comment($advertises -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         $advertise_count = count($advertises);
@@ -72,7 +72,7 @@
     /**
      * Pull conference profiles from the database
      * This method will pull the conference profiles
-     * from the database using the PEAR MDB2 extension
+     * from the database using the PDO extension
      * @return array
     */
     private function get_profiles_array() {
@@ -81,12 +81,12 @@
         , "ORDER BY profile_name"
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return array();
         }
-        while ($row = $res -> fetchRow()) {
+        while ($row = $res -> fetch(PDO::FETCH_ASSOC)) {
             $pn = $row['profile_name'];
             $profiles[$pn][] = $row;
         }
@@ -124,9 +124,9 @@
     }
 
     /**
-     * Pull caller-controls from database via MDB2
+     * Pull caller-controls from database via PDO
      * This method will pull the conference caller-controls from
-     * the database using the PEAR MDB2 extension
+     * the database using the PDO extension
      * @return array
     */
     private function get_controls_array() {
@@ -134,12 +134,12 @@
         "SELECT * FROM conference_controls ORDER BY conf_group"
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return array();
         }
-        while ($row = $res -> fetchRow()) {
+        while ($row = $res -> fetch(PDO::FETCH_ASSOC)) {
             $cg = $row['conf_group'];
             $profiles[$cg][] = $row;
         }
@@ -155,9 +155,9 @@
     private function write_controls() {
         $controls_array = $this -> get_controls_array();
         $controls_count = count($controls_array);
-        if (MDB2::isError($controls_array)) {
+        if (FS_PDO::isError($controls_array)) {
             $this -> comment($query);
-            $this -> comment($controls_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($controls_count < 1) {
@@ -182,4 +182,4 @@
         $this -> xmlw -> endElement();
     }
 }
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/dingaling.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/dingaling.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/dingaling.conf.php	Sun Feb 15 12:22:15 2009
@@ -48,9 +48,9 @@
         , "ORDER BY dingaling_id"
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return array();
         }
         while ($row = $res -> fetchRow()) {
@@ -67,9 +67,9 @@
     private function get_profile_array() {
         $query = sprintf('SELECT * FROM dingaling_profiles');
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         while ($row = $res -> fetchRow()) {
@@ -121,9 +121,9 @@
     private function write_settings() {
         $query = sprintf('SELECT * FROM dingaling_settings');
         $res = $this -> db -> queryAll($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         $setting_count = count($res);
@@ -139,4 +139,4 @@
         }
     }
 }
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/iax.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/iax.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/iax.conf.php	Sun Feb 15 12:22:15 2009
@@ -25,17 +25,17 @@
 
     private function get_profiles() {
         $query = "SELECT * FROM iax_conf ORDER BY id LIMIT 1";
-        $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+        $profiles = $this -> db -> queryAll($query);
         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_array = $this -> db -> queryAll($query);
         $aliases_count = count($aliases_array);
-        if (MDB2::isError($aliases_array)) {
+        if (FS_PDO::isError($aliases_array)) {
             $this -> comment($query);
-            $this -> comment($aliases_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($aliases_count < 1) {
@@ -55,11 +55,11 @@
     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_array = $this -> db -> queryAll($query);
         $settings_count = count($settings_array);
-        if (MDB2::isError($settings_array)) {
+        if (FS_PDO::isError($settings_array)) {
             $this -> comment($query);
-            $this -> comment($settings_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($settings_count < 1) {
@@ -80,12 +80,12 @@
     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_array = $this -> db -> queryAll($query);
         $gateway_count = count($gateway_array);
         //$this -> comment_array($gateway_array);
         if (MDB2::isError($gateway_array)) {
             $this -> comment($query);
-            $this -> comment($gateway_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($gateway_count < 1) {
@@ -113,11 +113,11 @@
 
     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_array = $this -> db -> queryAll($query);
         $domain_count = count($domain_array);
-        if (MDB2::isError($domain_array)) {
+        if (FS_PDO::isError($domain_array)) {
             $this -> comment($query);
-            $this -> comment($domain_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($domain_count < 1) {
@@ -169,4 +169,4 @@
     }
 }
 
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/ivr.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/ivr.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/ivr.conf.php	Sun Feb 15 12:22:15 2009
@@ -34,7 +34,7 @@
     */
     private function get_ivr_array() {
         $query = "SELECT * FROM ivr_conf";
-        $menus = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+        $menus = $this -> db -> queryAll($query);
         return $menus;
     }
 
@@ -47,10 +47,10 @@
         $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)) {
+        $entries_array = $this -> db -> queryAll($query);
+        if (FS_PDO::isError($entries_array)) {
             $this -> comment($query);
-            $this -> comment($entries_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         $entries_count = count($entries_array);
@@ -114,4 +114,4 @@
         $this -> xmlw -> endElement();
     }
 }
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/limit.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/limit.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/limit.conf.php	Sun Feb 15 12:22:15 2009
@@ -32,9 +32,9 @@
     private function get_params_array() {
         $query = sprintf('SELECT * FROM limit_conf;');
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return array();
         }
         $this -> comment($res -> numRows() . 'rows');

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/local_stream.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/local_stream.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/local_stream.conf.php	Sun Feb 15 12:22:15 2009
@@ -30,11 +30,11 @@
         , "WHERE stream_id=$profile_id "
         , "ORDER BY stream_id, param_name"
         );
-        $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+        $settings_array = $this -> db -> queryAll($query);
         $settings_count = count($settings_array);
-        if (MDB2::isError($settings_array)) {
+        if (FS_PDO::isError($settings_array)) {
             $this -> comment($query);
-            $this -> comment($settings_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($settings_count < 1) {
@@ -54,10 +54,10 @@
 
     private function get_directories() {
         $query = sprintf('SELECT * FROM local_stream_conf;');
-        $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
-        if (MDB2::isError($profiles)) {
+        $profiles = $this -> db -> queryAll($query);
+        if (FS_PDO::isError($profiles)) {
             $this -> comment($query);
-            $this -> comment($profiles -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return array();
         }
         return $profiles;
@@ -70,4 +70,4 @@
         }
     }
 }
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/post_load_modules.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/post_load_modules.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/post_load_modules.conf.php	Sun Feb 15 12:22:15 2009
@@ -35,7 +35,7 @@
         'SELECT * FROM post_load_modules_conf WHERE load_module=1 ORDER BY priority;'
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
             $this -> comment($res -> getMessage());
             return array();
@@ -44,7 +44,7 @@
         if ($res -> numRows() == 0) {
             return array();
         }
-        while ($row = $res -> fetchRow(MDB2_FETCHMODE_ASSOC)) {
+        while ($row = $res -> fetchRow()) {
             $feeds_array[] = $row;
         }
         return $feeds_array;

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/rss.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/rss.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/rss.conf.php	Sun Feb 15 12:22:15 2009
@@ -35,10 +35,10 @@
         'SELECT * FROM rss_conf ORDER BY priority, local_file;'
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             return false;
         }
-        while ($row = $res -> fetchRow(MDB2_FETCHMODE_ASSOC)) {
+        while ($row = $res -> fetchRow()) {
             $feeds_array[] = $row;
         }
         return $feeds_array;
@@ -67,4 +67,4 @@
     }
 }
 
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/sofia.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/sofia.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/sofia.conf.php	Sun Feb 15 12:22:15 2009
@@ -28,10 +28,10 @@
 	 */
     private function get_profiles() {
         $query = "SELECT * FROM sofia_conf";
-        $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
-        if (MDB2::isError($profiles)) {
+        $profiles = $this -> db -> queryAll($query);
+        if (FS_PDO::isError($profiles)) {
             $this -> comment($query);
-            $this -> comment($profiles -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         return $profiles;
@@ -43,11 +43,11 @@
 	 */
     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_array = $this -> db -> queryAll($query);
         $aliases_count = count($aliases_array);
-        if (MDB2::isError($aliases_array)) {
+        if (FS_PDO::isError($aliases_array)) {
             $this -> comment($query);
-            $this -> comment($aliases_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($aliases_count < 1) {
@@ -71,11 +71,11 @@
     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_array = $this -> db -> queryAll($query);
         $settings_count = count($settings_array);
-        if (MDB2::isError($settings_array)) {
+        if (FS_PDO::isError($settings_array)) {
             $this -> comment($query);
-            $this -> comment($settings_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($settings_count < 1) {
@@ -100,12 +100,12 @@
     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_array = $this -> db -> queryAll($query);
         $gateway_count = count($gateway_array);
         //$this -> comment_array($gateway_array);
-        if (MDB2::isError($gateway_array)) {
+        if (FS_PDO::isError($gateway_array)) {
             $this -> comment($query);
-            $this -> comment($gateway_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($gateway_count < 1) {
@@ -137,11 +137,11 @@
 	 */
     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_array = $this -> db -> queryAll($query);
         $domain_count = count($domain_array);
-        if (MDB2::isError($domain_array)) {
+        if (FS_PDO::isError($domain_array)) {
             $this -> comment($query);
-            $this -> comment($domain_array -> getMessage());
+			$this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($domain_count < 1) {
@@ -193,4 +193,4 @@
     }
 }
 
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/voicemail.conf.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/voicemail.conf.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/configuration/voicemail.conf.php	Sun Feb 15 12:22:15 2009
@@ -30,7 +30,7 @@
     */
     private function get_profiles() {
         $query = "SELECT * FROM voicemail_conf ORDER BY id";
-        $profiles = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+        $profiles = $this -> db -> queryAll($query);
         return $profiles;
     }
 
@@ -44,11 +44,11 @@
         , "WHERE voicemail_id=$profile_id "
         , "ORDER BY voicemail_id, param_name"
         );
-        $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+        $settings_array = $this -> db -> queryAll($query);
         $settings_count = count($settings_array);
-        if (MDB2::isError($settings_array)) {
+        if (FS_PDO::isError($settings_array)) {
             $this -> comment($query);
-            $this -> comment($settings_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($settings_count < 1) {
@@ -77,11 +77,11 @@
         , "WHERE voicemail_id=$profile_id "
         , "ORDER BY voicemail_id, param_name"
         );
-        $settings_array = $this -> db -> queryAll($query, null, MDB2_FETCHMODE_ASSOC);
+        $settings_array = $this -> db -> queryAll($query);
         $settings_count = count($settings_array);
-        if (MDB2::isError($settings_array)) {
+        if (FS_PDO::isError($settings_array)) {
             $this -> comment($query);
-            $this -> comment($settings_array -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             return ;
         }
         if ($settings_count < 1) {
@@ -129,4 +129,4 @@
     }
 }
 
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplans/lcr.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplans/lcr.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/dialplans/lcr.php	Sun Feb 15 12:22:15 2009
@@ -50,9 +50,9 @@
         $query = sprintf("SELECT l.digits, c.Carrier_Name, l.rate, cg.id, cg.gateway, cg.id AS gwid, l.lead_strip, l.trail_strip, l.prefix, l.suffix FROM lcr l JOIN carriers c ON l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id %s ORDER BY length(digits) DESC, rate;", $where_clause);
         $res = $obj -> db -> query($query);
         $obj -> comment($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $obj -> comment($query);
-            $obj -> comment($res -> getMessage());
+            $obj -> comment($this -> db  -> getMessage());
             $obj -> file_not_found();
         }
         $carriers = array();
@@ -70,4 +70,4 @@
 }
 
 
-?>
\ No newline at end of file
+?>

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php	Sun Feb 15 12:22:15 2009
@@ -53,12 +53,12 @@
         , "WHERE module_name='$mod_name' AND load_module=1"
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if ($this->db->errorCode() !== FS_SQL_SUCCESS) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this->db->errorCode());
             return true; //default allow policy
             return false; //comment previous line to default deny
-        } elseif ($res -> numRows() == 1) {
+        } elseif ($res -> rowCount() == 1) {
             return true;
         } else {
             return false;
@@ -77,7 +77,7 @@
         "SELECT COUNT(*) cnt FROM modless_conf WHERE conf_name = '$conf';"
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
             $this -> comment($res -> getMessage());
             return true; //default allow policy

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php	Sun Feb 15 12:22:15 2009
@@ -20,9 +20,9 @@
 */
 class fs_curl {
     /**
-     * MDB2 Object
-     * @link http://pear.php.net/MDB2
-     * @var $db MDB2
+     * FS_PDO Object
+     * @link http://www.php.net/pdo
+     * @var $db FS_PDO
      */
     public $db;
     /**
@@ -45,8 +45,8 @@
     private $comments;
 
     /**
-     * Instantiation of XMLWriter and MDB2
-     * This method will instantiate the MDB2 and XMLWriter classes for use
+     * Instantiation of XMLWriter and FS_PDO
+     * This method will instantiate the FS_PDO and XMLWriter classes for use
      * in child classes
      * @return void
     */
@@ -55,27 +55,27 @@
         header('Content-Type: text/xml');
         $this -> open_xml();
         $this -> generate_request_array();
-        $inc = array('required'=>'MDB2.php');
+        $inc = array('required'=>'fs_pdo.php'); // include an external file. i.e. 'required'=>'important_file.php'
         $this -> include_files($inc);
-        $this -> connect_db(DEFAULT_DSN);
+        $this -> connect_db(DEFAULT_DSN, DEFAULT_DSN_LOGIN, DEFAULT_DSN_PASSWORD );
         set_error_handler(array($this, 'error_handler'));
         //trigger_error('blah', E_USER_ERROR);
     }
 
     /**
-     * Connect to a database via MDB2
+     * Connect to a database via FS_PDO
      * @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);
+    public function connect_db($dsn, $login, $password) {
+        try {
+			$this -> db = new FS_PDO($dsn, $login, $password);
+		} catch(Exception $e) {
+				$this -> comment($e->getMessage());
+				$this -> file_not_found(); //program terminates in function file_not_found()
+		}
     }
-
+	
     /**
      * Method to add comments to XML
      * Adds a comment to be displayed in the final XML
@@ -181,6 +181,14 @@
      * @return void
     */
     public function output_xml() {
+		$this->comment(
+            sprintf('Total # of Queries Run: %d', $this->db->counter)
+        );
+        $this -> comment(sprintf("Estimated Execution Time Is: %s"
+                , (ereg_replace(
+                '^0\.([0-9]+) ([0-9]+)$', '\2.\1', microtime()) - START_TIME)
+        ));
+		
         $this -> close_xml();
         $comment_count = count($this -> comments);
         for ($i = 0; $i < $comment_count; $i++) {
@@ -191,7 +199,7 @@
         $this -> debug(explode("\n", $xml_out));
         $this -> debug('---- End XML Output ----');
         echo $xml_out;
-        exit();
+		exit();
     }
 
     /**

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php	Sun Feb 15 12:22:15 2009
@@ -61,9 +61,9 @@
         "SELECT * FROM dialplan_special WHERE context='%s'", $context
         );
         $res = $this -> db -> query($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         if ($res -> numRows() == 1) {
@@ -88,8 +88,8 @@
         , "global_weight, context, extension, weight"
         );
         $res = $this -> db -> query($dpQuery);
-        if (MDB2::isError($res)) {
-            $this -> comment($res -> getMessage());
+        if (FS_PDO::isError($res)) {
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         $condition_number = 0;

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php	Sun Feb 15 12:22:15 2009
@@ -61,9 +61,10 @@
         , $where_clause
         );
         $res = $this -> db -> queryAll($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         return $res;
@@ -80,9 +81,9 @@
         "SELECT * FROM directory_params WHERE directory_id='$user_id';"
         );
         $res = $this -> db -> queryAll($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
-            $this -> comment($res -> getMessage());
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         $param_count = count($res);
@@ -109,8 +110,8 @@
         "SELECT * FROM directory_vars WHERE directory_id='$user_id';"
         );
         $res = $this -> db -> queryAll($query);
-        if (MDB2::isError($res)) {
-            $this -> comment($res -> getMessage());
+        if (FS_PDO::isError($res)) {
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         $var_count = count($res);
@@ -139,8 +140,8 @@
         "SELECT * FROM directory_gateways WHERE directory_id='$user_id';"
         );
         $res = $this -> db -> queryAll($query);
-        if (MDB2::isError($res)) {
-            $this -> comment($res -> getMessage());
+        if (FS_PDO::isError($res)) {
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         $gw_count = count($res);
@@ -167,8 +168,8 @@
         "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());
+        if (FS_PDO::isError($res)) {
+            $this -> comment($this -> db -> getMessage());
             $this -> file_not_found();
         }
         $param_count = count($res);
@@ -193,10 +194,10 @@
         "WHERE dd.domain_name='" . $this -> request['domain'] . "'"
         );
         $res = $this -> db -> queryAll($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
             $error_msg = sprintf("Error while selecting global params - %s"
-            , $res -> getMessage()
+            , $this -> db -> getMessage()
             );
             trigger_error($error_msg);
         }
@@ -222,10 +223,10 @@
         "WHERE dd.domain_name='" . $this -> request['domain'] . "'"
         );
         $res = $this -> db -> queryAll($query);
-        if (MDB2::isError($res)) {
+        if (FS_PDO::isError($res)) {
             $this -> comment($query);
             $error_msg = sprintf("Error while selecting global vars - %s"
-            , $res -> getMessage()
+            , $this -> db -> getMessage()
             );
             trigger_error($error_msg);
         }

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php	Sun Feb 15 12:22:15 2009
@@ -11,14 +11,26 @@
 }
 
 /**
- * Defines the default dsn for the MDB2 PEAR class
+ * Defines the default dsn for the FS_PDO class
  */
-define('DEFAULT_DSN', 'mysql://freeswitch:Fr33Sw1tch@localhost/freeswitch');
+define('DEFAULT_DSN', 'mysql:dbname=freeswitch;host=127.0.0.1');
+/**
+ * Defines the default dsn login for the PDO class
+ */
+define('DEFAULT_DSN_LOGIN', 'freeswitch');
+/**
+ * Defines the default dsn password for the PDOclass
+ */
+define('DEFAULT_DSN_PASSWORD', 'fr33sw1tch');
 /**
  * Generic return success
  */
 define('FS_CURL_SUCCESS', 0);
 /**
+ * Generic return success
+ */
+define('FS_SQL_SUCCESS', '00000');
+/**
  * Generic return warning
  */
 define('FS_CURL_WARNING', 1);

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/index.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/index.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/index.php	Sun Feb 15 12:22:15 2009
@@ -14,6 +14,12 @@
  * class is successfully instantiated.
  * @return void
 */
+
+/**
+ * define for the time that execution of the script started
+ */
+define('START_TIME', ereg_replace('^0\.([0-9]+) ([0-9]+)$', '\2.\1', microtime()));
+
 function file_not_found($no=false, $str=false, $file=false, $line=false) {
     if ($no == E_STRICT) {
         return;
@@ -94,3 +100,4 @@
 $conf -> main();
 $conf -> output_xml();
 
+?>



More information about the Freeswitch-svn mailing list