]> granicus.if.org Git - php/commitdiff
Addendum to bug #28878: change ini keys as PHP_INI_SYSTEM
authorUwe Schindler <thetaphi@php.net>
Wed, 23 Jun 2004 13:02:01 +0000 (13:02 +0000)
committerUwe Schindler <thetaphi@php.net>
Wed, 23 Jun 2004 13:02:01 +0000 (13:02 +0000)
Also: Adding "bucket" parameter to non-ini-keys, Elemination of double CONTENT_TYPE/_LENGTH environment variables

sapi/nsapi/nsapi.c

index 69e4fe5dda81c0499f8e7783d810494bdbad0348..ca010e59869c66d39ea4fa918c1ebd408616c3a6 100644 (file)
@@ -105,12 +105,6 @@ typedef struct nsapi_equiv {
        const char *nsapi_eq;
 } nsapi_equiv;
 
-static nsapi_equiv nsapi_headers[] = {
-       { "CONTENT_LENGTH",                     "content-length" },
-       { "CONTENT_TYPE",                       "content-type" }
-};
-static size_t nsapi_headers_size = sizeof(nsapi_headers)/sizeof(nsapi_headers[0]);
-
 static nsapi_equiv nsapi_reqpb[] = {
        { "QUERY_STRING",               "query" },
        { "REQUEST_LINE",               "clf-request" },
@@ -136,7 +130,7 @@ static nsapi_equiv nsapi_client[] = {
 static size_t nsapi_client_size = sizeof(nsapi_client)/sizeof(nsapi_client[0]);
 
 /* this parameters to "Service"/"Error" are NSAPI ones which should not be php.ini keys and are excluded */
-static char *nsapi_exclude_from_ini_entries[] = { "fn", "type", "method", "directive", "code", "reason", "script", NULL };
+static char *nsapi_exclude_from_ini_entries[] = { "fn", "type", "method", "directive", "code", "reason", "script", "bucket", NULL };
 
 static char *nsapi_strdup(char *str)
 {
@@ -605,20 +599,19 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D
                }
        }
 
-       for (i = 0; i < nsapi_headers_size; i++) {
-               value = pblock_findval(nsapi_headers[i].nsapi_eq, rc->rq->headers);
-               if (value) {
-                       php_register_variable((char *)nsapi_headers[i].env_var, value, track_vars_array TSRMLS_CC);
-               }
-       }
-
        for (i=0; i < rc->rq->headers->hsize; i++) {
                entry=rc->rq->headers->ht[i];
                while (entry) {
                        if (!PG(safe_mode) || strncasecmp(entry->param->name, "authorization", 13)) {
-                               snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name);
+                               if (strcasecmp(entry->param->name, "content-length")==0 || strcasecmp(entry->param->name, "content-type")==0) {
+                                       strncpy(buf, entry->param->name, NS_BUF_SIZE);
+                                       pos = 0;
+                               } else {
+                                       snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name);
+                                       pos = 5;
+                               }
                                buf[NS_BUF_SIZE]='\0';
-                               for(p = buf + 5; *p; p++) {
+                               for(p = buf + pos; *p; p++) {
                                        *p = toupper(*p);
                                        if (*p < 'A' || *p > 'Z') {
                                                *p = '_';
@@ -777,7 +770,7 @@ static void nsapi_php_ini_entries(NSLS_D TSRMLS_DC)
                                /* 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_USER, PHP_INI_STAGE_RUNTIME)==FAILURE) {
+                                PHP_INI_SYSTEM, PHP_INI_STAGE_RUNTIME)==FAILURE) {
                                        log_error(LOG_WARN, pblock_findval("fn", NSG(pb)), NSG(sn), NSG(rq), "Cannot change php.ini key \"%s\" to \"%s\"", entry->param->name, entry->param->value);
                                }
                        }