[Freeswitch-svn] [commit] r7787 - in freeswitch/trunk/scripts/contrib/intralanman/PHP: fs_curl fs_sock

Freeswitch SVN intralanman at freeswitch.org
Tue Mar 4 18:38:38 EST 2008


Author: intralanman
Date: Tue Mar  4 18:38:37 2008
New Revision: 7787

Modified:
   freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php
   freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_curl/index.php
   freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_sock/fs_sock.php

Log:
couple of needed updates

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	Tue Mar  4 18:38:37 2008
@@ -24,7 +24,7 @@
 
     public function main() {
         $this -> comment($this -> request);
-        $context = $this -> request['context'];
+        $context = $this -> request['Caller-Context'];
         $dp_array = $this -> get_dialplan($context);
         $this -> writeDialplan($dp_array);
         $this -> output_xml();

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	Tue Mar  4 18:38:37 2008
@@ -15,6 +15,9 @@
  * @return void
 */
 function file_not_found($no=false, $str=false, $file=false, $line=false) {
+    if ($no == E_STRICT) {
+    	return;
+    }
     header('Content-Type: text/xml');
     $xmlw = new XMLWriter();
     $xmlw -> openMemory();
@@ -31,13 +34,21 @@
     $xmlw -> endElement();
     $xmlw -> endElement();
     $xmlw -> endElement();
+    if (!empty($no) && !empty($str) && !empty($file) &&!empty($line)) {
+        $xmlw -> writeComment("ERROR: $no - ($str) on line $line of $file");
+    }
     echo $xmlw -> outputMemory();
     exit();
 }
+error_reporting(E_ALL);
+set_error_handler('file_not_found');
 
 if (!(@include_once('fs_curl.php'))
 || !(@include_once('global_defines.php'))) {
-    file_not_found();
+    trigger_error('could not include fs_curl.php or global_defines.php');
+}
+if (!is_array($_REQUEST)) {
+    trigger_error('$_REQUEST is not an array');
 }
 $section = $_REQUEST['section'];
 $section_file = sprintf('fs_%s.php', $section);
@@ -45,10 +56,13 @@
  * this include will differ based on the section that's passed
  */
 if (!(@include_once($section_file))) {
-    file_not_found();
+    trigger_error("unable to include $section_file");
 }
 switch ($section) {
     case 'configuration':
+        if (!array_key_exists('key_value', $_REQUEST)) {
+            trigger_error('key_value does not exist in $_REQUEST');
+        }
         $config = $_REQUEST['key_value'];
         $processor = sprintf('configuration/%s.php', $config);
         $class = str_replace('.', '_', $config);

Modified: freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_sock/fs_sock.php
==============================================================================
--- freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_sock/fs_sock.php	(original)
+++ freeswitch/trunk/scripts/contrib/intralanman/PHP/fs_sock/fs_sock.php	Tue Mar  4 18:38:37 2008
@@ -176,7 +176,8 @@
      *
      * @param string $input command to write to the socket
      */
-    private function sock_put($input) {
+    private function sock_put($input, $sock=null) {
+        $sock = is_null($sock) ? $this -> sock : $sock;
         fputs($this -> sock, $input);
     }
 
@@ -185,7 +186,8 @@
      *
      * @return array multi-dimentional array of the event
      */
-    private function sock_get() {
+    private function sock_get($sock=null) {
+        $sock = is_null($sock) ? $this -> sock : $sock;
         $this -> debug('----   Event Start ----');
         while ($orig_line = fgets($this -> sock, BUFFER_SIZE)) {
             $trim_line = trim($orig_line);
@@ -253,7 +255,8 @@
      * @param string $cmd command string to send to socket excluding any \r or \n
      * @return boolean
      */
-    public function send_command($cmd) {
+    public function send_command($cmd, $sock) {
+        $sock = is_null($sock) ? $this -> sock : $sock;
         $this -> debug('command is ' . $cmd);
         $cmd_split = split(' ', $cmd);
         //$this -> debug($cmd_split);
@@ -263,9 +266,9 @@
             return false;
         }
         $this -> debug("sending command: '$cmd'");
-        $this -> sock_put("$cmd\r\n\r\n");
+        $this -> sock_put("$cmd\r\n\r\n", $sock);
         if ($this -> command != 'exit') {
-            $reply = $this -> sock_get();
+            $reply = $this -> sock_get($sock);
             //$this -> debug($reply);
         } else {
             unset($this -> command);
@@ -287,8 +290,9 @@
      * @param string $cmd_str
      * @return array of the response or false
      */
-    function api_command($cmd_str) {
-        $reply = $this -> send_command("api $cmd_str");
+    function api_command($cmd_str, $sock=null) {
+        $sock = is_null($sock) ? $this -> sock : $sock;
+        $reply = $this -> send_command("api $cmd_str", $sock);
         while ($reply['Content-Type'] != 'api/response') {
             if (count($reply) > 0) {
                 $debug_text = sprintf(
@@ -352,7 +356,7 @@
     function wait_for_event() {
         $event = array();
         while (count($event) < 1) {
-        	$event = $this -> read_event();
+            $event = $this -> read_event();
         }
         return $event;
     }



More information about the Freeswitch-svn mailing list