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">
.
.
# 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>
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;
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);
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);