2000-10-29 17:43:23 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-08 17:33:29 +00:00
|
|
|
| PHP Version 5 |
|
2000-10-29 17:43:23 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2007-01-01 09:36:18 +00:00
|
|
|
| Copyright (c) 1997-2007 The PHP Group |
|
2000-10-29 17:43:23 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 12:51:34 +00:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2000-10-29 17:43:23 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 12:51:34 +00:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2000-10-29 17:43:23 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2002-02-28 08:29:35 +00:00
|
|
|
| Author: Sascha Schumann <sascha@schumann.cx> |
|
2000-10-29 17:43:23 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2002-11-02 16:04:27 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2000-10-26 17:55:05 +00:00
|
|
|
#ifndef PHP_APACHE_H
|
|
|
|
#define PHP_APACHE_H
|
|
|
|
|
2002-04-18 22:10:57 +00:00
|
|
|
#include "httpd.h"
|
|
|
|
#include "http_config.h"
|
|
|
|
#include "http_core.h"
|
|
|
|
|
|
|
|
/* Declare this so we can get to it from outside the sapi_apache2.c file */
|
2003-03-29 04:52:46 +00:00
|
|
|
extern module AP_MODULE_DECLARE_DATA php5_module;
|
2002-04-18 22:10:57 +00:00
|
|
|
|
|
|
|
/* A way to specify the location of the php.ini dir in an apache directive */
|
|
|
|
extern char *apache2_php_ini_path_override;
|
|
|
|
|
|
|
|
/* The server_context used by PHP */
|
2000-10-26 17:55:05 +00:00
|
|
|
typedef struct php_struct {
|
|
|
|
int state;
|
PHP filters and Apache 2 aren't quite a perfect match yet, so we have
to do some trickery with the server_context to make sure it is always
valid within the current thread.
This patch makes sure the server_context is created in apache's
post_read_request hook phase, and then registeres a cleanup that
will NULL out the server context when the request goes out of scope.
Then, inside the output filters, if the server_context is null we
throw an error. Finally, instead of saving the output filter in
the server_context, now we store the entire request_rec pointer
in there.
POST bodies appear to be working now, although they are very inefficient.
The input filter is still just realloc()ing for whatever data comes
down the input pipe, and then sending this to PHP. This means that
we are doing some really nasty memory management on big POST bodies.
For now this it allows for unlimited input bodies, which means that
a big POST could potentially DoS a box by making it run out of memory.
We might want to put a limit on here just in case, at least until
we figure out how to consume input data more efficiently into php.
2002-04-11 19:25:08 +00:00
|
|
|
request_rec *r;
|
2002-04-11 20:34:56 +00:00
|
|
|
ap_filter_t *f; /* downstream output filters after the PHP filter. */
|
2000-10-29 14:52:15 +00:00
|
|
|
/* Length of post_data buffer */
|
|
|
|
int post_len;
|
|
|
|
/* Index for reading from buffer */
|
|
|
|
int post_idx;
|
2002-09-23 18:51:34 +00:00
|
|
|
/* stat structure of the current file */
|
|
|
|
struct stat finfo;
|
2000-10-29 14:52:15 +00:00
|
|
|
/* Buffer for request body filter */
|
|
|
|
char *post_data;
|
2002-04-11 06:01:54 +00:00
|
|
|
/* Whether or not we've processed PHP in the output filters yet. */
|
|
|
|
int request_processed;
|
2000-10-26 17:55:05 +00:00
|
|
|
} php_struct;
|
|
|
|
|
2006-07-03 16:51:38 +00:00
|
|
|
typedef struct _php_apr_bucket_brigade {
|
|
|
|
unsigned int total_len;
|
|
|
|
apr_bucket_brigade *bb;
|
|
|
|
} php_apr_bucket_brigade;
|
|
|
|
|
2000-10-26 17:55:05 +00:00
|
|
|
void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf);
|
|
|
|
void *create_php_config(apr_pool_t *p, char *dummy);
|
2002-10-22 12:20:12 +00:00
|
|
|
char *get_php_config(void *conf, char *name, size_t name_len);
|
2000-10-26 17:55:05 +00:00
|
|
|
void apply_config(void *);
|
2000-11-02 15:19:54 +00:00
|
|
|
extern const command_rec php_dir_cmds[];
|
2000-10-26 17:55:05 +00:00
|
|
|
|
2006-07-03 16:51:38 +00:00
|
|
|
static size_t php_apache_read_stream(void *, char *, size_t TSRMLS_DC);
|
|
|
|
static void php_apache_close_stream(void * TSRMLS_DC);
|
|
|
|
static long php_apache_fteller_stream(void * TSRMLS_DC);
|
|
|
|
|
2000-11-11 18:24:27 +00:00
|
|
|
#define APR_ARRAY_FOREACH_OPEN(arr, key, val) \
|
|
|
|
{ \
|
|
|
|
apr_table_entry_t *elts; \
|
|
|
|
int i; \
|
|
|
|
elts = (apr_table_entry_t *) arr->elts; \
|
|
|
|
for (i = 0; i < arr->nelts; i++) { \
|
|
|
|
key = elts[i].key; \
|
|
|
|
val = elts[i].val;
|
|
|
|
|
|
|
|
#define APR_ARRAY_FOREACH_CLOSE() }}
|
|
|
|
|
2000-10-26 17:55:05 +00:00
|
|
|
#endif /* PHP_APACHE_H */
|