ID:              24802
 User updated by: mattias at sudac dot org
 Reported By:     mattias at sudac dot org
 Status:          Open
 Bug Type:        Other web server
 PHP Version:     4CVS-2003-07-25 (stable)
 New Comment:

The web form seams to have mangle the patch a bit, &v insted of &val
for example.


Previous Comments:
------------------------------------------------------------------------

[2003-07-25 04:14:04] mattias at sudac dot org

Description:
------------
Hello

I think this is a better-then-nothing implementation of getenv for the
thttpd SAPI.

The patch should proabably work with both rev 1.77.2.13.2.2 and 1.91 of
thttpd.c

--- thttpd.c.orig   2003-07-25 10:56:54.000000000 +0200
+++ thttpd.c    2003-07-25 11:02:00.000000000 +0200
@@ -368,6 +368,20 @@
    return SUCCESS;
 }

+/* This implementation will return values of environment variables
matched in the
+ * $_SERVER array, if not return NULL and it will fallback to normal
libc getenv.
+ * By doing this getenv("REMOTE_ADDR") and others will work fine.
+ */
+static char *sapi_thttpd_getenv(char *name, size_t name_len
TSRMLS_DC)
+{
+    zval **val = NULL;
+
+   
if(zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]),name,name_len+1,(void**)&v
+        return Z_STRVAL_PP(val);
+    else
+        return NULL;
+}
+
 static sapi_module_struct thttpd_sapi_module = {
    "thttpd",
    "thttpd",
@@ -381,7 +395,7 @@
    sapi_thttpd_ub_write,
    NULL,
    NULL,                                   /* get uid */
-   NULL,                                   /* getenv */
+   sapi_thttpd_getenv,                     /* getenv */

    php_error,




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=24802&edit=1

Reply via email to