[Freeswitch-svn] [commit] r2621 - freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php

Freeswitch SVN docelmo at freeswitch.org
Sun Sep 10 09:10:06 EDT 2006


Author: docelmo
Date: Sun Sep 10 09:10:06 2006
New Revision: 2621

Modified:
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/classFreeswitch.php
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/mod_php.c

Log:
PHP doesnt crash freeswitch now

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/classFreeswitch.php
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/classFreeswitch.php	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/classFreeswitch.php	Sun Sep 10 09:10:06 2006
@@ -34,11 +34,11 @@
 global $sessn;
 class fs_class_api {
     	function fs_class_api() {
-	/*	if($sessn = $this->fs_getsessn($uuid)){}
+		if($sessn = $this->fs_getsessn($uuid)){}
 		else{
 		   echo "Couldnt get sessn!\n";
 		}
-	*/
+	
 	}
 	
 	function fs_start() {

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/mod_php.c
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/mod_php.c	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/mod_php.c	Sun Sep 10 09:10:06 2006
@@ -44,8 +44,6 @@
 
 const char modname[] = "mod_php";
 
-
-
 static void php_function(switch_core_session_t *session, char *data)
 {
 	char *uuid = switch_core_session_get_uuid(session);
@@ -55,28 +53,41 @@
 	int argc;
 	char *argv[5];
 	char php_code[1024]; 
-	void*** tsrm_ls = NULL;
+	//void*** tsrm_ls = NULL;
+		
 
 	snprintf(mydata, len, "%s %s", uuid, data);
 
-	argc = switch_separate_string(mydata, ' ',
-								  argv,
-								  (sizeof(argv) / sizeof(argv[0])));
-	
+	argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
 	sprintf(php_code, "$uuid=\"%s\"; include(\"%s\");\n", argv[0], argv[1]);
-	if (php_embed_init(argc, argv, &tsrm_ls) == SUCCESS){
-		//PHP_EMBED_START_BLOCK(argc, argv);
-		if (zend_eval_string(php_code, NULL, "Embedded code" TSRMLS_CC) == SUCCESS){
-		//PHP_EMBED_END_BLOCK();
-		php_embed_shutdown(tsrm_ls);
-		}else{
-		    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "There was a problem with the file");
-		}
-	}else{
-	    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "There was a problem with the file");	   
-	}
 
+	zend_file_handle script;
+	script.type = ZEND_HANDLE_FP;
+	script.filename = data;
+	script.opened_path = NULL;
+	script.free_filename = 0;
+	script.handle.fp = fopen(script.filename, "rb");	
 
+//	if (php_embed_init(argc, argv, &tsrm_ls) == SUCCESS){
+
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting Script %s\n",data);
+
+		PHP_EMBED_START_BLOCK(argc, argv);
+		void*** tsrm_ls = NULL;
+		//zend_error_cb = myapp_php_error_cb;
+		zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, &script);
+		//if (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, &script) == SUCCESS)
+		    //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "There was a problem with the file\n");
+		PHP_EMBED_END_BLOCK();
+		//php_embed_shutdown(tsrm_ls);
+		
+
+	//}else{
+	//    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "There was a problem with the file\n");	   
+	//}
+
+
 }
 
 static const switch_application_interface_t php_application_interface = {
@@ -123,3 +134,5 @@
   return SWITCH_STATUS_SUCCESS;
   }
 */
+
+



More information about the Freeswitch-svn mailing list