mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
* Get the Apache module to compile again
* Get rid of php3_rqst, use SG(server_context) instead (there's still Apache-specific code, but it nuked a global)
This commit is contained in:
@@ -62,11 +62,11 @@ WARNING_LEVEL = @WARNING_LEVEL@
|
||||
SOURCE = main.c internal_functions.c snprintf.c php3_sprintf.c \
|
||||
configuration-parser.c configuration-scanner.c request_info.c \
|
||||
safe_mode.c fopen-wrappers.c php3_realpath.c alloca.c output.c \
|
||||
php_ini.c
|
||||
php_ini.c SAPI.c
|
||||
OBJS = main.o internal_functions.o snprintf.o php3_sprintf.o \
|
||||
configuration-parser.o configuration-scanner.o request_info.o \
|
||||
safe_mode.o fopen-wrappers.o php3_realpath.o alloca.o output.o \
|
||||
php_ini.o
|
||||
php_ini.o SAPI.o
|
||||
|
||||
PHPLIBS = -L@top_srcdir@/libzend -lzend -Lext -lphpext
|
||||
LIBS = $(PHPLIBS) $(EXTRA_LIBS) @LIBS@
|
||||
|
||||
@@ -343,7 +343,7 @@ AC_ARG_WITH(apxs,
|
||||
])
|
||||
|
||||
|
||||
APACHE_INSTALL_FILES="$srcdir/mod_php3.* $srcdir/php_version.h libphp3.module"
|
||||
APACHE_INSTALL_FILES="$srcdir/mod_php3.* $srcdir/php_version.h libphp3.module $srcdir/SAPI.h"
|
||||
|
||||
|
||||
AC_MSG_CHECKING(for Apache module support via DSO through APACI)
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "ext/standard/head.h"
|
||||
#include "php_globals.h"
|
||||
#include "php_ini.h"
|
||||
#include "SAPI.h"
|
||||
#include "mod_php3.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -130,6 +131,7 @@ void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
|
||||
pval *arg_name,*arg_val;
|
||||
char *note_val;
|
||||
int arg_count = ARG_COUNT(ht);
|
||||
SLS_FETCH();
|
||||
|
||||
if (arg_count<1 || arg_count>2 ||
|
||||
getParameters(ht,arg_count,&arg_name,&arg_val) == FAILURE ) {
|
||||
@@ -137,11 +139,11 @@ void php3_apache_note(INTERNAL_FUNCTION_PARAMETERS)
|
||||
}
|
||||
|
||||
convert_to_string(arg_name);
|
||||
note_val = (char *) table_get(php3_rqst->notes,arg_name->value.str.val);
|
||||
note_val = (char *) table_get(((request_rec *) SG(server_context))->notes,arg_name->value.str.val);
|
||||
|
||||
if (arg_count == 2) {
|
||||
convert_to_string(arg_val);
|
||||
table_set(php3_rqst->notes,arg_name->value.str.val,arg_val->value.str.val);
|
||||
table_set(((request_rec *) SG(server_context))->notes,arg_name->value.str.val,arg_val->value.str.val);
|
||||
}
|
||||
|
||||
if (note_val) {
|
||||
@@ -158,13 +160,16 @@ void php3_info_apache(void) {
|
||||
char name[64];
|
||||
char *p;
|
||||
#endif
|
||||
server_rec *serv = php3_rqst->server;
|
||||
server_rec *serv;
|
||||
extern char server_root[MAX_STRING_LEN];
|
||||
extern uid_t user_id;
|
||||
extern char *user_name;
|
||||
extern gid_t group_id;
|
||||
extern int max_requests_per_child;
|
||||
SLS_FETCH();
|
||||
|
||||
serv = ((request_rec *) SG(server_context))->server;
|
||||
|
||||
#if WIN32|WINNT
|
||||
PUTS("Apache for Windows 95/NT<br>");
|
||||
#else
|
||||
@@ -214,13 +219,14 @@ void php3_virtual(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *filename;
|
||||
request_rec *rr = NULL;
|
||||
SLS_FETCH();
|
||||
|
||||
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string(filename);
|
||||
|
||||
if (!(rr = sub_req_lookup_uri (filename->value.str.val, php3_rqst))) {
|
||||
if (!(rr = sub_req_lookup_uri (filename->value.str.val, ((request_rec *) SG(server_context))))) {
|
||||
php3_error(E_WARNING, "Unable to include '%s' - URI lookup failed", filename->value.str.val);
|
||||
if (rr) destroy_sub_req (rr);
|
||||
RETURN_FALSE;
|
||||
@@ -259,11 +265,12 @@ void php3_getallheaders(INTERNAL_FUNCTION_PARAMETERS)
|
||||
array_header *env_arr;
|
||||
table_entry *tenv;
|
||||
int i;
|
||||
SLS_FETCH();
|
||||
|
||||
if (array_init(return_value) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
env_arr = table_elts(php3_rqst->headers_in);
|
||||
env_arr = table_elts(((request_rec *) SG(server_context))->headers_in);
|
||||
tenv = (table_entry *)env_arr->elts;
|
||||
for (i = 0; i < env_arr->nelts; ++i) {
|
||||
if (!tenv[i].key ||
|
||||
@@ -284,13 +291,14 @@ void php3_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *filename;
|
||||
request_rec *rr=NULL;
|
||||
SLS_FETCH();
|
||||
|
||||
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string(filename);
|
||||
|
||||
if(!(rr = sub_req_lookup_uri(filename->value.str.val, php3_rqst))) {
|
||||
if(!(rr = sub_req_lookup_uri(filename->value.str.val, ((request_rec *) SG(server_context))))) {
|
||||
php3_error(E_WARNING, "URI lookup failed", filename->value.str.val);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -353,16 +361,18 @@ void php3_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS)
|
||||
#if 0
|
||||
This function is most likely a bad idea. Just playing with it for now.
|
||||
|
||||
void php3_apache_exec_uri(INTERNAL_FUNCTION_PARAMETERS) {
|
||||
void php3_apache_exec_uri(INTERNAL_FUNCTION_PARAMETERS)
|
||||
{
|
||||
pval *filename;
|
||||
request_rec *rr=NULL;
|
||||
SLS_FETCH();
|
||||
|
||||
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&filename) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
convert_to_string(filename);
|
||||
|
||||
if(!(rr = ap_sub_req_lookup_uri(filename->value.str.val, php3_rqst))) {
|
||||
if(!(rr = ap_sub_req_lookup_uri(filename->value.str.val, ((request_rec *) SG(server_context))))) {
|
||||
php3_error(E_WARNING, "URI lookup failed", filename->value.str.val);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "php.h"
|
||||
#include "ext/standard/head.h"
|
||||
#include <math.h>
|
||||
#include "SAPI.h"
|
||||
#include "php3_gd.h"
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
@@ -189,7 +190,8 @@ void php3_info_gd(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int php3_mend_gd(void){
|
||||
int php3_mend_gd(SHUTDOWN_FUNC_ARGS)
|
||||
{
|
||||
GD_TLS_VARS;
|
||||
#ifdef THREAD_SAFE
|
||||
PHP3_TLS_THREAD_FREE(gdlib_globals);
|
||||
@@ -776,11 +778,13 @@ void php3_imagegif (INTERNAL_FUNCTION_PARAMETERS) {
|
||||
output = php3_header();
|
||||
|
||||
if (output) {
|
||||
SLS_FETCH();
|
||||
|
||||
gdImageGif (im, tmp);
|
||||
fseek(tmp, 0, SEEK_SET);
|
||||
#if APACHE && defined(CHARSET_EBCDIC)
|
||||
/* This is a binary file already: avoid EBCDIC->ASCII conversion */
|
||||
ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0);
|
||||
ap_bsetflag(((request_rec *) SG(server_context))->connection->client, B_EBCDIC2ASCII, 0);
|
||||
#endif
|
||||
while ((b = fread(buf, 1, sizeof(buf), tmp)) > 0) {
|
||||
php3_write(buf, b);
|
||||
|
||||
@@ -49,7 +49,7 @@ extern php3_module_entry gd_module_entry;
|
||||
/* gd.c functions */
|
||||
extern void php3_info_gd(void);
|
||||
extern int php3_minit_gd(INIT_FUNC_ARGS);
|
||||
extern int php3_mend_gd(void);
|
||||
extern int php3_mend_gd(SHUTDOWN_FUNC_ARGS);
|
||||
extern int gdImageColorResolve(gdImagePtr, int, int, int);
|
||||
extern void php3_imagearc(INTERNAL_FUNCTION_PARAMETERS);
|
||||
extern void php3_imagechar(INTERNAL_FUNCTION_PARAMETERS);
|
||||
|
||||
@@ -461,7 +461,9 @@ char *fnInsAnchorsIntoText(char *text, DLIST *pAnchorList, char **bodytag) {
|
||||
#if APACHE
|
||||
{
|
||||
int j;
|
||||
array_header *arr = table_elts(php3_rqst->subprocess_env);
|
||||
SLS_FETCH();
|
||||
|
||||
array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
|
||||
table_entry *elts = (table_entry *)arr->elts;
|
||||
|
||||
for (j=0; j < arr->nelts; j++) {
|
||||
|
||||
@@ -1681,7 +1681,10 @@ void php3_hw_pipedocument(INTERNAL_FUNCTION_PARAMETERS) {
|
||||
hw_connection *ptr;
|
||||
hw_document *doc;
|
||||
#if APACHE
|
||||
server_rec *serv = php3_rqst->server;
|
||||
server_rec *serv;
|
||||
SLS_FETCH();
|
||||
|
||||
serv = ((request_rec *) SG(server_context))->server;
|
||||
#endif
|
||||
|
||||
argc = ARG_COUNT(ht);
|
||||
@@ -1748,7 +1751,10 @@ void php3_hw_pipecgi(INTERNAL_FUNCTION_PARAMETERS) {
|
||||
hw_document *doc;
|
||||
char cgi_env_str[1000];
|
||||
#if APACHE
|
||||
server_rec *serv = php3_rqst->server;
|
||||
server_rec *serv;
|
||||
SLS_FETCH();
|
||||
|
||||
serv = ((request_rec *) SG(server_context))->server;
|
||||
#endif
|
||||
|
||||
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
|
||||
@@ -1809,7 +1815,10 @@ void php3_hw_insertdocument(INTERNAL_FUNCTION_PARAMETERS) {
|
||||
hw_connection *ptr;
|
||||
hw_document *docptr;
|
||||
#if APACHE
|
||||
server_rec *serv = php3_rqst->server;
|
||||
server_rec *serv;
|
||||
SLS_FETCH();
|
||||
|
||||
serv = ((request_rec *) SG(server_context))->server;
|
||||
#endif
|
||||
|
||||
if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &arg1, &arg2, &arg3) == FAILURE) {
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "zend_globals.h"
|
||||
|
||||
#include "php_globals.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
static unsigned char second_and_third_args_force_ref[] = { 3, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
|
||||
static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE };
|
||||
@@ -396,6 +397,7 @@ void php3_getenv(INTERNAL_FUNCTION_PARAMETERS)
|
||||
#endif
|
||||
pval *str;
|
||||
char *ptr;
|
||||
SLS_FETCH();
|
||||
|
||||
if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &str) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
@@ -423,7 +425,7 @@ void php3_getenv(INTERNAL_FUNCTION_PARAMETERS)
|
||||
|
||||
if (str->type == IS_STRING &&
|
||||
#if APACHE
|
||||
((ptr = (char *)table_get(php3_rqst->subprocess_env, str->value.str.val)) || (ptr = getenv(str->value.str.val)))
|
||||
((ptr = (char *)table_get(((request_rec *) SG(server_context))->subprocess_env, str->value.str.val)) || (ptr = getenv(str->value.str.val)))
|
||||
#endif
|
||||
#if CGI_BINARY
|
||||
(ptr = getenv(str->value.str.val))
|
||||
@@ -1166,11 +1168,13 @@ void php3_flush(HashTable *)
|
||||
void php3_flush(INTERNAL_FUNCTION_PARAMETERS)
|
||||
#endif
|
||||
{
|
||||
SLS_FETCH();
|
||||
|
||||
#if APACHE
|
||||
# if MODULE_MAGIC_NUMBER > 19970110
|
||||
rflush(php3_rqst);
|
||||
rflush(((request_rec *) SG(server_context)));
|
||||
# else
|
||||
bflush(php3_rqst->connection->client);
|
||||
bflush(((request_rec *) SG(server_context))->connection->client);
|
||||
# endif
|
||||
#endif
|
||||
#if FHTTPD
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "ext/standard/head.h"
|
||||
#include "exec.h"
|
||||
#include "php_globals.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
@@ -118,12 +119,14 @@ static int _Exec(int type, char *cmd, pval *array, pval *return_value)
|
||||
if (type != 3) {
|
||||
while (fgets(buf, EXEC_INPUT_BUF - 1, fp)) {
|
||||
if (type == 1) {
|
||||
SLS_FETCH();
|
||||
|
||||
if (output) PUTS(buf);
|
||||
#if APACHE
|
||||
# if MODULE_MAGIC_NUMBER > 19970110
|
||||
if (output) rflush(php3_rqst);
|
||||
if (output) rflush(((request_rec *) SG(server_context)));
|
||||
# else
|
||||
if (output) bflush(php3_rqst->connection->client);
|
||||
if (output) bflush(((request_rec *) SG(server_context))->connection->client);
|
||||
# endif
|
||||
#endif
|
||||
#if CGI_BINARY
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <stdio.h>
|
||||
#include "php.h"
|
||||
#include "ext/standard/php3_standard.h"
|
||||
#include "SAPI.h"
|
||||
#include "main.h"
|
||||
#include "head.h"
|
||||
#include "post.h"
|
||||
@@ -84,6 +85,10 @@ void php4i_add_header_information(char *header_information)
|
||||
char *temp = NULL;
|
||||
long myuid = 0L;
|
||||
char temp2[32];
|
||||
request_rec *req;
|
||||
SLS_FETCH();
|
||||
|
||||
req = ((request_rec *) SG(server_context));
|
||||
#endif
|
||||
|
||||
if (php3_HeaderPrinted == 1) {
|
||||
@@ -104,10 +109,10 @@ void php4i_add_header_information(char *header_information)
|
||||
*r = '\0';
|
||||
if (!strcasecmp(header_information, "Content-type")) {
|
||||
if (*(r + 1) == ' ')
|
||||
php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 2);
|
||||
req->content_type = pstrdup(req->pool,r + 2);
|
||||
else
|
||||
php3_rqst->content_type = pstrdup(php3_rqst->pool,r + 1);
|
||||
cont_type = (char *)php3_rqst->content_type;
|
||||
req->content_type = pstrdup(req->pool,r + 1);
|
||||
cont_type = (char *) req->content_type;
|
||||
} else {
|
||||
if (*(r + 1) == ' ') {
|
||||
rr = r + 2;
|
||||
@@ -126,26 +131,26 @@ void php4i_add_header_information(char *header_information)
|
||||
temp = _php3_regreplace("$", temp2, rr, 0, 0);
|
||||
}
|
||||
}
|
||||
table_set(php3_rqst->headers_out, header_information, temp);
|
||||
table_set(req->headers_out, header_information, temp);
|
||||
} else
|
||||
table_set(php3_rqst->headers_out, header_information, rr);
|
||||
table_set(req->headers_out, header_information, rr);
|
||||
}
|
||||
if (!strcasecmp(header_information, "location")) {
|
||||
php3_rqst->status = REDIRECT;
|
||||
req->status = REDIRECT;
|
||||
}
|
||||
*r = ':';
|
||||
php3_HeaderPrinted = 2;
|
||||
}
|
||||
if (!strncasecmp(header_information, "http/", 5)) {
|
||||
if (strlen(header_information) > 9) {
|
||||
php3_rqst->status = atoi(&((header_information)[9]));
|
||||
req->status = atoi(&((header_information)[9]));
|
||||
}
|
||||
/* Use a pstrdup here to get the memory straight from Apache's per-request pool to
|
||||
* avoid having our own memory manager complain about this memory not being freed
|
||||
* because it really shouldn't be freed until the end of the request and it isn't
|
||||
* easy for us to figure out when we allocated it vs. when something else might have.
|
||||
*/
|
||||
php3_rqst->status_line = pstrdup(php3_rqst->pool,&((header_information)[9]));
|
||||
req->status_line = pstrdup(req->pool,&((header_information)[9]));
|
||||
}
|
||||
#else
|
||||
r = strchr(header_information, ':');
|
||||
@@ -230,12 +235,13 @@ PHPAPI int php3_header(void)
|
||||
CookieList *cookie;
|
||||
int len = 0;
|
||||
time_t t;
|
||||
char *dt, *cookievalue = NULL;
|
||||
char *dt, *cookievalue = NULL;
|
||||
#endif
|
||||
#if APACHE || defined(USE_SAPI) || FHTTPD
|
||||
char *tempstr;
|
||||
#endif
|
||||
PLS_FETCH();
|
||||
SLS_FETCH();
|
||||
|
||||
if (PG(header_is_being_sent)) {
|
||||
return 0;
|
||||
@@ -244,7 +250,7 @@ PHPAPI int php3_header(void)
|
||||
}
|
||||
|
||||
#if APACHE
|
||||
if (!php3_rqst) { /* we're not in a request, allow output */
|
||||
if (!((request_rec *) SG(server_context))) { /* we're not in a request, allow output */
|
||||
PG(header_is_being_sent) = 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -305,7 +311,7 @@ PHPAPI int php3_header(void)
|
||||
if (cookie->secure) {
|
||||
strcat(tempstr, "; secure");
|
||||
}
|
||||
table_add(php3_rqst->headers_out, "Set-Cookie", tempstr);
|
||||
table_add(((request_rec *) SG(server_context))->headers_out, "Set-Cookie", tempstr);
|
||||
if (cookie->domain) efree(cookie->domain);
|
||||
if (cookie->path) efree(cookie->path);
|
||||
if (cookie->name) efree(cookie->name);
|
||||
@@ -317,8 +323,8 @@ PHPAPI int php3_header(void)
|
||||
}
|
||||
php3_HeaderPrinted = 1;
|
||||
header_called = 1;
|
||||
send_http_header(php3_rqst);
|
||||
if (php3_rqst->header_only) {
|
||||
send_http_header(((request_rec *) SG(server_context)));
|
||||
if (((request_rec *) SG(server_context))->header_only) {
|
||||
set_header_request(1);
|
||||
PG(header_is_being_sent) = 0;
|
||||
return(0);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "php_globals.h"
|
||||
#include "ext/standard/head.h"
|
||||
#include "info.h"
|
||||
#include "SAPI.h"
|
||||
#ifndef MSVC5
|
||||
#include "build-defs.h"
|
||||
#endif
|
||||
@@ -88,7 +89,6 @@ PHPAPI void _php3_info(void)
|
||||
ELS_FETCH();
|
||||
PLS_FETCH();
|
||||
|
||||
|
||||
#if WIN32|WINNT
|
||||
// Get build numbers for Windows NT or Win95
|
||||
if (dwVersion < 0x80000000){
|
||||
@@ -104,7 +104,7 @@ PHPAPI void _php3_info(void)
|
||||
|
||||
|
||||
PUTS("<img src=\"");
|
||||
/*PUTS(php3_rqst->uri);*/
|
||||
/*PUTS(r->uri);*/
|
||||
PUTS("?=PHPE9568F34-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"56\" align=\"right\">\n");
|
||||
php3_printf("<center><h1>PHP Version %s</h1></center>\n", PHP_VERSION);
|
||||
PUTS("<p>by <a href=\"mailto:rasmus@lerdorf.on.ca\">Rasmus Lerdorf</a>,\n");
|
||||
@@ -321,9 +321,15 @@ PHPAPI void _php3_info(void)
|
||||
#if APACHE
|
||||
{
|
||||
register int i;
|
||||
array_header *arr = table_elts(php3_rqst->subprocess_env);
|
||||
table_entry *elts = (table_entry *)arr->elts;
|
||||
array_header *arr;
|
||||
table_entry *elts;
|
||||
request_rec *r;
|
||||
SLS_FETCH();
|
||||
|
||||
r = ((request_rec *) SG(server_context));
|
||||
arr = table_elts(r->subprocess_env);
|
||||
elts = (table_entry *)arr->elts;
|
||||
|
||||
SECTION("Apache Environment");
|
||||
PUTS("<table border=5 width=\"600\">\n");
|
||||
PUTS("<tr><th bgcolor=\"" HEADER_COLOR "\">Variable</th><th bgcolor=\"" HEADER_COLOR "\">Value</th></tr>\n");
|
||||
@@ -343,14 +349,17 @@ PHPAPI void _php3_info(void)
|
||||
array_header *env_arr;
|
||||
table_entry *env;
|
||||
int i;
|
||||
|
||||
request_rec *r;
|
||||
SLS_FETCH();
|
||||
|
||||
r = ((request_rec *) SG(server_context));
|
||||
SECTION("HTTP Headers Information");
|
||||
PUTS("<table border=5 width=\"600\">\n");
|
||||
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Request Headers</th></tr>\n");
|
||||
PUTS("<tr><td bgcolor=\"" ENTRY_NAME_COLOR "\">HTTP Request</td><td bgcolor=\"" CONTENTS_COLOR "\">");
|
||||
PUTS(php3_rqst->the_request);
|
||||
PUTS(r->the_request);
|
||||
PUTS(" </td></tr>\n");
|
||||
env_arr = table_elts(php3_rqst->headers_in);
|
||||
env_arr = table_elts(r->headers_in);
|
||||
env = (table_entry *)env_arr->elts;
|
||||
for (i = 0; i < env_arr->nelts; ++i) {
|
||||
if (env[i].key) {
|
||||
@@ -362,7 +371,7 @@ PHPAPI void _php3_info(void)
|
||||
}
|
||||
}
|
||||
PUTS(" <tr><th colspan=2 bgcolor=\"" HEADER_COLOR "\">HTTP Response Headers</th></tr>\n");
|
||||
env_arr = table_elts(php3_rqst->headers_out);
|
||||
env_arr = table_elts(r->headers_out);
|
||||
env = (table_entry *)env_arr->elts;
|
||||
for(i = 0; i < env_arr->nelts; ++i) {
|
||||
if (env[i].key) {
|
||||
@@ -383,7 +392,7 @@ PHPAPI void _php3_info(void)
|
||||
PUTS("<table width=\"100%%\"><tr>\n");
|
||||
php3_printf("<td><h2>Zend</h2>This program makes use of the Zend scripting language engine:<br><pre>%s</pre></td>", get_zend_version());
|
||||
PUTS("<td width=\"100\"><a href=\"http://www.zend.com/\"><img src=\"");
|
||||
/*PUTS(php3_rqst->uri);*/
|
||||
/*PUTS(r->uri);*/
|
||||
PUTS("?=PHPE9568F35-D428-11d2-A769-00AA001ACF42\" border=\"0\" width=\"100\" height=\"89\"></a></td>\n");
|
||||
PUTS("</tr></table>\n");
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "php.h"
|
||||
#include "pageinfo.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -59,6 +60,11 @@ static void _php3_statpage(void)
|
||||
#if !APACHE
|
||||
char *path;
|
||||
struct stat sb;
|
||||
#else
|
||||
request_rec *r;
|
||||
SLS_FETCH();
|
||||
|
||||
r = ((request_rec *) SG(server_context));
|
||||
#endif
|
||||
|
||||
#if APACHE
|
||||
@@ -67,9 +73,9 @@ static void _php3_statpage(void)
|
||||
values. We can afford it, and it means we don't have to
|
||||
worry about resetting the static variables after every
|
||||
hit. */
|
||||
page_uid = php3_rqst->finfo.st_uid;
|
||||
page_inode = php3_rqst->finfo.st_ino;
|
||||
page_mtime = php3_rqst->finfo.st_mtime;
|
||||
page_uid = r ->finfo.st_uid;
|
||||
page_inode = r->finfo.st_ino;
|
||||
page_mtime = r->finfo.st_mtime;
|
||||
#else
|
||||
if (page_uid == -1) {
|
||||
path = request_info.filename;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "php.h"
|
||||
#include "php3_standard.h"
|
||||
#include "php_globals.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
#include "zend_globals.h"
|
||||
|
||||
@@ -54,6 +55,7 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
|
||||
int file_upload = 0;
|
||||
char *mb;
|
||||
char boundary[100];
|
||||
SLS_FETCH();
|
||||
|
||||
ctype = request_info.content_type;
|
||||
if (!ctype) {
|
||||
@@ -92,29 +94,29 @@ static char *php3_getpost(pval *http_post_vars PLS_DC)
|
||||
buf[length]=0;
|
||||
#else
|
||||
#if MODULE_MAGIC_NUMBER > 19961007
|
||||
if (should_client_block(php3_rqst)) {
|
||||
if (should_client_block(SG(server_context))) {
|
||||
void (*handler) (int);
|
||||
int dbsize, len_read, dbpos = 0;
|
||||
|
||||
hard_timeout("copy script args", php3_rqst); /* start timeout timer */
|
||||
hard_timeout("copy script args", ((request_rec *) SG(server_context))); /* start timeout timer */
|
||||
handler = signal(SIGPIPE, SIG_IGN); /* Ignore sigpipes for now */
|
||||
while ((len_read = get_client_block(php3_rqst, argsbuffer, HUGE_STRING_LEN)) > 0) {
|
||||
while ((len_read = get_client_block(((request_rec *) SG(server_context)), argsbuffer, HUGE_STRING_LEN)) > 0) {
|
||||
if ((dbpos + len_read) > length)
|
||||
dbsize = length - dbpos;
|
||||
else
|
||||
dbsize = len_read;
|
||||
reset_timeout(php3_rqst); /* Make sure we don't timeout */
|
||||
reset_timeout(((request_rec *) SG(server_context))); /* Make sure we don't timeout */
|
||||
memcpy(buf + dbpos, argsbuffer, dbsize);
|
||||
dbpos += dbsize;
|
||||
}
|
||||
signal(SIGPIPE, handler); /* restore normal sigpipe handling */
|
||||
kill_timeout(php3_rqst); /* stop timeout timer */
|
||||
kill_timeout(((request_rec *) SG(server_context))); /* stop timeout timer */
|
||||
}
|
||||
#else
|
||||
cnt = 0;
|
||||
do {
|
||||
#if APACHE
|
||||
bytes = read_client_block(php3_rqst, buf + cnt, length - cnt);
|
||||
bytes = read_client_block(((request_rec *) SG(server_context)), buf + cnt, length - cnt);
|
||||
#endif
|
||||
#if CGI_BINARY
|
||||
bytes = fread(buf + cnt, 1, length - cnt, stdin);
|
||||
@@ -405,29 +407,33 @@ PHPAPI void php3_TreatHeaders(void)
|
||||
char *user, *type;
|
||||
int len;
|
||||
char *escaped_str;
|
||||
request_rec *r;
|
||||
PLS_FETCH();
|
||||
SLS_FETCH();
|
||||
|
||||
if (php3_rqst->headers_in)
|
||||
s = table_get(php3_rqst->headers_in, "Authorization");
|
||||
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(php3_rqst)) {
|
||||
if (auth_type(r)) {
|
||||
/*php3_error(E_WARNING, "Authentication done by server module\n");*/
|
||||
return;
|
||||
}
|
||||
if (strcmp(t=getword(php3_rqst->pool, &s, ' '), "Basic")) {
|
||||
if (strcmp(t=getword(r->pool, &s, ' '), "Basic")) {
|
||||
/* Client tried to authenticate using wrong auth scheme */
|
||||
php3_error(E_WARNING, "client used wrong authentication scheme (%s)", t);
|
||||
return;
|
||||
}
|
||||
t = uudecode(php3_rqst->pool, s);
|
||||
t = uudecode(r->pool, s);
|
||||
#if MODULE_MAGIC_NUMBER > 19961007
|
||||
user = getword_nulls_nc(php3_rqst->pool, &t, ':');
|
||||
user = getword_nulls_nc(r->pool, &t, ':');
|
||||
#else
|
||||
user = getword(php3_rqst->pool, &t, ':');
|
||||
user = getword(r->pool, &t, ':');
|
||||
#endif
|
||||
type = "Basic";
|
||||
|
||||
|
||||
@@ -394,9 +394,6 @@ static void php3_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
|
||||
php3_sybase_module.num_links++;
|
||||
} else { /* we do */
|
||||
if (le->type != php3_sybase_module.le_plink) {
|
||||
#if BROKEN_SYBASE_PCONNECTS
|
||||
log_error("PHP/Sybase: Hashed persistent link is not a Sybase link!",php3_rqst->server);
|
||||
#endif
|
||||
php3_error(E_WARNING,"Sybase: Hashed persistent link is not a Sybase link!");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -404,25 +401,13 @@ static void php3_sybase_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
|
||||
sybase_ptr = (sybase_link *) le->ptr;
|
||||
/* test that the link hasn't died */
|
||||
if (DBDEAD(sybase_ptr->link)==TRUE) {
|
||||
#if BROKEN_SYBASE_PCONNECTS
|
||||
log_error("PHP/Sybase: Persistent link died, trying to reconnect...",php3_rqst->server);
|
||||
#endif
|
||||
if ((sybase_ptr->link=dbopen(sybase_ptr->login,host))==FAIL) {
|
||||
#if BROKEN_SYBASE_PCONNECTS
|
||||
log_error("PHP/Sybase: Unable to reconnect!",php3_rqst->server);
|
||||
#endif
|
||||
/*php3_error(E_WARNING,"Sybase: Link to server lost, unable to reconnect");*/
|
||||
_php3_hash_del(plist, hashed_details, hashed_details_length+1);
|
||||
efree(hashed_details);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
#if BROKEN_SYBASE_PCONNECTS
|
||||
log_error("PHP/Sybase: Reconnect successful!",php3_rqst->server);
|
||||
#endif
|
||||
if (dbsetopt(sybase_ptr->link,DBBUFFER,"2",-1)==FAIL) {
|
||||
#if BROKEN_SYBASE_PCONNECTS
|
||||
log_error("PHP/Sybase: Unable to set required options",php3_rqst->server);
|
||||
#endif
|
||||
_php3_hash_del(plist, hashed_details, hashed_details_length+1);
|
||||
efree(hashed_details);
|
||||
RETURN_FALSE;
|
||||
|
||||
2
fhttpd.c
2
fhttpd.c
@@ -169,7 +169,7 @@ PHPAPI void php3_fhttpd_puts_header(char *s)
|
||||
}
|
||||
}
|
||||
|
||||
void fhttpd_flush( /*php3_rqst->connection */ void)
|
||||
void fhttpd_flush(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#ifdef ZTS
|
||||
SAPI_API int sapi_globals_id;
|
||||
#else
|
||||
sapi_globals_struct sapi_globals;
|
||||
#endif
|
||||
|
||||
/* A true global (no need for thread safety) */
|
||||
|
||||
54
main/main.c
54
main/main.c
@@ -248,27 +248,14 @@ PHP_INI_END()
|
||||
/* True global (no need for thread safety */
|
||||
static int module_initialized = 0;
|
||||
|
||||
#ifndef ZTS
|
||||
|
||||
/*
|
||||
* Globals yet to be protected
|
||||
*/
|
||||
|
||||
#if APACHE
|
||||
request_rec *php3_rqst = NULL; /* request record pointer for apache module version */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* End of globals to be protected
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
#if APACHE
|
||||
void php3_apache_puts(const char *s)
|
||||
{
|
||||
if (php3_rqst) {
|
||||
rputs(s, php3_rqst);
|
||||
SLS_FETCH();
|
||||
|
||||
if (SG(server_context)) {
|
||||
rputs(s, (request_rec *) SG(server_context));
|
||||
} else {
|
||||
fputs(s, stdout);
|
||||
}
|
||||
@@ -276,8 +263,10 @@ void php3_apache_puts(const char *s)
|
||||
|
||||
void php3_apache_putc(char c)
|
||||
{
|
||||
if (php3_rqst) {
|
||||
rputc(c, php3_rqst);
|
||||
SLS_FETCH();
|
||||
|
||||
if (SG(server_context)) {
|
||||
rputc(c, (request_rec *) SG(server_context));
|
||||
} else {
|
||||
fputc(c, stdout);
|
||||
}
|
||||
@@ -288,6 +277,7 @@ void php3_log_err(char *log_message)
|
||||
{
|
||||
FILE *log_file;
|
||||
PLS_FETCH();
|
||||
SLS_FETCH();
|
||||
|
||||
/* Try to use the specified logging location. */
|
||||
if (PG(error_log) != NULL) {
|
||||
@@ -310,11 +300,11 @@ void php3_log_err(char *log_message)
|
||||
}
|
||||
/* Otherwise fall back to the default logging location. */
|
||||
#if APACHE
|
||||
if (php3_rqst) {
|
||||
if (SG(server_context)) {
|
||||
#if MODULE_MAGIC_NUMBER >= 19970831
|
||||
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, log_message);
|
||||
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, log_message);
|
||||
#else
|
||||
log_error(log_message, php3_rqst->server);
|
||||
log_error(log_message, ((requset_rec *) SG(server_context))->server);
|
||||
#endif
|
||||
} else {
|
||||
fprintf(stderr, log_message);
|
||||
@@ -581,6 +571,7 @@ static void php_message_handler_for_zend(long message, void *data)
|
||||
break;
|
||||
case ZMSG_MEMORY_LEAK_DETECTED: {
|
||||
ELS_FETCH();
|
||||
SLS_FETCH();
|
||||
|
||||
if (EG(error_reporting)&E_WARNING) {
|
||||
#if ZEND_DEBUG
|
||||
@@ -590,9 +581,9 @@ static void php_message_handler_for_zend(long message, void *data)
|
||||
|
||||
snprintf(memory_leak_buf,512,"Possible PHP4 memory leak detected (harmless): 0x%0.8lX, %d bytes from %s:%d", (long) t, t->size, t->filename, t->lineno);
|
||||
# if MODULE_MAGIC_NUMBER >= 19970831
|
||||
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, php3_rqst->server, memory_leak_buf);
|
||||
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, memory_leak_buf);
|
||||
# else
|
||||
log_error(memory_leak_buf,php3_rqst->server);
|
||||
log_error(memory_leak_buf, ((request_rec *) SG(server_context))->server);
|
||||
# endif
|
||||
# else
|
||||
php3_printf("Freeing 0x%0.8X (%d bytes), allocated in %s on line %d<br>\n",(void *)((char *)t+sizeof(mem_header)+PLATFORM_PADDING),t->size,t->filename,t->lineno);
|
||||
@@ -606,7 +597,7 @@ static void php_message_handler_for_zend(long message, void *data)
|
||||
|
||||
|
||||
|
||||
int php_request_startup(CLS_D ELS_DC PLS_DC)
|
||||
int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
|
||||
{
|
||||
zend_output_startup();
|
||||
|
||||
@@ -622,7 +613,7 @@ int php_request_startup(CLS_D ELS_DC PLS_DC)
|
||||
* memory.
|
||||
*/
|
||||
block_alarms();
|
||||
register_cleanup(php3_rqst->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
|
||||
register_cleanup(((request_rec *) SG(server_context))->pool, NULL, php_request_shutdown, php_request_shutdown_for_exec);
|
||||
unblock_alarms();
|
||||
#endif
|
||||
|
||||
@@ -935,7 +926,7 @@ int _php3_hash_environment(PLS_D)
|
||||
{
|
||||
pval **tmp_ptr;
|
||||
register int i;
|
||||
array_header *arr = table_elts(php3_rqst->subprocess_env);
|
||||
array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
|
||||
table_entry *elts = (table_entry *) arr->elts;
|
||||
int len;
|
||||
|
||||
@@ -961,8 +952,8 @@ int _php3_hash_environment(PLS_D)
|
||||
_php3_hash_update(&EG(symbol_table), "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), tmp_ptr, sizeof(pval *), NULL);
|
||||
}
|
||||
tmp = (pval *) emalloc(sizeof(pval));
|
||||
tmp->value.str.len = strlen(php3_rqst->uri);
|
||||
tmp->value.str.val = estrndup(php3_rqst->uri, tmp->value.str.len);
|
||||
tmp->value.str.len = strlen(((request_rec *) SG(server_context))->uri);
|
||||
tmp->value.str.val = estrndup(((request_rec *) SG(server_context))->uri, tmp->value.str.len);
|
||||
tmp->refcount=1;
|
||||
tmp->is_ref=0;
|
||||
tmp->type = IS_STRING;
|
||||
@@ -1171,7 +1162,7 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
|
||||
/* some systems are missing these from their header files */
|
||||
|
||||
#if APACHE
|
||||
PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_mode)
|
||||
PHPAPI int apache_php3_module_main(request_rec *r, int fd, int display_source_mode)
|
||||
{
|
||||
zend_file_handle file_handle;
|
||||
#ifdef ZTS
|
||||
@@ -1182,8 +1173,9 @@ PHPAPI int apache_php3_module_main(request_rec * r, int fd, int display_source_m
|
||||
zend_executor_globals *executor_globals=⪚
|
||||
php_core_globals *core_globals=&pcg;
|
||||
#endif
|
||||
SLS_FETCH();
|
||||
|
||||
php3_rqst = r;
|
||||
SG(server_context) = r;
|
||||
|
||||
if (php_request_startup(CLS_C ELS_CC PLS_CC) == FAILURE) {
|
||||
return FAILURE;
|
||||
|
||||
@@ -197,9 +197,6 @@ extern char *strerror(int);
|
||||
#include "http_log.h"
|
||||
#define BLOCK_INTERRUPTIONS block_alarms
|
||||
#define UNBLOCK_INTERRUPTIONS unblock_alarms
|
||||
# ifndef THREAD_SAFE
|
||||
extern request_rec *php3_rqst;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_PWD_H
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include "ext/standard/pageinfo.h"
|
||||
#include "safe_mode.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
/*
|
||||
* _php3_checkuid
|
||||
@@ -125,6 +126,7 @@ PHPAPI char *_php3_get_current_user()
|
||||
#endif
|
||||
struct passwd *pwd;
|
||||
int uid;
|
||||
SLS_FETCH();
|
||||
|
||||
if (request_info.current_user) {
|
||||
return request_info.current_user;
|
||||
@@ -140,7 +142,7 @@ PHPAPI char *_php3_get_current_user()
|
||||
uid = statbuf.st_uid;
|
||||
#endif
|
||||
#if APACHE
|
||||
uid = php3_rqst->finfo.st_uid;
|
||||
uid = ((request_rec *) SG(server_context))->finfo.st_uid;
|
||||
#endif
|
||||
|
||||
if ((pwd=getpwuid(uid))==NULL) {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "http_protocol.h"
|
||||
#include "http_request.h"
|
||||
#include "http_log.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
|
||||
/* These are taken out of php_ini.h
|
||||
@@ -101,8 +102,10 @@ void php3_save_umask()
|
||||
|
||||
static int zend_apache_ub_write(const char *str, uint str_length)
|
||||
{
|
||||
if (php3_rqst) {
|
||||
return rwrite(str, str_length, php3_rqst);
|
||||
SLS_FETCH();
|
||||
|
||||
if (SG(server_context)) {
|
||||
return rwrite(str, str_length, (request_rec *) SG(server_context));
|
||||
} else {
|
||||
return fwrite(str, 1, str_length, stdout);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
#include "php.h"
|
||||
#include "SAPI.h"
|
||||
|
||||
#ifndef THREAD_SAFE
|
||||
PHPAPI php3_request_info request_info;
|
||||
@@ -194,19 +195,22 @@ int php3_init_request_info(void *conf)
|
||||
int php3_init_request_info(void *conf)
|
||||
{
|
||||
const char *buf;
|
||||
request_rec *r;
|
||||
SLS_FETCH();
|
||||
|
||||
r = ((request_rec *) SG(server_context));
|
||||
request_info.current_user = NULL;
|
||||
request_info.current_user_length = 0;
|
||||
|
||||
request_info.filename = php3_rqst->filename;
|
||||
request_info.request_method = php3_rqst->method;
|
||||
request_info.query_string = php3_rqst->args;
|
||||
request_info.content_type = table_get(php3_rqst->subprocess_env, "CONTENT_TYPE");
|
||||
request_info.filename = r->filename;
|
||||
request_info.request_method = r->method;
|
||||
request_info.query_string = r->args;
|
||||
request_info.content_type = table_get(r->subprocess_env, "CONTENT_TYPE");
|
||||
|
||||
buf = table_get(php3_rqst->subprocess_env, "CONTENT_LENGTH");
|
||||
buf = table_get(r->subprocess_env, "CONTENT_LENGTH");
|
||||
request_info.content_length = (buf ? atoi(buf) : 0);
|
||||
|
||||
request_info.cookies = table_get(php3_rqst->subprocess_env, "HTTP_COOKIE");
|
||||
request_info.cookies = table_get(r->subprocess_env, "HTTP_COOKIE");
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user