1999-04-07 21:05:13 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
1999-07-16 13:13:16 +00:00
|
|
|
| PHP version 4.0 |
|
1999-04-07 21:05:13 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2000-01-01 01:32:05 +00:00
|
|
|
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group |
|
1999-04-07 21:05:13 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2000-05-18 15:34:45 +00:00
|
|
|
| This source file is subject to version 2.02 of the PHP license, |
|
1999-07-16 13:13:16 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available at through the world-wide-web at |
|
2000-05-18 15:34:45 +00:00
|
|
|
| http://www.php.net/license/2_02.txt. |
|
1999-07-16 13:13:16 +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. |
|
1999-04-07 21:05:13 +00:00
|
|
|
+----------------------------------------------------------------------+
|
1999-05-28 03:54:15 +00:00
|
|
|
| Authors: Rasmus Lerdorf <rasmus@php.net> |
|
1999-04-07 21:05:13 +00:00
|
|
|
| (with helpful hints from Dean Gaudet <dgaudet@arctic.org> |
|
1999-05-11 00:01:47 +00:00
|
|
|
| PHP 4.0 patches by Zeev Suraski <zeev@zend.com> |
|
1999-04-07 21:05:13 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
/* $Id$ */
|
|
|
|
|
2000-02-18 10:13:15 +00:00
|
|
|
#define NO_REGEX_EXTRA_H
|
2000-04-30 04:15:26 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
2000-02-16 17:46:14 +00:00
|
|
|
|
1999-10-30 14:22:10 +00:00
|
|
|
#include "zend.h"
|
|
|
|
#include "php.h"
|
2000-01-28 17:38:08 +00:00
|
|
|
#include "php_variables.h"
|
2000-02-10 19:41:21 +00:00
|
|
|
#include "SAPI.h"
|
1999-10-30 14:22:10 +00:00
|
|
|
|
1999-04-07 21:05:13 +00:00
|
|
|
#include "httpd.h"
|
|
|
|
#include "http_config.h"
|
|
|
|
#if MODULE_MAGIC_NUMBER > 19980712
|
1999-09-27 16:34:28 +00:00
|
|
|
# include "ap_compat.h"
|
1999-04-07 21:05:13 +00:00
|
|
|
#else
|
1999-09-27 16:34:28 +00:00
|
|
|
# if MODULE_MAGIC_NUMBER > 19980324
|
|
|
|
# include "compat.h"
|
|
|
|
# endif
|
1999-04-07 21:05:13 +00:00
|
|
|
#endif
|
|
|
|
#include "http_core.h"
|
|
|
|
#include "http_main.h"
|
|
|
|
#include "http_protocol.h"
|
|
|
|
#include "http_request.h"
|
|
|
|
#include "http_log.h"
|
1999-04-09 21:15:07 +00:00
|
|
|
|
1999-05-11 00:01:47 +00:00
|
|
|
#include "php_ini.h"
|
1999-09-13 00:35:03 +00:00
|
|
|
#include "php_globals.h"
|
1999-05-11 00:01:47 +00:00
|
|
|
#include "SAPI.h"
|
2000-06-05 23:24:42 +00:00
|
|
|
#include "php_main.h"
|
1999-05-09 08:48:05 +00:00
|
|
|
|
1999-09-27 16:34:28 +00:00
|
|
|
#include "zend_compile.h"
|
|
|
|
#include "zend_execute.h"
|
|
|
|
#include "zend_highlight.h"
|
|
|
|
#include "zend_indent.h"
|
|
|
|
|
1999-12-04 19:19:57 +00:00
|
|
|
#include "ext/standard/php_standard.h"
|
1999-09-27 16:34:28 +00:00
|
|
|
|
1999-04-07 21:05:13 +00:00
|
|
|
#include "util_script.h"
|
|
|
|
|
1999-05-22 09:24:21 +00:00
|
|
|
#include "mod_php4.h"
|
1999-04-07 21:05:13 +00:00
|
|
|
#if HAVE_MOD_DAV
|
|
|
|
# include "mod_dav.h"
|
|
|
|
#endif
|
|
|
|
|
2000-07-10 07:57:01 +00:00
|
|
|
int apache_php_module_main(request_rec *r, int display_source_mode CLS_DC ELS_DC PLS_DC SLS_DC);
|
1999-12-05 14:37:38 +00:00
|
|
|
void php_save_umask(void);
|
|
|
|
void php_restore_umask(void);
|
|
|
|
int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC);
|
|
|
|
char *sapi_apache_read_cookies(SLS_D);
|
|
|
|
int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC);
|
|
|
|
int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC);
|
|
|
|
int send_php(request_rec *r, int display_source_mode, char *filename);
|
|
|
|
int send_parsed_php(request_rec * r);
|
|
|
|
int send_parsed_php_source(request_rec * r);
|
|
|
|
int php_xbithack_handler(request_rec * r);
|
|
|
|
void php_init_handler(server_rec *s, pool *p);
|
|
|
|
|
2000-07-09 12:51:01 +00:00
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970728
|
2000-07-10 09:20:35 +00:00
|
|
|
static void php_child_exit_handler(server_rec *s, pool *p);
|
2000-07-09 12:51:01 +00:00
|
|
|
#endif
|
|
|
|
|
1999-12-05 14:37:38 +00:00
|
|
|
#if MODULE_MAGIC_NUMBER > 19961007
|
|
|
|
#define CONST_PREFIX const
|
|
|
|
#else
|
|
|
|
#define CONST_PREFIX
|
|
|
|
#endif
|
|
|
|
CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
|
|
|
|
CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
|
|
|
|
CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
|
|
|
|
CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
|
|
|
|
CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
|
|
|
|
CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2);
|
1999-05-11 00:01:47 +00:00
|
|
|
|
1999-05-22 09:24:21 +00:00
|
|
|
/* ### these should be defined in mod_php4.h or somewhere else */
|
1999-04-07 21:05:13 +00:00
|
|
|
#define USE_PATH 1
|
|
|
|
#define IGNORE_URL 2
|
|
|
|
|
1999-05-22 09:24:21 +00:00
|
|
|
module MODULE_VAR_EXPORT php4_module;
|
1999-04-07 21:05:13 +00:00
|
|
|
|
|
|
|
int saved_umask;
|
1999-10-04 15:18:26 +00:00
|
|
|
static unsigned char apache_php_initialized;
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-05-29 19:06:22 +00:00
|
|
|
typedef struct _php_per_dir_entry {
|
|
|
|
char *key;
|
|
|
|
char *value;
|
|
|
|
uint key_length;
|
|
|
|
uint value_length;
|
|
|
|
int type;
|
|
|
|
} php_per_dir_entry;
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-04-10 17:39:08 +00:00
|
|
|
php_apache_info_struct php_apache_info; /* active config */
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-09-27 16:34:28 +00:00
|
|
|
/* some systems are missing these from their header files */
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-12-05 14:37:38 +00:00
|
|
|
void php_save_umask(void)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-04-24 00:12:00 +00:00
|
|
|
saved_umask = umask(077);
|
|
|
|
umask(saved_umask);
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-04-26 14:00:49 +00:00
|
|
|
|
2000-01-13 17:37:25 +00:00
|
|
|
static int sapi_apache_ub_write(const char *str, uint str_length)
|
1999-04-26 14:00:49 +00:00
|
|
|
{
|
1999-09-04 20:12:47 +00:00
|
|
|
int ret;
|
1999-09-04 21:16:41 +00:00
|
|
|
SLS_FETCH();
|
1999-12-17 14:24:39 +00:00
|
|
|
PLS_FETCH();
|
1999-09-04 20:12:47 +00:00
|
|
|
|
1999-04-26 17:26:37 +00:00
|
|
|
if (SG(server_context)) {
|
1999-09-04 20:12:47 +00:00
|
|
|
ret = rwrite(str, str_length, (request_rec *) SG(server_context));
|
1999-04-26 14:00:49 +00:00
|
|
|
} else {
|
2000-05-14 16:05:25 +00:00
|
|
|
ret = fwrite(str, 1, str_length, stderr);
|
1999-09-04 20:12:47 +00:00
|
|
|
}
|
|
|
|
if(ret != str_length) {
|
|
|
|
PG(connection_status) = PHP_CONNECTION_ABORTED;
|
2000-01-28 17:38:08 +00:00
|
|
|
if (!PG(ignore_user_abort)) {
|
|
|
|
zend_bailout();
|
|
|
|
}
|
1999-04-26 14:00:49 +00:00
|
|
|
}
|
1999-09-04 20:12:47 +00:00
|
|
|
return ret;
|
1999-04-26 14:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-13 17:37:25 +00:00
|
|
|
|
|
|
|
static void sapi_apache_flush(void *server_context)
|
|
|
|
{
|
2000-02-10 19:29:21 +00:00
|
|
|
if (server_context) {
|
2000-01-13 17:37:25 +00:00
|
|
|
#if MODULE_MAGIC_NUMBER > 19970110
|
2000-02-10 19:29:21 +00:00
|
|
|
rflush((request_rec *) server_context);
|
2000-01-13 17:37:25 +00:00
|
|
|
#else
|
2000-02-10 19:29:21 +00:00
|
|
|
bflush((request_rec *) server_context->connection->client);
|
2000-01-13 17:37:25 +00:00
|
|
|
#endif
|
2000-02-10 19:29:21 +00:00
|
|
|
}
|
2000-01-13 17:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-11 00:01:47 +00:00
|
|
|
int sapi_apache_read_post(char *buffer, uint count_bytes SLS_DC)
|
1999-05-09 08:48:05 +00:00
|
|
|
{
|
1999-05-11 12:52:17 +00:00
|
|
|
uint total_read_bytes=0, read_bytes;
|
|
|
|
request_rec *r = (request_rec *) SG(server_context);
|
|
|
|
void (*handler)(int);
|
|
|
|
|
|
|
|
handler = signal(SIGPIPE, SIG_IGN);
|
|
|
|
while (total_read_bytes<count_bytes) {
|
|
|
|
hard_timeout("Read POST information", r); /* start timeout timer */
|
|
|
|
read_bytes = get_client_block(r, buffer+total_read_bytes, count_bytes-total_read_bytes);
|
|
|
|
reset_timeout(r);
|
|
|
|
if (read_bytes<=0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
total_read_bytes += read_bytes;
|
|
|
|
}
|
|
|
|
signal(SIGPIPE, handler);
|
|
|
|
return total_read_bytes;
|
1999-05-09 08:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *sapi_apache_read_cookies(SLS_D)
|
|
|
|
{
|
1999-05-11 00:01:47 +00:00
|
|
|
return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE");
|
1999-05-09 08:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC)
|
|
|
|
{
|
|
|
|
char *header_name, *header_content, *p;
|
|
|
|
request_rec *r = (request_rec *) SG(server_context);
|
|
|
|
|
|
|
|
header_name = sapi_header->header;
|
|
|
|
|
|
|
|
header_content = p = strchr(header_name, ':');
|
|
|
|
if (!p) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
do {
|
1999-05-11 00:01:47 +00:00
|
|
|
header_content++;
|
1999-05-09 08:48:05 +00:00
|
|
|
} while (*header_content==' ');
|
|
|
|
|
|
|
|
if (!strcasecmp(header_name, "Content-Type")) {
|
1999-05-11 00:01:47 +00:00
|
|
|
r->content_type = pstrdup(r->pool, header_content);
|
1999-07-21 20:31:07 +00:00
|
|
|
} else if (!strcasecmp(header_name, "Set-Cookie")) {
|
|
|
|
table_add(r->headers_out, header_name, header_content);
|
1999-05-09 08:48:05 +00:00
|
|
|
} else {
|
|
|
|
table_set(r->headers_out, header_name, header_content);
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = ':'; /* a well behaved header handler shouldn't change its original arguments */
|
|
|
|
|
1999-05-11 00:09:22 +00:00
|
|
|
efree(sapi_header->header);
|
|
|
|
|
1999-05-09 08:48:05 +00:00
|
|
|
return 0; /* don't use the default SAPI mechanism, Apache duplicates this functionality */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-11 00:01:47 +00:00
|
|
|
int sapi_apache_send_headers(sapi_headers_struct *sapi_headers SLS_DC)
|
1999-05-09 08:48:05 +00:00
|
|
|
{
|
2000-05-17 08:11:20 +00:00
|
|
|
if(SG(server_context) == NULL) { /* server_context is not here anymore */
|
|
|
|
return SAPI_HEADER_SEND_FAILED;
|
|
|
|
}
|
|
|
|
|
1999-05-11 18:36:35 +00:00
|
|
|
((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code;
|
1999-05-09 08:48:05 +00:00
|
|
|
send_http_header((request_rec *) SG(server_context));
|
|
|
|
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-28 17:24:53 +00:00
|
|
|
static void sapi_apache_register_server_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC)
|
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env);
|
|
|
|
table_entry *elts = (table_entry *) arr->elts;
|
|
|
|
char *script_filename=NULL;
|
2000-05-04 03:28:34 +00:00
|
|
|
|
2000-01-28 17:24:53 +00:00
|
|
|
for (i = 0; i < arr->nelts; i++) {
|
|
|
|
char *val;
|
|
|
|
|
|
|
|
if (elts[i].val) {
|
|
|
|
val = elts[i].val;
|
2000-04-08 11:16:19 +00:00
|
|
|
if (!strcmp(elts[i].key, "SCRIPT_FILENAME")) {
|
2000-01-28 17:24:53 +00:00
|
|
|
script_filename = val;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val = empty_string;
|
|
|
|
}
|
2000-07-06 17:40:18 +00:00
|
|
|
php_register_variable(elts[i].key, val, track_vars_array ELS_CC PLS_CC);
|
2000-01-28 17:24:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* insert special variables */
|
|
|
|
if (script_filename) {
|
2000-04-08 11:16:19 +00:00
|
|
|
php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array ELS_CC PLS_CC);
|
2000-01-28 17:24:53 +00:00
|
|
|
}
|
2000-04-08 11:16:19 +00:00
|
|
|
php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array ELS_CC PLS_CC);
|
2000-01-28 17:24:53 +00:00
|
|
|
}
|
2000-01-28 17:38:08 +00:00
|
|
|
|
2000-05-04 03:28:34 +00:00
|
|
|
static int php_apache_startup(sapi_module_struct *sapi_module)
|
2000-02-02 06:09:00 +00:00
|
|
|
{
|
|
|
|
if(php_module_startup(sapi_module) == FAILURE
|
2000-02-02 17:19:36 +00:00
|
|
|
|| zend_startup_module(&apache_module_entry) == FAILURE) {
|
2000-02-02 06:09:00 +00:00
|
|
|
return FAILURE;
|
|
|
|
} else {
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-28 17:24:53 +00:00
|
|
|
|
2000-02-10 15:55:10 +00:00
|
|
|
static void php_apache_log_message(char *message)
|
|
|
|
{
|
|
|
|
SLS_FETCH();
|
|
|
|
|
|
|
|
if (SG(server_context)) {
|
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970831
|
2000-04-13 03:35:02 +00:00
|
|
|
aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, "%s", message);
|
2000-02-10 15:55:10 +00:00
|
|
|
#else
|
2000-08-04 16:48:42 +00:00
|
|
|
log_error(message, ((request_rec *) SG(server_context))->server);
|
2000-02-10 15:55:10 +00:00
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, message);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-14 16:05:25 +00:00
|
|
|
static void php_apache_request_shutdown(void *dummy)
|
|
|
|
{
|
|
|
|
SLS_FETCH();
|
|
|
|
|
|
|
|
SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */
|
|
|
|
php_request_shutdown(dummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-10 16:44:59 +00:00
|
|
|
static int php_apache_sapi_activate(SLS_D)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* For the Apache module version, this bit of code registers a cleanup
|
|
|
|
* function that gets triggered when our request pool is destroyed.
|
|
|
|
* We need this because at any point in our code we can be interrupted
|
|
|
|
* and that may happen before we have had time to free our memory.
|
|
|
|
* The php_request_shutdown function needs to free all outstanding allocated
|
|
|
|
* memory.
|
|
|
|
*/
|
|
|
|
block_alarms();
|
2000-05-14 16:05:25 +00:00
|
|
|
register_cleanup(((request_rec *) SG(server_context))->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec);
|
2000-02-10 16:44:59 +00:00
|
|
|
unblock_alarms();
|
2000-02-10 19:41:21 +00:00
|
|
|
return SUCCESS;
|
2000-02-10 16:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-10 18:19:04 +00:00
|
|
|
static struct stat *php_apache_get_stat(SLS_D)
|
2000-02-10 17:26:57 +00:00
|
|
|
{
|
2000-02-10 18:19:04 +00:00
|
|
|
return &((request_rec *) SG(server_context))->finfo;
|
2000-02-10 17:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-10 17:55:01 +00:00
|
|
|
static char *php_apache_getenv(char *name, int name_len SLS_DC)
|
|
|
|
{
|
2000-02-10 19:41:21 +00:00
|
|
|
return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name);
|
2000-02-10 17:55:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-26 20:39:59 +00:00
|
|
|
static sapi_module_struct sapi_module_conf = {
|
2000-06-26 18:05:55 +00:00
|
|
|
"apache", /* name */
|
|
|
|
"Apache", /* pretty name */
|
1999-05-02 19:16:21 +00:00
|
|
|
|
2000-02-02 06:09:00 +00:00
|
|
|
php_apache_startup, /* startup */
|
1999-05-02 19:16:21 +00:00
|
|
|
php_module_shutdown_wrapper, /* shutdown */
|
|
|
|
|
2000-02-10 16:44:59 +00:00
|
|
|
php_apache_sapi_activate, /* activate */
|
|
|
|
NULL, /* deactivate */
|
|
|
|
|
2000-01-13 17:37:25 +00:00
|
|
|
sapi_apache_ub_write, /* unbuffered write */
|
|
|
|
sapi_apache_flush, /* flush */
|
2000-02-10 18:19:04 +00:00
|
|
|
php_apache_get_stat, /* get uid */
|
2000-02-10 17:55:01 +00:00
|
|
|
php_apache_getenv, /* getenv */
|
1999-05-09 08:48:05 +00:00
|
|
|
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error, /* error handler */
|
1999-05-09 08:48:05 +00:00
|
|
|
|
|
|
|
sapi_apache_header_handler, /* header handler */
|
|
|
|
sapi_apache_send_headers, /* send headers handler */
|
|
|
|
NULL, /* send header handler */
|
|
|
|
|
|
|
|
sapi_apache_read_post, /* read POST data */
|
1999-09-16 23:18:15 +00:00
|
|
|
sapi_apache_read_cookies, /* read Cookies */
|
|
|
|
|
2000-01-28 17:24:53 +00:00
|
|
|
sapi_apache_register_server_variables, /* register server variables */
|
2000-02-10 15:55:10 +00:00
|
|
|
php_apache_log_message, /* Log message */
|
2000-01-28 17:24:53 +00:00
|
|
|
|
2000-04-30 04:15:26 +00:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
#else
|
2000-02-10 18:44:33 +00:00
|
|
|
block_alarms, /* Block interruptions */
|
|
|
|
unblock_alarms, /* Unblock interruptions */
|
2000-04-30 04:15:26 +00:00
|
|
|
#endif
|
2000-02-10 18:44:33 +00:00
|
|
|
|
1999-09-16 23:18:15 +00:00
|
|
|
STANDARD_SAPI_MODULE_PROPERTIES
|
1999-04-26 14:00:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-12-05 14:37:38 +00:00
|
|
|
void php_restore_umask(void)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-04-24 00:12:00 +00:00
|
|
|
umask(saved_umask);
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-04-26 14:00:49 +00:00
|
|
|
|
1999-05-11 00:01:47 +00:00
|
|
|
static void init_request_info(SLS_D)
|
|
|
|
{
|
|
|
|
request_rec *r = ((request_rec *) SG(server_context));
|
|
|
|
char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH");
|
1999-05-12 22:49:23 +00:00
|
|
|
const char *authorization=NULL;
|
|
|
|
char *tmp;
|
1999-05-11 00:01:47 +00:00
|
|
|
|
|
|
|
SG(request_info).query_string = r->args;
|
|
|
|
SG(request_info).path_translated = r->filename;
|
|
|
|
SG(request_info).request_uri = r->uri;
|
1999-05-28 03:54:15 +00:00
|
|
|
SG(request_info).request_method = (char *)r->method;
|
1999-05-11 00:01:47 +00:00
|
|
|
SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE");
|
|
|
|
SG(request_info).content_length = (content_length ? atoi(content_length) : 0);
|
2000-08-02 22:48:45 +00:00
|
|
|
SG(request_info).headers_only = r->header_only;
|
|
|
|
SG(sapi_headers).http_response_code = r->status;
|
1999-05-12 22:49:23 +00:00
|
|
|
|
|
|
|
if (r->headers_in) {
|
|
|
|
authorization = table_get(r->headers_in, "Authorization");
|
|
|
|
}
|
|
|
|
if (authorization
|
1999-08-28 23:30:37 +00:00
|
|
|
/* && !auth_type(r) */
|
2000-06-30 17:39:21 +00:00
|
|
|
&& !strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
|
1999-05-12 22:49:23 +00:00
|
|
|
tmp = uudecode(r->pool, authorization);
|
|
|
|
SG(request_info).auth_user = getword_nulls_nc(r->pool, &tmp, ':');
|
|
|
|
if (SG(request_info).auth_user) {
|
2000-07-05 18:02:42 +00:00
|
|
|
r->connection->user = pstrdup(r->connection->pool,SG(request_info).auth_user);
|
|
|
|
r->connection->ap_auth_type = "Basic";
|
1999-05-12 22:49:23 +00:00
|
|
|
SG(request_info).auth_user = estrdup(SG(request_info).auth_user);
|
|
|
|
}
|
|
|
|
SG(request_info).auth_password = tmp;
|
|
|
|
if (SG(request_info).auth_password) {
|
|
|
|
SG(request_info).auth_password = estrdup(SG(request_info).auth_password);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SG(request_info).auth_user = NULL;
|
|
|
|
SG(request_info).auth_password = NULL;
|
|
|
|
}
|
1999-05-11 00:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-29 19:06:22 +00:00
|
|
|
static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry)
|
|
|
|
{
|
2000-02-26 16:07:05 +00:00
|
|
|
php_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length+1, per_dir_entry->type, PHP_INI_STAGE_ACTIVATE);
|
1999-09-13 00:35:03 +00:00
|
|
|
return 0;
|
1999-05-29 19:06:22 +00:00
|
|
|
}
|
|
|
|
|
2000-02-25 21:27:03 +00:00
|
|
|
static char *php_apache_get_default_mimetype(request_rec *r SLS_DC)
|
|
|
|
{
|
|
|
|
|
|
|
|
char *mimetype;
|
|
|
|
if (SG(default_mimetype) || SG(default_charset)) {
|
|
|
|
/* Assume output will be of the default MIME type. Individual
|
|
|
|
scripts may change this later. */
|
|
|
|
char *tmpmimetype;
|
|
|
|
tmpmimetype = sapi_get_default_content_type(SLS_C);
|
|
|
|
mimetype = pstrdup(r->pool, tmpmimetype);
|
|
|
|
efree(tmpmimetype);
|
|
|
|
} else {
|
2000-02-26 05:03:41 +00:00
|
|
|
mimetype = SAPI_DEFAULT_MIMETYPE "; charset=" SAPI_DEFAULT_CHARSET;
|
2000-02-25 21:27:03 +00:00
|
|
|
}
|
|
|
|
return mimetype;
|
|
|
|
}
|
1999-05-29 19:06:22 +00:00
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
int send_php(request_rec *r, int display_source_mode, char *filename)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
2000-07-10 07:57:01 +00:00
|
|
|
int retval;
|
1999-05-29 19:06:22 +00:00
|
|
|
HashTable *per_dir_conf;
|
1999-05-11 00:01:47 +00:00
|
|
|
SLS_FETCH();
|
1999-12-17 14:24:39 +00:00
|
|
|
ELS_FETCH();
|
2000-05-04 03:28:34 +00:00
|
|
|
CLS_FETCH();
|
|
|
|
PLS_FETCH();
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-05-28 22:41:48 +00:00
|
|
|
if (setjmp(EG(bailout))!=0) {
|
|
|
|
return OK;
|
|
|
|
}
|
1999-05-29 19:06:22 +00:00
|
|
|
per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module);
|
2000-06-28 18:27:13 +00:00
|
|
|
if (per_dir_conf) {
|
|
|
|
zend_hash_apply((HashTable *) per_dir_conf, (int (*)(void *)) php_apache_alter_ini_entries);
|
|
|
|
}
|
1999-05-29 19:06:22 +00:00
|
|
|
|
1999-04-07 21:05:13 +00:00
|
|
|
/* We don't accept OPTIONS requests, but take everything else */
|
|
|
|
if (r->method_number == M_OPTIONS) {
|
|
|
|
r->allowed |= (1 << METHODS) - 1;
|
|
|
|
return DECLINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure file exists */
|
|
|
|
if (filename == NULL && r->finfo.st_mode == 0) {
|
2000-05-26 18:43:09 +00:00
|
|
|
return DECLINED;
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
/* If PHP parser engine has been turned off with an "engine off"
|
1999-04-07 21:05:13 +00:00
|
|
|
* directive, then decline to handle this request
|
|
|
|
*/
|
1999-04-10 17:39:08 +00:00
|
|
|
if (!php_apache_info.engine) {
|
2000-02-25 21:27:03 +00:00
|
|
|
r->content_type = php_apache_get_default_mimetype(r SLS_CC);
|
1999-04-07 21:05:13 +00:00
|
|
|
r->allowed |= (1 << METHODS) - 1;
|
|
|
|
return DECLINED;
|
|
|
|
}
|
|
|
|
if (filename == NULL) {
|
|
|
|
filename = r->filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Apache 1.2 has a more complex mechanism for reading POST data */
|
|
|
|
#if MODULE_MAGIC_NUMBER > 19961007
|
|
|
|
if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR)))
|
|
|
|
return retval;
|
|
|
|
#endif
|
|
|
|
|
1999-04-10 17:39:08 +00:00
|
|
|
if (php_apache_info.last_modified) {
|
1999-04-07 21:05:13 +00:00
|
|
|
#if MODULE_MAGIC_NUMBER < 19970912
|
|
|
|
if ((retval = set_last_modified(r, r->finfo.st_mtime))) {
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
update_mtime (r, r->finfo.st_mtime);
|
|
|
|
set_last_modified(r);
|
|
|
|
set_etag(r);
|
|
|
|
#endif
|
|
|
|
}
|
2000-02-25 21:27:03 +00:00
|
|
|
/* Assume output will be of the default MIME type. Individual
|
|
|
|
scripts may change this later in the request. */
|
|
|
|
r->content_type = php_apache_get_default_mimetype(r SLS_CC);
|
1999-04-07 21:05:13 +00:00
|
|
|
|
|
|
|
/* Init timeout */
|
|
|
|
hard_timeout("send", r);
|
|
|
|
|
1999-05-11 00:01:47 +00:00
|
|
|
SG(server_context) = r;
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
php_save_umask();
|
2000-04-15 14:28:48 +00:00
|
|
|
V_CHDIR_FILE(filename);
|
1999-04-07 21:05:13 +00:00
|
|
|
add_common_vars(r);
|
|
|
|
add_cgi_vars(r);
|
1999-05-28 22:41:48 +00:00
|
|
|
|
|
|
|
init_request_info(SLS_C);
|
2000-07-10 07:57:01 +00:00
|
|
|
apache_php_module_main(r, display_source_mode CLS_CC ELS_CC PLS_CC SLS_CC);
|
1999-04-07 21:05:13 +00:00
|
|
|
|
|
|
|
/* Done, restore umask, turn off timeout, close file and return */
|
1999-05-28 03:54:15 +00:00
|
|
|
php_restore_umask();
|
1999-04-07 21:05:13 +00:00
|
|
|
kill_timeout(r);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
1999-04-26 14:00:49 +00:00
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
int send_parsed_php(request_rec * r)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-05-28 03:54:15 +00:00
|
|
|
return send_php(r, 0, NULL);
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-04-26 14:00:49 +00:00
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
int send_parsed_php_source(request_rec * r)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-07-03 18:13:43 +00:00
|
|
|
return send_php(r, 1, NULL);
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-04-26 14:00:49 +00:00
|
|
|
|
2000-01-17 17:33:37 +00:00
|
|
|
static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry)
|
1999-05-29 19:06:22 +00:00
|
|
|
{
|
|
|
|
free(per_dir_entry->key);
|
|
|
|
free(per_dir_entry->value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry)
|
|
|
|
{
|
|
|
|
php_per_dir_entry tmp = *per_dir_entry;
|
|
|
|
|
|
|
|
per_dir_entry->key = (char *) malloc(tmp.key_length+1);
|
|
|
|
memcpy(per_dir_entry->key, tmp.key, tmp.key_length);
|
|
|
|
per_dir_entry->key[per_dir_entry->key_length] = 0;
|
|
|
|
|
|
|
|
per_dir_entry->value = (char *) malloc(tmp.value_length+1);
|
|
|
|
memcpy(per_dir_entry->value, tmp.value, tmp.value_length);
|
|
|
|
per_dir_entry->value[per_dir_entry->value_length] = 0;
|
|
|
|
}
|
|
|
|
|
1999-09-20 11:54:06 +00:00
|
|
|
|
|
|
|
static void php_destroy_per_dir_info(HashTable *per_dir_info)
|
|
|
|
{
|
|
|
|
zend_hash_destroy(per_dir_info);
|
|
|
|
free(per_dir_info);
|
|
|
|
}
|
|
|
|
|
1999-05-29 19:06:22 +00:00
|
|
|
static void *php_create_dir(pool *p, char *dummy)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-05-29 19:06:22 +00:00
|
|
|
HashTable *per_dir_info;
|
|
|
|
|
|
|
|
per_dir_info = (HashTable *) malloc(sizeof(HashTable));
|
2000-01-17 17:33:37 +00:00
|
|
|
zend_hash_init(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1);
|
1999-09-20 11:54:06 +00:00
|
|
|
register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy);
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-05-29 19:06:22 +00:00
|
|
|
return per_dir_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *php_merge_dir(pool *p, void *basev, void *addv)
|
|
|
|
{
|
|
|
|
php_per_dir_entry tmp;
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-06-05 17:47:16 +00:00
|
|
|
zend_hash_merge((HashTable *) addv, (HashTable *) basev, (void (*)(void *)) copy_per_dir_entry, &tmp, sizeof(php_per_dir_entry), 0);
|
|
|
|
return addv;
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-04-09 21:15:07 +00:00
|
|
|
|
1999-07-15 19:26:25 +00:00
|
|
|
CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
|
1999-04-09 21:15:07 +00:00
|
|
|
{
|
1999-05-29 19:06:22 +00:00
|
|
|
php_per_dir_entry per_dir_entry;
|
|
|
|
|
|
|
|
if (!apache_php_initialized) {
|
2000-04-30 04:15:26 +00:00
|
|
|
apache_php_initialized = 1;
|
2000-05-04 03:28:34 +00:00
|
|
|
#ifdef ZTS
|
|
|
|
tsrm_startup(1, 1, 0);
|
|
|
|
#endif
|
2000-07-26 20:39:59 +00:00
|
|
|
sapi_startup(&sapi_module_conf);
|
|
|
|
php_apache_startup(&sapi_module_conf);
|
1999-05-29 16:03:49 +00:00
|
|
|
}
|
1999-07-15 19:26:25 +00:00
|
|
|
per_dir_entry.type = mode;
|
1999-05-29 19:06:22 +00:00
|
|
|
|
2000-03-02 14:32:24 +00:00
|
|
|
if (strcasecmp(arg2, "none") == 0) {
|
|
|
|
arg2 = "";
|
|
|
|
}
|
|
|
|
|
1999-05-29 19:06:22 +00:00
|
|
|
per_dir_entry.key_length = strlen(arg1);
|
|
|
|
per_dir_entry.value_length = strlen(arg2);
|
|
|
|
|
|
|
|
per_dir_entry.key = (char *) malloc(per_dir_entry.key_length+1);
|
|
|
|
memcpy(per_dir_entry.key, arg1, per_dir_entry.key_length);
|
|
|
|
per_dir_entry.key[per_dir_entry.key_length] = 0;
|
|
|
|
|
|
|
|
per_dir_entry.value = (char *) malloc(per_dir_entry.value_length+1);
|
|
|
|
memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length);
|
|
|
|
per_dir_entry.value[per_dir_entry.value_length] = 0;
|
|
|
|
|
|
|
|
zend_hash_update((HashTable *) conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL);
|
1999-04-09 21:15:07 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-15 19:34:26 +00:00
|
|
|
CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
|
1999-07-15 19:26:25 +00:00
|
|
|
{
|
1999-07-15 19:31:29 +00:00
|
|
|
return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);
|
1999-07-15 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-15 19:34:26 +00:00
|
|
|
CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
|
1999-07-15 19:26:25 +00:00
|
|
|
{
|
1999-07-15 19:31:29 +00:00
|
|
|
return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);
|
1999-07-15 19:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode)
|
1999-04-09 21:15:07 +00:00
|
|
|
{
|
|
|
|
char bool_val[2];
|
|
|
|
|
1999-07-24 14:40:08 +00:00
|
|
|
if (!strcasecmp(arg2, "On")) {
|
1999-04-09 21:15:07 +00:00
|
|
|
bool_val[0] = '1';
|
|
|
|
} else {
|
|
|
|
bool_val[0] = '0';
|
|
|
|
}
|
|
|
|
bool_val[1] = 0;
|
|
|
|
|
1999-07-15 19:26:25 +00:00
|
|
|
return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
|
1999-04-09 21:15:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-15 19:34:26 +00:00
|
|
|
CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
|
1999-07-15 19:31:29 +00:00
|
|
|
{
|
|
|
|
return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-15 19:34:26 +00:00
|
|
|
CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2)
|
1999-07-15 19:31:29 +00:00
|
|
|
{
|
|
|
|
return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
int php_xbithack_handler(request_rec * r)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-04-10 17:39:08 +00:00
|
|
|
php_apache_info_struct *conf;
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-05-22 09:24:21 +00:00
|
|
|
conf = (php_apache_info_struct *) get_module_config(r->per_dir_config, &php4_module);
|
1999-04-07 21:05:13 +00:00
|
|
|
if (!(r->finfo.st_mode & S_IXUSR)) {
|
|
|
|
r->allowed |= (1 << METHODS) - 1;
|
|
|
|
return DECLINED;
|
|
|
|
}
|
|
|
|
if (conf->xbithack == 0) {
|
|
|
|
r->allowed |= (1 << METHODS) - 1;
|
|
|
|
return DECLINED;
|
|
|
|
}
|
1999-05-28 03:54:15 +00:00
|
|
|
return send_parsed_php(r);
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-09-04 20:12:47 +00:00
|
|
|
static void apache_php_module_shutdown_wrapper(void)
|
1999-05-29 16:03:49 +00:00
|
|
|
{
|
1999-05-29 19:06:22 +00:00
|
|
|
apache_php_initialized = 0;
|
2000-07-31 15:07:58 +00:00
|
|
|
sapi_module_conf.shutdown(&sapi_module_conf);
|
2000-07-09 12:51:01 +00:00
|
|
|
|
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970728
|
|
|
|
/* This function is only called on server exit if the apache API
|
|
|
|
* child_exit handler exists, so shutdown globally
|
|
|
|
*/
|
|
|
|
sapi_shutdown();
|
|
|
|
#endif
|
|
|
|
|
2000-05-04 03:28:34 +00:00
|
|
|
#ifdef ZTS
|
|
|
|
tsrm_shutdown();
|
|
|
|
#endif
|
1999-05-29 16:03:49 +00:00
|
|
|
}
|
|
|
|
|
2000-07-09 12:51:01 +00:00
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970728
|
|
|
|
static void php_child_exit_handler(server_rec *s, pool *p)
|
|
|
|
{
|
|
|
|
/* apache_php_initialized = 0; */
|
2000-07-31 15:07:58 +00:00
|
|
|
sapi_module_conf.shutdown(&sapi_module_conf);
|
2000-07-09 12:51:01 +00:00
|
|
|
|
|
|
|
#ifdef ZTS
|
|
|
|
tsrm_shutdown();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
1999-04-26 14:00:49 +00:00
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
void php_init_handler(server_rec *s, pool *p)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-12-05 14:37:38 +00:00
|
|
|
register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec);
|
1999-05-29 19:06:22 +00:00
|
|
|
if (!apache_php_initialized) {
|
2000-04-30 04:15:26 +00:00
|
|
|
apache_php_initialized = 1;
|
2000-05-04 03:28:34 +00:00
|
|
|
#ifdef ZTS
|
|
|
|
tsrm_startup(1, 1, 0);
|
|
|
|
#endif
|
2000-07-26 20:39:59 +00:00
|
|
|
sapi_startup(&sapi_module_conf);
|
|
|
|
php_apache_startup(&sapi_module_conf);
|
1999-05-29 16:03:49 +00:00
|
|
|
}
|
1999-04-07 21:05:13 +00:00
|
|
|
#if MODULE_MAGIC_NUMBER >= 19980527
|
1999-12-17 14:24:39 +00:00
|
|
|
{
|
|
|
|
PLS_FETCH();
|
|
|
|
if (PG(expose_php)) {
|
|
|
|
ap_add_version_component("PHP/" PHP_VERSION);
|
|
|
|
}
|
1999-09-12 03:08:29 +00:00
|
|
|
}
|
1999-04-07 21:05:13 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_MOD_DAV
|
|
|
|
|
|
|
|
extern int phpdav_mkcol_test_handler(request_rec *r);
|
|
|
|
extern int phpdav_mkcol_create_handler(request_rec *r);
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
/* conf is being read twice (both here and in send_php()) */
|
|
|
|
int send_parsed_php_dav_script(request_rec *r)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-04-10 17:39:08 +00:00
|
|
|
php_apache_info_struct *conf;
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-04-10 17:39:08 +00:00
|
|
|
conf = (php_apache_info_struct *) get_module_config(r->per_dir_config,
|
1999-05-22 09:24:21 +00:00
|
|
|
&php4_module);
|
1999-05-28 03:54:15 +00:00
|
|
|
return send_php(r, 0, 0, conf->dav_script);
|
1999-04-07 21:05:13 +00:00
|
|
|
}
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
static int php_type_checker(request_rec *r)
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-04-10 17:39:08 +00:00
|
|
|
php_apache_info_struct *conf;
|
1999-04-07 21:05:13 +00:00
|
|
|
|
1999-04-10 17:39:08 +00:00
|
|
|
conf = (php_apache_info_struct *)get_module_config(r->per_dir_config,
|
1999-05-22 09:24:21 +00:00
|
|
|
&php4_module);
|
1999-04-07 21:05:13 +00:00
|
|
|
|
|
|
|
/* If DAV support is enabled, use mod_dav's type checker. */
|
|
|
|
if (conf->dav_script) {
|
1999-05-28 03:54:15 +00:00
|
|
|
dav_api_set_request_handler(r, send_parsed_php_dav_script);
|
1999-04-07 21:05:13 +00:00
|
|
|
dav_api_set_mkcol_handlers(r, phpdav_mkcol_test_handler,
|
|
|
|
phpdav_mkcol_create_handler);
|
|
|
|
/* leave the rest of the request to mod_dav */
|
|
|
|
return dav_api_type_checker(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DECLINED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* HAVE_MOD_DAV */
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
# define php_type_checker NULL
|
1999-04-07 21:05:13 +00:00
|
|
|
|
|
|
|
#endif /* HAVE_MOD_DAV */
|
|
|
|
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
handler_rec php_handlers[] =
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-05-29 16:03:49 +00:00
|
|
|
{"application/x-httpd-php", send_parsed_php},
|
|
|
|
{"application/x-httpd-php-source", send_parsed_php_source},
|
1999-05-28 03:54:15 +00:00
|
|
|
{"text/html", php_xbithack_handler},
|
1999-04-07 21:05:13 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-05-28 03:54:15 +00:00
|
|
|
command_rec php_commands[] =
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
1999-07-14 10:26:43 +00:00
|
|
|
{"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"},
|
1999-07-15 19:26:25 +00:00
|
|
|
{"php_flag", php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
|
|
|
|
{"php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
|
|
|
|
{"php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
|
1999-04-07 21:05:13 +00:00
|
|
|
{NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-05-22 09:24:21 +00:00
|
|
|
module MODULE_VAR_EXPORT php4_module =
|
1999-04-07 21:05:13 +00:00
|
|
|
{
|
|
|
|
STANDARD_MODULE_STUFF,
|
1999-05-28 03:54:15 +00:00
|
|
|
php_init_handler, /* initializer */
|
|
|
|
php_create_dir, /* per-directory config creator */
|
1999-05-29 19:06:22 +00:00
|
|
|
php_merge_dir, /* dir merger */
|
1999-04-07 21:05:13 +00:00
|
|
|
NULL, /* per-server config creator */
|
|
|
|
NULL, /* merge server config */
|
1999-05-28 03:54:15 +00:00
|
|
|
php_commands, /* command table */
|
|
|
|
php_handlers, /* handlers */
|
1999-04-07 21:05:13 +00:00
|
|
|
NULL, /* filename translation */
|
|
|
|
NULL, /* check_user_id */
|
|
|
|
NULL, /* check auth */
|
|
|
|
NULL, /* check access */
|
1999-05-28 03:54:15 +00:00
|
|
|
php_type_checker, /* type_checker */
|
1999-04-07 21:05:13 +00:00
|
|
|
NULL, /* fixups */
|
|
|
|
NULL /* logger */
|
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970103
|
|
|
|
,NULL /* header parser */
|
|
|
|
#endif
|
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970719
|
|
|
|
,NULL /* child_init */
|
|
|
|
#endif
|
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970728
|
2000-07-09 12:51:01 +00:00
|
|
|
,php_child_exit_handler /* child_exit */
|
1999-04-07 21:05:13 +00:00
|
|
|
#endif
|
|
|
|
#if MODULE_MAGIC_NUMBER >= 19970902
|
|
|
|
,NULL /* post read-request */
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2000-04-30 04:15:26 +00:00
|
|
|
|
1999-04-07 21:05:13 +00:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
*/
|