summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-09-11 14:09:29 +0000
committerZeev Suraski <zeev@php.net>1999-09-11 14:09:29 +0000
commit1b6ccfe86c3664a667ec03973970045f137e6e7d (patch)
tree46b2e32d179f5fb3c76e1b1b2588c7e8769b9229
parentfb910c64cd3586b0e5bd1aee3fcaefa1b6216415 (diff)
downloadphp-git-1b6ccfe86c3664a667ec03973970045f137e6e7d.tar.gz
Cleanups & optimizations
-rw-r--r--cgi_main.c3
-rw-r--r--ext/standard/post.c111
-rw-r--r--ext/standard/post.h7
-rw-r--r--ext/standard/string.c5
-rw-r--r--main/main.c20
-rw-r--r--main/rfc1867.c2
6 files changed, 22 insertions, 126 deletions
diff --git a/cgi_main.c b/cgi_main.c
index ae435e39e8..24ceb764ea 100644
--- a/cgi_main.c
+++ b/cgi_main.c
@@ -347,7 +347,6 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
SG(headers_sent) = 1;
}
cgi_started=1;
- php3_TreatHeaders();
php_print_info(0xFFFFFFFF);
exit(1);
break;
@@ -404,8 +403,6 @@ any .htaccess restrictions anywhere on your site you can leave doc_root undefine
file_handle.type = ZEND_HANDLE_FP;
file_handle.handle.fp = stdin;
- php3_TreatHeaders();
-
if (!cgi) {
if (!SG(request_info).query_string) {
diff --git a/ext/standard/post.c b/ext/standard/post.c
index 4d25fc7a10..ea119f08de 100644
--- a/ext/standard/post.c
+++ b/ext/standard/post.c
@@ -33,14 +33,12 @@
* the old TreatData function. This is a temporary measure filling
* the gap until a more flexible parser can be built to do this.
*/
-void php_parse_gpc_data(char *val, char *var, pval *track_vars_array)
+void php_parse_gpc_data(char *val, char *var, pval *track_vars_array ELS_DC PLS_DC)
{
int var_type;
char *ind, *tmp = NULL, *ret = NULL;
int var_len, val_len;
pval *entry;
- ELS_FETCH();
- PLS_FETCH();
var_type = php3_check_ident_type(var);
if (var_type == GPC_INDEXED_ARRAY) {
@@ -176,14 +174,11 @@ void php_parse_gpc_data(char *val, char *var, pval *track_vars_array)
}
-void php3_treat_data(int arg, char *str)
+void php_treat_data(int arg, char *str ELS_DC PLS_DC SLS_DC)
{
char *res = NULL, *var, *val;
pval *array_ptr;
int free_buffer=0;
- ELS_FETCH();
- PLS_FETCH();
- SLS_FETCH();
switch (arg) {
case PARSE_POST:
@@ -255,7 +250,7 @@ void php3_treat_data(int arg, char *str)
/* FIXME: XXX: not binary safe, discards returned length */
_php3_urldecode(var, strlen(var));
_php3_urldecode(val, strlen(val));
- php_parse_gpc_data(val,var,array_ptr);
+ php_parse_gpc_data(val,var,array_ptr ELS_CC PLS_CC);
}
if (arg == PARSE_COOKIE) {
var = strtok(NULL, ";");
@@ -271,106 +266,6 @@ void php3_treat_data(int arg, char *str)
}
-PHPAPI void php3_TreatHeaders(void)
-{
-#if 0
-#if APACHE
-#if MODULE_MAGIC_NUMBER > 19961007
- const char *s = NULL;
-#else
- char *s = NULL;
-#endif
- char *t;
- char *user, *type;
- int len;
- char *escaped_str;
- request_rec *r;
- PLS_FETCH();
- SLS_FETCH();
-
- r = ((request_rec *) SG(server_context));
-
- if (r->headers_in)
- s = table_get(r->headers_in, "Authorization");
- if (!s)
- return;
-
- /* Check to make sure that this URL isn't authenticated
- using a traditional auth module mechanism */
- if (auth_type(r)) {
- /*php_error(E_WARNING, "Authentication done by server module\n");*/
- return;
- }
- if (strcmp(t=getword(r->pool, &s, ' '), "Basic")) {
- /* Client tried to authenticate using wrong auth scheme */
- php_error(E_WARNING, "client used wrong authentication scheme (%s)", t);
- return;
- }
- t = uudecode(r->pool, s);
-#if MODULE_MAGIC_NUMBER > 19961007
- user = getword_nulls_nc(r->pool, &t, ':');
-#else
- user = getword(r->pool, &t, ':');
-#endif
- type = "Basic";
-
- if (user) {
- if (PG(magic_quotes_gpc)) {
- escaped_str = php_addslashes(user, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_USER", estrdup(user));
- }
- }
- if (t) {
- if (PG(magic_quotes_gpc)) {
- escaped_str = php_addslashes(t, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_PW", estrdup(t));
- }
- }
- if (type) {
- if (PG(magic_quotes_gpc)) {
- escaped_str = php_addslashes(type, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_TYPE", escaped_str, len);
- } else {
- SET_VAR_STRING("PHP_AUTH_TYPE", estrdup(type));
- }
- }
-#endif
-#if FHTTPD
- int i,len;
- struct rline *l;
- char *type;
- char *escaped_str;
-
- if(req && req->remote_user){
- for(i=0; i < req->nlines; i++){
- l=req->lines+i;
- if((l->paramc > 1)&&!strcasecmp(l->params[0], "REMOTE_PW")){
- type = "Basic";
- if (PG(magic_quotes_gpc)) {
- escaped_str = php_addslashes(type, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_TYPE", escaped_str, len);
- escaped_str = php_addslashes(l->params[1], 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_PW", escaped_str, len);
- escaped_str = php_addslashes(req->remote_user, 0, &len, 0);
- SET_VAR_STRINGL("PHP_AUTH_USER", escaped_str, len);
-
- } else {
- SET_VAR_STRING("PHP_AUTH_TYPE", estrdup(type));
- SET_VAR_STRING("PHP_AUTH_PW", estrdup(l->params[1]));
- SET_VAR_STRING("PHP_AUTH_USER", estrdup(req->remote_user));
- }
- i=req->nlines;
- }
- }
- }
-#endif
-#endif
-}
-
/*
* Local variables:
* tab-width: 4
diff --git a/ext/standard/post.h b/ext/standard/post.h
index 7886d4ac8a..bfbddcb34e 100644
--- a/ext/standard/post.h
+++ b/ext/standard/post.h
@@ -31,13 +31,14 @@
#ifndef _POST_H
#define _POST_H
+#include "SAPI.h"
+
#define PARSE_POST 0
#define PARSE_GET 1
#define PARSE_COOKIE 2
#define PARSE_STRING 3
-void php3_treat_data(int arg, char *str);
-void php_parse_gpc_data(char *, char *, pval *track_vars_array);
-PHPAPI void php3_TreatHeaders(void);
+void php_treat_data(int arg, char *str ELS_DC PLS_DC SLS_DC);
+void php_parse_gpc_data(char *val, char *var, pval *track_vars_array ELS_DC PLS_DC);
#endif
diff --git a/ext/standard/string.c b/ext/standard/string.c
index b23a224323..6c3ceb5f46 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1873,6 +1873,9 @@ PHP_FUNCTION(parse_str)
{
pval *arg;
char *res = NULL;
+ ELS_FETCH();
+ PLS_FETCH();
+ SLS_FETCH();
if (getParameters(ht, 1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1881,7 +1884,7 @@ PHP_FUNCTION(parse_str)
if (arg->value.str.val && *arg->value.str.val) {
res = estrndup(arg->value.str.val,arg->value.str.len);
}
- php3_treat_data(PARSE_STRING, res);
+ php_treat_data(PARSE_STRING, res ELS_CC PLS_CC SLS_CC);
}
/* }}} */
diff --git a/main/main.c b/main/main.c
index 6fbf6f6314..472e030087 100644
--- a/main/main.c
+++ b/main/main.c
@@ -579,15 +579,17 @@ static void php_message_handler_for_zend(long message, void *data)
switch (message) {
case ZMSG_ENABLE_TRACK_VARS: {
int old;
+ ELS_FETCH();
PLS_FETCH();
+ SLS_FETCH();
old = PG(track_vars);
PG(track_vars) = 1;
if(old == 0) {
- php3_treat_data(PARSE_POST, NULL);
- php3_treat_data(PARSE_COOKIE, NULL);
- php3_treat_data(PARSE_GET, NULL);
+ php_treat_data(PARSE_POST, NULL ELS_CC PLS_CC SLS_CC);
+ php_treat_data(PARSE_COOKIE, NULL ELS_CC PLS_CC SLS_CC);
+ php_treat_data(PARSE_GET, NULL ELS_CC PLS_CC SLS_CC);
}
}
break;
@@ -943,12 +945,11 @@ void php_module_shutdown()
/* in 3.1 some of this should move into sapi */
-int zend_hash_environment(PLS_D ELS_DC)
+static int zend_hash_environment(PLS_D ELS_DC SLS_DC)
{
char **env, *p, *t;
unsigned char _gpc_flags[3] = {0,0,0};
pval *tmp;
- SLS_FETCH();
p = PG(gpc_order);
while(*p) {
@@ -956,21 +957,21 @@ int zend_hash_environment(PLS_D ELS_DC)
case 'p':
case 'P':
if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "POST")) {
- php3_treat_data(PARSE_POST, NULL); /* POST Data */
+ php_treat_data(PARSE_POST, NULL ELS_CC PLS_CC SLS_CC); /* POST Data */
_gpc_flags[0]=1;
}
break;
case 'c':
case 'C':
if (!_gpc_flags[1]) {
- php3_treat_data(PARSE_COOKIE, NULL); /* Cookie Data */
+ php_treat_data(PARSE_COOKIE, NULL ELS_CC PLS_CC SLS_CC); /* Cookie Data */
_gpc_flags[1]=1;
}
break;
case 'g':
case 'G':
if (!_gpc_flags[2]) {
- php3_treat_data(PARSE_GET, NULL); /* GET Data */
+ php_treat_data(PARSE_GET, NULL ELS_CC PLS_CC SLS_CC); /* GET Data */
_gpc_flags[2]=1;
}
break;
@@ -1150,7 +1151,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
if (setjmp(EG(bailout))!=0) {
return;
}
- zend_hash_environment(PLS_C ELS_CC);
+ zend_hash_environment(PLS_C ELS_CC SLS_CC);
#if WIN32||WINNT
UpdateIniFromRegistry(primary_file->filename);
@@ -1198,7 +1199,6 @@ PHPAPI int apache_php_module_main(request_rec *r, int fd, int display_source_mod
if (php_request_startup(CLS_C ELS_CC PLS_CC SLS_CC) == FAILURE) {
return FAILURE;
}
- php3_TreatHeaders();
file_handle.type = ZEND_HANDLE_FD;
file_handle.handle.fd = fd;
file_handle.filename = SG(request_info).path_translated;
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 412e1a1668..4fce5d5064 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -159,7 +159,7 @@ void php_mime_split(char *buf, int cnt, char *boundary)
*(loc - 4) = '\0';
/* Magic function that figures everything out */
- php_parse_gpc_data(ptr,namebuf,http_post_vars);
+ php_parse_gpc_data(ptr,namebuf,http_post_vars ELS_CC PLS_CC);
/* And a little kludge to pick out special MAX_FILE_SIZE */
itype = php3_check_ident_type(namebuf);