]> granicus.if.org Git - php/commitdiff
(php_ns_hash_environment): provide more CGI/1.1 variables to scripts.
authorSascha Schumann <sas@php.net>
Wed, 20 Oct 1999 19:30:37 +0000 (19:30 +0000)
committerSascha Schumann <sas@php.net>
Wed, 20 Oct 1999 19:30:37 +0000 (19:30 +0000)
Added REQUEST_METHOD, QUERY_STRING, REMOTE_ADDR

sapi/aolserver/aolserver.c

index 15769a72e90cb576d24d9205d19e5c73eebc474c..f80f04d5a78423bb2cbf950c8593e622ca49b63d 100644 (file)
@@ -19,6 +19,8 @@
 /*
  * TODO:
  * - write documentation
+ * - CGI/1.1 conformance
+ * - HTTP basic auth
  */
 
 /* $Id$ */
@@ -259,6 +261,13 @@ static sapi_module_struct sapi_module = {
  * with a number of variables. HTTP_* variables are created for
  * the HTTP header data, so that a script can access these.
  */
+#define ADD_STRING(name)                                                                               \
+       MAKE_STD_ZVAL(pval);                                                                            \
+       pval->type = IS_STRING;                                                                         \
+       pval->value.str.len = strlen(buf);                                                      \
+       pval->value.str.val = estrndup(buf, pval->value.str.len);       \
+       zend_hash_update(&EG(symbol_table), name, sizeof(name),         \
+                       &pval, sizeof(zval *), NULL)
 
 static void
 php_ns_hash_environment(NSLS_D CLS_DC ELS_DC PLS_DC SLS_DC)
@@ -292,30 +301,30 @@ php_ns_hash_environment(NSLS_D CLS_DC ELS_DC PLS_DC SLS_DC)
        }
        
        snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion());
+       ADD_STRING("SERVER_SOFTWARE");
+       snprintf(buf, 511, "HTTP/%1.1f", NSG(conn)->request->version);
+       ADD_STRING("SERVER_PROTOCOL");
+
+       strncpy(buf, NSG(conn)->request->method, 511);
+       ADD_STRING("REQUEST_METHOD");
+
+       if(NSG(conn)->request->query) {
+               strncpy(buf, NSG(conn)->request->query, 511);
+       } else {
+               buf[0] = '\0';
+       }
+       ADD_STRING("QUERY_STRING");
        
-       MAKE_STD_ZVAL(pval);
-       pval->type = IS_STRING;
-       pval->value.str.len = strlen(buf);
-       pval->value.str.val = estrndup(buf, pval->value.str.len);
-       zend_hash_update(&EG(symbol_table), "SERVER_SOFTWARE", sizeof("SERVER_SOFTWARE"), &pval, sizeof(zval *), NULL);
+       strncpy(buf, Ns_InfoBuildDate(), 511);
+       ADD_STRING("SERVER_BUILDDATE");
+
+       strncpy(buf, Ns_ConnPeer(NSG(conn)), 511);
+       ADD_STRING("REMOTE_ADDR");
 
        MAKE_STD_ZVAL(pval);
        pval->type = IS_LONG;
        pval->value.lval = Ns_InfoBootTime();
        zend_hash_update(&EG(symbol_table), "SERVER_BOOTTIME", sizeof("SERVER_BOOTTIME"), &pval, sizeof(zval *), NULL);
-
-       MAKE_STD_ZVAL(pval);
-       pval->type = IS_STRING;
-       pval->value.str.val = estrdup(Ns_InfoBuildDate());
-       pval->value.str.len = strlen(pval->value.str.val);
-       zend_hash_update(&EG(symbol_table), "SERVER_BUILDDATE", sizeof("SERVER_BUILDDATE"), &pval, sizeof(zval *), NULL);
-
-       snprintf(buf, 511, "HTTP/%1.1f", NSG(conn)->request->version);
-       MAKE_STD_ZVAL(pval);
-       pval->type = IS_STRING;
-       pval->value.str.len = strlen(buf);
-       pval->value.str.val = estrndup(buf, pval->value.str.len);
-       zend_hash_update(&EG(symbol_table), "SERVER_PROTOCOL", sizeof("SERVER_PROTOCOL"), &pval, sizeof(zval *), NULL);
 }
 
 /*