cvs: php4 /sapi/nsapi nsapi-readme.txt nsapi.c

From: Date: Sun, 18 May 2003 15:36:33 +0000
Subject: cvs: php4 /sapi/nsapi nsapi-readme.txt nsapi.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-21049@lists.php.net to get a copy of this message
thetaphi Sun May 18 11:36:33 2003 EDT Modified files: /php4/sapi/nsapi nsapi-readme.txt nsapi.c Log: Implement feature request #8879: Added possibility to alter ini entries by php4_execute service line. php4_init now supports path to an alternate php.ini (for example in the webservers config directory) Index: php4/sapi/nsapi/nsapi-readme.txt diff -u php4/sapi/nsapi/nsapi-readme.txt:1.4 php4/sapi/nsapi/nsapi-readme.txt:1.5 --- php4/sapi/nsapi/nsapi-readme.txt:1.4 Sun Mar 9 07:09:06 2003 +++ php4/sapi/nsapi/nsapi-readme.txt Sun May 18 11:36:33 2003 @@ -32,10 +32,10 @@ Windows: "c:\path\to\PHP4\nsapiPHP4.dll" -Note! Place following two lines after mime.types init: +Note! Place following two lines after mime.types init ([] means optional): Init fn="load-modules" funcs="php4_init,php4_close,php4_execute,php4_auth_trans" shlib="/php4/nsapiPHP4.dll" - Init fn=php4_init errorString="Failed to initialize PHP!" + Init fn=php4_init errorString="Failed to initialize PHP!" [php_ini="/path/to/php.ini"] <Object name="default"> . @@ -43,8 +43,10 @@ . # NOTE this next line should happen after all 'ObjectType' and before # all 'AddLog' lines + # You can modify some entries in php.ini request specific by adding it to the Service + # directive, e.g. doc_root="/path" - Service fn="php4_execute" type="magnus-internal/x-httpd-php" + Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value ...] . . </Object> Index: php4/sapi/nsapi/nsapi.c diff -u php4/sapi/nsapi/nsapi.c:1.34 php4/sapi/nsapi/nsapi.c:1.35 --- php4/sapi/nsapi/nsapi.c:1.34 Mon Mar 24 05:33:21 2003 +++ php4/sapi/nsapi/nsapi.c Sun May 18 11:36:33 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: nsapi.c,v 1.34 2003/03/24 10:33:21 thetaphi Exp $ */ +/* $Id: nsapi.c,v 1.35 2003/05/18 15:36:33 thetaphi Exp $ */ /* * PHP includes @@ -491,9 +491,32 @@ nsapi_free(SG(request_info).content_type); } +static void nsapi_php_ini_entries(NSLS_D TSRMLS_DC) +{ + struct pb_entry *entry; + register int i; + + for (i=0; i < NSG(pb)->hsize; i++) { + entry=NSG(pb)->ht[i]; + while (entry) { + /* exclude standard entries given to "Service" which should not go into ini entries */ + if (strcasecmp(entry->param->name,"fn") && strcasecmp(entry->param->name,"type") + && strcasecmp(entry->param->name,"method") && strcasecmp(entry->param->name,"Directive")) { + /* change the ini entry */ + if (zend_alter_ini_entry(entry->param->name, strlen(entry->param->name)+1, + entry->param->value, strlen(entry->param->value), + PHP_INI_SYSTEM, PHP_INI_STAGE_RUNTIME)==FAILURE) { + log_error(LOG_WARN, "php4_execute", NSG(sn), NSG(rq), "Cannot change php.ini key \"%s\" to \"%s\"", entry->param->name, entry->param->value); + } + } + entry=entry->next; + } + } +} + int nsapi_module_main(NSLS_D TSRMLS_DC) { - zend_file_handle file_handle; + zend_file_handle file_handle = {0}; if (php_request_startup(TSRMLS_C) == FAILURE) { return FAILURE; @@ -523,16 +546,28 @@ if (nsapi_sapi_module.shutdown) { nsapi_sapi_module.shutdown(&nsapi_sapi_module); } + + if (nsapi_sapi_module.php_ini_path_override) { + free(nsapi_sapi_module.php_ini_path_override); + } + tsrm_shutdown(); } int NSAPI_PUBLIC php4_init(pblock *pb, Session *sn, Request *rq) { php_core_globals *core_globals; + char *ini_path; tsrm_startup(1, 1, 0, NULL); core_globals = ts_resource(core_globals_id); + /* look if php_ini parameter is given to php4_init */ + if (ini_path = pblock_findval("php_ini", pb)) { + nsapi_sapi_module.php_ini_path_override = strdup(ini_path); + } + + /* start SAPI */ sapi_startup(&nsapi_sapi_module); nsapi_sapi_module.startup(&nsapi_sapi_module); @@ -555,6 +590,7 @@ SG(server_context) = request_context; nsapi_request_ctor(NSLS_C TSRMLS_CC); + nsapi_php_ini_entries(NSLS_C TSRMLS_CC); retval = nsapi_module_main(NSLS_C TSRMLS_CC); nsapi_request_dtor(NSLS_C TSRMLS_CC);

« previous php.cvs (#21049) next »