summaryrefslogtreecommitdiff
path: root/sapi/nsapi
diff options
context:
space:
mode:
authorUwe Schindler <thetaphi@php.net>2003-05-18 15:36:33 +0000
committerUwe Schindler <thetaphi@php.net>2003-05-18 15:36:33 +0000
commit2a90ecf4a3c443c76f09f8cffa48001d80cab1a4 (patch)
tree06ea097799075344fb285c7b025a8d8f95c7ce3b /sapi/nsapi
parent422309353d6751b96ab64e77c7ce6ff1dae20ac4 (diff)
downloadphp-git-2a90ecf4a3c443c76f09f8cffa48001d80cab1a4.tar.gz
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)
Diffstat (limited to 'sapi/nsapi')
-rw-r--r--sapi/nsapi/nsapi-readme.txt8
-rw-r--r--sapi/nsapi/nsapi.c38
2 files changed, 42 insertions, 4 deletions
diff --git a/sapi/nsapi/nsapi-readme.txt b/sapi/nsapi/nsapi-readme.txt
index df595e9129..29f3b12288 100644
--- a/sapi/nsapi/nsapi-readme.txt
+++ b/sapi/nsapi/nsapi-readme.txt
@@ -32,10 +32,10 @@ in the server-id/config/magnus.conf file, and not the server-id/config/obj.conf
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! Place following two lines after mime.types init:
.
# 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>
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index a9ed176d6d..b501f31999 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -491,9 +491,32 @@ static void nsapi_request_dtor(NSLS_D TSRMLS_DC)
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 @@ void NSAPI_PUBLIC php4_close(void *vparam)
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 @@ int NSAPI_PUBLIC php4_execute(pblock *pb, Session *sn, Request *rq)
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);