diff options
Diffstat (limited to 'sapi')
122 files changed, 0 insertions, 14257 deletions
diff --git a/sapi/Makefile.in b/sapi/Makefile.in deleted file mode 100644 index 089a1e4a65..0000000000 --- a/sapi/Makefile.in +++ /dev/null @@ -1,4 +0,0 @@ - -SUBDIRS = $(PHP_SAPI) - -include $(top_srcdir)/build/rules.mk diff --git a/sapi/README b/sapi/README deleted file mode 100644 index d9a759dd93..0000000000 --- a/sapi/README +++ /dev/null @@ -1,17 +0,0 @@ -Each SAPI backend has to contain: - -config.m4: just like for extensions, this file contains -autoconf directives that end up in the configure script. The -only difference is that the sapi config.m4 files are read in diversion -(output block) 2 instead of 3. The sapi config.m4 files should set -two variables: PHP_SAPI (which sapi backend to choose) and INSTALL_IT -(the actions performed when "make install" is executed). If they are -not specified, they will default to "cgi" and "do nothing," -respectively. Additionally, the following m4 macros can be used to -influence what is created during "make": - -PHP_BUILD_SHARED -- build shared target $SAPI_SHARED -PHP_BUILD_STATIC -- build static target $SAPI_STATIC -PHP_BUILD_PROGRAM -- build executable $SAPI_PROGRAM - -(paths relative to top build dir) diff --git a/sapi/aolserver/CREDITS b/sapi/aolserver/CREDITS deleted file mode 100644 index 8f9a4af950..0000000000 --- a/sapi/aolserver/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -AOLserver -Sascha Schumann diff --git a/sapi/aolserver/Makefile.in b/sapi/aolserver/Makefile.in deleted file mode 100644 index 96a33af6bd..0000000000 --- a/sapi/aolserver/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = aolserver.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/aolserver/README b/sapi/aolserver/README deleted file mode 100644 index 0a725a10bc..0000000000 --- a/sapi/aolserver/README +++ /dev/null @@ -1,69 +0,0 @@ -AOLserver README ($Id$) - -To compile PHP 4.0 as a module for AOLserver, you need: - -- installed AOLserver 3.1 or later - (see the note below for AOLserver 3.0) - -NOTE: You should not use this module in production. PHP is not 100% stable - yet in threaded mode. To increase reliability enable the Global Lock - by removing #define NO_GLOBAL_LOCK in main/main.c. Also don't use - php_value as it will lead to races in a sub-system (use an ini file - instead). - - -1.) Configuring AOLserver - -Read doc/install.txt in the source distribution - -It usually boils down to changing the INST/PREFIX variable in -include/Makefile.global and running make all install. - -2.) Configuring PHP - -$ ./configure \ - --with-aolserver=/path/to/installed/aolserver \ - <other options> - -NOTE: If you are still using AOLserver 3.0, you need to retain the - AOLserver source code and pass another option to PHP: - - --with-aolserver-src=/path/to/source/distribution - -3.) Compiling and Installing PHP - -$ make install - -4.) Changing nsd.tcl - -a) New section - -Add a new section to pass options to PHP (required): - -ns_section "ns/server/${servername}/module/php" - -You can use the following commands in this section: - -The 'map' command will cause AOLserver to pass all requests to *.php to -the PHP module (can be specified multiple times). Example: - -ns_param map *.php - -The 'php_value "name val"' command assigns the configuration option name -the value val (can be used multiple times). Example: - -ns_param php_value "session.auto_start 1" - -b) Enabling PHP - -Then enable the PHP module: - -ns_section "ns/server/${servername}/modules" -... -ns_param php ${bindir}/libphp4.so - - -============================================================================= -This has been tested with AOLserver release 3.0. - -AOLserver support has been written by Sascha Schumann <sascha@schumann.cx>. diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c deleted file mode 100644 index 3d2f0164f0..0000000000 --- a/sapi/aolserver/aolserver.c +++ /dev/null @@ -1,628 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* - * TODO: - * - write documentation - * - CGI/1.1 conformance - */ - -/* $Id$ */ - -/* conflict between PHP and AOLserver headers */ -#define Debug php_Debug -#include "php.h" -#undef Debug - -#ifdef HAVE_AOLSERVER - -#ifndef ZTS -#error AOLserver module is only useable in thread-safe mode -#endif - -#include "ext/standard/info.h" -#define SECTION(name) PUTS("<H2 align=\"center\">" name "</H2>\n") - -#define NS_BUF_SIZE 511 - -#include "php_ini.h" -#include "php_globals.h" -#include "SAPI.h" -#include "php_main.h" -#include "php_variables.h" - -#include "ns.h" - -#include "php_version.h" - -/* This symbol is used by AOLserver to tell the API version we expect */ - -int Ns_ModuleVersion = 1; - -#define NSG(v) TSRMG(ns_globals_id, ns_globals_struct *, v) - -/* php_ns_context is per-server (thus only once at all) */ - -typedef struct { - sapi_module_struct *sapi_module; - char *ns_server; - char *ns_module; -} php_ns_context; - -/* ns_globals_struct is per-thread */ - -typedef struct { - Ns_Conn *conn; - size_t data_avail; -} ns_globals_struct; - -/* TSRM id */ - -static int ns_globals_id; - -/* global context */ - -static php_ns_context *global_context; - -static void php_ns_config(php_ns_context *ctx, char global); - -/* - * php_ns_sapi_ub_write() writes data to the client connection. - */ - -static int -php_ns_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - int n; - uint sent = 0; - - while (str_length > 0) { - n = Ns_ConnWrite(NSG(conn), (void *) str, str_length); - - if (n == -1) - php_handle_aborted_connection(); - - str += n; - sent += n; - str_length -= n; - } - - return sent; -} - -/* - * php_ns_sapi_header_handler() sets a HTTP reply header to be - * sent to the client. - */ - -static int -php_ns_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers) -{ - char *header_name, *header_content; - char *p; - TSRMLS_FETCH(); - - header_name = sapi_header->header; - header_content = p = strchr(header_name, ':'); - - if (p) { - *p = '\0'; - do { - header_content++; - } while (*header_content == ' '); - - if (!strcasecmp(header_name, "Content-type")) { - Ns_ConnSetTypeHeader(NSG(conn), header_content); - } else { - Ns_ConnSetHeaders(NSG(conn), header_name, header_content); - } - - *p = ':'; - } - - sapi_free_header(sapi_header); - - return 0; -} - -/* - * php_ns_sapi_send_headers() flushes the headers to the client. - * Called before real content is sent by PHP. - */ - -static int -php_ns_sapi_send_headers(sapi_headers_struct *sapi_headers) -{ - TSRMLS_FETCH(); - - if(SG(sapi_headers).send_default_content_type) { - Ns_ConnSetRequiredHeaders(NSG(conn), "text/html", 0); - } - - Ns_ConnFlushHeaders(NSG(conn), SG(sapi_headers).http_response_code); - - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - -/* - * php_ns_sapi_read_post() reads a specified number of bytes from - * the client. Used for POST/PUT requests. - */ - -static int -php_ns_sapi_read_post(char *buf, uint count_bytes) -{ - uint max_read; - uint total_read = 0; - TSRMLS_FETCH(); - - max_read = MIN(NSG(data_avail), count_bytes); - - total_read = Ns_ConnRead(NSG(conn), buf, max_read); - - if(total_read == NS_ERROR) { - total_read = -1; - } else { - NSG(data_avail) -= total_read; - } - - return total_read; -} - -/* - * php_ns_sapi_read_cookies() returns the Cookie header from - * the HTTP request header - */ - -static char * -php_ns_sapi_read_cookies() -{ - int i; - char *http_cookie = NULL; - TSRMLS_FETCH(); - - i = Ns_SetIFind(NSG(conn->headers), "cookie"); - if(i != -1) { - http_cookie = Ns_SetValue(NSG(conn->headers), i); - } - - return http_cookie; -} - -static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS) -{ - char buf[512]; - int uptime = Ns_InfoUptime(); - int i; - TSRMLS_FETCH(); - - php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id$"); - php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); - php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); - php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); - php_info_print_table_row(2, "Installation path", Ns_InfoHomePath()); - php_info_print_table_row(2, "Hostname of server", Ns_InfoHostname()); - php_info_print_table_row(2, "Source code label", Ns_InfoLabel()); - php_info_print_table_row(2, "Server platform", Ns_InfoPlatform()); - snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); - php_info_print_table_row(2, "Server version", buf); - snprintf(buf, 511, "%d day(s), %02d:%02d:%02d", - uptime / 86400, - (uptime / 3600) % 24, - (uptime / 60) % 60, - uptime % 60); - php_info_print_table_row(2, "Server uptime", buf); - php_info_print_table_end(); - - SECTION("HTTP Headers Information"); - php_info_print_table_start(); - php_info_print_table_colspan_header(2, "HTTP Request Headers"); - php_info_print_table_row(2, "HTTP Request", NSG(conn)->request->line); - for (i = 0; i < Ns_SetSize(NSG(conn)->headers); i++) { - php_info_print_table_row(2, Ns_SetKey(NSG(conn)->headers, i), Ns_SetValue(NSG(conn)->headers, i)); - } - - php_info_print_table_colspan_header(2, "HTTP Response Headers"); - for (i = 0; i < Ns_SetSize(NSG(conn)->outputheaders); i++) { - php_info_print_table_row(2, Ns_SetKey(NSG(conn)->outputheaders, i), Ns_SetValue(NSG(conn)->outputheaders, i)); - } - php_info_print_table_end(); -} - -PHP_FUNCTION(getallheaders); - -static function_entry aolserver_functions[] = { - PHP_FE(getallheaders, NULL) - {0} -}; - -static zend_module_entry php_aolserver_module = { - "AOLserver", - aolserver_functions, - NULL, - NULL, - NULL, - NULL, - php_info_aolserver, - STANDARD_MODULE_PROPERTIES -}; - -PHP_FUNCTION(getallheaders) -{ - int i; - TSRMLS_FETCH(); - - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } - - for (i = 0; i < Ns_SetSize(NSG(conn->headers)); i++) { - char *key = Ns_SetKey(NSG(conn->headers), i); - char *value = Ns_SetValue(NSG(conn->headers), i); - - add_assoc_string(return_value, key, value, 1); - } -} - -static int -php_ns_startup(sapi_module_struct *sapi_module) -{ - if(php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_aolserver_module) == FAILURE) { - return FAILURE; - } else { - return SUCCESS; - } -} - - -/* - * php_ns_sapi_register_variables() populates the php script environment - * with a number of variables. HTTP_* variables are created for - * the HTTP header data, so that a script can access these. - */ - -#define ADD_STRINGX(name, buf) \ - php_register_variable(name, buf, track_vars_array TSRMLS_CC) - -#define ADD_STRING(name) \ - ADD_STRINGX(name, buf) - -static void -php_ns_sapi_register_variables(zval *track_vars_array TSRMLS_DC) -{ - int i; - char buf[NS_BUF_SIZE + 1]; - char *tmp; - - for(i = 0; i < Ns_SetSize(NSG(conn->headers)); i++) { - char *key = Ns_SetKey(NSG(conn->headers), i); - char *value = Ns_SetValue(NSG(conn->headers), i); - char *p; - char c; - int buf_len; - - buf_len = snprintf(buf, NS_BUF_SIZE, "HTTP_%s", key); - for(p = buf + 5; (c = *p); p++) { - c = toupper(c); - if(c < 'A' || c > 'Z') { - c = '_'; - } - *p = c; - } - - ADD_STRINGX(buf, value); - } - - snprintf(buf, NS_BUF_SIZE, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); - ADD_STRING("SERVER_SOFTWARE"); - snprintf(buf, NS_BUF_SIZE, "HTTP/%1.1f", NSG(conn)->request->version); - ADD_STRING("SERVER_PROTOCOL"); - - ADD_STRINGX("REQUEST_METHOD", NSG(conn)->request->method); - - if(NSG(conn)->request->query) - ADD_STRINGX("QUERY_STRING", NSG(conn)->request->query); - - ADD_STRINGX("SERVER_BUILDDATE", Ns_InfoBuildDate()); - - ADD_STRINGX("REMOTE_ADDR", Ns_ConnPeer(NSG(conn))); - - snprintf(buf, NS_BUF_SIZE, "%d", Ns_ConnPeerPort(NSG(conn))); - ADD_STRING("REMOTE_PORT"); - - snprintf(buf, NS_BUF_SIZE, "%d", Ns_ConnPort(NSG(conn))); - ADD_STRING("SERVER_PORT"); - - tmp = Ns_ConnHost(NSG(conn)); - if (tmp) - ADD_STRINGX("SERVER_NAME", tmp); - - ADD_STRINGX("PATH_TRANSLATED", SG(request_info).path_translated); - ADD_STRINGX("REQUEST_URI", SG(request_info).request_uri); - ADD_STRINGX("PHP_SELF", SG(request_info).request_uri); - - ADD_STRINGX("GATEWAY_INTERFACE", "CGI/1.1"); - - snprintf(buf, NS_BUF_SIZE, "%d", Ns_InfoBootTime()); - ADD_STRING("SERVER_BOOTTIME"); -} - - - -/* this structure is static (as in "it does not change") */ - -static sapi_module_struct aolserver_sapi_module = { - "aolserver", - "AOLserver", - - php_ns_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - NULL, /* activate */ - NULL, /* deactivate */ - - php_ns_sapi_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, /* error handler */ - - php_ns_sapi_header_handler, /* header handler */ - php_ns_sapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ - - php_ns_sapi_read_post, /* read POST data */ - php_ns_sapi_read_cookies, /* read Cookies */ - - php_ns_sapi_register_variables, - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -/* - * php_ns_module_main() is called by the per-request handler and - * "executes" the script - */ - -static int -php_ns_module_main(TSRMLS_D) -{ - zend_file_handle file_handle; - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - php_ns_config(global_context, 0); - if (php_request_startup(TSRMLS_C) == FAILURE) { - return NS_ERROR; - } - - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); - - return NS_OK; -} - -/* - * php_ns_request_ctor() initializes the per-request data structure - * and fills it with data provided by the web server - */ - -static void -php_ns_request_ctor(TSRMLS_D) -{ - char *server; - Ns_DString ds; - char *root; - int index; - char *tmp; - - server = Ns_ConnServer(NSG(conn)); - -#define safe_strdup(x) ((x)?strdup((x)):NULL) - SG(request_info).query_string = safe_strdup(NSG(conn->request->query)); - - Ns_DStringInit(&ds); - Ns_UrlToFile(&ds, server, NSG(conn->request->url)); - - /* path_translated is the absolute path to the file */ - SG(request_info).path_translated = safe_strdup(Ns_DStringValue(&ds)); - Ns_DStringFree(&ds); - root = Ns_PageRoot(server); - SG(request_info).request_uri = strdup(SG(request_info).path_translated + strlen(root)); - SG(request_info).request_method = NSG(conn)->request->method; - SG(request_info).content_length = Ns_ConnContentLength(NSG(conn)); - index = Ns_SetIFind(NSG(conn)->headers, "content-type"); - SG(request_info).content_type = index == -1 ? NULL : - Ns_SetValue(NSG(conn)->headers, index); - SG(sapi_headers).http_response_code = 200; - - tmp = Ns_ConnAuthUser(NSG(conn)); - if (tmp) - tmp = estrdup(tmp); - SG(request_info).auth_user = tmp; - - tmp = Ns_ConnAuthPasswd(NSG(conn)); - if (tmp) - tmp = estrdup(tmp); - SG(request_info).auth_password = tmp; - - NSG(data_avail) = SG(request_info).content_length; -} - -/* - * php_ns_request_dtor() destroys all data associated with - * the per-request structure - */ - -static void -php_ns_request_dtor(TSRMLS_D) -{ - free(SG(request_info).path_translated); - if (SG(request_info).query_string) - free(SG(request_info).query_string); - free(SG(request_info).request_uri); -} - -/* - * The php_ns_request_handler() is called per request and handles - * everything for one request. - */ - -static int -php_ns_request_handler(void *context, Ns_Conn *conn) -{ - int status = NS_OK; - TSRMLS_FETCH(); - - NSG(conn) = conn; - - SG(server_context) = global_context; - - php_ns_request_ctor(TSRMLS_C); - - status = php_ns_module_main(TSRMLS_C); - - php_ns_request_dtor(TSRMLS_C); - - return status; -} - -/* - * php_ns_config() fetches the configuration data. - * - * It understands the "map" and "php_value" command. - */ - -static void -php_ns_config(php_ns_context *ctx, char global) -{ - int i; - char *path; - Ns_Set *set; - - path = Ns_ConfigGetPath(ctx->ns_server, ctx->ns_module, NULL); - set = Ns_ConfigGetSection(path); - - for (i = 0; set && i < Ns_SetSize(set); i++) { - char *key = Ns_SetKey(set, i); - char *value = Ns_SetValue(set, i); - - if (global && !strcasecmp(key, "map")) { - Ns_Log(Notice, "Registering PHP for \"%s\"", value); - Ns_RegisterRequest(ctx->ns_server, "GET", value, php_ns_request_handler, NULL, ctx, 0); - Ns_RegisterRequest(ctx->ns_server, "POST", value, php_ns_request_handler, NULL, ctx, 0); - Ns_RegisterRequest(ctx->ns_server, "HEAD", value, php_ns_request_handler, NULL, ctx, 0); - - /* - * Deactivated for now. The ini system will cause random crashes when - * accessed from here (since there are no locks to protect the global - * known_directives) - */ - - } else if (!global && !strcasecmp(key, "php_value")) { - Ns_Log(Notice, "php_value has been deactivated temporarily. Please use a php.ini file to pass directives to PHP. Thanks."); -#if 0 - char *val; - - val = strchr(value, ' '); - if (val) { - char *new_key; - - new_key = estrndup(value, val - value); - - do { - val++; - } while(*val == ' '); - - Ns_Log(Debug, "PHP configuration option '%s=%s'", new_key, val); - zend_alter_ini_entry(new_key, strlen(new_key) + 1, val, - strlen(val) + 1, PHP_INI_SYSTEM, PHP_INI_STAGE_RUNTIME); - - efree(new_key); - } -#endif - } - - } -} - -/* - * php_ns_server_shutdown() performs the last steps before the - * server exits. Shutdowns basic services and frees memory - */ - -static void -php_ns_server_shutdown(void *context) -{ - php_ns_context *ctx = (php_ns_context *) context; - - ctx->sapi_module->shutdown(ctx->sapi_module); - sapi_shutdown(); - tsrm_shutdown(); - - free(ctx->ns_module); - free(ctx->ns_server); - free(ctx); -} - -/* - * Ns_ModuleInit() is called by AOLserver once at startup - * - * This functions allocates basic structures and initializes - * basic services. - */ - -int Ns_ModuleInit(char *server, char *module) -{ - php_ns_context *ctx; - - tsrm_startup(1, 1, 0, NULL); - sapi_startup(&aolserver_sapi_module); - sapi_module.startup(&aolserver_sapi_module); - - /* TSRM is used to allocate a per-thread structure */ - ts_allocate_id(&ns_globals_id, sizeof(ns_globals_struct), NULL, NULL); - - /* the context contains data valid for all threads */ - ctx = malloc(sizeof *ctx); - ctx->sapi_module = &aolserver_sapi_module; - ctx->ns_server = strdup(server); - ctx->ns_module = strdup(module); - - /* read the configuration */ - php_ns_config(ctx, 1); - - global_context = ctx; - - /* register shutdown handler */ - Ns_RegisterServerShutdown(server, php_ns_server_shutdown, ctx); - - return NS_OK; -} - -#endif diff --git a/sapi/aolserver/config.m4 b/sapi/aolserver/config.m4 deleted file mode 100644 index 790462d7c6..0000000000 --- a/sapi/aolserver/config.m4 +++ /dev/null @@ -1,32 +0,0 @@ -dnl ## $Id$ -*- sh -*- - -AC_MSG_CHECKING(for AOLserver support) -AC_ARG_WITH(aolserver, -[ --with-aolserver=DIR Specify path to the installed AOLserver],[ - PHP_AOLSERVER=$withval -],[ - PHP_AOLSERVER=no -]) -AC_MSG_RESULT($PHP_AOLSERVER) - -if test "$PHP_AOLSERVER" != "no"; then - if test -d "$PHP_AOLSERVER/include"; then - PHP_AOLSERVER_SRC=$PHP_AOLSERVER - fi - if test -z "$PHP_AOLSERVER_SRC" || test ! -d $PHP_AOLSERVER_SRC/include; then - AC_MSG_ERROR(Please specify the path to the source distribution of AOLserver using --with-aolserver-src=DIR) - fi - if test ! -d $PHP_AOLSERVER/bin ; then - AC_MSG_ERROR(Please specify the path to the root of AOLserver using --with-aolserver=DIR) - fi - PHP_BUILD_THREAD_SAFE - PHP_ADD_INCLUDE($PHP_AOLSERVER_SRC/include) - AC_DEFINE(HAVE_AOLSERVER,1,[Whether you have AOLserver]) - PHP_SAPI=aolserver - PHP_BUILD_SHARED - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PHP_AOLSERVER/bin/" -fi - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/aolserver/php.sym b/sapi/aolserver/php.sym deleted file mode 100644 index b401ffd2b3..0000000000 --- a/sapi/aolserver/php.sym +++ /dev/null @@ -1,2 +0,0 @@ -Ns_ModuleVersion -Ns_ModuleInit diff --git a/sapi/aolserver/php4aolserver.dsp b/sapi/aolserver/php4aolserver.dsp deleted file mode 100644 index 1d5a79598c..0000000000 --- a/sapi/aolserver/php4aolserver.dsp +++ /dev/null @@ -1,135 +0,0 @@ -# Microsoft Developer Studio Project File - Name="php4aolserver" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php4aolserver - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4aolserver.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4aolserver.mak" CFG="php4aolserver - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4aolserver - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4aolserver - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4aolserver - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4aolserver - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4AOLSERVER_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "NDEBUG" /D "PHP4AOLSERVER_EXPORTS" /D "PHP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "HAVE_AOLSERVER" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 nsd.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /version:4.0 /dll /machine:I386 /out:"../../Release_TS/php4aolserver.so" /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
-
-!ELSEIF "$(CFG)" == "php4aolserver - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS_inline"
-# PROP BASE Intermediate_Dir "Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4AOLSERVER_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "PHPAOLSERVER_EXPORTS" /D "PHP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "HAVE_AOLSERVER" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 nsd.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /version:4.0 /dll /machine:I386 /out:"../../Release_TS_inline/php4aolserver.so" /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
-
-!ELSEIF "$(CFG)" == "php4aolserver - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4AOLSERVER_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PHP4AOLSERVER_EXPORTS" /D "PHP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "WIN32" /D "_MBCS" /D "HAVE_AOLSERVER" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 nsd.lib php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /version:4.0 /dll /debug /machine:I386 /out:"..\..\Debug_TS/php4aolserver.so" /pdbtype:sept /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4aolserver - Win32 Release_TS"
-# Name "php4aolserver - Win32 Release_TS_inline"
-# Name "php4aolserver - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\aolserver.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/apache/CREDITS b/sapi/apache/CREDITS deleted file mode 100644 index 991deb5633..0000000000 --- a/sapi/apache/CREDITS +++ /dev/null @@ -1,3 +0,0 @@ -Apache 1.3 -Rasmus Lerdorf, Zeev Suraski, Stig Bakken, David Sklar - diff --git a/sapi/apache/Makefile.in b/sapi/apache/Makefile.in deleted file mode 100644 index 477b3a4762..0000000000 --- a/sapi/apache/Makefile.in +++ /dev/null @@ -1,7 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = sapi_apache.c mod_php4.c php_apache.c - -EXTRA_INCLUDES = $(APACHE_INCLUDE) - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/apache/apMakefile.libdir b/sapi/apache/apMakefile.libdir deleted file mode 100644 index 7b5254013a..0000000000 --- a/sapi/apache/apMakefile.libdir +++ /dev/null @@ -1,4 +0,0 @@ -This is a place-holder which indicates to Configure that it shouldn't -provide the default targets when building the Makefile in this directory. -Instead it'll just prepend all the important variable definitions, and -copy the Makefile.tmpl onto the end. diff --git a/sapi/apache/apMakefile.tmpl b/sapi/apache/apMakefile.tmpl deleted file mode 100644 index f77b9975ba..0000000000 --- a/sapi/apache/apMakefile.tmpl +++ /dev/null @@ -1,77 +0,0 @@ -## -## Apache 1.3 Makefile template for PHP 4.0 Module -## [src/modules/php4/Makefile.tmpl] -## - -# the parametrized target -LIB=libphp4.$(LIBEXT) - -# objects for building the static library -OBJS=mod_php4.o -OBJS_LIB=libmodphp4.a - -# objects for building the shared object library -SHLIB_OBJS=mod_php4.so-o -SHLIB_OBJS_LIB=libmodphp4.a - -# the general targets -all: lib -lib: $(LIB) - -# build the static library by merging the object files -libphp4.a: $(OBJS) $(OBJS_LIB) - cp $(OBJS_LIB) $@ - ar r $@ $(OBJS) - $(RANLIB) $@ - -# ugly hack to support older Apache-1.3 betas that don't set $LIBEXT -libphp4.: $(OBJS) $(OBJS_LIB) - cp $(OBJS_LIB) $@ - ar r $@ $(OBJS) - $(RANLIB) $@ - cp libphp4. libphp4.a - -# build the shared object library by linking the object files -libphp4.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) - rm -f $@ - $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) $(LIBS) - -# 1. extension .o for shared objects cannot be used here because -# first these files aren't still shared objects and second we -# have to use a different name to trigger the different -# implicit Make rule -# 2. extension -so.o (as used elsewhere) cannot be used because -# the suffix feature of Make really wants just .x, so we use -# extension .so-o -.SUFFIXES: .o .so-o -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(SPACER) $< -.c.so-o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $(CPPFLAGS) $(SPACER) $< && mv $*.o $*.so-o - -# cleanup -clean: - -rm -f $(OBJS) $(SHLIB_OBJS) $(LIB) - -# We really don't expect end users to use this rule. It works only with -# gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after -# using it. -depend: - cp Makefile.tmpl Makefile.tmpl.bak \ - && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \ - && gcc -MM $(INCLUDES) $(CFLAGS) $(CPPFLAGS) *.c >> Makefile.new \ - && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' Makefile.new \ - > Makefile.tmpl \ - && rm Makefile.new - -#Dependencies - -$(OBJS): Makefile - -# DO NOT REMOVE -mod_php4.o: mod_php4.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ - $(INCDIR)/buff.h \ - $(INCDIR)/http_config.h \ - $(INCDIR)/http_core.h $(INCDIR)/http_main.h \ - $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php4.h diff --git a/sapi/apache/config.m4 b/sapi/apache/config.m4 deleted file mode 100644 index 3cdb95566b..0000000000 --- a/sapi/apache/config.m4 +++ /dev/null @@ -1,237 +0,0 @@ -dnl ## -*- sh -*- - - -AC_MSG_CHECKING(for Apache module support via DSO through APXS) -AC_ARG_WITH(apxs, -[ --with-apxs[=FILE] Build shared Apache module. FILE is the optional - pathname to the Apache apxs tool; defaults to "apxs".],[ - if test "$withval" = "yes"; then - APXS=apxs - $APXS -q CFLAGS >/dev/null 2>&1 - if test "$?" != "0" && test -x /usr/sbin/apxs; then #SUSE 6.x - APXS=/usr/sbin/apxs - fi - else - PHP_EXPAND_PATH($withval, APXS) - fi - - $APXS -q CFLAGS >/dev/null 2>&1 - if test "$?" != "0"; then - AC_MSG_RESULT() - AC_MSG_RESULT() - AC_MSG_RESULT([Sorry, I was not able to successfully run APXS. Possible reasons:]) - AC_MSG_RESULT() - AC_MSG_RESULT([1. Perl is not installed;]) - AC_MSG_RESULT([2. Apache was not compiled with DSO support (--enable-module=so);]) - AC_MSG_RESULT([3. 'apxs' is not in your path. Try to use --with-apxs=/path/to/apxs]) - AC_MSG_RESULT([The output of $APXS follows]) - $APXS - AC_MSG_ERROR([Aborting]) - fi - - APXS_LDFLAGS="@SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@" - APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR` - APXS_CFLAGS=`$APXS -q CFLAGS` - for flag in $APXS_CFLAGS; do - case $flag in - -D*) CPPFLAGS="$CPPFLAGS $flag";; - esac - done - PHP_ADD_INCLUDE($APXS_INCLUDEDIR) - PHP_SAPI=apache - APACHE_INSTALL="\$(mkinstalldirs) \"\$(INSTALL_ROOT)`$APXS -q LIBEXECDIR`\" && $APXS -S LIBEXECDIR=\"\$(INSTALL_ROOT)`$APXS -q LIBEXECDIR`\" -i -a -n php4 $SAPI_SHARED" - PHP_BUILD_SHARED - if test -z "`$APXS -q LD_SHLIB`" || test "`$APXS -q LIBEXECDIR`" = "modules"; then - PHP_APXS_BROKEN=yes - fi - STRONGHOLD= - AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ]) - AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ]) - AC_MSG_RESULT(yes) - case $host_alias in - *aix*) - APXS_LIBEXECDIR=`$APXS -q LIBEXECDIR` - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp" - ;; - esac -],[ - AC_MSG_RESULT(no) -]) - -APACHE_INSTALL_FILES="\$(srcdir)/sapi/apache/mod_php4.* sapi/apache/libphp4.module" - -if test "$PHP_SAPI" != "apache"; then -AC_MSG_CHECKING(for Apache module support) -AC_ARG_WITH(apache, -[ --with-apache[=DIR] Build Apache module. DIR is the top-level Apache - build directory, defaults to /usr/local/etc/httpd.],[ - if test "$withval" = "yes"; then - # Apache's default directory - withval=/usr/local/apache - fi - if test "$withval" != "no"; then - APACHE_MODULE=yes - PHP_EXPAND_PATH($withval, withval) - # For Apache 1.2.x - if test -f $withval/src/httpd.h; then - APACHE_INCLUDE=-I$withval/src - APACHE_TARGET=$withval/src - PHP_SAPI=apache - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_INSTALL_FILES $APACHE_TARGET" - PHP_LIBS="-L. -lphp3" - AC_MSG_RESULT(yes - Apache 1.2.x) - STRONGHOLD= - if test -f $withval/src/ap_config.h; then - AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ]) - fi - # For Apache 2.0.x - elif test -f $withval/src/include/httpd.h && - test -f $withval/src/lib/apr/include/apr_general.h ; then - APACHE_HAS_REGEX=1 - APACHE_INCLUDE="-I$withval/src/include -I$withval/src/os/unix -I$withval/src/lib/apr/include" - APACHE_TARGET=$withval/src/modules/php4 - if test ! -d $APACHE_TARGET; then - mkdir $APACHE_TARGET - fi - PHP_SAPI=apache - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir" - PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4" - AC_MSG_RESULT(yes - Apache 2.0.X) - STRONGHOLD= - if test -f $withval/src/include/ap_config.h; then - AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ]) - fi - if test -f $withval/src/include/ap_compat.h; then - AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ]) - if test ! -f $withval/src/include/ap_config_auto.h; then - AC_MSG_ERROR(Please run Apache\'s configure or src/Configure program once and try again) - fi - else - if test -f $withval/src/include/compat.h; then - AC_DEFINE(HAVE_OLD_COMPAT_H,1,[ ]) - fi - fi - # For Apache 1.3.x - elif test -f $withval/src/main/httpd.h; then - APACHE_HAS_REGEX=1 - APACHE_INCLUDE="-I$withval/src/main -I$withval/src/os/unix -I$withval/src/ap" - APACHE_TARGET=$withval/src/modules/php4 - if test ! -d $APACHE_TARGET; then - mkdir $APACHE_TARGET - fi - PHP_SAPI=apache - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir" - PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4" - AC_MSG_RESULT(yes - Apache 1.3.x) - STRONGHOLD= - if test -f $withval/src/include/ap_config.h; then - AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ]) - fi - if test -f $withval/src/include/ap_compat.h; then - AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ]) - if test ! -f $withval/src/include/ap_config_auto.h; then - AC_MSG_ERROR(Please run Apache\'s configure or src/Configure program once and try again) - fi - else - if test -f $withval/src/include/compat.h; then - AC_DEFINE(HAVE_OLD_COMPAT_H,1,[ ]) - fi - fi - # Also for Apache 1.3.x - elif test -f $withval/src/include/httpd.h; then - APACHE_HAS_REGEX=1 - APACHE_INCLUDE="-I$withval/src/include -I$withval/src/os/unix" - APACHE_TARGET=$withval/src/modules/php4 - if test ! -d $APACHE_TARGET; then - mkdir $APACHE_TARGET - fi - PHP_SAPI=apache - PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4" - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir" - AC_MSG_RESULT(yes - Apache 1.3.x) - STRONGHOLD= - if test -f $withval/src/include/ap_config.h; then - AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ]) - fi - if test -f $withval/src/include/ap_compat.h; then - AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ]) - if test ! -f $withval/src/include/ap_config_auto.h; then - AC_MSG_ERROR(Please run Apache\'s configure or src/Configure program once and try again) - fi - else - if test -f $withval/src/include/compat.h; then - AC_DEFINE(HAVE_OLD_COMPAT_H,1,[ ]) - fi - fi - # For StrongHold 2.2 - elif test -f $withval/apache/httpd.h; then - APACHE_INCLUDE=-"I$withval/apache -I$withval/ssl/include" - APACHE_TARGET=$withval/apache - PHP_SAPI=apache - PHP_LIBS="-Lmodules/php4 -L../modules/php4 -L../../modules/php4 -lmodphp4" - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp4.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET" - STRONGHOLD=-DSTRONGHOLD=1 - AC_MSG_RESULT(yes - StrongHold) - if test -f $withval/apache/ap_config.h; then - AC_DEFINE(HAVE_AP_CONFIG_H,1,[ ]) - fi - if test -f $withval/src/ap_compat.h; then - AC_DEFINE(HAVE_AP_COMPAT_H,1,[ ]) - if test ! -f $withval/src/include/ap_config_auto.h; then - AC_MSG_ERROR(Please run Apache\'s configure or src/Configure program once and try again) - fi - else - if test -f $withval/src/compat.h; then - AC_DEFINE(HAVE_OLD_COMPAT_H,1,[ ]) - fi - fi - else - AC_MSG_RESULT(no) - AC_MSG_ERROR(Invalid Apache directory - unable to find httpd.h under $withval) - fi - else - AC_MSG_RESULT(no) - fi -],[ - AC_MSG_RESULT(no) -]) - - INCLUDES="$INCLUDES $APACHE_INCLUDE" -fi - -if test "x$APXS" != "x" -a "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then - APXS_EXP=-bE:sapi/apache/mod_php4.exp -fi - -PHP_SUBST(APXS_EXP) -PHP_SUBST(APACHE_INCLUDE) -PHP_SUBST(APACHE_TARGET) -PHP_SUBST(APXS) -PHP_SUBST(APXS_LDFLAGS) -PHP_SUBST(APACHE_INSTALL) -PHP_SUBST(STRONGHOLD) - -AC_MSG_CHECKING(for mod_charset compatibility option) -AC_ARG_WITH(mod_charset, -[ --with-mod_charset Enable transfer tables for mod_charset (Rus Apache).], -[ - AC_MSG_RESULT(yes) - AC_DEFINE(USE_TRANSFER_TABLES,1,[ ]) -],[ - AC_MSG_RESULT(no) -]) - -if test -n "$APACHE_MODULE"; then - PHP_TARGET_RDYNAMIC - $php_shtool mkdir -p sapi/apache - PHP_OUTPUT(sapi/apache/libphp4.module) - PHP_BUILD_STATIC -fi - -if test -n "$APACHE_INSTALL"; then - INSTALL_IT=$APACHE_INSTALL -fi - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/apache/libphp4.module.in b/sapi/apache/libphp4.module.in deleted file mode 100644 index 277394b722..0000000000 --- a/sapi/apache/libphp4.module.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: php4_module -ConfigStart - RULE_WANTHSREGEX=no - LIBS="@NATIVE_RPATHS@ @PHP_LDFLAGS@ @PHP_LIBS@ @EXTRA_LIBS@ $LIBS" - RULE_HIDE=yes - CFLAGS="$CFLAGS -I@abs_srcdir@ -I@abs_srcdir@/main -I@abs_builddir@/main -I@abs_srcdir@/Zend -I@abs_builddir@/Zend -I@abs_builddir@/TSRM -I@abs_srcdir@/TSRM -I@abs_builddir@" -ConfigEnd diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c deleted file mode 100644 index 1bcf3bccf4..0000000000 --- a/sapi/apache/mod_php4.c +++ /dev/null @@ -1,912 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Rasmus Lerdorf <rasmus@php.net> | - | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> | - | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#define NO_REGEX_EXTRA_H -#ifdef WIN32 -#include <winsock2.h> -#include <stddef.h> -#endif - -#include "zend.h" -#include "php.h" -#include "php_variables.h" - -#include "httpd.h" -#include "http_config.h" -#if MODULE_MAGIC_NUMBER > 19980712 -# include "ap_compat.h" -#else -# if MODULE_MAGIC_NUMBER > 19980324 -# include "compat.h" -# endif -#endif -#include "http_core.h" -#include "http_main.h" -#include "http_protocol.h" -#include "http_request.h" -#include "http_log.h" - -#include "php_ini.h" -#include "php_globals.h" -#include "SAPI.h" -#include "php_main.h" - -#include "zend_compile.h" -#include "zend_execute.h" -#include "zend_highlight.h" -#include "zend_indent.h" - -#include "ext/standard/php_standard.h" - -#include "util_script.h" - -#include "mod_php4.h" - -#undef shutdown - -/* {{{ Prototypes - */ -int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC); -void php_save_umask(void); -void php_restore_umask(void); -int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC); -char *sapi_apache_read_cookies(TSRMLS_D); -int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC); -int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC); -static int send_php(request_rec *r, int display_source_mode, char *filename); -static int send_parsed_php(request_rec * r); -static int send_parsed_php_source(request_rec * r); -int php_xbithack_handler(request_rec * r); -void php_init_handler(server_rec *s, pool *p); -/* }}} */ - -#if MODULE_MAGIC_NUMBER >= 19970728 -static void php_child_exit_handler(server_rec *s, pool *p); -#endif - -#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); - -/* ### these should be defined in mod_php4.h or somewhere else */ -#define USE_PATH 1 -#define IGNORE_URL 2 - -module MODULE_VAR_EXPORT php4_module; - -int saved_umask; -static unsigned char apache_php_initialized; - -typedef struct _php_per_dir_entry { - char *key; - char *value; - uint key_length; - uint value_length; - int type; -} php_per_dir_entry; - -/* some systems are missing these from their header files */ - -/* {{{ php_save_umask - */ -void php_save_umask(void) -{ - saved_umask = umask(077); - umask(saved_umask); -} -/* }}} */ - -/* {{{ sapi_apache_ub_write - */ -static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - int ret=0; - - if (SG(server_context)) { - ret = rwrite(str, str_length, (request_rec *) SG(server_context)); - } - if (ret != str_length) { - php_handle_aborted_connection(); - } - return ret; -} -/* }}} */ - -/* {{{ sapi_apache_flush - */ -static void sapi_apache_flush(void *server_context) -{ - if (server_context) { -#if MODULE_MAGIC_NUMBER > 19970110 - rflush((request_rec *) server_context); -#else - bflush((request_rec *) server_context->connection->client); -#endif - } -} -/* }}} */ - -/* {{{ sapi_apache_read_post - */ -int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - 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; -} -/* }}} */ - -/* {{{ sapi_apache_read_cookies - */ -char *sapi_apache_read_cookies(TSRMLS_D) -{ - return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, "HTTP_COOKIE"); -} -/* }}} */ - -/* {{{ sapi_apache_header_handler - */ -int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_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 { - header_content++; - } while (*header_content==' '); - - if (!strcasecmp(header_name, "Content-Type")) { - r->content_type = pstrdup(r->pool, header_content); - } else if (!strcasecmp(header_name, "Set-Cookie")) { - table_add(r->headers_out, header_name, header_content); - } else { - table_set(r->headers_out, header_name, header_content); - } - - *p = ':'; /* a well behaved header handler shouldn't change its original arguments */ - - efree(sapi_header->header); - - return 0; /* don't use the default SAPI mechanism, Apache duplicates this functionality */ -} -/* }}} */ - -/* {{{ sapi_apache_send_headers - */ -int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - if(SG(server_context) == NULL) { /* server_context is not here anymore */ - return SAPI_HEADER_SEND_FAILED; - } - - ((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code; - send_http_header((request_rec *) SG(server_context)); - return SAPI_HEADER_SENT_SUCCESSFULLY; -} -/* }}} */ - -/* {{{ sapi_apache_register_server_variables - */ -static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_DC) -{ - register int i; - array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env); - table_entry *elts = (table_entry *) arr->elts; - zval **path_translated; - HashTable *symbol_table; - - for (i = 0; i < arr->nelts; i++) { - char *val; - - if (elts[i].val) { - val = elts[i].val; - } else { - val = empty_string; - } - php_register_variable(elts[i].key, val, track_vars_array TSRMLS_CC); - } - - /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */ - if (track_vars_array) { - symbol_table = track_vars_array->value.ht; - } else if (PG(register_globals)) { - /* should never happen nowadays */ - symbol_table = EG(active_symbol_table); - } else { - symbol_table = NULL; - } - if (symbol_table - && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")) - && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)==SUCCESS) { - php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array TSRMLS_CC); - } - - php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array TSRMLS_CC); -} -/* }}} */ - -/* {{{ php_apache_startup - */ -static int php_apache_startup(sapi_module_struct *sapi_module) -{ - if (php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&apache_module_entry) == FAILURE) { - return FAILURE; - } else { - return SUCCESS; - } -} -/* }}} */ - -/* {{{ php_apache_log_message - */ -static void php_apache_log_message(char *message) -{ - TSRMLS_FETCH(); - - if (SG(server_context)) { -#if MODULE_MAGIC_NUMBER >= 19970831 - aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, "%s", message); -#else - log_error(message, ((request_rec *) SG(server_context))->server); -#endif - } else { - fprintf(stderr, "%s", message); - fprintf(stderr, "\n"); - } -} -/* }}} */ - -/* {{{ php_apache_request_shutdown - */ -static void php_apache_request_shutdown(void *dummy) -{ - TSRMLS_FETCH(); - - php_output_set_status(0 TSRMLS_CC); - SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */ - if (AP(in_request)) { - AP(in_request) = 0; - php_request_shutdown(dummy); - } -} -/* }}} */ - -/* {{{ php_apache_sapi_activate - */ -static int php_apache_sapi_activate(TSRMLS_D) -{ - request_rec *r = (request_rec *) SG(server_context); - - /* - * 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(); - register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec); - AP(in_request)=1; - unblock_alarms(); - - /* Override the default headers_only value - sometimes "GET" requests should actually only - * send headers. - */ - SG(request_info).headers_only = r->header_only; - return SUCCESS; -} -/* }}} */ - -/* {{{ php_apache_get_stat - */ -static struct stat *php_apache_get_stat(TSRMLS_D) -{ - return &((request_rec *) SG(server_context))->finfo; -} -/* }}} */ - -/* {{{ php_apache_getenv - */ -static char *php_apache_getenv(char *name, size_t name_len TSRMLS_DC) -{ - return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name); -} -/* }}} */ - -/* {{{ sapi_module_struct apache_sapi_module - */ -static sapi_module_struct apache_sapi_module = { - "apache", /* name */ - "Apache", /* pretty name */ - - php_apache_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - php_apache_sapi_activate, /* activate */ - NULL, /* deactivate */ - - sapi_apache_ub_write, /* unbuffered write */ - sapi_apache_flush, /* flush */ - php_apache_get_stat, /* get uid */ - php_apache_getenv, /* getenv */ - - php_error, /* error handler */ - - sapi_apache_header_handler, /* header handler */ - sapi_apache_send_headers, /* send headers handler */ - NULL, /* send header handler */ - - sapi_apache_read_post, /* read POST data */ - sapi_apache_read_cookies, /* read Cookies */ - - sapi_apache_register_server_variables, /* register server variables */ - php_apache_log_message, /* Log message */ - - NULL, /* php.ini path override */ - -#ifdef PHP_WIN32 - NULL, - NULL, -#else - block_alarms, /* Block interruptions */ - unblock_alarms, /* Unblock interruptions */ -#endif - - STANDARD_SAPI_MODULE_PROPERTIES -}; -/* }}} */ - -/* {{{ php_restore_umask - */ -void php_restore_umask(void) -{ - umask(saved_umask); -} -/* }}} */ - -/* {{{ init_request_info - */ -static void init_request_info(TSRMLS_D) -{ - request_rec *r = ((request_rec *) SG(server_context)); - char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH"); - const char *authorization=NULL; - char *tmp; - - SG(request_info).query_string = r->args; - SG(request_info).path_translated = r->filename; - SG(request_info).request_uri = r->uri; - SG(request_info).request_method = (char *)r->method; - SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE"); - SG(request_info).content_length = (content_length ? atoi(content_length) : 0); - SG(sapi_headers).http_response_code = r->status; - - if (r->headers_in) { - authorization = table_get(r->headers_in, "Authorization"); - } - if (authorization -/* && !auth_type(r) */ - && !strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) { - tmp = uudecode(r->pool, authorization); - SG(request_info).auth_user = getword_nulls_nc(r->pool, &tmp, ':'); - if (SG(request_info).auth_user) { - r->connection->user = pstrdup(r->connection->pool, SG(request_info).auth_user); - r->connection->ap_auth_type = "Basic"; - 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; - } -} -/* }}} */ - -/* {{{ php_apache_alter_ini_entries - */ -static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_DC) -{ - zend_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, PHP_INI_STAGE_ACTIVATE); - return 0; -} -/* }}} */ - -/* {{{ php_apache_get_default_mimetype - */ -static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_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(TSRMLS_C); - mimetype = pstrdup(r->pool, tmpmimetype); - efree(tmpmimetype); - } else { - mimetype = SAPI_DEFAULT_MIMETYPE "; charset=" SAPI_DEFAULT_CHARSET; - } - return mimetype; -} -/* }}} */ - -/* {{{ send_php - */ -static int send_php(request_rec *r, int display_source_mode, char *filename) -{ - int retval; - HashTable *per_dir_conf; - TSRMLS_FETCH(); - - if (AP(in_request)) { - zend_file_handle fh; - - fh.filename = r->filename; - fh.opened_path = NULL; - fh.free_filename = 0; - fh.type = ZEND_HANDLE_FILENAME; - zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, 1, &fh); - return OK; - } - - zend_first_try { - /* 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) { - return DECLINED; - } - - per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module); - if (per_dir_conf) { - zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC); - } - - /* If PHP parser engine has been turned off with an "engine off" - * directive, then decline to handle this request - */ - if (!AP(engine)) { - r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC); - r->allowed |= (1 << METHODS) - 1; - zend_try { - zend_ini_deactivate(TSRMLS_C); - } zend_end_try(); - 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))) { - zend_try { - zend_ini_deactivate(TSRMLS_C); - } zend_end_try(); - return retval; - } -#endif - - if (AP(last_modified)) { -#if MODULE_MAGIC_NUMBER < 19970912 - if ((retval = set_last_modified(r, r->finfo.st_mtime))) { - zend_try { - zend_ini_deactivate(TSRMLS_C); - } zend_end_try(); - return retval; - } -#else - update_mtime (r, r->finfo.st_mtime); - set_last_modified(r); - set_etag(r); -#endif - } - /* 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 TSRMLS_CC); - - /* Init timeout */ - hard_timeout("send", r); - - SG(server_context) = r; - - php_save_umask(); - add_common_vars(r); - add_cgi_vars(r); - - init_request_info(TSRMLS_C); - apache_php_module_main(r, display_source_mode TSRMLS_CC); - - /* Done, restore umask, turn off timeout, close file and return */ - php_restore_umask(); - kill_timeout(r); - } zend_end_try(); - - return OK; -} -/* }}} */ - -/* {{{ send_parsed_php - */ -static int send_parsed_php(request_rec * r) -{ - int result = send_php(r, 0, NULL); - -#if MEMORY_LIMIT - { - char mem_usage[ 32 ]; - TSRMLS_FETCH(); - - sprintf(mem_usage,"%u", (int) AG(allocated_memory_peak)); - ap_table_setn(r->notes, "mod_php_memory_usage", ap_pstrdup(r->pool, mem_usage)); - } -#endif - - return result; -} -/* }}} */ - -/* {{{ send_parsed_php_source - */ -static int send_parsed_php_source(request_rec * r) -{ - return send_php(r, 1, NULL); -} -/* }}} */ - -/* {{{ estroy_per_dir_entry - */ -static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry) -{ - free(per_dir_entry->key); - free(per_dir_entry->value); -} -/* }}} */ - -/* {{{ copy_per_dir_entry - */ -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; -} -/* }}} */ - -/* {{{ should_overwrite_per_dir_entry - */ -static zend_bool should_overwrite_per_dir_entry(php_per_dir_entry *orig_per_dir_entry, php_per_dir_entry *new_per_dir_entry) -{ - if (new_per_dir_entry->type==PHP_INI_SYSTEM - && orig_per_dir_entry->type!=PHP_INI_SYSTEM) { - return 1; - } else { - return 0; - } -} -/* }}} */ - -/* {{{ php_destroy_per_dir_info - */ -static void php_destroy_per_dir_info(HashTable *per_dir_info) -{ - zend_hash_destroy(per_dir_info); - free(per_dir_info); -} -/* }}} */ - -/* {{{ php_create_dir - */ -static void *php_create_dir(pool *p, char *dummy) -{ - HashTable *per_dir_info; - - per_dir_info = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1); - register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy); - - return per_dir_info; -} -/* }}} */ - -/* {{{ php_merge_dir - */ -static void *php_merge_dir(pool *p, void *basev, void *addv) -{ - /* This function *must* return addv, and not modify basev */ - zend_hash_merge_ex((HashTable *) addv, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (zend_bool (*)(void *, void *)) should_overwrite_per_dir_entry); - return addv; -} -/* }}} */ - -/* {{{ php_apache_value_handler_ex - */ -CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode) -{ - php_per_dir_entry per_dir_entry; - - if (!apache_php_initialized) { - apache_php_initialized = 1; -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); -#endif - sapi_startup(&apache_sapi_module); - php_apache_startup(&apache_sapi_module); - } - per_dir_entry.type = mode; - - if (strcasecmp(arg2, "none") == 0) { - arg2 = ""; - } - - 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); - return NULL; -} -/* }}} */ - -/* {{{ php_apache_value_handler - */ -CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR); -} -/* }}} */ - -/* {{{ php_apache_admin_value_handler - */ -CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM); -} -/* }}} */ - -/* {{{ php_apache_flag_handler_ex - */ -CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode) -{ - char bool_val[2]; - - if (!strcasecmp(arg2, "On")) { - bool_val[0] = '1'; - } else { - bool_val[0] = '0'; - } - bool_val[1] = 0; - - return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode); -} -/* }}} */ - -/* {{{ php_apache_flag_handler - */ -CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR); -} -/* }}} */ - -/* {{{ php_apache_admin_flag_handler - */ -CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM); -} -/* }}} */ - -/* {{{ int php_xbithack_handler(request_rec * r) - */ -int php_xbithack_handler(request_rec * r) -{ - php_apache_info_struct *conf; - - conf = (php_apache_info_struct *) get_module_config(r->per_dir_config, &php4_module); - 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; - } - return send_parsed_php(r); -} -/* }}} */ - -/* {{{ apache_php_module_shutdown_wrapper - */ -static void apache_php_module_shutdown_wrapper(void) -{ - apache_php_initialized = 0; - apache_sapi_module.shutdown(&apache_sapi_module); - -#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 - -#ifdef ZTS - tsrm_shutdown(); -#endif -} -/* }}} */ - -#if MODULE_MAGIC_NUMBER >= 19970728 -/* {{{ php_child_exit_handler - */ -static void php_child_exit_handler(server_rec *s, pool *p) -{ -/* apache_php_initialized = 0; */ - apache_sapi_module.shutdown(&apache_sapi_module); - -#ifdef ZTS - tsrm_shutdown(); -#endif -} -/* }}} */ -#endif - -/* {{{ void php_init_handler(server_rec *s, pool *p) - */ -void php_init_handler(server_rec *s, pool *p) -{ - register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec); - if (!apache_php_initialized) { - apache_php_initialized = 1; -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); -#endif - sapi_startup(&apache_sapi_module); - php_apache_startup(&apache_sapi_module); - } -#if MODULE_MAGIC_NUMBER >= 19980527 - { - TSRMLS_FETCH(); - if (PG(expose_php)) { - ap_add_version_component("PHP/" PHP_VERSION); - } - } -#endif -} -/* }}} */ - -/* {{{ handler_rec php_handlers[] - */ -handler_rec php_handlers[] = -{ - {"application/x-httpd-php", send_parsed_php}, - {"application/x-httpd-php-source", send_parsed_php_source}, - {"text/html", php_xbithack_handler}, - {NULL} -}; -/* }}} */ - -/* {{{ command_rec php_commands[] - */ -command_rec php_commands[] = -{ - {"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"}, - {"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)"}, - {NULL} -}; -/* }}} */ - -/* {{{ odule MODULE_VAR_EXPORT php4_module - */ -module MODULE_VAR_EXPORT php4_module = -{ - STANDARD_MODULE_STUFF, - php_init_handler, /* initializer */ - php_create_dir, /* per-directory config creator */ - php_merge_dir, /* dir merger */ - NULL, /* per-server config creator */ - NULL, /* merge server config */ - php_commands, /* command table */ - php_handlers, /* handlers */ - NULL, /* filename translation */ - NULL, /* check_user_id */ - NULL, /* check auth */ - NULL, /* check access */ - NULL, /* type_checker */ - 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 - , php_child_exit_handler /* child_exit */ -#endif -#if MODULE_MAGIC_NUMBER >= 19970902 - , NULL /* post read-request */ -#endif -}; -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/sapi/apache/mod_php4.exp b/sapi/apache/mod_php4.exp deleted file mode 100644 index 2dca1256c2..0000000000 --- a/sapi/apache/mod_php4.exp +++ /dev/null @@ -1 +0,0 @@ -php4_module diff --git a/sapi/apache/mod_php4.h b/sapi/apache/mod_php4.h deleted file mode 100644 index 92229e8cf3..0000000000 --- a/sapi/apache/mod_php4.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Rasmus Lerdorf <rasmus@php.net> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#ifndef MOD_PHP4_H -#define MOD_PHP4_H - -#if !defined(WIN32) && !defined(WINNT) -#ifndef MODULE_VAR_EXPORT -#define MODULE_VAR_EXPORT -#endif -#endif - -typedef struct { - long engine; - long last_modified; - long xbithack; - long terminate_child; - zend_bool in_request; -} php_apache_info_struct; - -extern zend_module_entry apache_module_entry; - -#ifdef ZTS -extern int php_apache_info_id; -#define AP(v) TSRMG(alloc_globals_id, php_apache_info_struct *, v) -#else -extern php_apache_info_struct php_apache_info; -#define AP(v) (php_apache_info.v) -#endif - - -#ifdef WIN32 -#define S_IXUSR _S_IEXEC -#endif - -#endif /* MOD_PHP4_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/sapi/apache/php.sym b/sapi/apache/php.sym deleted file mode 100644 index 2dca1256c2..0000000000 --- a/sapi/apache/php.sym +++ /dev/null @@ -1 +0,0 @@ -php4_module diff --git a/sapi/apache/php4apache.dsp b/sapi/apache/php4apache.dsp deleted file mode 100644 index 87508b3065..0000000000 --- a/sapi/apache/php4apache.dsp +++ /dev/null @@ -1,151 +0,0 @@ -# Microsoft Developer Studio Project File - Name="php4apache" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php4apache - Win32 Release_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4apache.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4apache.mak" CFG="php4apache - Win32 Release_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4apache - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4apache - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4apache - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4apache - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP4_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\apache\src\include" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP4_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts.lib ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x60000000" /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\apache\src\corer" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
-
-!ELSEIF "$(CFG)" == "php4apache - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP4_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\apache\src\include" /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP4_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts_debug.lib ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x60000000" /version:4.0 /dll /incremental:yes /debug /machine:I386 /out:"..\..\Debug_TS/php4apache.dll" /pdbtype:sept /libpath:"..\..\..\php_build\apache\src\cored" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
-
-!ELSEIF "$(CFG)" == "php4apache - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS_inline"
-# PROP BASE Intermediate_Dir "Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "APACHEPHP4_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\..\php_build\apache\src\include" /I "..\..\main" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "APACHEPHP4_EXPORTS" /D "WIN32" /D "_MBCS" /D "APACHE_READDIR_H" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts.lib ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /dll /machine:I386 /libpath:"\apache\src\corer" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4apache - Win32 Release_TS"
-# Name "php4apache - Win32 Debug_TS"
-# Name "php4apache - Win32 Release_TS_inline"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\mod_php4.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_apache.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\sapi_apache.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\mod_php4.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_apache_http.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c deleted file mode 100644 index 7140501cf6..0000000000 --- a/sapi/apache/php_apache.c +++ /dev/null @@ -1,466 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - | Stig Sæther Bakken <ssb@guardian.no> | - | David Sklar <sklar@student.net> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#define NO_REGEX_EXTRA_H - -#ifdef WIN32 -#include <winsock2.h> -#include <stddef.h> -#endif - -#include "php.h" -#include "ext/standard/head.h" -#include "php_globals.h" -#include "php_ini.h" -#include "SAPI.h" -#include "mod_php4.h" -#include "ext/standard/info.h" - -#include <stdlib.h> -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <string.h> -#include <errno.h> -#include <ctype.h> - -#include "php_apache_http.h" -#include "http_request.h" - -#ifdef ZTS -int php_apache_info_id; -#else -php_apache_info_struct php_apache_info; -#endif - -#ifdef PHP_WIN32 -#include "zend.h" -#include "ap_compat.h" -#else -#include "build-defs.h" -#endif - -#define SECTION(name) PUTS("<H2 align=\"center\">" name "</H2>\n") - -extern module *top_module; - -PHP_FUNCTION(virtual); -PHP_FUNCTION(getallheaders); -PHP_FUNCTION(apachelog); -PHP_FUNCTION(apache_note); -PHP_FUNCTION(apache_lookup_uri); -PHP_FUNCTION(apache_child_terminate); - -PHP_MINFO_FUNCTION(apache); - -function_entry apache_functions[] = { - PHP_FE(virtual, NULL) - PHP_FE(getallheaders, NULL) - PHP_FE(apache_note, NULL) - PHP_FE(apache_lookup_uri, NULL) - PHP_FE(apache_child_terminate, NULL) - {NULL, NULL, NULL} -}; - - -PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateInt, xbithack, php_apache_info_struct, php_apache_info) - STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateInt, engine, php_apache_info_struct, php_apache_info) - STD_PHP_INI_ENTRY("last_modified", "0", PHP_INI_ALL, OnUpdateInt, last_modified, php_apache_info_struct, php_apache_info) - STD_PHP_INI_ENTRY("child_terminate", "0", PHP_INI_ALL, OnUpdateInt, terminate_child, php_apache_info_struct, php_apache_info) -PHP_INI_END() - - - -static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRMLS_DC) -{ - apache_globals->in_request = 0; -} - - -static PHP_MINIT_FUNCTION(apache) -{ -#ifdef ZTS - ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), php_apache_globals_ctor, NULL); -#else - php_apache_globals_ctor(&php_apache_info TSRMLS_CC); -#endif - REGISTER_INI_ENTRIES(); - return SUCCESS; -} - - -static PHP_MSHUTDOWN_FUNCTION(apache) -{ - UNREGISTER_INI_ENTRIES(); - return SUCCESS; -} - - -zend_module_entry apache_module_entry = { - "apache", apache_functions, PHP_MINIT(apache), PHP_MSHUTDOWN(apache), NULL, NULL, PHP_MINFO(apache), STANDARD_MODULE_PROPERTIES -}; - -/* {{{ proto string child_terminate() - Get and set Apache request notes */ -PHP_FUNCTION(apache_child_terminate) -{ -#ifndef MULTITHREAD - if (AP(terminate_child)) { - ap_child_terminate( ((request_rec *)SG(server_context)) ); - } else { /* tell them to get lost! */ - php_error(E_WARNING, "apache.child_terminate is disabled"); - } -#else - php_error(E_WARNING, "apache_child_terminate() is not supported in this build"); -#endif -} -/* }}} */ - -/* {{{ proto string apache_note(string note_name [, string note_value]) - Get and set Apache request notes */ -PHP_FUNCTION(apache_note) -{ - pval **arg_name, **arg_val; - char *note_val; - int arg_count = ARG_COUNT(ht); - TSRMLS_FETCH(); - - if (arg_count<1 || arg_count>2 || - zend_get_parameters_ex(arg_count, &arg_name, &arg_val) ==FAILURE ) { - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(arg_name); - note_val = (char *) table_get(((request_rec *)SG(server_context))->notes, (*arg_name)->value.str.val); - - if (arg_count == 2) { - convert_to_string_ex(arg_val); - table_set(((request_rec *)SG(server_context))->notes, (*arg_name)->value.str.val, (*arg_val)->value.str.val); - } - - if (note_val) { - RETURN_STRING(note_val, 1); - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ PHP_MINFO_FUNCTION - */ -PHP_MINFO_FUNCTION(apache) -{ - module *modp = NULL; - char output_buf[128]; -#if !defined(WIN32) && !defined(WINNT) - char name[64]; - char modulenames[1024]; - char *p; -#endif - 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; - - serv = ((request_rec *) SG(server_context))->server; - - - php_info_print_table_start(); - -#ifdef PHP_WIN32 - php_info_print_table_row(1, "Apache for Windows 95/NT"); - php_info_print_table_end(); - php_info_print_table_start(); -#else - php_info_print_table_row(2, "APACHE_INCLUDE", PHP_APACHE_INCLUDE); - php_info_print_table_row(2, "APACHE_TARGET", PHP_APACHE_TARGET); -#endif - - php_info_print_table_row(2, "Apache Version", SERVER_VERSION); - -#ifdef APACHE_RELEASE - sprintf(output_buf, "%d", APACHE_RELEASE); - php_info_print_table_row(2, "Apache Release", output_buf); -#endif - sprintf(output_buf, "%d", MODULE_MAGIC_NUMBER); - php_info_print_table_row(2, "Apache API Version", output_buf); - sprintf(output_buf, "%s:%u", serv->server_hostname, serv->port); - php_info_print_table_row(2, "Hostname:Port", output_buf); -#if !defined(WIN32) && !defined(WINNT) - sprintf(output_buf, "%s(%d)/%d", user_name, (int)user_id, (int)group_id); - php_info_print_table_row(2, "User/Group", output_buf); - sprintf(output_buf, "Per Child: %d<br>Keep Alive: %s<br>Max Per Connection: %d", max_requests_per_child, serv->keep_alive ? "on":"off", serv->keep_alive_max); - php_info_print_table_row(2, "Max Requests", output_buf); -#endif - sprintf(output_buf, "Connection: %d<br>Keep-Alive: %d", serv->timeout, serv->keep_alive_timeout); - php_info_print_table_row(2, "Timeouts", output_buf); -#if !defined(WIN32) && !defined(WINNT) - php_info_print_table_row(2, "Server Root", server_root); - - strcpy(modulenames, ""); - for(modp = top_module; modp; modp = modp->next) { - strlcpy(name, modp->name, sizeof(name)); - if ((p = strrchr(name, '.'))) { - *p='\0'; /* Cut off ugly .c extensions on module names */ - } - strcat(modulenames, name); - if (modp->next) { - strcat(modulenames, ", "); - } - } - php_info_print_table_row(2, "Loaded Modules", modulenames); -#endif - - php_info_print_table_end(); - - DISPLAY_INI_ENTRIES(); - - { - register int i; - array_header *arr; - table_entry *elts; - request_rec *r; - - r = ((request_rec *) SG(server_context)); - arr = table_elts(r->subprocess_env); - elts = (table_entry *)arr->elts; - - SECTION("Apache Environment"); - php_info_print_table_start(); - php_info_print_table_header(2, "Variable", "Value"); - for (i=0; i < arr->nelts; i++) { - php_info_print_table_row(2, elts[i].key, elts[i].val); - } - php_info_print_table_end(); - } - - { - array_header *env_arr; - table_entry *env; - int i; - request_rec *r; - - r = ((request_rec *) SG(server_context)); - SECTION("HTTP Headers Information"); - php_info_print_table_start(); - php_info_print_table_colspan_header(2, "HTTP Request Headers"); - php_info_print_table_row(2, "HTTP Request", r->the_request); - 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) { - php_info_print_table_row(2, env[i].key, env[i].val); - } - } - php_info_print_table_colspan_header(2, "HTTP Response Headers"); - 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) { - php_info_print_table_row(2, env[i].key, env[i].val); - } - } - php_info_print_table_end(); - } -} -/* }}} */ - -/* {{{ proto int virtual(string filename) - Perform an Apache sub-request */ -/* This function is equivalent to <!--#include virtual...--> - * in mod_include. It does an Apache sub-request. It is useful - * for including CGI scripts or .shtml files, or anything else - * that you'd parse through Apache (for .phtml files, you'd probably - * want to use <?Include>. This only works when PHP is compiled - * as an Apache module, since it uses the Apache API for doing - * sub requests. - */ -PHP_FUNCTION(virtual) -{ - pval **filename; - request_rec *rr = NULL; - - if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(filename); - - if (!(rr = sub_req_lookup_uri ((*filename)->value.str.val, ((request_rec *) SG(server_context))))) { - php_error(E_WARNING, "Unable to include '%s' - URI lookup failed", (*filename)->value.str.val); - if (rr) destroy_sub_req (rr); - RETURN_FALSE; - } - - if (rr->status != 200) { - php_error(E_WARNING, "Unable to include '%s' - error finding URI", (*filename)->value.str.val); - if (rr) destroy_sub_req (rr); - RETURN_FALSE; - } - - php_end_ob_buffers(1 TSRMLS_CC); - php_header(); - - if (run_sub_req(rr)) { - php_error(E_WARNING, "Unable to include '%s' - request execution failed", (*filename)->value.str.val); - if (rr) destroy_sub_req (rr); - RETURN_FALSE; - } else { - if (rr) destroy_sub_req (rr); - RETURN_TRUE; - } -} -/* }}} */ - -/* {{{ proto array getallheaders(void) - Fetch all HTTP request headers */ -PHP_FUNCTION(getallheaders) -{ - array_header *env_arr; - table_entry *tenv; - int i; - TSRMLS_FETCH(); - - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } - 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 || - (PG(safe_mode) && - !strncasecmp(tenv[i].key, "authorization", 13))) { - continue; - } - if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) { - RETURN_FALSE; - } - } -} -/* }}} */ - -/* {{{ proto class apache_lookup_uri(string URI) - Perform a partial request of the given URI to obtain information about it */ -PHP_FUNCTION(apache_lookup_uri) -{ - pval **filename; - request_rec *rr=NULL; - TSRMLS_FETCH(); - - if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(filename); - - if(!(rr = sub_req_lookup_uri((*filename)->value.str.val, ((request_rec *) SG(server_context))))) { - php_error(E_WARNING, "URI lookup failed", (*filename)->value.str.val); - RETURN_FALSE; - } - object_init(return_value); - add_property_long(return_value,"status", rr->status); - if (rr->the_request) { - add_property_string(return_value,"the_request", rr->the_request, 1); - } - if (rr->status_line) { - add_property_string(return_value,"status_line", (char *)rr->status_line, 1); - } - if (rr->method) { - add_property_string(return_value,"method", (char *)rr->method, 1); - } - if (rr->content_type) { - add_property_string(return_value,"content_type", (char *)rr->content_type, 1); - } - if (rr->handler) { - add_property_string(return_value,"handler", (char *)rr->handler, 1); - } - if (rr->uri) { - add_property_string(return_value,"uri", rr->uri, 1); - } - if (rr->filename) { - add_property_string(return_value,"filename", rr->filename, 1); - } - if (rr->path_info) { - add_property_string(return_value,"path_info", rr->path_info, 1); - } - if (rr->args) { - add_property_string(return_value,"args", rr->args, 1); - } - if (rr->boundary) { - add_property_string(return_value,"boundary", rr->boundary, 1); - } - add_property_long(return_value,"no_cache", rr->no_cache); - add_property_long(return_value,"no_local_copy", rr->no_local_copy); - add_property_long(return_value,"allowed", rr->allowed); - add_property_long(return_value,"sent_bodyct", rr->sent_bodyct); - add_property_long(return_value,"bytes_sent", rr->bytes_sent); - add_property_long(return_value,"byterange", rr->byterange); - add_property_long(return_value,"clength", rr->clength); - -#if MODULE_MAGIC_NUMBER >= 19980324 - if (rr->unparsed_uri) { - add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1); - } - if(rr->mtime) { - add_property_long(return_value,"mtime", rr->mtime); - } -#endif - if(rr->request_time) { - add_property_long(return_value,"request_time", rr->request_time); - } - - destroy_sub_req(rr); -} -/* }}} */ - - -#if 0 -This function is most likely a bad idea. Just playing with it for now. - -PHP_FUNCTION(apache_exec_uri) -{ - pval **filename; - request_rec *rr=NULL; - TSRMLS_FETCH(); - - if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &filename) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_string_ex(filename); - - if(!(rr = ap_sub_req_lookup_uri((*filename)->value.str.val, ((request_rec *) SG(server_context))))) { - php_error(E_WARNING, "URI lookup failed", (*filename)->value.str.val); - RETURN_FALSE; - } - RETVAL_LONG(ap_run_sub_req(rr)); - ap_destroy_sub_req(rr); -} -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/sapi/apache/php_apache_http.h b/sapi/apache/php_apache_http.h deleted file mode 100644 index a878b8fa3e..0000000000 --- a/sapi/apache/php_apache_http.h +++ /dev/null @@ -1,24 +0,0 @@ -# if HAVE_AP_CONFIG_H -#include "ap_config_auto.h" -#ifdef RHAPSODY -#undef HAVE_SNPRINTF -#endif -#include "ap_config.h" -#ifdef RHAPSODY -#undef HAVE_SNPRINTF -#define HAVE_SNPRINTF 1 -#endif -# endif -# if HAVE_OLD_COMPAT_H -#include "compat.h" -# endif -# if HAVE_AP_COMPAT_H -#include "ap_compat.h" -# endif -#include "httpd.h" -#include "http_main.h" -#include "http_core.h" -#include "http_request.h" -#include "http_protocol.h" -#include "http_config.h" -#include "http_log.h" diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c deleted file mode 100644 index 572d46ebff..0000000000 --- a/sapi/apache/sapi_apache.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Rasmus Lerdorf <rasmus@php.net> | - | (with helpful hints from Dean Gaudet <dgaudet@arctic.org> | - | PHP 4.0 patches by: | - | Zeev Suraski <zeev@zend.com> | - | Stig Bakken <ssb@fast.no> | - +----------------------------------------------------------------------+ - */ -/* $Id$ */ - -#define NO_REGEX_EXTRA_H -#ifdef WIN32 -#include <winsock2.h> -#include <stddef.h> -#endif - -#include "php.h" - -#include "httpd.h" -#include "http_config.h" -#if MODULE_MAGIC_NUMBER > 19980712 -# include "ap_compat.h" -#else -# if MODULE_MAGIC_NUMBER > 19980324 -# include "compat.h" -# endif -#endif -#include "http_core.h" -#include "http_main.h" -#include "http_protocol.h" -#include "http_request.h" -#include "http_log.h" - -#include "zend.h" -#include "php_ini.h" -#include "php_globals.h" -#include "SAPI.h" -#include "php_main.h" -#include "zend_compile.h" -#include "zend_execute.h" -#include "zend_highlight.h" -#include "zend_indent.h" -#include "ext/standard/php_standard.h" -#include "util_script.h" -#include "php_version.h" -#include "mod_php4.h" - -/* {{{ apache_php_module_main - */ -int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC) -{ - zend_file_handle file_handle; - - if (php_request_startup(TSRMLS_C) == FAILURE) { - return FAILURE; - } - /* sending a file handle to another dll is not working - // so let zend open it. - */ - - if (display_source_mode) { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - php_get_highlight_struct(&syntax_highlighter_ini); - if (highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC)){ - return OK; - } else { - return NOT_FOUND; - } - } else { - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.handle.fd = 0; - file_handle.filename = SG(request_info).path_translated; - file_handle.opened_path = NULL; - file_handle.free_filename = 0; - - (void) php_execute_script(&file_handle TSRMLS_CC); - } - - AP(in_request) = 0; - - zend_try { - php_request_shutdown(NULL); - } zend_end_try(); - - return (OK); -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/sapi/apache2filter/CREDITS b/sapi/apache2filter/CREDITS deleted file mode 100644 index 8fa27e8393..0000000000 --- a/sapi/apache2filter/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -Apache 2.0 -Sascha Schumann diff --git a/sapi/apache2filter/Makefile.in b/sapi/apache2filter/Makefile.in deleted file mode 100644 index e4e876c904..0000000000 --- a/sapi/apache2filter/Makefile.in +++ /dev/null @@ -1,7 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = sapi_apache2.c apache_config.c php_functions.c - -EXTRA_INCLUDES = $(APACHE_INCLUDE) - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/apache2filter/README b/sapi/apache2filter/README deleted file mode 100644 index f2b0a0097d..0000000000 --- a/sapi/apache2filter/README +++ /dev/null @@ -1,63 +0,0 @@ -WHAT IS THIS? - - This module exploits the layered I/O support in Apache 2.0. - -HOW DOES IT WORK? - - In Apache 2.0, you have handlers which generate content (like - reading a script from disk). The content goes then through - a chain of filters. PHP can be such a filter, so that it processes - your script and hands the output to the next filter (which will - usually cause a write to the network). - -DOES IT WORK? - - It is experimental as interfaces in Apache 2.0 might change in the - future. - -HOW TO INSTALL - - Get the latest Apache 2.0 alpha or the CVS code and install it. - - $ cd apache-2.x - $ cd src - $ ./configure --enable-so - $ make install - - For testing purposes, you might want to use --with-mpm=prefork. - (Albeit PHP also works with threaded MPMs.) - - Configure PHP 4: - - $ cd php-4.x - $ ./configure --with-apxs2=/path/to/apache-2.0/bin/apxs - $ make install - - At the end of conf/httpd.conf, add: - - <Files *.php> - SetOutputFilter PHP - SetInputFilter PHP - </Files> - - That's it. Now start bin/httpd. - -DEBUGGING APACHE AND PHP - - To debug Apache, we recommened: - - 1. Use the Prefork MPM (Apache 1.3-like process model) by - configuring Apache with '--with-mpm=prefork'. - 2. Set the variable "ONE_PROCESS" to 1 and export it before - starting Apache/a debugger. - - If you want to debug a part of the PHP startup procedure, set a - breakpoint on 'load_module'. Step through it until apr_dso_load() is - done. Then you can set a breakpoint on any PHP-related symbol. - -TODO - - PHP functions like apache_sub_req (see php_functions.c) - Protocol handlers - Passing script data to engine without temporary file - Syntax Highlighter (relies on files as well) diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c deleted file mode 100644 index 2b0ce50c7e..0000000000 --- a/sapi/apache2filter/apache_config.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -#include "php.h" -#include "php_ini.h" - -#include "apr_strings.h" -#include "ap_config.h" -#include "util_filter.h" -#include "httpd.h" -#include "http_config.h" -#include "http_request.h" -#include "http_core.h" -#include "http_protocol.h" -#include "http_log.h" -#include "http_main.h" -#include "util_script.h" -#include "http_core.h" - -#ifdef PHP_AP_DEBUG -#define phpapdebug(a) fprintf a -#else -#define phpapdebug(a) -#endif - -typedef struct { - HashTable config; -} php_conf_rec; - -typedef struct { - char *value; - size_t value_len; - char status; -} php_dir_entry; - -static const char *real_value_hnd(cmd_parms *cmd, void *dummy, const char *name, const char *value, int status) -{ - php_conf_rec *d = dummy; - php_dir_entry e; - php_dir_entry *pe; - size_t str_len; - - phpapdebug((stderr, "Getting %s=%s for %p (%d)\n", name, value, dummy, zend_hash_num_elements(&d->config))); - e.value = apr_pstrdup(cmd->pool, value); - e.value_len = strlen(value); - e.status = status; - - str_len = strlen(name); - - if (zend_hash_find(&d->config, (char *) name, str_len + 1, (void **) &pe) == SUCCESS) { - if (pe->status > status) - return NULL; - } - - zend_hash_update(&d->config, (char *) name, strlen(name) + 1, &e, sizeof(e), - NULL); - return NULL; -} - -static const char *php_apache_value_handler(cmd_parms *cmd, void *dummy, const char *name, const char *value) -{ - return real_value_hnd(cmd, dummy, name, value, PHP_INI_USER); -} - -static const char *php_apache_admin_value_handler(cmd_parms *cmd, void *dummy, const char *name, const char *value) -{ - return real_value_hnd(cmd, dummy, name, value, PHP_INI_SYSTEM); -} - -void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf) -{ - php_conf_rec *d = base_conf, *e = new_conf; - php_dir_entry *pe; - php_dir_entry *data; - char *str; - ulong str_len; - ulong num_index; - - phpapdebug((stderr, "Merge dir (%p) (%p)\n", base_conf, new_conf)); - for (zend_hash_internal_pointer_reset(&d->config); - zend_hash_get_current_key_ex(&d->config, &str, &str_len, &num_index, 0, NULL) == HASH_KEY_IS_STRING; - zend_hash_move_forward(&d->config)) { - pe = NULL; - zend_hash_get_current_data(&d->config, (void **) &data); - if (zend_hash_find(&e->config, str, str_len, (void **) &pe) == SUCCESS) { - if (pe->status >= data->status) continue; - } - zend_hash_update(&e->config, str, str_len, data, sizeof(*data), NULL); - phpapdebug((stderr, "ADDING/OVERWRITING %s (%d vs. %d)\n", str, data->status, pe?pe->status:-1)); - } - return new_conf; -} - -void apply_config(void *dummy) -{ - php_conf_rec *d = dummy; - char *str; - ulong str_len; - php_dir_entry *data; - - for (zend_hash_internal_pointer_reset(&d->config); - zend_hash_get_current_key_ex(&d->config, &str, &str_len, NULL, 0, NULL) == HASH_KEY_IS_STRING; - zend_hash_move_forward(&d->config)) { - zend_hash_get_current_data(&d->config, (void **) &data); - phpapdebug((stderr, "APPLYING (%s)(%s)\n", str, data->value)); - if (zend_alter_ini_entry(str, str_len, data->value, data->value_len + 1, - data->status, PHP_INI_STAGE_RUNTIME) == FAILURE) - phpapdebug((stderr, "..FAILED\n")); - } -} - -const command_rec php_dir_cmds[] = -{ - AP_INIT_TAKE2("php_value", php_apache_value_handler, NULL, OR_OPTIONS, - "PHP Value Modifier"), - AP_INIT_TAKE2("php_admin_value", php_apache_admin_value_handler, NULL, OR_NONE, - "PHP Value Modifier"), - {NULL} -}; - -static apr_status_t destroy_php_config(void *data) -{ - php_conf_rec *d = data; - - phpapdebug((stderr, "Destroying config %p\n", data)); - zend_hash_destroy(&d->config); - - return APR_SUCCESS; -} - -void *create_php_config(apr_pool_t *p, char *dummy) -{ - php_conf_rec *newx = - (php_conf_rec *) apr_pcalloc(p, sizeof(*newx)); - - phpapdebug((stderr, "Creating new config (%p) for %s\n", newx, dummy)); - zend_hash_init(&newx->config, 0, NULL, NULL, 1); - apr_pool_cleanup_register(p, newx, destroy_php_config, NULL); - return (void *) newx; -} - diff --git a/sapi/apache2filter/config.m4 b/sapi/apache2filter/config.m4 deleted file mode 100644 index cb3aeb2997..0000000000 --- a/sapi/apache2filter/config.m4 +++ /dev/null @@ -1,59 +0,0 @@ -dnl ## -*- sh -*- - -AC_MSG_CHECKING(for Apache 2.0 module support via DSO through APXS) -AC_ARG_WITH(apxs2, -[ --with-apxs2[=FILE] Build shared Apache 2.0 module. FILE is the optional - pathname to the Apache apxs tool; defaults to "apxs".],[ - if test "$withval" = "yes"; then - APXS=apxs - $APXS -q CFLAGS >/dev/null 2>&1 - if test "$?" != "0" && test -x /usr/sbin/apxs; then - APXS=/usr/sbin/apxs - fi - else - PHP_EXPAND_PATH($withval, APXS) - fi - - $APXS -q CFLAGS >/dev/null 2>&1 - if test "$?" != "0"; then - AC_MSG_RESULT() - AC_MSG_RESULT() - AC_MSG_RESULT([Sorry, I cannot run apxs. Possible reasons follow:]) - AC_MSG_RESULT() - AC_MSG_RESULT([1. Perl is not installed]) - AC_MSG_RESULT([2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs]) - AC_MSG_RESULT([3. Apache was not built using --enable-so (the apxs usage page is displayed)]) - AC_MSG_RESULT() - AC_MSG_RESULT([The output of $APXS follows:]) - $APXS - AC_MSG_ERROR([Aborting]) - fi - - APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR` - APXS_CFLAGS=`$APXS -q CFLAGS` - for flag in $APXS_CFLAGS; do - case $flag in - -D*) CPPFLAGS="$CPPFLAGS $flag";; - esac - done - PHP_ADD_INCLUDE($APXS_INCLUDEDIR) - PHP_SAPI=apache2filter - INSTALL_IT="$APXS -i -a -n php4 $SAPI_LIBTOOL" - PHP_BUILD_SHARED - PHP_BUILD_THREAD_SAFE - AC_MSG_RESULT(yes) - case $host_alias in - *aix*) - APXS_SBINDIR=`$APXS -q SBINDIR` - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-bI:$APXS_SBINDIR/httpd.exp" - ;; - esac -],[ - AC_MSG_RESULT(no) -]) - -PHP_SUBST(APXS) - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/apache2filter/php.sym b/sapi/apache2filter/php.sym deleted file mode 100644 index 2dca1256c2..0000000000 --- a/sapi/apache2filter/php.sym +++ /dev/null @@ -1 +0,0 @@ -php4_module diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h deleted file mode 100644 index 101c81430b..0000000000 --- a/sapi/apache2filter/php_apache.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -#ifndef PHP_APACHE_H -#define PHP_APACHE_H - -typedef struct php_struct { - int state; - apr_bucket_brigade *bb; - ap_filter_t *f; - /* Length of post_data buffer */ - int post_len; - /* Index for reading from buffer */ - int post_idx; - /* Buffer for request body filter */ - char *post_data; -} php_struct; - -int php_apache_register_module(void); -void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf); -void *create_php_config(apr_pool_t *p, char *dummy); -void apply_config(void *); -extern const command_rec php_dir_cmds[]; - -#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() }} - -#endif /* PHP_APACHE_H */ diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c deleted file mode 100644 index 7d1aa1bd08..0000000000 --- a/sapi/apache2filter/php_functions.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -#include "php.h" -#include "SAPI.h" - -#include "apr_strings.h" -#include "ap_config.h" -#include "util_filter.h" -#include "httpd.h" -#include "http_config.h" -#include "http_request.h" -#include "http_core.h" -#include "http_protocol.h" -#include "http_log.h" -#include "http_main.h" -#include "util_script.h" -#include "http_core.h" - -#include "php_apache.h" - -static request_rec *php_apache_lookup_uri(INTERNAL_FUNCTION_PARAMETERS) -{ - zval **p1; - php_struct *ctx; - TSRMLS_FETCH(); - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p1) == FAILURE) - return NULL; - - convert_to_string_ex(p1); - - ctx = SG(server_context); - return ap_sub_req_lookup_uri(Z_STRVAL_PP(p1), ctx->f->r, NULL); -} - -PHP_FUNCTION(apache_sub_req) -{ - request_rec *rr; - - rr = php_apache_lookup_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU); - - if (!rr) - WRONG_PARAM_COUNT; - - if (rr->status == HTTP_OK) { - ap_run_sub_req(rr); - RETURN_TRUE; - } - RETURN_FALSE; -} - -#define ADD_LONG(name) \ - add_assoc_long(return_value, #name, rr->name) -#define ADD_STRING(name) \ - if (rr->name) add_assoc_string(return_value, #name, (char *) rr->name, 1) - -PHP_FUNCTION(apache_lookup_uri) -{ - request_rec *rr; - - rr = php_apache_lookup_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU); - if (!rr) - WRONG_PARAM_COUNT; - - if (rr->status == HTTP_OK) { - array_init(return_value); - - ADD_LONG(status); - ADD_STRING(the_request); - ADD_STRING(status_line); - ADD_STRING(method); - ADD_LONG(mtime); - ADD_LONG(clength); - ADD_STRING(boundary); - ADD_STRING(range); - ADD_LONG(chunked); - ADD_STRING(content_type); - ADD_STRING(handler); - ADD_LONG(no_cache); - ADD_LONG(no_local_copy); - ADD_STRING(unparsed_uri); - ADD_STRING(uri); - ADD_STRING(filename); - ADD_STRING(path_info); - ADD_STRING(args); - - return; - } - RETURN_FALSE; -} - -PHP_FUNCTION(get_all_headers) -{ - php_struct *ctx; - apr_array_header_t *arr; - char *key, *val; - TSRMLS_FETCH(); - - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } - - ctx = SG(server_context); - arr = apr_table_elts(ctx->f->r->headers_in); - - APR_ARRAY_FOREACH_OPEN(arr, key, val) - if (!val) val = empty_string; - add_assoc_string(return_value, key, val, 1); - APR_ARRAY_FOREACH_CLOSE() -} - -PHP_MINFO_FUNCTION(apache) -{ -} - -static function_entry apache_functions[] = { - PHP_FE(apache_lookup_uri, NULL) - PHP_FE(apache_sub_req, NULL) - PHP_FE(get_all_headers, NULL) - {0} -}; - -static zend_module_entry php_apache_module = { - "Apache 2.0", - apache_functions, - NULL, - NULL, - NULL, - NULL, - PHP_MINFO(apache), - STANDARD_MODULE_PROPERTIES -}; - -int php_apache_register_module(void) -{ - return zend_startup_module(&php_apache_module); -} diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c deleted file mode 100644 index cca75156bf..0000000000 --- a/sapi/apache2filter/sapi_apache2.c +++ /dev/null @@ -1,419 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Sascha Schumann <sascha@schumann.cx> | - | Parts based on Apache 1.3 SAPI module by | - | Rasmus Lerdorf and Zeev Suraski | - +----------------------------------------------------------------------+ - */ - -#include <fcntl.h> - -#include "php.h" -#include "php_main.h" -#include "php_ini.h" -#include "php_variables.h" -#include "SAPI.h" - -#include "ext/standard/php_smart_str.h" - -#include "apr_strings.h" -#include "ap_config.h" -#include "util_filter.h" -#include "httpd.h" -#include "http_config.h" -#include "http_request.h" -#include "http_core.h" -#include "http_protocol.h" -#include "http_log.h" -#include "http_main.h" -#include "util_script.h" -#include "http_core.h" - -#include "php_apache.h" - -static int -php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - apr_bucket *b; - apr_bucket_brigade *bb; - php_struct *ctx; - uint now; - - ctx = SG(server_context); - - if (str_length == 0) return 0; - - bb = apr_brigade_create(ctx->f->r->pool); - while (str_length > 0) { - now = MIN(str_length, 4096); - b = apr_bucket_transient_create(str, now); - APR_BRIGADE_INSERT_TAIL(bb, b); - str += now; - str_length -= now; - } - if (ap_pass_brigade(ctx->f->next, bb) != APR_SUCCESS) { - php_handle_aborted_connection(); - } - - return str_length; -} - -static int -php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - php_struct *ctx = SG(server_context); - char *val; - - val = strchr(sapi_header->header, ':'); - - if (!val) return 0; - - *val = '\0'; - - do { - val++; - } while (*val == ' '); - - if (!strcasecmp(sapi_header->header, "content-type")) - ctx->f->r->content_type = apr_pstrdup(ctx->f->r->pool, val); - else if (sapi_header->replace) - apr_table_set(ctx->f->r->headers_out, sapi_header->header, val); - else - apr_table_add(ctx->f->r->headers_out, sapi_header->header, val); - - sapi_free_header(sapi_header); - - return 0; -} - -static int -php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - php_struct *ctx = SG(server_context); - - ctx->f->r->status = SG(sapi_headers).http_response_code; - - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - -static int -php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) -{ - int n; - int to_read; - php_struct *ctx = SG(server_context); - - to_read = ctx->post_len - ctx->post_idx; - n = MIN(to_read, count_bytes); - - if (n > 0) { - memcpy(buf, ctx->post_data + ctx->post_idx, n); - ctx->post_idx += n; - } else { - if (ctx->post_data) free(ctx->post_data); - ctx->post_data = NULL; - } - - return n; -} - -static char * -php_apache_sapi_read_cookies(TSRMLS_D) -{ - php_struct *ctx = SG(server_context); - const char *http_cookie; - - http_cookie = apr_table_get(ctx->f->r->headers_in, "cookie"); - - /* The SAPI interface should use 'const char *' */ - return (char *) http_cookie; -} - -static void -php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC) -{ - php_struct *ctx = SG(server_context); - apr_array_header_t *arr = apr_table_elts(ctx->f->r->subprocess_env); - char *key, *val; - - APR_ARRAY_FOREACH_OPEN(arr, key, val) - if (!val) val = empty_string; - php_register_variable(key, val, track_vars_array TSRMLS_CC); - APR_ARRAY_FOREACH_CLOSE() - - php_register_variable("PHP_SELF", ctx->f->r->uri, track_vars_array TSRMLS_CC); -} - -static void -php_apache_sapi_flush(void *server_context) -{ - php_struct *ctx = server_context; - apr_bucket_brigade *bb; - apr_bucket *b; - - /* Send a flush bucket down the filter chain. The current default - * handler seems to act on the first flush bucket, but ignores - * all further flush buckets. - */ - - bb = apr_brigade_create(ctx->f->r->pool); - b = apr_bucket_flush_create(); - APR_BRIGADE_INSERT_TAIL(bb, b); - if (ap_pass_brigade(ctx->f->next, bb) != APR_SUCCESS) { - php_handle_aborted_connection(); - } -} - -static void php_apache_sapi_log_message(char *msg) -{ - php_struct *ctx; - TSRMLS_FETCH(); - - ctx = SG(server_context); - - apr_file_puts(msg, ctx->f->r->server->error_log); -} - -static sapi_module_struct apache2_sapi_module = { - "apache2filter", - "Apache 2.0 Filter", - - php_module_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - NULL, /* activate */ - NULL, /* deactivate */ - - php_apache_sapi_ub_write, /* unbuffered write */ - php_apache_sapi_flush, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, /* error handler */ - - php_apache_sapi_header_handler, /* header handler */ - php_apache_sapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ - - php_apache_sapi_read_post, /* read POST data */ - php_apache_sapi_read_cookies, /* read Cookies */ - - php_apache_sapi_register_variables, - php_apache_sapi_log_message, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - - -AP_MODULE_DECLARE_DATA module php4_module; - -#define INIT_CTX \ - if (ctx == NULL) { \ - /* Initialize filter context */ \ - SG(server_context) = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); \ - ctx->bb = apr_brigade_create(f->c->pool); \ - } - -static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, - ap_input_mode_t mode, apr_size_t *readbytes) -{ - php_struct *ctx; - long old_index; - apr_bucket *b; - const char *str; - apr_ssize_t n; - apr_status_t rv; - TSRMLS_FETCH(); - - ctx = SG(server_context); - - INIT_CTX; - - if ((rv = ap_get_brigade(f->next, bb, mode, readbytes)) != APR_SUCCESS) { - return rv; - } - - APR_BRIGADE_FOREACH(b, bb) { - apr_bucket_read(b, &str, &n, 1); - if (n > 0) { - old_index = ctx->post_len; - ctx->post_len += n; - ctx->post_data = realloc(ctx->post_data, ctx->post_len + 1); - memcpy(ctx->post_data + old_index, str, n); - } - } - return APR_SUCCESS; -} - -static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx TSRMLS_DC) -{ - char *content_type; - const char *auth; - - PG(during_request_startup) = 0; - SG(sapi_headers).http_response_code = 200; - SG(request_info).content_type = apr_table_get(f->r->headers_in, "Content-Type"); -#undef safe_strdup -#define safe_strdup(x) ((x)?strdup((x)):NULL) - SG(request_info).query_string = safe_strdup(f->r->args); - SG(request_info).request_method = f->r->method; - SG(request_info).request_uri = safe_strdup(f->r->uri); - f->r->no_local_copy = 1; - content_type = sapi_get_default_content_type(TSRMLS_C); - f->r->content_type = apr_pstrdup(f->r->pool, content_type); - SG(request_info).post_data = ctx->post_data; - SG(request_info).post_data_length = ctx->post_len; - efree(content_type); - apr_table_unset(f->r->headers_out, "Content-Length"); - apr_table_unset(f->r->headers_out, "Last-Modified"); - apr_table_unset(f->r->headers_out, "Expires"); - apr_table_unset(f->r->headers_out, "ETag"); - apr_table_unset(f->r->headers_in, "Connection"); - auth = apr_table_get(f->r->headers_in, "Authorization"); - php_handle_auth_data(auth TSRMLS_CC); - - php_request_startup(TSRMLS_C); -} - -static void php_apache_request_dtor(ap_filter_t *f TSRMLS_DC) -{ - php_request_shutdown(NULL); - -#undef safe_free -#define safe_free(x) ((x)?free((x)):0) - safe_free(SG(request_info).query_string); - safe_free(SG(request_info).request_uri); -} - -static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) -{ - php_struct *ctx; - apr_bucket *b; - void *conf = ap_get_module_config(f->r->per_dir_config, &php4_module); - TSRMLS_FETCH(); - - ctx = SG(server_context); - INIT_CTX; - - ctx->f = f; - - /* states: - * 0: request startup - * 1: collecting data - * 2: script execution and request shutdown - */ - if (ctx->state == 0) { - - apply_config(conf); - - ctx->state++; - - php_apache_request_ctor(f, ctx TSRMLS_CC); - } - - /* moves all buckets from bb to ctx->bb */ - ap_save_brigade(f, &ctx->bb, &bb, f->r->pool); - - /* If we have received all data from the previous filters, - * we "flatten" the buckets by creating a single string buffer. - */ - if (ctx->state == 1 && APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(ctx->bb))) { - zend_file_handle zfd; - apr_bucket *eos; - - /* We want to execute only one script per request. - * A bug in Apache or other filters could cause us - * to reenter php_filter during script execution, so - * we protect ourselves here. - */ - ctx->state = 2; - - /* Handle phpinfo/phpcredits/built-in images */ - if (!php_handle_special_queries(TSRMLS_C)) { - - b = APR_BRIGADE_FIRST(ctx->bb); - - if (APR_BUCKET_IS_FILE(b)) { - const char *path; - - apr_file_name_get(&path, ((apr_bucket_file *) b->data)->fd); - - zfd.type = ZEND_HANDLE_FILENAME; - zfd.filename = (char *) path; - zfd.free_filename = 0; - zfd.opened_path = NULL; - - php_execute_script(&zfd TSRMLS_CC); - } else { - -#define NO_DATA "The PHP Filter did not receive suitable input data" - - eos = apr_bucket_transient_create(NO_DATA, sizeof(NO_DATA)-1); - APR_BRIGADE_INSERT_HEAD(bb, eos); - } - } - - php_apache_request_dtor(f TSRMLS_CC); - - SG(server_context) = 0; - /* Pass EOS bucket to next filter to signal end of request */ - eos = apr_bucket_eos_create(); - APR_BRIGADE_INSERT_TAIL(bb, eos); - - return ap_pass_brigade(f->next, bb); - } else - apr_brigade_destroy(bb); - - return APR_SUCCESS; -} - -static apr_status_t -php_apache_server_shutdown(void *tmp) -{ - apache2_sapi_module.shutdown(&apache2_sapi_module); - sapi_shutdown(); - tsrm_shutdown(); - return APR_SUCCESS; -} - -static void -php_apache_server_startup(apr_pool_t *pchild, server_rec *s) -{ - tsrm_startup(1, 1, 0, NULL); - sapi_startup(&apache2_sapi_module); - apache2_sapi_module.startup(&apache2_sapi_module); - apr_pool_cleanup_register(pchild, NULL, php_apache_server_shutdown, NULL); - php_apache_register_module(); -} - -static void php_register_hook(apr_pool_t *p) -{ - ap_hook_child_init(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE); - ap_register_output_filter("PHP", php_output_filter, AP_FTYPE_CONTENT); - ap_register_input_filter("PHP", php_input_filter, AP_FTYPE_CONTENT); -} - -AP_MODULE_DECLARE_DATA module php4_module = { - STANDARD20_MODULE_STUFF, - create_php_config, /* create per-directory config structure */ - merge_php_config, /* merge per-directory config structures */ - NULL, /* create per-server config structure */ - NULL, /* merge per-server config structures */ - php_dir_cmds, /* command apr_table_t */ - php_register_hook /* register hooks */ -}; diff --git a/sapi/caudium/CREDITS b/sapi/caudium/CREDITS deleted file mode 100644 index 45789dbdfe..0000000000 --- a/sapi/caudium/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -Caudium / Roxen -David Hedbor diff --git a/sapi/caudium/Makefile.in b/sapi/caudium/Makefile.in deleted file mode 100644 index 6063dd209b..0000000000 --- a/sapi/caudium/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = caudium.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/caudium/README b/sapi/caudium/README deleted file mode 100644 index 86ef65655d..0000000000 --- a/sapi/caudium/README +++ /dev/null @@ -1,16 +0,0 @@ -Embedded Caudium PHP support. It seems to work but isn't tested -much. Due to a design choice it requires _Pike_ threads and a -thread-safe PHP. It doesn't however require _Caudium_ to run in -threaded mode. Due to the design, utilization of multiple processors -should be pretty good. - -It requires a new Pike 7.0 and Caudium. It will not work with -Roxen. Also, with the help of the VIRTUAL_DIR code in PHP, PHP -execution should be very similar to that of mod_php or the cgi -script. - -If you have any questions, please contact me, David Hedbor -(neotron@php.net or neotron@caudium.net). For more information on -Caudium, see http://caudium.net/ and http://caudium.org/. - - diff --git a/sapi/caudium/TODO b/sapi/caudium/TODO deleted file mode 100644 index b8217c5934..0000000000 --- a/sapi/caudium/TODO +++ /dev/null @@ -1,30 +0,0 @@ -TODO: - -- per-virtual-server configuration -- configurable limit of number of concurrent PHP executions -- fix setting of auth info. - -FIXED: -+ => fixed -- => not fixed and no fix planned -? => Maybe fixed, maybe not. - -+ Allow multiple headers - This is now fixed. -+ fix backtraces - Uses th_farm, thus problem is fixed -+ exit in PHP exits Caudium - Name conflict with do_exit in Pike and PHP. Reported to both teams. -+ POST newline added? - Was a Caudium bug. -+ use th_farm - Yeppers. Works great. -- change cwd in single threaded mode - There will be no single threaded mode support. The Caudium module - will requite PHP ZTS and Pike threads to run. Single threaded PHP - is rather uninteresting anyway. -? Recursive mutex lock problem: - Dunno if this is fixed. Major rewrite so it would have to be - retested. - - diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c deleted file mode 100644 index 962b9acc92..0000000000 --- a/sapi/caudium/caudium.c +++ /dev/null @@ -1,836 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: David Hedbor <neotron@php.net> | - | Based on aolserver SAPI by Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" -#ifdef HAVE_CAUDIUM - -#include "php_ini.h" -#include "php_globals.h" -#include "SAPI.h" -#include "php_main.h" -#include "ext/standard/info.h" - -#include "php_version.h" - -/* Pike Include Files - * - * conflicts with pike avoided by only using long names. Requires a new - * Pike 0.7 since it was implemented for this interface only. - * - */ -#define NO_PIKE_SHORTHAND - -/* Ok, we are now using Pike level threads to handle PHP4 since - * the nice th_farm threads aren't working on Linux with glibc 2.2 - * (why this is I don't know). - */ -#define USE_PIKE_LEVEL_THREADS - -#include <fdlib.h> -#include <program.h> -#include <pike_types.h> -#include <interpret.h> -#include <module_support.h> -#include <array.h> -#include <backend.h> -#include <stralloc.h> -#include <mapping.h> -#include <object.h> -#include <threads.h> -#include <builtin_functions.h> -#include <operators.h> -#include <version.h> - -#if (PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION == 1 && PIKE_BUILD_VERSION >= 12) || PIKE_MAJOR_VERSION > 7 || (PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION > 1) -# include "pike_error.h" -#else -# include "error.h" -# ifndef Pike_error -# define Pike_error error -# endif -#endif - -#ifndef ZTS -/* Need thread safety */ -#error You need to compile PHP with threads. -#endif - -#ifndef PIKE_THREADS -#error The PHP4 module requires that your Pike has thread support. -#endif - -#undef HIDE_GLOBAL_VARIABLES -#undef REVEAL_GLOBAL_VARIABLES -#define HIDE_GLOBAL_VARIABLES() -#define REVEAL_GLOBAL_VARIABLES() - -/* php_caudium_request is per-request object storage */ - -typedef struct -{ - struct mapping *request_data; - struct object *my_fd_obj; - struct svalue done_cb; - struct pike_string *filename; - int my_fd; - int written; - TSRMLS_D; -} php_caudium_request; - - -void pike_module_init(void); -void pike_module_exit(void); -static void free_struct(TSRMLS_D); -void f_php_caudium_request_handler(INT32 args); - -/* Defines to get to the data supplied when the script is started. */ - -/* Per thread storage area id... */ -static int caudium_globals_id; - -#define GET_THIS() php_caudium_request *_request = ts_resource(caudium_globals_id) -#define THIS _request -#define PTHIS ((php_caudium_request *)(Pike_fp->current_storage)) -/* File descriptor integer. Used to write directly to the FD without - * passing Pike - */ -#define MY_FD (THIS->my_fd) - -/* FD object. Really a PHPScript object from Pike which implements a couple - * of functions to handle headers, writing and buffering. - */ -#define MY_FD_OBJ ((struct object *)(THIS->my_fd_obj)) - -/* Mapping with data supplied from the calling Caudium module. Contains - * a mapping with headers, an FD object etc. - */ -#define REQUEST_DATA ((struct mapping *)(THIS->request_data)) - -extern int fd_from_object(struct object *o); -static unsigned char caudium_php_initialized; - -#ifndef mt_lock_interpreter -#define mt_lock_interpreter() mt_lock(&interpreter_lock); -#define mt_unlock_interpreter() mt_unlock(&interpreter_lock); -#endif - - -/* This allows calling of pike functions from the PHP callbacks, - * which requires the Pike interpreter to be locked. - */ -#define THREAD_SAFE_RUN(COMMAND, what) do {\ - struct thread_state *state;\ - if((state = thread_state_for_id(th_self()))!=NULL) {\ - if(!state->swapped) {\ - COMMAND;\ - } else {\ - mt_lock_interpreter();\ - SWAP_IN_THREAD(state);\ - COMMAND;\ - SWAP_OUT_THREAD(state);\ - mt_unlock_interpreter();\ - }\ - }\ -} while(0) - - - -/* Low level header lookup. Basically looks for the named header in the mapping - * headers in the supplied options mapping. - */ - -INLINE static struct svalue *lookup_header(char *headername) -{ - struct svalue *headers, *value; - struct pike_string *sind; - GET_THIS(); - sind = make_shared_string("env"); - headers = low_mapping_string_lookup(REQUEST_DATA, sind); - free_string(sind); - if(!headers || headers->type != PIKE_T_MAPPING) return NULL; - sind = make_shared_string(headername); - value = low_mapping_string_lookup(headers->u.mapping, sind); - free_string(sind); - if(!value) return NULL; - return value; -} - -/* Lookup a header in the mapping and return the value as a string, or - * return the default if it's missing - */ -INLINE static char *lookup_string_header(char *headername, char *default_value) -{ - struct svalue *head = NULL; - THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup"); - if(!head || head->type != PIKE_T_STRING) - return default_value; - return head->u.string->str; -} - -/* Lookup a header in the mapping and return the value as if it's an integer - * and otherwise return the default. - */ -INLINE static int lookup_integer_header(char *headername, int default_value) -{ - struct svalue *head = NULL; - THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup"); - if(!head || head->type != PIKE_T_INT) - return default_value; - return head->u.integer; -} - -/* - * php_caudium_low_ub_write() writes data to the client connection. Might be - * rewritten to do more direct IO to save CPU and the need to lock the - * interpreter for better threading. - */ - -INLINE static int -php_caudium_low_ub_write(const char *str, uint str_length TSRMLS_DC) { - int sent_bytes = 0; - struct pike_string *to_write = NULL; - GET_THIS(); - if(!MY_FD_OBJ->prog) { - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - return -1; - } - to_write = make_shared_binary_string(str, str_length); - push_string(to_write); - safe_apply(MY_FD_OBJ, "write", 1); - if(Pike_sp[-1].type == PIKE_T_INT) - sent_bytes = Pike_sp[-1].u.integer; - pop_stack(); - if(sent_bytes != str_length) { - /* This means the connection is closed. Dead. Gone. *sniff* */ - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - } - return sent_bytes; -} - -/* - * php_caudium_sapi_ub_write() calls php_caudium_low_ub_write in a Pike thread - * safe manner or writes directly to the output FD if RXML post-parsing is - * disabled. - */ - -static int -php_caudium_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - GET_THIS(); - int sent_bytes = 0, fd = MY_FD; - if(fd) - { - for(sent_bytes=0;sent_bytes < str_length;) - { - int written; - written = fd_write(fd, str + sent_bytes, str_length - sent_bytes); - if(written < 0) - { - switch(errno) - { - default: - /* This means the connection is closed. Dead. Gone. *sniff* */ - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - THIS->written += sent_bytes; - return sent_bytes; - case EINTR: - case EWOULDBLOCK: - continue; - } - } else { - sent_bytes += written; - } - } - THIS->written += sent_bytes; - } else { - THREAD_SAFE_RUN(sent_bytes = php_caudium_low_ub_write(str, str_length TSRMLS_CC), - "write"); - } - return sent_bytes; -} - -/* php_caudium_set_header() sets a header in the header mapping. Called in a - * thread safe manner from php_caudium_sapi_header_handler. - */ -INLINE static void -php_caudium_set_header(char *header_name, char *value, char *p) -{ - struct svalue hsval; - struct pike_string *hval, *ind, *hind; - struct mapping *headermap; - struct svalue *s_headermap, *soldval; - int vallen; - GET_THIS(); - // hval = make_shared_string(value); - ind = make_shared_string(" _headers"); - hind = make_shared_binary_string(header_name, - (int)(p - header_name)); - - s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind); - if(!s_headermap || s_headermap->type != PIKE_T_MAPPING) - { - struct svalue mappie; - mappie.type = PIKE_T_MAPPING; - headermap = allocate_mapping(1); - mappie.u.mapping = headermap; - mapping_string_insert(REQUEST_DATA, ind, &mappie); - free_mapping(headermap); - hval = make_shared_string(value); - } else { - headermap = s_headermap->u.mapping; - soldval = low_mapping_string_lookup(headermap, hind); - vallen = strlen(value); - if(soldval != NULL && - soldval->type == PIKE_T_STRING && - soldval->u.string->size_shift == 0) { - /* Existing, valid header. Prepend.*/ - hval = begin_shared_string(soldval->u.string->len + 1 + vallen); - MEMCPY(hval->str, soldval->u.string->str, soldval->u.string->len); - STR0(hval)[soldval->u.string->len] = '\0'; - MEMCPY(hval->str+soldval->u.string->len+1, value, vallen); - hval = end_shared_string(hval); - } else { - hval = make_shared_string(value); - } - } - hsval.type = PIKE_T_STRING; - hsval.u.string = hval; - - mapping_string_insert(headermap, hind, &hsval); - - free_string(hval); - free_string(ind); - free_string(hind); -} - -/* - * php_caudium_sapi_header_handler() sets a HTTP reply header to be - * sent to the client. - */ -static int -php_caudium_sapi_header_handler(sapi_header_struct *sapi_header, - sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - char *header_name, *header_content, *p; - header_name = sapi_header->header; - header_content = p = strchr(header_name, ':'); - - if(p) { - do { - header_content++; - } while(*header_content == ' '); - THREAD_SAFE_RUN(php_caudium_set_header(header_name, header_content, p), "header handler"); - } - sapi_free_header(sapi_header); - return 0; -} - -/* - * php_caudium_sapi_send_headers() flushes the headers to the client. - * Called before real content is sent by PHP. - */ - -INLINE static int -php_caudium_low_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - struct pike_string *ind; - struct svalue *s_headermap; - GET_THIS(); - if(!MY_FD_OBJ->prog) { - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - return SAPI_HEADER_SEND_FAILED; - } - ind = make_shared_string(" _headers"); - s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind); - free_string(ind); - - push_int(SG(sapi_headers).http_response_code); - if(s_headermap && s_headermap->type == PIKE_T_MAPPING) - ref_push_mapping(s_headermap->u.mapping); - else - push_int(0); - safe_apply(MY_FD_OBJ, "send_headers", 2); - pop_stack(); - - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - -static int -php_caudium_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - int res = 0; - THREAD_SAFE_RUN(res = php_caudium_low_send_headers(sapi_headers TSRMLS_CC), "send headers"); - return res; -} - -/* - * php_caudium_sapi_read_post() reads a specified number of bytes from - * the client. Used for POST/PUT requests. - */ - -INLINE static int php_caudium_low_read_post(char *buf, uint count_bytes) -{ - uint total_read = 0; - GET_THIS(); - TSRMLS_FETCH(); - - if(!MY_FD_OBJ->prog) - { - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - return -1; - } - push_int(count_bytes); - safe_apply(MY_FD_OBJ, "read_post", 1); - if(Pike_sp[-1].type == PIKE_T_STRING) { - MEMCPY(buf, Pike_sp[-1].u.string->str, - (total_read = Pike_sp[-1].u.string->len)); - buf[total_read] = '\0'; - } else - total_read = 0; - pop_stack(); - return total_read; -} - -static int -php_caudium_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) -{ - uint total_read = 0; - THREAD_SAFE_RUN(total_read = php_caudium_low_read_post(buf, count_bytes), "read post"); - return total_read; -} - -/* - * php_caudium_sapi_read_cookies() returns the Cookie header from - * the HTTP request header - */ - -static char * -php_caudium_sapi_read_cookies(TSRMLS_D) -{ - char *cookies; - cookies = lookup_string_header("HTTP_COOKIE", NULL); - return cookies; -} - -static void php_info_caudium(ZEND_MODULE_INFO_FUNC_ARGS) -{ - /* char buf[512]; */ - php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id$"); - /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); - php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); - php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); - php_info_print_table_row(2, "Installation path", Ns_InfoHomePath()); - php_info_print_table_row(2, "Hostname of server", Ns_InfoHostname()); - php_info_print_table_row(2, "Source code label", Ns_InfoLabel()); - php_info_print_table_row(2, "Server platform", Ns_InfoPlatform()); - snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); - php_info_print_table_row(2, "Server version", buf); - snprintf(buf, 511, "%d day(s), %02d:%02d:%02d", - uptime / 86400, - (uptime / 3600) % 24, - (uptime / 60) % 60, - uptime % 60); - php_info_print_table_row(2, "Server uptime", buf); - */ - php_info_print_table_end(); -} - -static zend_module_entry php_caudium_module = { - "Caudium", - NULL, - NULL, - NULL, - NULL, - NULL, - php_info_caudium, - STANDARD_MODULE_PROPERTIES -}; - - -INLINE static void low_sapi_caudium_register_variables(zval *track_vars_array TSRMLS_DC) -{ - char *tmp; - php_register_variable("PHP_SELF", SG(request_info).request_uri, - track_vars_array TSRMLS_CC); - php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", - track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_METHOD", - (char *) SG(request_info).request_method, - track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_URI", SG(request_info).request_uri, - track_vars_array TSRMLS_CC); - php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, - track_vars_array TSRMLS_CC); - - if( (tmp = lookup_string_header("SERVER_NAME", NULL)) != NULL) - php_register_variable("SERVER_NAME", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("SERVER_PORT", NULL)) != NULL) - php_register_variable("SERVER_PORT", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("SERVER_PROTOCOL", NULL)) != NULL) - php_register_variable("SERVER_PROTOCOL", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("SCRIPT_NAME", NULL)) != NULL) - php_register_variable("SCRIPT_NAME", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("SCRIPT_FILENAME", NULL)) != NULL) - php_register_variable("SCRIPT_FILENAME", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("REMOTE_ADDR", NULL)) != NULL) - php_register_variable("REMOTE_ADDR", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("REMOTE_PORT", NULL)) != NULL) - php_register_variable("REMOTE_PORT", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("DOCUMENT_ROOT", NULL)) != NULL) - php_register_variable("DOCUMENT_ROOT", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("HTTP_CONNECTION", NULL)) != NULL) - php_register_variable("HTTP_CONNECTION", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("HTTP_USER_AGENT", NULL)) != NULL) - php_register_variable("HTTP_USER_AGENT", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("DOCUMENT_ROOT", NULL)) != NULL) - php_register_variable("DOCUMENT_ROOT", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("QUERY_STRING", "")) != NULL) - php_register_variable("QUERY_STRING", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("REMOTE_USER", NULL)) != NULL) - php_register_variable("REMOTE_USER", tmp, track_vars_array TSRMLS_CC); - if( (tmp = lookup_string_header("REMOTE_PASSWORD", NULL)) != NULL) - php_register_variable("REMOTE_PASSWORD", tmp, track_vars_array TSRMLS_CC); - -} - -static void sapi_caudium_register_variables(zval *track_vars_array TSRMLS_DC) -{ - THREAD_SAFE_RUN(low_sapi_caudium_register_variables(track_vars_array TSRMLS_CC), "register_variables"); -} - -/* this structure is static (as in "it does not change") */ -static sapi_module_struct caudium_sapi_module = { - "caudium", - "Caudium", - php_module_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - NULL, /* activate */ - NULL, /* deactivate */ - php_caudium_sapi_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - php_error, /* error handler */ - php_caudium_sapi_header_handler, /* header handler */ - php_caudium_sapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ - php_caudium_sapi_read_post, /* read POST data */ - php_caudium_sapi_read_cookies, /* read cookies */ - sapi_caudium_register_variables, /* register server variables */ - NULL, /* Log message */ - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -/* - * php_caudium_hash_environment() populates the php script environment - * with a number of variables. HTTP_* variables are created for - * the HTTP header data, so that a script can access these. - */ -static void php_caudium_hash_environment(TSRMLS_D) -{ - int i; - char buf[512]; - zval *pval; - struct svalue *headers; - struct pike_string *sind; - struct array *indices; - struct svalue *ind, *val; - GET_THIS(); - sind = make_shared_string("env"); - headers = low_mapping_string_lookup(REQUEST_DATA, sind); - free_string(sind); - if(headers && headers->type == PIKE_T_MAPPING) { - indices = mapping_indices(headers->u.mapping); - for(i = 0; i < indices->size; i++) { - ind = &indices->item[i]; - val = low_mapping_lookup(headers->u.mapping, ind); - if(ind && ind->type == PIKE_T_STRING && - val && val->type == PIKE_T_STRING) { - int buf_len; - buf_len = MIN(511, ind->u.string->len); - strncpy(buf, ind->u.string->str, buf_len); - buf[buf_len] = '\0'; /* Terminate correctly */ - MAKE_STD_ZVAL(pval); - pval->type = IS_STRING; - pval->value.str.len = val->u.string->len; - pval->value.str.val = estrndup(val->u.string->str, pval->value.str.len); - - zend_hash_update(&EG(symbol_table), buf, buf_len + 1, &pval, sizeof(zval *), NULL); - } - } - free_array(indices); - } - - /* - MAKE_STD_ZVAL(pval); - pval->type = IS_LONG; - pval->value.lval = Ns_InfoBootTime(); - zend_hash_update(&EG(symbol_table), "SERVER_BOOTTIME", sizeof("SERVER_BOOTTIME"), &pval, sizeof(zval *), NULL); - */ -} - -/* - * php_caudium_module_main() is called by the per-request handler and - * "executes" the script - */ - -static void php_caudium_module_main(php_caudium_request *ureq) -{ - int res; - zend_file_handle file_handle; -#ifndef USE_PIKE_LEVEL_THREADS - struct thread_state *state; - extern struct program *thread_id_prog; -#endif - TSRMLS_FETCH(); - GET_THIS(); - THIS->filename = ureq->filename; - THIS->done_cb = ureq->done_cb; - THIS->my_fd_obj = ureq->my_fd_obj; - THIS->my_fd = ureq->my_fd; - THIS->request_data = ureq->request_data; - free(ureq); - -#ifndef USE_PIKE_LEVEL_THREADS - mt_lock_interpreter(); - init_interpreter(); -#if PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION < 1 - thread_id = low_clone(thread_id_prog); - state = OBJ2THREAD(thread_id); - Pike_stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION; - recoveries = NULL; - call_c_initializers(thread_id); - OBJ2THREAD(thread_id)->id=th_self(); - num_threads++; - thread_table_insert(thread_id); - state->status=THREAD_RUNNING; -#else - Pike_interpreter.thread_id = low_clone(thread_id_prog); - state = OBJ2THREAD(Pike_interpreter.thread_id); - Pike_interpreter.stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION; - Pike_interpreter.recoveries = NULL; - call_c_initializers(Pike_interpreter.thread_id); - state->id=th_self(); - // SWAP_OUT_THREAD(OBJ2THREAD(Pike_interpreter.thread_id)); - num_threads++; - thread_table_insert(Pike_interpreter.thread_id); - state->status=THREAD_RUNNING; -#endif - state->swapped = 0; -#endif - SG(request_info).query_string = lookup_string_header("QUERY_STRING", 0); - SG(server_context) = (void *)1; /* avoid server_context == NULL */ - - /* path_translated is apparently the absolute path to the file, not - the translated PATH_INFO - */ - SG(request_info).path_translated = - lookup_string_header("SCRIPT_FILENAME", NULL); - SG(request_info).request_uri = lookup_string_header("DOCUMENT_URI", NULL); - if(!SG(request_info).request_uri) - SG(request_info).request_uri = lookup_string_header("SCRIPT_NAME", NULL); - SG(request_info).request_method = lookup_string_header("REQUEST_METHOD", "GET"); - SG(request_info).content_length = lookup_integer_header("HTTP_CONTENT_LENGTH", 0); - SG(request_info).content_type = lookup_string_header("HTTP_CONTENT_TYPE", NULL); - SG(sapi_headers).http_response_code = 200; - if (!strcmp(SG(request_info).request_method, "HEAD")) { - SG(request_info).headers_only = 1; - } else { - SG(request_info).headers_only = 0; - } - - /* Let PHP4 handle the deconding of the AUTH */ - php_handle_auth_data(lookup_string_header("HTTP_AUTHORIZATION", NULL), TSRMLS_C); - /* Swap out this thread and release the interpreter lock to allow - * Pike threads to run. We wait since the above would otherwise require - * a lot of unlock/lock. - */ -#ifndef USE_PIKE_LEVEL_THREADS - SWAP_OUT_THREAD(state); - mt_unlock_interpreter(); -#else - THREADS_ALLOW(); -#endif - -#ifdef VIRTUAL_DIR - /* Change virtual directory, if the feature is enabled, which is - * (almost) a requirement for PHP in Caudium. Might want to fail if it - * isn't. Not a problem though, since it's on by default when using ZTS - * which we require. - */ - VCWD_CHDIR_FILE(THIS->filename->str); -#endif - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = THIS->filename->str; - file_handle.opened_path = NULL; - file_handle.free_filename = 0; - - THIS->written = 0; - res = php_request_startup(TSRMLS_C); - - if(res == FAILURE) { - THREAD_SAFE_RUN({ - apply_svalue(&THIS->done_cb, 0); - pop_stack(); - free_struct(TSRMLS_C); - }, "Negative run response"); - } else { - THREAD_SAFE_RUN(php_caudium_hash_environment(TSRMLS_C), - "environment hashing"); - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); - THREAD_SAFE_RUN({ - push_int(THIS->written); - apply_svalue(&THIS->done_cb, 1); - pop_stack(); - free_struct(TSRMLS_C); - }, "positive run response"); - } - -#ifndef USE_PIKE_LEVEL_THREADS - mt_lock_interpreter(); - SWAP_IN_THREAD(state); -#if PIKE_MAJOR_VERSION == 7 && PIKE_MINOR_VERSION < 1 - state->status=THREAD_EXITED; - co_signal(& state->status_change); - thread_table_delete(thread_id); - free_object(thread_id); - thread_id=NULL; -#else - state->status=THREAD_EXITED; - co_signal(& state->status_change); - thread_table_delete(Pike_interpreter.thread_id); - free_object(Pike_interpreter.thread_id); - Pike_interpreter.thread_id=NULL; -#endif - cleanup_interpret(); - num_threads--; - mt_unlock_interpreter(); -#else - THREADS_DISALLOW(); -#endif -} - -/* - * The php_caudium_request_handler() is called per request and handles - * everything for one request. - */ - -void f_php_caudium_request_handler(INT32 args) -{ - struct object *my_fd_obj; - struct mapping *request_data; - struct svalue *done_callback; - struct pike_string *script; - struct svalue *raw_fd; - struct pike_string *ind; - php_caudium_request *_request; - THIS = malloc(sizeof(php_caudium_request)); - if(THIS == NULL) - Pike_error("Out of memory."); - - get_all_args("PHP4.Interpreter->run", args, "%S%m%O%*", &script, - &request_data, &my_fd_obj, &done_callback); - if(done_callback->type != PIKE_T_FUNCTION) - Pike_error("PHP4.Interpreter->run: Bad argument 4, expected function.\n"); - add_ref(request_data); - add_ref(my_fd_obj); - add_ref(script); - - THIS->request_data = request_data; - THIS->my_fd_obj = my_fd_obj; - THIS->filename = script; - assign_svalue_no_free(&THIS->done_cb, done_callback); - - ind = make_shared_binary_string("my_fd", 5); - raw_fd = low_mapping_string_lookup(THIS->request_data, ind); - if(raw_fd && raw_fd->type == PIKE_T_OBJECT) - { - int fd = fd_from_object(raw_fd->u.object); - if(fd == -1) - THIS->my_fd = 0; /* Don't send directly to this FD... */ - else - THIS->my_fd = fd; - } else - THIS->my_fd = 0; -#ifdef USE_PIKE_LEVEL_THREADS - php_caudium_module_main(THIS); -#else - th_farm((void (*)(void *))php_caudium_module_main, THIS); -#endif - pop_n_elems(args); -} - -static void free_struct(TSRMLS_D) -{ - GET_THIS(); - if(THIS->request_data) free_mapping(THIS->request_data); - if(THIS->my_fd_obj) free_object(THIS->my_fd_obj); - free_svalue(&THIS->done_cb); - if(THIS->filename) free_string(THIS->filename); - MEMSET(THIS, 0, sizeof(php_caudium_request)); -} - - -/* - * pike_module_init() is called by Pike once at startup - * - * This functions allocates basic structures - */ - -void pike_module_init( void ) -{ - if (!caudium_php_initialized) { - caudium_php_initialized = 1; - tsrm_startup(1, 1, 0, NULL); - ts_allocate_id(&caudium_globals_id, sizeof(php_caudium_request), NULL, NULL); - sapi_startup(&caudium_sapi_module); - sapi_module.startup(&caudium_sapi_module); - zend_startup_module(&php_caudium_module); - } - start_new_program(); /* Text */ - pike_add_function("run", f_php_caudium_request_handler, - "function(string, mapping, object, function:void)", 0); - end_class("Interpreter", 0); -} - -/* - * pike_module_exit() performs the last steps before the - * server exists. Shutdowns basic services and frees memory - */ - -void pike_module_exit(void) -{ - caudium_php_initialized = 0; - sapi_module.shutdown(&caudium_sapi_module); - tsrm_shutdown(); -} -#endif diff --git a/sapi/caudium/config.m4 b/sapi/caudium/config.m4 deleted file mode 100644 index 9fdbb3bebb..0000000000 --- a/sapi/caudium/config.m4 +++ /dev/null @@ -1,98 +0,0 @@ -dnl ## $Id$ -*- sh -*- - -RESULT=no -AC_MSG_CHECKING(for Caudium support) -AC_ARG_WITH(caudium, -[ --with-caudium=DIR Build PHP as a Pike module for use with Caudium - DIR is the Caudium server dir, with the default value - /usr/local/caudium/server.], -[ - if test "$prefix" = "NONE"; then CPREF=/usr/local/; fi - if test ! -d $withval ; then - if test "$prefix" = "NONE"; then - withval=/usr/local/caudium/server/ - else - withval=$prefix/caudium/server/ - fi - fi - if test -f $withval/bin/caudium; then - PIKE=$withval/bin/caudium - elif test -f $withval/bin/pike; then - PIKE=$withval/bin/pike - else - AC_MSG_ERROR(Couldn't find a pike in $withval/bin/) - fi - if $PIKE -e 'float v; int rel;sscanf(version(), "Pike v%f release %d", v, rel);v += rel/10000.0; if(v < 7.0268) exit(1); exit(0);'; then - PIKE_MODULE_DIR=`$PIKE --show-paths 2>&1| grep '^Module' | sed -e 's/.*: //'` - PIKE_INCLUDE_DIR=`echo $PIKE_MODULE_DIR | sed -e 's,lib/pike/modules,include/pike,' -e 's,lib/modules,include/pike,' ` - if test -z "$PIKE_INCLUDE_DIR" -o -z "$PIKE_MODULE_DIR"; then - AC_MSG_ERROR(Failed to figure out Pike module and include directories) - fi - AC_MSG_RESULT(yes) - PIKE=`echo $PIKE | pike -e 'int tries=100; - string orig,pike=Stdio.File("stdin")->read()-"\n"; - orig=pike; - if(search(orig, "/")) - orig = combine_path(getcwd(), orig); - while(!catch(pike=readlink(pike)) && tries--) - ; - write(combine_path(dirname(orig), pike)); '` - PHP_ADD_INCLUDE($PIKE_INCLUDE_DIR) - if test "$prefix" != "NONE"; then - PIKE_C_INCLUDE=$prefix/include/`basename $PIKE` - else - PIKE_C_INCLUDE=/usr/local/include/`basename $PIKE` - fi - AC_MSG_CHECKING(for C includes in $PIKE_C_INCLUDE) - if test -f $PIKE_C_INCLUDE/version.h; then - PIKE_TEST_VER=`$PIKE -e 'string v; int rel;sscanf(version(), "Pike v%s release %d", v, rel); write(v+"."+rel);'` - ###### VERSION MATCH CHECK ####### - PMAJOR="^#define PIKE_MAJOR_VERSION" - PMINOR="^#define PIKE_MINOR_VERSION" - PBUILD="^#define PIKE_BUILD_VERSION" - - PIKE_CMAJOR_VERSION=0 - PIKE_CMINOR_VERSION=0 - PIKE_CBUILD_VERSION=0 - - PIKE_CMAJOR_VERSION=`grep "$PMAJOR" $PIKE_C_INCLUDE/version.h | sed -e 's/\(#define.*N \)\(.*\)/\2/'` - if test -z "$PIKE_CMAJOR_VERSION"; then - if test -n "`grep f_version $PIKE_C_INCLUDE/version.h`"; then - PIKE_CMAJOR_VERSION=6 - fi - else - PIKE_CMINOR_VERSION=`grep "$PMINOR" $PIKE_C_INCLUDE/version.h | sed -e 's/\(#define.*N \)\(.*\)/\2/'` - PIKE_CBUILD_VERSION=`grep "$PBUILD" $PIKE_C_INCLUDE/version.h | sed -e 's/\(#define.*N \)\(.*\)/\2/'` - fi - - if test "$PIKE_TEST_VER" = "${PIKE_CMAJOR_VERSION}.${PIKE_CMINOR_VERSION}.${PIKE_CBUILD_VERSION}"; then - PHP_ADD_INCLUDE($PIKE_C_INCLUDE) - PIKE_INCLUDE_DIR="$PIKE_INCLUDE_DIR, $PIKE_C_INCLUDE" - AC_MSG_RESULT(found) - else - AC_MSG_RESULT(version mismatch) - fi - else - AC_MSG_RESULT(not found) - fi - else - AC_MSG_ERROR(Caudium PHP4 requires Pike 7.0 or newer) - fi - PIKE_VERSION=`$PIKE -e 'string v; int rel;sscanf(version(), "Pike v%s release %d", v, rel); write(v+"."+rel);'` - AC_DEFINE(HAVE_CAUDIUM,1,[Whether to compile with Caudium support]) - PHP_SAPI=caudium - PHP_BUILD_SHARED - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $withval/lib/$PIKE_VERSION/PHP4.so" - RESULT=" *** Pike binary used: $PIKE - *** Pike include dir(s) used: $PIKE_INCLUDE_DIR - *** Pike version: $PIKE_VERSION" - dnl Always use threads since thread-free support really blows. - PHP_BUILD_THREAD_SAFE - -]) -AC_MSG_RESULT($RESULT) - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: - diff --git a/sapi/cgi/CREDITS b/sapi/cgi/CREDITS deleted file mode 100644 index 734f5c5a78..0000000000 --- a/sapi/cgi/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -CGI -Rasmus Lerdorf, Stig Bakken diff --git a/sapi/cgi/Makefile.in b/sapi/cgi/Makefile.in deleted file mode 100644 index 3b66c7d418..0000000000 --- a/sapi/cgi/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = cgi_main.c getopt.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c deleted file mode 100644 index 5e895bd899..0000000000 --- a/sapi/cgi/cgi_main.c +++ /dev/null @@ -1,802 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> | - | Stig Bakken <ssb@fast.no> | - | Zeev Suraski <zeev@zend.com> | - +----------------------------------------------------------------------+ -*/ - - -#include "php.h" -#include "php_globals.h" -#include "php_variables.h" -#include "zend_modules.h" - -#include "SAPI.h" - -#include <stdio.h> -#include "php.h" -#ifdef PHP_WIN32 -#include "win32/time.h" -#include "win32/signal.h" -#include <process.h> -#else -#include "build-defs.h" -#endif -#if HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#if HAVE_SIGNAL_H -#include <signal.h> -#endif -#if HAVE_SETLOCALE -#include <locale.h> -#endif -#include "zend.h" -#include "zend_extensions.h" -#include "php_ini.h" -#include "php_globals.h" -#include "php_main.h" -#include "fopen_wrappers.h" -#include "ext/standard/php_standard.h" -#ifdef PHP_WIN32 -#include <io.h> -#include <fcntl.h> -#include "win32/php_registry.h" -#endif - -#if HAVE_SIGNAL_H -#include <signal.h> -#endif - -#include "zend_compile.h" -#include "zend_execute.h" -#include "zend_highlight.h" -#include "zend_indent.h" - - -#include "php_getopt.h" - -#define PHP_MODE_STANDARD 1 -#define PHP_MODE_HIGHLIGHT 2 -#define PHP_MODE_INDENT 3 -#define PHP_MODE_LINT 4 - -extern char *ap_php_optarg; -extern int ap_php_optind; - -#define OPTSTRING "aCc:d:ef:g:hilmnqs?vz:" - -static int _print_module_info(zend_module_entry *module, void *arg TSRMLS_DC) -{ - php_printf("%s\n", module->name); - return 0; -} - -#ifndef STDOUT_FILENO -#define STDOUT_FILENO 1 -#endif - -static inline size_t sapi_cgibin_single_write(const char *str, uint str_length) -{ -#ifdef PHP_WRITE_STDOUT - long ret; - - ret = write(STDOUT_FILENO, str, str_length); - if (ret <= 0) return 0; - return ret; -#else - size_t ret; - - ret = fwrite(str, 1, MIN(str_length, 16384), stdout); - return ret; -#endif -} - -static int sapi_cgibin_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - const char *ptr = str; - uint remaining = str_length; - size_t ret; - - while (remaining > 0) - { - ret = sapi_cgibin_single_write(ptr, remaining); - if (!ret) { - php_handle_aborted_connection(); - } - ptr += ret; - remaining -= ret; - } - - return str_length; -} - - -static void sapi_cgibin_flush(void *server_context) -{ - if (fflush(stdout)==EOF) { - php_handle_aborted_connection(); - } -} - - -static void sapi_cgi_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC) -{ - if (sapi_header) { - PHPWRITE_H(sapi_header->header, sapi_header->header_len); - } - PHPWRITE_H("\r\n", 2); -} - - -static int sapi_cgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - uint read_bytes=0, tmp_read_bytes; - - count_bytes = MIN(count_bytes, (uint)SG(request_info).content_length-SG(read_post_bytes)); - while (read_bytes < count_bytes) { - tmp_read_bytes = read(0, buffer+read_bytes, count_bytes-read_bytes); - if (tmp_read_bytes<=0) { - break; - } - read_bytes += tmp_read_bytes; - } - return read_bytes; -} - - -static char *sapi_cgi_read_cookies(TSRMLS_D) -{ - return getenv("HTTP_COOKIE"); -} - - -static void sapi_cgi_register_variables(zval *track_vars_array TSRMLS_DC) -{ - /* In CGI mode, we consider the environment to be a part of the server - * variables - */ - php_import_environment_variables(track_vars_array TSRMLS_CC); - - /* Build the special-case PHP_SELF variable for the CGI version */ - php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array TSRMLS_CC); -} - - -static void sapi_cgi_log_message(char *message) -{ - if (php_header()) { - fprintf(stderr, "%s", message); - fprintf(stderr, "\n"); - } -} - -static int sapi_cgi_deactivate(TSRMLS_D) -{ - fflush(stdout); - if(SG(request_info).argv0) { - free(SG(request_info).argv0); - SG(request_info).argv0 = NULL; - } - return SUCCESS; -} - - -/* {{{ sapi_module_struct cgi_sapi_module - */ -static sapi_module_struct cgi_sapi_module = { - "cgi", /* name */ - "CGI", /* pretty name */ - - php_module_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - NULL, /* activate */ - sapi_cgi_deactivate, /* deactivate */ - - sapi_cgibin_ub_write, /* unbuffered write */ - sapi_cgibin_flush, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, /* error handler */ - - NULL, /* header handler */ - NULL, /* send headers handler */ - sapi_cgi_send_header, /* send header handler */ - - sapi_cgi_read_post, /* read POST data */ - sapi_cgi_read_cookies, /* read Cookies */ - - sapi_cgi_register_variables, /* register server variables */ - sapi_cgi_log_message, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; -/* }}} */ - -/* {{{ php_cgi_usage - */ -static void php_cgi_usage(char *argv0) -{ - char *prog; - - prog = strrchr(argv0, '/'); - if (prog) { - prog++; - } else { - prog = "php"; - } - - php_printf("Usage: %s [-q] [-h] [-s [-v] [-i] [-f <file>] | {<file> [args...]}\n" - " -q Quiet-mode. Suppress HTTP Header output.\n" - " -s Display colour syntax highlighted source.\n" - " -f <file> Parse <file>. Implies `-q'\n" - " -v Version number\n" - " -C Do not chdir to the script's directory\n" - " -c <path> Look for php.ini file in this directory\n" - " -a Run interactively\n" - " -d foo[=bar] Define INI entry foo with value 'bar'\n" - " -e Generate extended information for debugger/profiler\n" - " -z <file> Load Zend extension <file>.\n" - " -l Syntax check only (lint)\n" - " -m Show compiled in modules\n" - " -i PHP information\n" - " -h This help\n", prog); -} -/* }}} */ - -/* {{{ init_request_info - */ -static void init_request_info(TSRMLS_D) -{ - char *content_length = getenv("CONTENT_LENGTH"); - char *content_type = getenv("CONTENT_TYPE"); - const char *auth; - -#if 0 -/* SG(request_info).path_translated is always set to NULL at the end of this function - call so why the hell did this code exist in the first place? Am I missing something? */ - char *script_filename; - - - script_filename = getenv("SCRIPT_FILENAME"); - /* Hack for annoying servers that do not set SCRIPT_FILENAME for us */ - if (!script_filename) { - script_filename = SG(request_info).argv0; - } -#ifdef PHP_WIN32 - /* FIXME WHEN APACHE NT IS FIXED */ - /* a hack for apache nt because it does not appear to set argv[1] and sets - script filename to php.exe thus makes us parse php.exe instead of file.php - requires we get the info from path translated. This can be removed at - such a time that apache nt is fixed */ - if (!script_filename) { - script_filename = getenv("PATH_TRANSLATED"); - } -#endif - - /* doc_root configuration variable is currently ignored, - as it is with every other access method currently also. */ - - /* We always need to emalloc() filename, since it gets placed into - the include file hash table, and gets freed with that table. - Notice that this means that we don't need to efree() it in - php_destroy_request_info()! */ -#if DISCARD_PATH - if (script_filename) { - SG(request_info).path_translated = strdup(script_filename); - } else { - SG(request_info).path_translated = NULL; - } -#endif - -#endif /* 0 */ - - SG(request_info).request_method = getenv("REQUEST_METHOD"); - SG(request_info).query_string = getenv("QUERY_STRING"); - SG(request_info).request_uri = getenv("PATH_INFO"); - if (!SG(request_info).request_uri) { - SG(request_info).request_uri = getenv("SCRIPT_NAME"); - } - SG(request_info).path_translated = NULL; /* we have to update it later, when we have that information */ - SG(request_info).content_type = (content_type ? content_type : "" ); - SG(request_info).content_length = (content_length?atoi(content_length):0); - SG(sapi_headers).http_response_code = 200; - - /* The CGI RFC allows servers to pass on unvalidated Authorization data */ - auth = getenv("HTTP_AUTHORIZATION"); - php_handle_auth_data(auth TSRMLS_CC); -} -/* }}} */ - -static void define_command_line_ini_entry(char *arg) -{ - char *name, *value; - - name = arg; - value = strchr(arg, '='); - if (value) { - *value = 0; - value++; - } else { - value = "1"; - } - zend_alter_ini_entry(name, strlen(name)+1, value, strlen(value), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); -} - - -static void php_register_command_line_global_vars(char **arg TSRMLS_DC) -{ - char *var, *val; - - var = *arg; - val = strchr(var, '='); - if (!val) { - printf("No value specified for variable '%s'\n", var); - } else { - *val++ = '\0'; - php_register_variable(var, val, NULL TSRMLS_CC); - } - efree(*arg); -} - -/* {{{ main - */ -int main(int argc, char *argv[]) -{ - int exit_status = SUCCESS; - int cgi = 0, c, i, len; - zend_file_handle file_handle; - int retval = FAILURE; - char *s; -/* temporary locals */ - int behavior=PHP_MODE_STANDARD; - int no_headers=0; - int orig_optind=ap_php_optind; - char *orig_optarg=ap_php_optarg; - char *argv0=NULL; - char *script_file=NULL; - zend_llist global_vars; - int interactive=0; -/* end of temporary locals */ -#ifdef ZTS - zend_compiler_globals *compiler_globals; - zend_executor_globals *executor_globals; - php_core_globals *core_globals; - sapi_globals_struct *sapi_globals; - void ***tsrm_ls; -#endif - - -#ifdef HAVE_SIGNAL_H -#if defined(SIGPIPE) && defined(SIG_IGN) - signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so - that sockets created via fsockopen() - don't kill PHP if the remote site - closes it. in apache|apxs mode apache - does that for us! thies@thieso.net - 20000419 */ -#endif -#endif - - -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); -#endif - - sapi_startup(&cgi_sapi_module); - -#ifdef PHP_WIN32 - _fmode = _O_BINARY; /*sets default for file streams to binary */ - setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */ - setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ -#endif - - - /* Make sure we detect we are a cgi - a bit redundancy here, - but the default case is that we have to check only the first one. */ - if (getenv("SERVER_SOFTWARE") - || getenv("SERVER_NAME") - || getenv("GATEWAY_INTERFACE") - || getenv("REQUEST_METHOD")) { - cgi = 1; - if (argc > 1) { - argv0 = strdup(argv[1]); - } else { - argv0 = NULL; - } - } - - if (!cgi) { - while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) { - switch (c) { - case 'c': - cgi_sapi_module.php_ini_path_override = strdup(ap_php_optarg); - break; - } - - } - ap_php_optind = orig_optind; - ap_php_optarg = orig_optarg; - } - - /* startup after we get the above ini override se we get things right */ - if (php_module_startup(&cgi_sapi_module)==FAILURE) { - return FAILURE; - } - -#if FORCE_CGI_REDIRECT - /* check force_cgi after startup, so we have proper output */ - if (cgi) { - /* Apache will generate REDIRECT_STATUS, - * Netscape and redirect.so will generate HTTP_REDIRECT_STATUS. - * redirect.so and installation instructions available from - * http://www.koehntopp.de/php. - * -- kk@netuse.de - */ - if (!getenv("REDIRECT_STATUS") && !getenv ("HTTP_REDIRECT_STATUS")) { - PUTS("<b>Security Alert!</b> PHP CGI cannot be accessed directly.\n\ -\n\ -<P>This PHP CGI binary was compiled with force-cgi-redirect enabled. This\n\ -means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\ -set. This variable is set, for example, by Apache's Action directive redirect.\n\ -<P>You may disable this restriction by recompiling the PHP binary with the\n\ ---disable-force-cgi-redirect switch. If you do this and you have your PHP CGI\n\ -binary accessible somewhere in your web tree, people will be able to circumvent\n\ -.htaccess security by loading files through the PHP parser. A good way around\n\ -this is to define doc_root in your php.ini file to something other than your\n\ -top-level DOCUMENT_ROOT. This way you can separate the part of your web space\n\n\ -which uses PHP from the normal part using .htaccess security. If you do not have\n\ -any .htaccess restrictions anywhere on your site you can leave doc_root undefined.\n\ -\n"); - - /* remove that detailed explanation some time */ - - return FAILURE; - } - } -#endif /* FORCE_CGI_REDIRECT */ - -#ifdef ZTS - compiler_globals = ts_resource(compiler_globals_id); - executor_globals = ts_resource(executor_globals_id); - core_globals = ts_resource(core_globals_id); - sapi_globals = ts_resource(sapi_globals_id); - tsrm_ls = ts_resource(0); -#endif - - zend_first_try { - if (!cgi) { - while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) { - switch (c) { - case '?': - no_headers = 1; - php_output_startup(); - php_output_activate(TSRMLS_C); - SG(headers_sent) = 1; - php_cgi_usage(argv[0]); - php_end_ob_buffers(1 TSRMLS_CC); - exit(1); - break; - } - } - ap_php_optind = orig_optind; - ap_php_optarg = orig_optarg; - } - - init_request_info(TSRMLS_C); - SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */ - CG(extended_info) = 0; - - SG(request_info).argv0 = argv0; - - zend_llist_init(&global_vars, sizeof(char *), NULL, 0); - - if (!cgi) { /* never execute the arguments if you are a CGI */ - if (SG(request_info).argv0) { - free(SG(request_info).argv0); - SG(request_info).argv0 = NULL; - } - while ((c = ap_php_getopt(argc, argv, OPTSTRING)) != -1) { - switch (c) { - - case 'a': /* interactive mode */ - printf("Interactive mode enabled\n\n"); - interactive=1; - break; - - case 'C': /* don't chdir to the script directory */ - SG(options) |= SAPI_OPTION_NO_CHDIR; - break; - case 'd': /* define ini entries on command line */ - define_command_line_ini_entry(ap_php_optarg); - break; - - case 'e': /* enable extended info output */ - CG(extended_info) = 1; - break; - - case 'f': /* parse file */ - script_file = strdup(ap_php_optarg); - no_headers = 1; - break; - - case 'g': /* define global variables on command line */ - { - char *arg = estrdup(ap_php_optarg); - - zend_llist_add_element(&global_vars, &arg); - } - break; - - case 'h': /* help & quit */ - case '?': - no_headers = 1; - php_output_startup(); - php_output_activate(TSRMLS_C); - SG(headers_sent) = 1; - php_cgi_usage(argv[0]); - php_end_ob_buffers(1 TSRMLS_CC); - exit(1); - break; - - case 'i': /* php info & quit */ - if (php_request_startup(TSRMLS_C)==FAILURE) { - php_module_shutdown(TSRMLS_C); - return FAILURE; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - php_print_info(0xFFFFFFFF TSRMLS_CC); - exit(1); - break; - - case 'l': /* syntax check mode */ - no_headers = 1; - behavior=PHP_MODE_LINT; - break; - - case 'm': /* list compiled in modules */ - php_output_startup(); - php_output_activate(TSRMLS_C); - SG(headers_sent) = 1; - php_printf("Running PHP %s\n%s\n", PHP_VERSION , get_zend_version()); - php_printf("[PHP Modules]\n"); - zend_hash_apply_with_argument(&module_registry, (apply_func_arg_t) _print_module_info, NULL TSRMLS_CC); - php_printf("\n[Zend Modules]\n"); - /* zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) _print_module_info, NULL TSRMLS_CC); */ - php_printf("Not Implemented\n"); - php_printf("\n"); - php_end_ob_buffers(1 TSRMLS_CC); - exit(1); - break; - -#if 0 /* not yet operational, see also below ... */ - case 'n': /* generate indented source mode*/ - behavior=PHP_MODE_INDENT; - break; -#endif - - case 'q': /* do not generate HTTP headers */ - no_headers = 1; - break; - - case 's': /* generate highlighted HTML from source */ - behavior=PHP_MODE_HIGHLIGHT; - break; - - case 'v': /* show php version & quit */ - no_headers = 1; - if (php_request_startup(TSRMLS_C)==FAILURE) { - php_module_shutdown(TSRMLS_C); - return FAILURE; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - php_printf("%s\n", PHP_VERSION); - php_end_ob_buffers(1 TSRMLS_CC); - exit(1); - break; - - case 'z': /* load extension file */ - zend_load_extension(ap_php_optarg); - break; - - default: - break; - } - } - } /* not cgi */ - - CG(interactive) = interactive; - - if (!cgi) { - if (!SG(request_info).query_string) { - len = 0; - if (script_file) { - len += strlen(script_file) + 1; - } - for (i = ap_php_optind; i < argc; i++) { - len += strlen(argv[i]) + 1; - } - - s = malloc(len + 1); /* leak - but only for command line version, so ok */ - *s = '\0'; /* we are pretending it came from the environment */ - if (script_file) { - strcpy(s, script_file); - if (ap_php_optind<argc) { - strcat(s, "+"); - } - } - for (i = ap_php_optind, len = 0; i < argc; i++) { - strcat(s, argv[i]); - if (i < (argc - 1)) { - strcat(s, "+"); - } - } - SG(request_info).query_string = s; - } - } - - if (script_file) { - SG(request_info).path_translated = script_file; - } - - if (php_request_startup(TSRMLS_C)==FAILURE) { - php_module_shutdown(TSRMLS_C); - return FAILURE; - } - if (no_headers) { - SG(headers_sent) = 1; - SG(request_info).no_headers = 1; - } - file_handle.filename = "-"; - file_handle.type = ZEND_HANDLE_FP; - file_handle.handle.fp = stdin; - file_handle.opened_path = NULL; - file_handle.free_filename = 0; - - /* This actually destructs the elements of the list - ugly hack */ - zend_llist_apply(&global_vars, (llist_apply_func_t) php_register_command_line_global_vars TSRMLS_CC); - zend_llist_destroy(&global_vars); - - if (!cgi) { - if (!SG(request_info).path_translated && argc > ap_php_optind) { - SG(request_info).path_translated = strdup(argv[ap_php_optind]); - } - } else { - /* If for some reason the CGI interface is not setting the - PATH_TRANSLATED correctly, SG(request_info).path_translated is NULL. - We still call php_fopen_primary_script, because if you set doc_root - or user_dir configuration directives, PATH_INFO is used to construct - the filename as a side effect of php_fopen_primary_script. - */ - char *env_path_translated=NULL; -#if DISCARD_PATH - env_path_translated = getenv("SCRIPT_FILENAME"); -#else - env_path_translated = getenv("PATH_TRANSLATED"); -#endif - if(env_path_translated) { - SG(request_info).path_translated = strdup(env_path_translated); - } - } - if (cgi || SG(request_info).path_translated) { - retval = php_fopen_primary_script(&file_handle TSRMLS_CC); - } - - if (cgi && (retval == FAILURE)) { - if(!argv0 || !(file_handle.handle.fp = VCWD_FOPEN(argv0, "rb"))) { - PUTS("No input file specified.\n"); - php_request_shutdown((void *) 0); - php_module_shutdown(TSRMLS_C); - return FAILURE; - } - file_handle.filename = argv0; - file_handle.opened_path = expand_filepath(argv0, NULL TSRMLS_CC); - } else if (retval == SUCCESS) { - /* #!php support */ - c = fgetc(file_handle.handle.fp); - if (c == '#') { - while (c != 10 && c != 13) { - c = fgetc(file_handle.handle.fp); /* skip to end of line */ - } - CG(zend_lineno)++; - } else { - rewind(file_handle.handle.fp); - } - } - - switch (behavior) { - case PHP_MODE_STANDARD: - exit_status = php_execute_script(&file_handle TSRMLS_CC); - break; - case PHP_MODE_LINT: - PG(during_request_startup) = 0; - exit_status = php_lint_script(&file_handle TSRMLS_CC); - if (exit_status==SUCCESS) { - zend_printf("No syntax errors detected in %s\n", file_handle.filename); - } else { - zend_printf("Errors parsing %s\n", file_handle.filename); - } - break; - case PHP_MODE_HIGHLIGHT: - { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - if (open_file_for_scanning(&file_handle TSRMLS_CC)==SUCCESS) { - php_get_highlight_struct(&syntax_highlighter_ini); - zend_highlight(&syntax_highlighter_ini TSRMLS_CC); - fclose(file_handle.handle.fp); - } - return SUCCESS; - } - break; -#if 0 - /* Zeev might want to do something with this one day */ - case PHP_MODE_INDENT: - open_file_for_scanning(&file_handle TSRMLS_CC); - zend_indent(); - fclose(file_handle.handle.fp); - return SUCCESS; - break; -#endif - } - - php_request_shutdown((void *) 0); - - if (SG(request_info).path_translated) { - free(SG(request_info).path_translated); - } - - if (cgi_sapi_module.php_ini_path_override) { - free(cgi_sapi_module.php_ini_path_override); - } - - } zend_catch { - exit_status = -1; - } zend_end_try(); - - php_module_shutdown(TSRMLS_C); - -#ifdef ZTS - tsrm_shutdown(); -#endif - - return exit_status; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ diff --git a/sapi/cgi/config.m4 b/sapi/cgi/config.m4 deleted file mode 100644 index 7a0007e572..0000000000 --- a/sapi/cgi/config.m4 +++ /dev/null @@ -1,98 +0,0 @@ -AC_DEFUN(PHP_TEST_WRITE_STDOUT,[ - AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[ - AC_TRY_RUN([ -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#define TEXT "This is the test message -- " - -main() -{ - int n; - - n = write(1, TEXT, sizeof(TEXT)-1); - return (!(n == sizeof(TEXT)-1)); -} - ],[ - ac_cv_write_stdout=yes - ],[ - ac_cv_write_stdout=no - ],[ - ac_cv_write_stdout=no - ]) - ]) - if test "$ac_cv_write_stdout" = "yes"; then - AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works]) - fi -]) - -if test "$PHP_SAPI" = "cgi"; then - - PHP_TEST_WRITE_STDOUT - - PHP_ARG_ENABLE(force-cgi-redirect,whether to force Apache CGI redirect, -[ --enable-force-cgi-redirect - Enable the security check for internal server - redirects. You should use this if you are - running the CGI version with Apache. ]) - - if test "$PHP_FORCE_CGI_REDIRECT" = "yes"; then - REDIRECT=1 - else - REDIRECT=0 - fi - AC_DEFINE_UNQUOTED(FORCE_CGI_REDIRECT,$REDIRECT,[ ]) - - PHP_ARG_ENABLE(discard-path,whether to discard path_info + path_translated, -[ --enable-discard-path If this is enabled, the PHP CGI binary - can safely be placed outside of the - web tree and people will not be able - to circumvent .htaccess security. ]) - - if test "$PHP_DISCARD_PATH" = "yes"; then - DISCARD_PATH=1 - else - DISCARD_PATH=0 - fi - AC_DEFINE_UNQUOTED(DISCARD_PATH, $DISCARD_PATH, [ ]) - -fi - -if test "$PHP_SAPI" = "cgi" ; then - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_PROGRAM \$(INSTALL_ROOT)\$(bindir)/$SAPI_CGI" -fi - -AC_MSG_CHECKING(for fhttpd module support) -AC_ARG_WITH(fhttpd, -[ --with-fhttpd[=DIR] Build fhttpd module. DIR is the fhttpd sources - directory, defaults to /usr/local/src/fhttpd.], -[ - if test "$withval" = "yes"; then - # fhttpd source directory - withval=/usr/local/src/fhttpd - fi - if test "$withval" != "no"; then -# For fhttpd 0.3.x - if test -f $withval/servproc.h; then - FHTTPD_INCLUDE=-I$withval/ - FHTTPD_LIB=$withval/servproc.o - FHTTPD_TARGET=$withval/ - PHP_BUILD_STATIC - PHP_SAPI=cgi - AC_DEFINE(FHTTPD,1,[ ]) - AC_MSG_RESULT(yes - fhttpd 0.3.x) - else - AC_MSG_RESULT(no) - AC_MSG_ERROR(Invalid fhttpd directory - unable to find servproc.h under $withval) - fi - else - AC_MSG_RESULT(no) - fi -],[ - AC_MSG_RESULT(no) -]) -INCLUDES="$INCLUDES $FHTTPD_INCLUDE" -dnl## AC_SUBST(FHTTPD_INCLUDE) -PHP_SUBST(FHTTPD_LIB) -PHP_SUBST(FHTTPD_TARGET) diff --git a/sapi/cgi/getopt.c b/sapi/cgi/getopt.c deleted file mode 100644 index 120870108a..0000000000 --- a/sapi/cgi/getopt.c +++ /dev/null @@ -1,175 +0,0 @@ -/* Borrowed from Apache NT Port */ - -#include <stdio.h> -#include <string.h> -#include <assert.h> -#include <stdlib.h> -#include "php_getopt.h" -#define OPTERRCOLON (1) -#define OPTERRNF (2) -#define OPTERRARG (3) - - -char *ap_php_optarg; -int ap_php_optind = 1; -static int ap_php_opterr = 1; -static int ap_php_optopt; - -static int -ap_php_optiserr(int argc, char * const *argv, int oint, const char *optstr, - int optchr, int err) -{ - if (ap_php_opterr) - { - fprintf(stderr, "Error in argument %d, char %d: ", oint, optchr+1); - switch(err) - { - case OPTERRCOLON: - fprintf(stderr, ": in flags\n"); - break; - case OPTERRNF: - fprintf(stderr, "option not found %c\n", argv[oint][optchr]); - break; - case OPTERRARG: - fprintf(stderr, "no argument for option %c\n", argv[oint][optchr]); - break; - default: - fprintf(stderr, "unknown\n"); - break; - } - } - ap_php_optopt = argv[oint][optchr]; - return('?'); -} - -int ap_php_getopt(int argc, char* const *argv, const char *optstr) -{ - static int optchr = 0; - static int dash = 0; /* have already seen the - */ - - char *cp; - - if (ap_php_optind >= argc) - return(EOF); - if (!dash && (argv[ap_php_optind][0] != '-')) - return(EOF); - if (!dash && (argv[ap_php_optind][0] == '-') && !argv[ap_php_optind][1]) - { - /* - * use to specify stdin. Need to let pgm process this and - * the following args - */ - return(EOF); - } - if ((argv[ap_php_optind][0] == '-') && (argv[ap_php_optind][1] == '-')) - { - /* -- indicates end of args */ - ap_php_optind++; - return(EOF); - } - if (!dash) - { - assert((argv[ap_php_optind][0] == '-') && argv[ap_php_optind][1]); - dash = 1; - optchr = 1; - } - - /* Check if the guy tries to do a -: kind of flag */ - assert(dash); - if (argv[ap_php_optind][optchr] == ':') - { - dash = 0; - ap_php_optind++; - return(ap_php_optiserr(argc, argv, ap_php_optind-1, optstr, optchr, OPTERRCOLON)); - } - if (!(cp = strchr(optstr, argv[ap_php_optind][optchr]))) - { - int errind = ap_php_optind; - int errchr = optchr; - - if (!argv[ap_php_optind][optchr+1]) - { - dash = 0; - ap_php_optind++; - } - else - optchr++; - return(ap_php_optiserr(argc, argv, errind, optstr, errchr, OPTERRNF)); - } - if (cp[1] == ':') - { - /* Check for cases where the value of the argument - is in the form -<arg> <val> or in the form -<arg><val> */ - dash = 0; - if(!argv[ap_php_optind][2]) { - ap_php_optind++; - if (ap_php_optind == argc) - return(ap_php_optiserr(argc, argv, ap_php_optind-1, optstr, optchr, OPTERRARG)); - ap_php_optarg = argv[ap_php_optind++]; - } - else - { - ap_php_optarg = &argv[ap_php_optind][2]; - ap_php_optind++; - } - return(*cp); - } - else - { - if (!argv[ap_php_optind][optchr+1]) - { - dash = 0; - ap_php_optind++; - } - else - optchr++; - return(*cp); - } - assert(0); - return(0); -} - -#ifdef TESTGETOPT -int - main (int argc, char **argv) - { - int c; - extern char *ap_php_optarg; - extern int ap_php_optind; - int aflg = 0; - int bflg = 0; - int errflg = 0; - char *ofile = NULL; - - while ((c = ap_php_getopt(argc, argv, "abo:")) != EOF) - switch (c) { - case 'a': - if (bflg) - errflg++; - else - aflg++; - break; - case 'b': - if (aflg) - errflg++; - else - bflg++; - break; - case 'o': - ofile = ap_php_optarg; - (void)printf("ofile = %s\n", ofile); - break; - case '?': - errflg++; - } - if (errflg) { - (void)fprintf(stderr, - "usage: cmd [-a|-b] [-o <filename>] files...\n"); - exit (2); - } - for ( ; ap_php_optind < argc; ap_php_optind++) - (void)printf("%s\n", argv[ap_php_optind]); - return 0; - } - -#endif /* TESTGETOPT */ diff --git a/sapi/cgi/php.sym b/sapi/cgi/php.sym deleted file mode 100644 index e69de29bb2..0000000000 --- a/sapi/cgi/php.sym +++ /dev/null diff --git a/sapi/cgi/php_getopt.h b/sapi/cgi/php_getopt.h deleted file mode 100644 index 40da432b59..0000000000 --- a/sapi/cgi/php_getopt.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Borrowed from Apache NT Port */ -#include "php.h" - -extern char *ap_php_optarg; -extern int ap_php_optind; - -int ap_php_getopt(int argc, char* const *argv, const char *optstr); diff --git a/sapi/fastcgi/CREDITS b/sapi/fastcgi/CREDITS deleted file mode 100644 index eb9cece428..0000000000 --- a/sapi/fastcgi/CREDITS +++ /dev/null @@ -1,4 +0,0 @@ -fastcgi -Ben Mansell -Stephen Landamore -Daniel Silverstone diff --git a/sapi/fastcgi/Makefile.in b/sapi/fastcgi/Makefile.in deleted file mode 100644 index 0bea9c31b1..0000000000 --- a/sapi/fastcgi/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = fastcgi.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/fastcgi/README.FastCGI b/sapi/fastcgi/README.FastCGI deleted file mode 100644 index 65dbc44ea0..0000000000 --- a/sapi/fastcgi/README.FastCGI +++ /dev/null @@ -1,17 +0,0 @@ -FastCGI module --------------- - -This module requires the FastCGI development kit, available from -http://www.fastcgi.com/ - -Before building PHP, please enter the dev kit, and run: - -./configure -make -make export - -This will compile the library code required for the FastCGI module. All -that is then required is to configure PHP with the '--with-fastcgi' option. -After making the code, you will end up with a binary file called 'php'. -Installation of this file will depend on the web server being used, please -see their documentation for details. diff --git a/sapi/fastcgi/config.m4 b/sapi/fastcgi/config.m4 deleted file mode 100644 index 74dba3a0d0..0000000000 --- a/sapi/fastcgi/config.m4 +++ /dev/null @@ -1,22 +0,0 @@ -AC_MSG_CHECKING(for FastCGI support) -AC_ARG_WITH(fastcgi, -[ --with-fastcgi=SRCDIR Build PHP as FastCGI application],[ - if test "$withval" = "yes"; then - FASTCGIPATH=/usr/local - else - FASTCGIPATH=$withval - fi - test -f "$FASTCGIPATH/lib/libfcgi.a" || AC_MSG_ERROR(Unable to find libfcgi.a in $FASTCGIPATH/lib) - test -f "$FASTCGIPATH/include/fastcgi.h" || AC_MSG_ERROR(Unable to find fastcgi.h in $FASTCGIPATH/include) - PHP_SAPI=fastcgi - PHP_LIBS=$FASTCGIPATH/lib/libfcgi.a - PHP_ADD_INCLUDE($FASTCGIPATH/include) - EXT_PROGRAM_LDADD="$EXT_PROGRAM_LDADD $FASTCGIPATH/lib/libfcgi.a" - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_PROGRAM \$(bindir)/$SAPI_FASTCGI" - RESULT=yes - PHP_SUBST(FASTCGI_LIBADD) - PHP_SUBST(EXT_PROGRAM_LDADD) -],[ - RESULT=no -]) -AC_MSG_RESULT($RESULT) diff --git a/sapi/fastcgi/fastcgi.c b/sapi/fastcgi/fastcgi.c deleted file mode 100644 index e0a3fe7384..0000000000 --- a/sapi/fastcgi/fastcgi.c +++ /dev/null @@ -1,501 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Ben Mansell <php@slimyhorror.com> | - +----------------------------------------------------------------------+ -*/ - -/* Debugging */ -/* #define DEBUG_FASTCGI 1 */ - -/* Two configurables for the FastCGI runner. - * - * PHP_FCGI_CHILDREN - if set, the FastCGI will pre-fork this many processes - * which will accept requests. - * - * PHP_FCGI_MAX_REQUESTS - if set, the runner will kill itself after handling - * the given number of requests. This is to curb any - * memory leaks in PHP. - */ - - -/* The following code is based mainly on the thttpd sapi and the original - * CGI code, no doubt with many new and interesting bugs created... :) - */ - -#include "php.h" -#include "SAPI.h" -#include "php_main.h" -#include "php_fastcgi.h" -#include "php_variables.h" - -#include "fcgi_config.h" -#include "fcgiapp.h" -#include <stdio.h> -#if HAVE_STDLIB_H -#include <stdlib.h> -#endif -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <sys/wait.h> -#include <sys/stat.h> - -#if HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#if HAVE_SIGNAL_H -#include <signal.h> -#endif - -FCGX_Stream *in, *out, *err; -FCGX_ParamArray envp; -char *path_info = NULL; -struct sigaction act, old_term, old_quit, old_int; - -/* Our original environment from when the FastCGI first started */ -char **orig_env; - -/* The environment given by the FastCGI */ -char **cgi_env; - -/* The manufactured environment, from merging the base environ with - * the parameters set by the per-connection environment - */ -char **merge_env; - -/** - * Number of child processes that will get created to service requests - */ -static int children = 8; - -/** - * Set to non-zero if we are the parent process - */ -static int parent = 1; - -/** - * Process group - */ -static pid_t pgroup; - - -static int sapi_fastcgi_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - uint sent = FCGX_PutStr( str, str_length, out ); - return sent; -} - - -static void sapi_fastcgi_flush( void *server_context ) -{ - if( FCGX_FFlush( out ) == -1 ) { - php_handle_aborted_connection(); - } -} - - -static void sapi_fastcgi_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC) -{ - if( sapi_header ) { -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Header: %s\n", sapi_header->header ); -#endif - FCGX_PutStr( sapi_header->header, sapi_header->header_len, out ); - } - FCGX_PutStr( "\r\n", 2, out ); -} - -static int sapi_fastcgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - size_t read_bytes = 0, tmp; - int c; - char *pos = buffer; - - while( count_bytes ) { - c = FCGX_GetStr( pos, count_bytes, in ); - read_bytes += c; - count_bytes -= c; - pos += c; - if( !c ) break; - } - return read_bytes; -} - -static char *sapi_fastcgi_read_cookies(TSRMLS_D) -{ - return getenv( "HTTP_COOKIE" ); -} - - -static void sapi_fastcgi_register_variables(zval *track_vars_array TSRMLS_DC) -{ - char *self = getenv("REQUEST_URI"); - char *ptr = strchr( self, '?' ); - - /* - * note that the environment will already have been set up - * via fastcgi_module_main(), below. - * - * fastcgi_module_main() -> php_request_startup() -> - * php_hash_environment() -> php_import_environment_variables() - */ - - /* strip query string off this */ - if ( ptr ) *ptr = 0; - php_register_variable( "PHP_SELF", getenv("REQUEST_URI"), track_vars_array TSRMLS_CC); - if ( ptr ) *ptr = '?'; -} - - -static sapi_module_struct fastcgi_sapi_module = { - "fastcgi", - "FastCGI", - - php_module_startup, - php_module_shutdown_wrapper, - - NULL, /* activate */ - NULL, /* deactivate */ - - sapi_fastcgi_ub_write, - sapi_fastcgi_flush, - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, - - NULL, - NULL, - sapi_fastcgi_send_header, - sapi_fastcgi_read_post, - sapi_fastcgi_read_cookies, - - sapi_fastcgi_register_variables, - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -static void fastcgi_module_main(TSRMLS_D) -{ - zend_file_handle file_handle; - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - if (php_request_startup(TSRMLS_C) == SUCCESS) { - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); - } -} - - -static void init_request_info( TSRMLS_D ) -{ - char *content_length = getenv("CONTENT_LENGTH"); - char *content_type = getenv( "CONTENT_TYPE" ); - const char *auth; - struct stat st; - char *pi = getenv( "PATH_INFO" ); - char *pt = getenv( "PATH_TRANSLATED" ); - path_info = strdup( pi ); - - SG(request_info).request_method = getenv("REQUEST_METHOD"); - SG(request_info).query_string = getenv("QUERY_STRING"); - SG(request_info).request_uri = path_info; - SG(request_info).content_type = ( content_type ? content_type : "" ); - SG(request_info).content_length = (content_length?atoi(content_length):0); - SG(sapi_headers).http_response_code = 200; - - SG(request_info).path_translated = pt; - /* - * if the file doesn't exist, try to extract PATH_INFO out - * of it by stat'ing back through the '/' - */ - if ( stat( pt, &st ) == -1 ) { - int len = strlen(pt); - char *ptr; - while( ptr = strrchr(pt,'/') ) { - *ptr = 0; - if ( stat(pt, &st) == 0 && S_ISREG(st.st_mode) ) { - /* - * okay, we found the base script! - * work out how many chars we had to strip off; - * then we can modify PATH_INFO - * accordingly - */ - int slen = len - strlen(pt); - if ( pi ) { - int pilen = strlen( pi ); - strcpy( pi, pi + pilen - slen ); - } - break; - } - } - /* - * if we stripped out all the '/' and still didn't find - * a valid path... we will fail, badly. of course we would - * have failed anyway... is there a nice way to error? - */ - } else { - /* the first stat succeeded... */ - if ( pi ) *pi = 0; - } - - /* The CGI RFC allows servers to pass on unvalidated Authorization data */ - auth = getenv("HTTP_AUTHORIZATION"); -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Authorization: %s\n", auth ); -#endif - php_handle_auth_data(auth TSRMLS_CC); - - -} - - -void fastcgi_php_init(void) -{ - sapi_startup(&fastcgi_sapi_module); - fastcgi_sapi_module.startup(&fastcgi_sapi_module); - SG(server_context) = (void *) 1; -} - -void fastcgi_php_shutdown(void) -{ - if (SG(server_context) != NULL) { - fastcgi_sapi_module.shutdown(&fastcgi_sapi_module); - sapi_shutdown(); - } -} - - -/** - * Clean up child processes upon exit - */ -void fastcgi_cleanup(int signal) -{ - int i; - -#ifdef DEBUG_FASTCGI - fprintf( stderr, "FastCGI shutdown, pid %d\n", getpid() ); -#endif - - sigaction( SIGTERM, &old_term, 0 ); - - /* Kill all the processes in our process group */ - kill( -pgroup, SIGTERM ); - - /* We should exit at this point, but MacOSX doesn't seem to */ - exit( 0 ); -} - - -int main(int argc, char *argv[]) -{ - int exit_status = SUCCESS; - int c, i, len; - zend_file_handle file_handle; - char *s; - char *argv0=NULL; - char *script_file=NULL; - zend_llist global_vars; - int max_requests = 500; - int requests = 0; - int status; - int env_size, cgi_env_size; - -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Initialising now, pid %d!\n", getpid() ); -#endif - - if( FCGX_IsCGI() ) { - fprintf( stderr, "The FastCGI version of PHP cannot be " - "run as a CGI application\n" ); - exit( 1 ); - } - - /* Calculate environment size */ - env_size = 0; - while( environ[ env_size ] ) { env_size++; } - /* Also include the final NULL pointer */ - env_size++; - - /* Allocate for our environment */ - orig_env = malloc( env_size * sizeof( char *)); - if( !orig_env ) { - perror( "Can't malloc environment" ); - exit( 1 ); - } - memcpy( orig_env, environ, env_size * sizeof( char *)); - -#ifdef HAVE_SIGNAL_H -#if defined(SIGPIPE) && defined(SIG_IGN) - signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so - that sockets created via fsockopen() - don't kill PHP if the remote site - closes it. in apache|apxs mode apache - does that for us! thies@thieso.net - 20000419 */ -#endif -#endif - - sapi_startup(&fastcgi_sapi_module); - - if (php_module_startup(&fastcgi_sapi_module)==FAILURE) { - return FAILURE; - } - - /* How many times to run PHP scripts before dying */ - if( getenv( "PHP_FCGI_MAX_REQUESTS" )) { - max_requests = atoi( getenv( "PHP_FCGI_MAX_REQUESTS" )); - if( !max_requests ) { - fprintf( stderr, - "PHP_FCGI_MAX_REQUESTS is not valid\n" ); - exit( 1 ); - } - } - - /* Pre-fork, if required */ - if( getenv( "PHP_FCGI_CHILDREN" )) { - children = atoi( getenv( "PHP_FCGI_CHILDREN" )); - if( !children ) { - fprintf( stderr, - "PHP_FCGI_CHILDREN is not valid\n" ); - exit( 1 ); - } - } - - if( children ) { - int running = 0; - int i; - pid_t pid; - - /* Create a process group for ourself & children */ - setsid(); - pgroup = getpgrp(); -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Process group %d\n", pgroup ); -#endif - - /* Set up handler to kill children upon exit */ - act.sa_flags = 0; - act.sa_handler = fastcgi_cleanup; - if( sigaction( SIGTERM, &act, &old_term ) || - sigaction( SIGINT, &act, &old_int ) || - sigaction( SIGQUIT, &act, &old_quit )) { - perror( "Can't set signals" ); - exit( 1 ); - } - - while( parent ) { - do { -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Forking, %d running\n", - running ); -#endif - pid = fork(); - switch( pid ) { - case 0: - /* One of the children. - * Make sure we don't go round the - * fork loop any more - */ - parent = 0; - - /* don't catch our signals */ - sigaction( SIGTERM, &old_term, 0 ); - sigaction( SIGQUIT, &old_quit, 0 ); - sigaction( SIGINT, &old_int, 0 ); - break; - case -1: - perror( "php (pre-forking)" ); - exit( 1 ); - break; - default: - /* Fine */ - running++; - break; - } - } while( parent && ( running < children )); - - if( parent ) { -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Wait for kids, pid %d\n", - getpid() ); -#endif - wait( &status ); - running--; - } - } - } - - /* Main FastCGI loop */ -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Going into accept loop\n" ); -#endif - - while( FCGX_Accept( &in, &out, &err, &cgi_env ) >= 0 ) { - -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Got accept\n" ); -#endif - - cgi_env_size = 0; - while( cgi_env[ cgi_env_size ] ) { cgi_env_size++; } - merge_env = malloc( (env_size+cgi_env_size)*sizeof(char*) ); - if( !merge_env ) { - perror( "Can't malloc environment" ); - exit( 1 ); - } - memcpy( merge_env, orig_env, (env_size-1)*sizeof(char *) ); - memcpy( merge_env + env_size - 1, - cgi_env, (cgi_env_size+1)*sizeof(char *) ); - environ = merge_env; - - init_request_info(TSRMLS_C); - SG(server_context) = (void *) 1; /* avoid server_context==NULL checks */ - CG(extended_info) = 0; - SG(request_info).argv0 = argv0; - zend_llist_init(&global_vars, sizeof(char *), NULL, 0); - - fastcgi_module_main(TSRMLS_C); - if( path_info ) { - free( path_info ); - path_info = NULL; - } - - /* TODO: We should free our environment here, but - * some platforms are unhappy if they've altered our - * existing environment and we then free() the new - * environ pointer - */ - - requests++; - if( max_requests && ( requests == max_requests )) { - FCGX_Finish(); - break; - } - } - -#ifdef DEBUG_FASTCGI - fprintf( stderr, "Exiting...\n" ); -#endif - return 0; -} diff --git a/sapi/fastcgi/php.sym b/sapi/fastcgi/php.sym deleted file mode 100644 index e69de29bb2..0000000000 --- a/sapi/fastcgi/php.sym +++ /dev/null diff --git a/sapi/fastcgi/php_fastcgi.h b/sapi/fastcgi/php_fastcgi.h deleted file mode 100644 index 9031d7bd11..0000000000 --- a/sapi/fastcgi/php_fastcgi.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_FASTCGI_H -#define PHP_FASTCGI_H - -#include <sys/types.h> -#include <sys/stat.h> - -void fastcgi_php_shutdown(void); -void fastcgi_php_init(void); - -#endif diff --git a/sapi/fhttpd/CREDITS b/sapi/fhttpd/CREDITS deleted file mode 100644 index aaa5aac1fd..0000000000 --- a/sapi/fhttpd/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -fhttpd -Alex Belits diff --git a/sapi/fhttpd/fhttpd.c b/sapi/fhttpd/fhttpd.c deleted file mode 100644 index 762251df3d..0000000000 --- a/sapi/fhttpd/fhttpd.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Alex Belits <abelits@phobos.illtel.denver.co.us> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ -#include "php.h" - -#include <stdlib.h> -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <string.h> -#include <errno.h> -#include <ctype.h> - -#if FHTTPD -#include <servproc.h> -#include <signal.h> - -struct http_server *server = NULL; -struct request *req = NULL; -struct httpresponse *response = NULL; -int headermade = 0; -int global_alarmflag = 0; -int idle_timeout = IDLE_TIMEOUT; -int exit_status = 0; -char **currentheader = NULL; -char *headerfirstline = NULL; -int headerlines = 0; -static int headerlinesallocated = 0; - -void alarmhandler(SIGACTARGS) -{ - global_alarmflag = 1; -} - -void setalarm(int t) -{ - struct sigaction tmpsigaction; - global_alarmflag = 0; - if (t){ - bzero((char *) &tmpsigaction, sizeof(struct sigaction)); - tmpsigaction.sa_handler = alarmhandler; - sigaddset(&tmpsigaction.sa_mask, SIGALRM); - tmpsigaction.sa_flags = 0; - sigaction(SIGALRM, &tmpsigaction, NULL); - alarm(t); - } -} - -int checkinput(int h) -{ - fd_set readfd; - FD_ZERO(&readfd); - FD_SET(h, &readfd); - return select(h + 1, &readfd, NULL, NULL, NULL) > 0; -} - - -PHPAPI void php_fhttpd_free_header(void) -{ - int i; - - if (headerfirstline) { - free(headerfirstline); - headerfirstline = NULL; - } - if (currentheader) { - for (i = 0; i < headerlines; i++) { - free(currentheader[i]); - } - free(currentheader); - currentheader = NULL; - } - headerlines = 0; - headerlinesallocated = 0; - headermade = 0; -} - - -PHPAPI void php_fhttpd_puts_header(char *s) -{ - char *p0, *p1, *p2, *p3, **p; - int l; - - if (!s || !*s || *s == '\r' || *s == '\n') - return; - l = strlen(s); - p2 = strchr(s, '\r'); - p3 = strchr(s, '\n'); - p0 = strchr(s, ':'); - p1 = strchr(s, ' '); - if (p0 && (!p1 || p1 > p0)) { - if (!headerlinesallocated) { - currentheader = (char **) malloc(10 * sizeof(char *)); - if (currentheader) - headerlinesallocated = 10; - } else { - if (headerlinesallocated <= headerlines) { - p = (char **) realloc(currentheader, (headerlinesallocated + 10) * sizeof(char *)); - if (p) { - currentheader = p; - headerlinesallocated += 10; - } - } - } - - if (headerlinesallocated > headerlines) { - currentheader[headerlines] = malloc(l + 3); - if (currentheader[headerlines]) { - strcpy(currentheader[headerlines], s); - if (!p3) { - if (p2) { - (currentheader[headerlines] + (p2 - s))[1] = '\n'; - (currentheader[headerlines] + (p2 - s))[2] = 0; - } else { - currentheader[headerlines][l] = '\r'; - currentheader[headerlines][l + 1] = '\n'; - currentheader[headerlines][l + 2] = 0; - } - } - headerlines++; - headermade = 1; - } - } - } else { - if (headerfirstline) - free(headerfirstline); - headerfirstline = malloc(l + 3); - if (headerfirstline) { - strcpy(headerfirstline, s); - if (!p3) { - if (p2) { - (headerfirstline + (p2 - s))[1] = '\n'; - (headerfirstline + (p2 - s))[2] = 0; - } else { - headerfirstline[l] = '\r'; - headerfirstline[l + 1] = '\n'; - headerfirstline[l + 2] = 0; - } - } - } - headermade = 1; - } -} - -void fhttpd_flush(void) -{ -} - -PHPAPI void php_fhttpd_puts(char *s) -{ - putlinetoresponse(response, s); -} - -PHPAPI void php_fhttpd_putc(char c) -{ - writetoresponse(response, &c, 1); -} - -PHPAPI int php_fhttpd_write(char *a, int n) -{ - return writetoresponse(response, a, n); -} -#endif -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/sapi/isapi/CREDITS b/sapi/isapi/CREDITS deleted file mode 100644 index 11c6fdc73c..0000000000 --- a/sapi/isapi/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -ISAPI -Andi Gutmans, Zeev Suraski diff --git a/sapi/isapi/Makefile.in b/sapi/isapi/Makefile.in deleted file mode 100644 index 34d4bdc15c..0000000000 --- a/sapi/isapi/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = php4isapi.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/isapi/config.m4 b/sapi/isapi/config.m4 deleted file mode 100644 index 85fc88059a..0000000000 --- a/sapi/isapi/config.m4 +++ /dev/null @@ -1,26 +0,0 @@ -dnl ## $Id$ -*- sh -*- - -RESULT=no -AC_MSG_CHECKING(for Zeus ISAPI support) -AC_ARG_WITH(isapi, -[ --with-isapi=DIR Build PHP as an ISAPI module for use with Zeus.], -[ - if test "$withval" = "yes"; then - ZEUSPATH=/usr/local/zeus # the default - else - ZEUSPATH=$withval - fi - test -f "$ZEUSPATH/web/include/httpext.h" || AC_MSG_ERROR(Unable to find httpext.h in $ZEUSPATH/web/include) - PHP_BUILD_THREAD_SAFE - AC_DEFINE(WITH_ZEUS,1,[ ]) - PHP_ADD_INCLUDE($ZEUSPATH/web/include) - PHP_SAPI=isapi - PHP_BUILD_SHARED - INSTALL_IT="\$(SHELL) \$(srcdir)/install-sh -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$ZEUSPATH/web/bin/" - RESULT=yes -]) -AC_MSG_RESULT($RESULT) - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/isapi/php.sym b/sapi/isapi/php.sym deleted file mode 100644 index 34b50b851c..0000000000 --- a/sapi/isapi/php.sym +++ /dev/null @@ -1,5 +0,0 @@ -GetFilterVersion -HttpFilterProc -GetExtensionVersion -HttpExtensionProc -ZSLMain diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c deleted file mode 100644 index 6256d7f93b..0000000000 --- a/sapi/isapi/php4isapi.c +++ /dev/null @@ -1,858 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Authors: Zeev Suraski <zeev@zend.com> | - | Zeus Support: Ben Mansell <ben@zeus.com> | - +----------------------------------------------------------------------+ - */ - -#ifdef PHP_WIN32 -# include <windows.h> -# include <process.h> -#else -# define __try -# define __except(val) -# define __declspec(foo) -#endif - -#include <httpext.h> -#include <httpfilt.h> -#include <httpext.h> -#include "php.h" -#include "php_main.h" -#include "SAPI.h" -#include "php_globals.h" -#include "ext/standard/info.h" -#include "php_variables.h" -#include "php_ini.h" - -#ifdef WITH_ZEUS -# include "httpext.h" -# include <errno.h> -# define GetLastError() errno -#endif - -#ifdef PHP_WIN32 -#define PHP_ENABLE_SEH -#endif - -/* -uncomment the following lines to turn off -exception trapping when running under a debugger - -#ifdef _DEBUG -#undef PHP_ENABLE_SEH -#endif -*/ - -#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION") -#define ISAPI_SERVER_VAR_BUF_SIZE 1024 -#define ISAPI_POST_DATA_BUF 1024 - -static zend_bool bFilterLoaded=0; -static zend_bool bTerminateThreadsOnError=0; - -static char *isapi_special_server_variable_names[] = { - "ALL_HTTP", - "HTTPS", -#ifndef WITH_ZEUS - "SCRIPT_NAME", -#endif - NULL -}; - -#define NUM_SPECIAL_VARS (sizeof(isapi_special_server_variable_names)/sizeof(char *)) -#define SPECIAL_VAR_ALL_HTTP 0 -#define SPECIAL_VAR_HTTPS 1 -#define SPECIAL_VAR_PHP_SELF 2 - -static char *isapi_server_variable_names[] = { - "AUTH_PASSWORD", - "AUTH_TYPE", - "AUTH_USER", - "CONTENT_LENGTH", - "CONTENT_TYPE", - "PATH_TRANSLATED", - "QUERY_STRING", - "REMOTE_ADDR", - "REMOTE_HOST", - "REMOTE_USER", - "REQUEST_METHOD", - "SERVER_NAME", - "SERVER_PORT", - "SERVER_PROTOCOL", - "SERVER_SOFTWARE", -#ifndef WITH_ZEUS - "APPL_MD_PATH", - "APPL_PHYSICAL_PATH", - "INSTANCE_ID", - "INSTANCE_META_PATH", - "LOGON_USER", - "REQUEST_URI", - "URL", -#else - "DOCUMENT_ROOT", -#endif - NULL -}; - - -static char *isapi_secure_server_variable_names[] = { - "CERT_COOKIE", - "CERT_FLAGS", - "CERT_ISSUER", - "CERT_KEYSIZE", - "CERT_SECRETKEYSIZE", - "CERT_SERIALNUMBER", - "CERT_SERVER_ISSUER", - "CERT_SERVER_SUBJECT", - "CERT_SUBJECT", - "HTTPS_KEYSIZE", - "HTTPS_SECRETKEYSIZE", - "HTTPS_SERVER_ISSUER", - "HTTPS_SERVER_SUBJECT", - "SERVER_PORT_SECURE", -#ifdef WITH_ZEUS - "SSL_CLIENT_CN", - "SSL_CLIENT_EMAIL", - "SSL_CLIENT_OU", - "SSL_CLIENT_O", - "SSL_CLIENT_L", - "SSL_CLIENT_ST", - "SSL_CLIENT_C", - "SSL_CLIENT_I_CN", - "SSL_CLIENT_I_EMAIL", - "SSL_CLIENT_I_OU", - "SSL_CLIENT_I_O", - "SSL_CLIENT_I_L", - "SSL_CLIENT_I_ST", - "SSL_CLIENT_I_C", -#endif - NULL -}; - - -static void php_info_isapi(ZEND_MODULE_INFO_FUNC_ARGS) -{ - char **p; - char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - DWORD variable_len; - char **all_variables[] = { - isapi_server_variable_names, - isapi_special_server_variable_names, - isapi_secure_server_variable_names, - NULL - }; - char ***server_variable_names; - LPEXTENSION_CONTROL_BLOCK lpECB; - - lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - - php_info_print_table_start(); - php_info_print_table_header(2, "Server Variable", "Value"); - server_variable_names = all_variables; - while (*server_variable_names) { - p = *server_variable_names; - while (*p) { - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) - && variable_buf[0]) { - php_info_print_table_row(2, *p, variable_buf); - } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - char *tmp_variable_buf; - - tmp_variable_buf = (char *) emalloc(variable_len); - if (lpECB->GetServerVariable(lpECB->ConnID, *p, tmp_variable_buf, &variable_len) - && variable_buf[0]) { - php_info_print_table_row(2, *p, tmp_variable_buf); - } - efree(tmp_variable_buf); - } - p++; - } - server_variable_names++; - } - php_info_print_table_end(); -} - - -static zend_module_entry php_isapi_module = { - "ISAPI", - NULL, - NULL, - NULL, - NULL, - NULL, - php_info_isapi, - STANDARD_MODULE_PROPERTIES -}; - - -static int sapi_isapi_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - DWORD num_bytes = str_length; - LPEXTENSION_CONTROL_BLOCK ecb; - - ecb = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - if (ecb->WriteClient(ecb->ConnID, (char *) str, &num_bytes, HSE_IO_SYNC ) == FALSE) { - php_handle_aborted_connection(); - } - return num_bytes; -} - - -static int sapi_isapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - return SAPI_HEADER_ADD; -} - - - -static void accumulate_header_length(sapi_header_struct *sapi_header, uint *total_length TSRMLS_DC) -{ - *total_length += sapi_header->header_len+2; -} - - -static void concat_header(sapi_header_struct *sapi_header, char **combined_headers_ptr TSRMLS_DC) -{ - memcpy(*combined_headers_ptr, sapi_header->header, sapi_header->header_len); - *combined_headers_ptr += sapi_header->header_len; - **combined_headers_ptr = '\r'; - (*combined_headers_ptr)++; - **combined_headers_ptr = '\n'; - (*combined_headers_ptr)++; -} - - -static int sapi_isapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - uint total_length = 2; /* account for the trailing \r\n */ - char *combined_headers, *combined_headers_ptr; - LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - HSE_SEND_HEADER_EX_INFO header_info; - char status_buf[MAX_STATUS_LENGTH]; - sapi_header_struct default_content_type; - - /* Obtain headers length */ - if (SG(sapi_headers).send_default_content_type) { - sapi_get_default_content_type_header(&default_content_type TSRMLS_CC); - accumulate_header_length(&default_content_type, (void *) &total_length TSRMLS_CC); - } - zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) accumulate_header_length, (void *) &total_length TSRMLS_CC); - - /* Generate headers */ - combined_headers = (char *) emalloc(total_length+1); - combined_headers_ptr = combined_headers; - if (SG(sapi_headers).send_default_content_type) { - concat_header(&default_content_type, (void *) &combined_headers_ptr TSRMLS_CC); - sapi_free_header(&default_content_type); /* we no longer need it */ - } - zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) concat_header, (void *) &combined_headers_ptr TSRMLS_CC); - *combined_headers_ptr++ = '\r'; - *combined_headers_ptr++ = '\n'; - *combined_headers_ptr = 0; - - switch (SG(sapi_headers).http_response_code) { - case 200: - header_info.pszStatus = "200 OK"; - break; - case 302: - header_info.pszStatus = "302 Moved Temporarily"; - break; - case 401: - header_info.pszStatus = "401 Authorization Required"; - break; - default: - snprintf(status_buf, MAX_STATUS_LENGTH, "%d Undescribed", SG(sapi_headers).http_response_code); - header_info.pszStatus = status_buf; - break; - } - header_info.cchStatus = strlen(header_info.pszStatus); - header_info.pszHeader = combined_headers; - header_info.cchHeader = total_length; - lpECB->dwHttpStatusCode = SG(sapi_headers).http_response_code; - - lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); - - efree(combined_headers); - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - - -static int php_isapi_startup(sapi_module_struct *sapi_module) -{ - if (php_module_startup(sapi_module)==FAILURE - || zend_startup_module(&php_isapi_module)==FAILURE) { - return FAILURE; - } else { - bTerminateThreadsOnError = (zend_bool) INI_INT("isapi.terminate_threads_on_error"); - return SUCCESS; - } -} - - - -static int sapi_isapi_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - DWORD read_from_buf=0; - DWORD read_from_input=0; - DWORD total_read=0; - - if ((DWORD) SG(read_post_bytes) < lpECB->cbAvailable) { - read_from_buf = MIN(lpECB->cbAvailable-SG(read_post_bytes), count_bytes); - memcpy(buffer, lpECB->lpbData+SG(read_post_bytes), read_from_buf); - total_read += read_from_buf; - } - if (read_from_buf<count_bytes - && (SG(read_post_bytes)+read_from_buf) < lpECB->cbTotalBytes) { - DWORD cbRead=0, cbSize; - - read_from_input = MIN(count_bytes-read_from_buf, lpECB->cbTotalBytes-SG(read_post_bytes)-read_from_buf); - while (cbRead < read_from_input) { - cbSize = read_from_input - cbRead; - if (!lpECB->ReadClient(lpECB->ConnID, buffer+read_from_buf+cbRead, &cbSize) || cbSize==0) { - break; - } - cbRead += cbSize; - } - total_read += cbRead; - } - return total_read; -} - - -static char *sapi_isapi_read_cookies(TSRMLS_D) -{ - LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - - if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_COOKIE", variable_buf, &variable_len)) { - return estrndup(variable_buf, variable_len); - } else if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { - char *tmp_variable_buf = (char *) emalloc(variable_len+1); - - if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_COOKIE", tmp_variable_buf, &variable_len)) { - tmp_variable_buf[variable_len] = 0; - return tmp_variable_buf; - } else { - efree(tmp_variable_buf); - } - } - return NULL; -} - - -#ifdef WITH_ZEUS - -static void sapi_isapi_register_zeus_ssl_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array TSRMLS_DC) -{ - char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - char static_cons_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - /* - * We need to construct the /C=.../ST=... - * DN's for SSL_CLIENT_DN and SSL_CLIENT_I_DN - */ - strcpy( static_cons_buf, "/C=" ); - if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_C", static_variable_buf, &variable_len ) && static_variable_buf[0] ) { - strcat( static_cons_buf, static_variable_buf ); - } - strcat( static_cons_buf, "/ST=" ); - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_ST", static_variable_buf, &variable_len ) && static_variable_buf[0] ) { - strcat( static_cons_buf, static_variable_buf ); - } - php_register_variable( "SSL_CLIENT_DN", static_cons_buf, track_vars_array TSRMLS_CC ); - - strcpy( static_cons_buf, "/C=" ); - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_I_C", static_variable_buf, &variable_len ) && static_variable_buf[0] ) { - strcat( static_cons_buf, static_variable_buf ); - } - strcat( static_cons_buf, "/ST=" ); - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_I_ST", static_variable_buf, &variable_len ) && static_variable_buf[0] ) { - strcat( static_cons_buf, static_variable_buf ); - } - php_register_variable( "SSL_CLIENT_I_DN", static_cons_buf, track_vars_array TSRMLS_CC ); -} - -static void sapi_isapi_register_zeus_variables(LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array TSRMLS_DC) -{ - char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - DWORD scriptname_len = ISAPI_SERVER_VAR_BUF_SIZE; - DWORD pathinfo_len = 0; - char *strtok_buf = NULL; - - /* Get SCRIPT_NAME, we use this to work out which bit of the URL - * belongs in PHP's version of PATH_INFO - */ - lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_NAME", static_variable_buf, &scriptname_len); - - /* Adjust Zeus' version of PATH_INFO, set PHP_SELF, - * and generate REQUEST_URI - */ - if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_INFO", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - - /* PHP_SELF is just PATH_INFO */ - php_register_variable( "PHP_SELF", static_variable_buf, track_vars_array TSRMLS_CC ); - - /* Chop off filename to get just the 'real' PATH_INFO' */ - pathinfo_len = variable_len - scriptname_len; - php_register_variable( "PATH_INFO", static_variable_buf + scriptname_len - 1, track_vars_array TSRMLS_CC ); - /* append query string to give url... extra byte for '?' */ - if ( strlen(lpECB->lpszQueryString) + variable_len + 1 < ISAPI_SERVER_VAR_BUF_SIZE ) { - /* append query string only if it is present... */ - if ( strlen(lpECB->lpszQueryString) ) { - static_variable_buf[ variable_len - 1 ] = '?'; - strcpy( static_variable_buf + variable_len, lpECB->lpszQueryString ); - } - php_register_variable( "URL", static_variable_buf, track_vars_array TSRMLS_CC ); - php_register_variable( "REQUEST_URI", static_variable_buf, track_vars_array TSRMLS_CC ); - } - } - - /* Get and adjust PATH_TRANSLATED to what PHP wants */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if ( lpECB->GetServerVariable(lpECB->ConnID, "PATH_TRANSLATED", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - static_variable_buf[ variable_len - pathinfo_len - 1 ] = '\0'; - php_register_variable( "PATH_TRANSLATED", static_variable_buf, track_vars_array TSRMLS_CC ); - } - - /* Bring in the AUTHENTICATION stuff as needed */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_USER", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "PHP_AUTH_USER", static_variable_buf, track_vars_array TSRMLS_CC ); - } - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_PASSWORD", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "PHP_AUTH_PW", static_variable_buf, track_vars_array TSRMLS_CC ); - } - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if ( lpECB->GetServerVariable(lpECB->ConnID, "AUTH_TYPE", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "PHP_AUTH_TYPE", static_variable_buf, track_vars_array TSRMLS_CC ); - } - - /* And now, for the SSL variables (if applicable) */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if ( lpECB->GetServerVariable(lpECB->ConnID, "CERT_COOKIE", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - sapi_isapi_register_zeus_ssl_variables( lpECB, track_vars_array TSRMLS_CC ); - } - /* Copy some of the variables we need to meet Apache specs */ - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if ( lpECB->GetServerVariable(lpECB->ConnID, "SERVER_SOFTWARE", static_variable_buf, &variable_len) && static_variable_buf[0] ) { - php_register_variable( "SERVER_SIGNATURE", static_variable_buf, track_vars_array TSRMLS_CC ); - } -} -#endif - - -static void sapi_isapi_register_server_variables2(char **server_variables, LPEXTENSION_CONTROL_BLOCK lpECB, zval *track_vars_array, char **recorded_values TSRMLS_DC) -{ - char **p=server_variables; - DWORD variable_len; - char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - char *variable_buf; - - while (*p) { - variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if (lpECB->GetServerVariable(lpECB->ConnID, *p, static_variable_buf, &variable_len) - && static_variable_buf[0]) { - php_register_variable(*p, static_variable_buf, track_vars_array TSRMLS_CC); - if (recorded_values) { - recorded_values[p-server_variables] = estrndup(static_variable_buf, variable_len); - } - } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - variable_buf = (char *) emalloc(variable_len); - if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) - && variable_buf[0]) { - php_register_variable(*p, variable_buf, track_vars_array TSRMLS_CC); - } - if (recorded_values) { - recorded_values[p-server_variables] = variable_buf; - } else { - efree(variable_buf); - } - } - p++; - } -} - - -static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_DC) -{ - DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - char *variable; - char *strtok_buf = NULL; - char *isapi_special_server_variables[NUM_SPECIAL_VARS]; - LPEXTENSION_CONTROL_BLOCK lpECB; - - lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - - /* Register the special ISAPI variables */ - memset(isapi_special_server_variables, 0, sizeof(isapi_special_server_variables)); - sapi_isapi_register_server_variables2(isapi_special_server_variable_names, lpECB, track_vars_array, isapi_special_server_variables TSRMLS_CC); - if (SG(request_info).cookie_data) { - php_register_variable("HTTP_COOKIE", SG(request_info).cookie_data, track_vars_array TSRMLS_CC); - } - - /* Register the standard ISAPI variables */ - sapi_isapi_register_server_variables2(isapi_server_variable_names, lpECB, track_vars_array, NULL TSRMLS_CC); - - if (isapi_special_server_variables[SPECIAL_VAR_HTTPS] - && atoi(isapi_special_server_variables[SPECIAL_VAR_HTTPS])) { - /* Register SSL ISAPI variables */ - sapi_isapi_register_server_variables2(isapi_secure_server_variable_names, lpECB, track_vars_array, NULL TSRMLS_CC); - } - - if (isapi_special_server_variables[SPECIAL_VAR_HTTPS]) { - efree(isapi_special_server_variables[SPECIAL_VAR_HTTPS]); - } - - -#ifdef WITH_ZEUS - sapi_isapi_register_zeus_variables(lpECB, track_vars_array TSRMLS_CC); -#endif - - /* PHP_SELF support */ - if (isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]) { - php_register_variable("PHP_SELF", isapi_special_server_variables[SPECIAL_VAR_PHP_SELF], track_vars_array TSRMLS_CC); - efree(isapi_special_server_variables[SPECIAL_VAR_PHP_SELF]); - } - - if (isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]) { - /* Register the internal bits of ALL_HTTP */ - variable = php_strtok_r(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP], "\r\n", &strtok_buf); - while (variable) { - char *colon = strchr(variable, ':'); - - if (colon) { - char *value = colon+1; - - while (*value==' ') { - value++; - } - *colon = 0; - php_register_variable(variable, value, track_vars_array TSRMLS_CC); - *colon = ':'; - } - variable = php_strtok_r(NULL, "\r\n", &strtok_buf); - } - efree(isapi_special_server_variables[SPECIAL_VAR_ALL_HTTP]); - } - -#ifdef PHP_WIN32 - { - HSE_URL_MAPEX_INFO humi; - DWORD path_len = 2; - char path[] = "/"; - - if (lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_MAP_URL_TO_PATH_EX, path, &path_len, (LPDWORD) &humi)) { - /* Remove trailing \ */ - if (humi.lpszPath[path_len-2] == '\\') { - humi.lpszPath[path_len-2] = 0; - } - php_register_variable("DOCUMENT_ROOT", humi.lpszPath, track_vars_array TSRMLS_CC); - } - } -#endif -} - - -static sapi_module_struct isapi_sapi_module = { - "isapi", /* name */ - "ISAPI", /* pretty name */ - - php_isapi_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - NULL, /* activate */ - NULL, /* deactivate */ - - sapi_isapi_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, /* error handler */ - - sapi_isapi_header_handler, /* header handler */ - sapi_isapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ - - sapi_isapi_read_post, /* read POST data */ - sapi_isapi_read_cookies, /* read Cookies */ - - sapi_isapi_register_server_variables, /* register server variables */ - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - - -BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pFilterVersion) -{ - bFilterLoaded = 1; - pFilterVersion->dwFilterVersion = HTTP_FILTER_REVISION; - strcpy(pFilterVersion->lpszFilterDesc, isapi_sapi_module.pretty_name); - pFilterVersion->dwFlags= (SF_NOTIFY_AUTHENTICATION | SF_NOTIFY_PREPROC_HEADERS); - return TRUE; -} - - -DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LPVOID pvNotification) -{ - TSRMLS_FETCH(); - - switch (notificationType) { - case SF_NOTIFY_PREPROC_HEADERS: - SG(request_info).auth_user = NULL; - SG(request_info).auth_password = NULL; - break; - case SF_NOTIFY_AUTHENTICATION: { - char *auth_user = ((HTTP_FILTER_AUTHENT *) pvNotification)->pszUser; - char *auth_password = ((HTTP_FILTER_AUTHENT *) pvNotification)->pszPassword; - - if (auth_user && auth_user[0]) { - SG(request_info).auth_user = estrdup(auth_user); - } - if (auth_password && auth_password[0]) { - SG(request_info).auth_password = estrdup(auth_password); - } - return SF_STATUS_REQ_HANDLED_NOTIFICATION; - } - break; - } - return SF_STATUS_REQ_NEXT_NOTIFICATION; -} - - -static void init_request_info(LPEXTENSION_CONTROL_BLOCK lpECB TSRMLS_DC) -{ - SG(request_info).request_method = lpECB->lpszMethod; - SG(request_info).query_string = lpECB->lpszQueryString; - SG(request_info).path_translated = lpECB->lpszPathTranslated; - SG(request_info).request_uri = lpECB->lpszPathInfo; - SG(request_info).content_type = lpECB->lpszContentType; - SG(request_info).content_length = lpECB->cbTotalBytes; - SG(sapi_headers).http_response_code = 200; /* I think dwHttpStatusCode is invalid at this stage -RL */ - if (!bFilterLoaded) { /* we don't have valid ISAPI Filter information */ - SG(request_info).auth_user = SG(request_info).auth_password = NULL; - } -} - - -static void php_isapi_report_exception(char *message, int message_len TSRMLS_DC) -{ - if (!SG(headers_sent)) { - HSE_SEND_HEADER_EX_INFO header_info; - LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - - header_info.pszStatus = "500 Internal Server Error"; - header_info.cchStatus = strlen(header_info.pszStatus); - header_info.pszHeader = "Content-Type: text/html\r\n\r\n"; - header_info.cchHeader = strlen(header_info.pszHeader); - - lpECB->dwHttpStatusCode = 500; - lpECB->ServerSupportFunction(lpECB->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &header_info, NULL, NULL); - SG(headers_sent)=1; - } - sapi_isapi_ub_write(message, message_len TSRMLS_CC); -} - - -BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO *pVer) -{ - pVer->dwExtensionVersion = HSE_VERSION; -#ifdef WITH_ZEUS - strncpy( pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); -#else - lstrcpyn(pVer->lpszExtensionDesc, isapi_sapi_module.name, HSE_MAX_EXT_DLL_NAME_LEN); -#endif - return TRUE; -} - - -static void my_endthread() -{ -#ifdef PHP_WIN32 - if (bTerminateThreadsOnError) { - _endthread(); - } -#endif -} - -#ifdef PHP_WIN32 -/* ep is accessible only in the context of the __except expression, - * so we have to call this function to obtain it. - */ -BOOL exceptionhandler(LPEXCEPTION_POINTERS *e, LPEXCEPTION_POINTERS ep) -{ - *e=ep; - return TRUE; -} -#endif - -DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) -{ - zend_file_handle file_handle; - zend_bool stack_overflown=0; -#ifdef PHP_ENABLE_SEH - LPEXCEPTION_POINTERS e; -#endif - TSRMLS_FETCH(); - - zend_first_try { -#ifdef PHP_ENABLE_SEH - __try { -#endif - init_request_info(lpECB TSRMLS_CC); - SG(server_context) = lpECB; - -#ifdef WITH_ZEUS - /* PATH_TRANSLATED can contain extra PATH_INFO stuff after the - * file being loaded, so we must use SCRIPT_FILENAME instead - */ - file_handle.filename = (char *)emalloc( ISAPI_SERVER_VAR_BUF_SIZE ); - file_handle.free_filename = 1; - { - DWORD filename_len = ISAPI_SERVER_VAR_BUF_SIZE; - if( !lpECB->GetServerVariable(lpECB->ConnID, "SCRIPT_FILENAME", file_handle.filename, &filename_len) || file_handle.filename[ 0 ] == '\0' ) { - /* If we're running on an earlier version of Zeus, this - * variable won't be present, so fall back to old behaviour. - */ - efree( file_handle.filename ); - file_handle.filename = sapi_globals->request_info.path_translated; - file_handle.free_filename = 0; - } - } -#else - file_handle.filename = SG(request_info.path_translated); - file_handle.free_filename = 0; -#endif - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.opened_path = NULL; - - php_request_startup(TSRMLS_C); - php_execute_script(&file_handle TSRMLS_CC); - if (SG(request_info).cookie_data) { - efree(SG(request_info).cookie_data); - } -#ifdef PHP_ENABLE_SEH - } __except(exceptionhandler(&e, GetExceptionInformation())) { - char buf[1024]; - if (_exception_code()==EXCEPTION_STACK_OVERFLOW) { - LPBYTE lpPage; - static SYSTEM_INFO si; - static MEMORY_BASIC_INFORMATION mi; - static DWORD dwOldProtect; - - GetSystemInfo(&si); - - /* Get page ESP is pointing to */ - _asm mov lpPage, esp; - - /* Get stack allocation base */ - VirtualQuery(lpPage, &mi, sizeof(mi)); - - /* Go to the page below the current page */ - lpPage = (LPBYTE) (mi.BaseAddress) - si.dwPageSize; - - /* Free pages below current page */ - if (!VirtualFree(mi.AllocationBase, (LPBYTE)lpPage - (LPBYTE) mi.AllocationBase, MEM_DECOMMIT)) { - _endthread(); - } - - /* Restore the guard page */ - if (!VirtualProtect(lpPage, si.dwPageSize, PAGE_GUARD | PAGE_READWRITE, &dwOldProtect)) { - _endthread(); - } - - CG(unclean_shutdown)=1; - _snprintf(buf, sizeof(buf)-1,"PHP has encountered a Stack overflow"); - php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); - } else if (_exception_code()==EXCEPTION_ACCESS_VIOLATION) { - _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Access Violation at %p", e->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); - my_endthread(); - } else { - _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p", e->ExceptionRecord->ExceptionCode , e->ExceptionRecord->ExceptionAddress); - php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC); - my_endthread(); - } -#endif - } -#ifdef PHP_ENABLE_SEH - __try { - php_request_shutdown(NULL); - } __except(EXCEPTION_EXECUTE_HANDLER) { - my_endthread(); - } -#else - php_request_shutdown(NULL); -#endif - } zend_catch { - zend_try { - php_request_shutdown(NULL); - } zend_end_try(); - return HSE_STATUS_ERROR; - } zend_end_try(); - - return HSE_STATUS_SUCCESS; -} - - - -__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: -#ifdef WITH_ZEUS - tsrm_startup(128, 1, TSRM_ERROR_LEVEL_CORE, "TSRM.log"); -#else - tsrm_startup(128, 1, TSRM_ERROR_LEVEL_CORE, "C:\\TSRM.log"); -#endif - sapi_startup(&isapi_sapi_module); - if (isapi_sapi_module.startup) { - isapi_sapi_module.startup(&sapi_module); - } - break; - case DLL_THREAD_ATTACH: - break; - case DLL_THREAD_DETACH: - ts_free_thread(); - break; - case DLL_PROCESS_DETACH: - if (isapi_sapi_module.shutdown) { - isapi_sapi_module.shutdown(&sapi_module); - } - tsrm_shutdown(); - break; - } - return TRUE; -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/sapi/isapi/php4isapi.def b/sapi/isapi/php4isapi.def deleted file mode 100644 index 596023ef55..0000000000 --- a/sapi/isapi/php4isapi.def +++ /dev/null @@ -1,5 +0,0 @@ -EXPORTS -HttpFilterProc -GetFilterVersion -HttpExtensionProc -GetExtensionVersion diff --git a/sapi/isapi/php4isapi.dsp b/sapi/isapi/php4isapi.dsp deleted file mode 100644 index 7913ec6fad..0000000000 --- a/sapi/isapi/php4isapi.dsp +++ /dev/null @@ -1,165 +0,0 @@ -# Microsoft Developer Studio Project File - Name="php4isapi" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php4isapi - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4isapi.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4isapi.mak" CFG="php4isapi - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4isapi - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4isapi - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4isapi - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4isapi - Win32 Release_TSDbg" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4isapi - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D "COMPILE_LIBZEND" /D ZEND_DEBUG=1 /D "_WINDOWS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib /nologo /version:4.0 /dll /debug /machine:I386 /nodefaultlib:"libcmt" /pdbtype:sept /libpath:"..\..\Debug_TS"
-
-!ELSEIF "$(CFG)" == "php4isapi - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /version:4.0 /dll /machine:I386 /libpath:"..\..\Release_TS"
-
-!ELSEIF "$(CFG)" == "php4isapi - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php4isapi___Win32_Release_TS_inline"
-# PROP BASE Intermediate_Dir "php4isapi___Win32_Release_TS_inline"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "WIN32" /D "_MBCS" /D ZEND_DEBUG=0 /FR /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "_WINDOWS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386 /libpath:"..\..\Release_TS"
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /version:4.0 /dll /machine:I386 /libpath:"..\..\Release_TS_inline"
-
-!ELSEIF "$(CFG)" == "php4isapi - Win32 Release_TSDbg"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php4isapi___Win32_Release_TSDbg"
-# PROP BASE Intermediate_Dir "php4isapi___Win32_Release_TSDbg"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TSDbg"
-# PROP Intermediate_Dir "Release_TSDbg"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /Zi /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP4ISAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /version:4.0 /dll /machine:I386 /libpath:"..\..\Release_TS"
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /version:4.0 /dll /debug /machine:I386 /libpath:"..\..\Release_TSDbg"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4isapi - Win32 Debug_TS"
-# Name "php4isapi - Win32 Release_TS"
-# Name "php4isapi - Win32 Release_TS_inline"
-# Name "php4isapi - Win32 Release_TSDbg"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\php4isapi.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php4isapi.def
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/isapi/stresstest/notes.txt b/sapi/isapi/stresstest/notes.txt deleted file mode 100644 index 2bab38dd07..0000000000 --- a/sapi/isapi/stresstest/notes.txt +++ /dev/null @@ -1,56 +0,0 @@ -This stress test program is for debugging threading issues with the ISAPI -module. - -2 ways to use it: - -1: test any php script file on multiple threads -2: run the php test scripts bundled with the source code - - - -GLOBAL SETTINGS -=============== - -If you need to set special environement variables, in addition to your -regular environment, create a file that contains them, one setting per line: - -MY_ENV_VAR=XXXXXXXX - -This can be used to simulate ISAPI environment variables if need be. - -By default, stress test uses 10 threads. To change this, change the define -NUM_THREADS in stresstest.cpp. - - - -1: Test any php script file on multiple threads -=============================================== - -Create a file that contains a list of php script files, one per line. If -you need to provide input, place the GET data, or Query String, after the -filename. File contents would look like: - -e:\inetpub\pages\index.php -e:\inetpub\pages\info.php -e:\inetpub\pages\test.php a=1&b=2 - -Run: stresstest L files.txt - - - -2: Run the php test scripts bundled with the source code -======================================================== - -supply the path to the parent of the "tests" directory (expect a couple -long pauses for a couple of the larger tests) - -Run: stresstest T c:\php4-source - - - -TODO: - -* Make more options configurable: number of threads, iterations, etc. -* Improve stdout output to make it more useful -* Implement support for SKIPIF -* Improve speed of CompareFile function (too slow on big files). diff --git a/sapi/isapi/stresstest/stresstest.cpp b/sapi/isapi/stresstest/stresstest.cpp deleted file mode 100644 index 34084eee89..0000000000 --- a/sapi/isapi/stresstest/stresstest.cpp +++ /dev/null @@ -1,854 +0,0 @@ -/* - * ======================================================================= * - * File: stress .c * - * stress tester for isapi dll's * - * based on cgiwrap * - * ======================================================================= * - * -*/ -#define WIN32_LEAN_AND_MEAN -#include <afx.h> -#include <afxtempl.h> -#include <winbase.h> -#include <winerror.h> -#include <httpext.h> -#include <stdio.h> -#include <stdlib.h> - -// These are things that go out in the Response Header -// -#define HTTP_VER "HTTP/1.0" -#define SERVER_VERSION "Http-Srv-Beta2/1.0" - -// -// Simple wrappers for the heap APIS -// -#define xmalloc(s) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (s)) -#define xfree(s) HeapFree(GetProcessHeap(), 0, (s)) - -// -// The mandatory exports from the ISAPI DLL -// -#define NUM_THREADS 10 -#define ITERATIONS 1 -HANDLE StartNow; -// quick and dirty environment -typedef CMapStringToString TEnvironment; -TEnvironment IsapiEnvironment; - -typedef struct _TResults { - LONG ok; - LONG bad; -} TResults; - -CStringArray IsapiFileList; // list of filenames -CStringArray TestNames; // --TEST-- -CStringArray IsapiGetData; // --GET-- -CStringArray IsapiPostData; // --POST-- -CStringArray IsapiMatchData; // --EXPECT-- -CArray<TResults, TResults> Results; - -typedef struct _TIsapiContext { - HANDLE in; - HANDLE out; - DWORD tid; - TEnvironment env; -} TIsapiContext; - -// -// Prototypes of the functions this sample implements -// -extern "C" { -HINSTANCE hDll; -typedef BOOL (WINAPI *VersionProc)(HSE_VERSION_INFO *) ; -typedef DWORD (WINAPI *HttpExtProc)(EXTENSION_CONTROL_BLOCK *); -BOOL WINAPI FillExtensionControlBlock(EXTENSION_CONTROL_BLOCK *, TIsapiContext *) ; -BOOL WINAPI GetServerVariable(HCONN, LPSTR, LPVOID, LPDWORD ); -BOOL WINAPI ReadClient(HCONN, LPVOID, LPDWORD); -BOOL WINAPI WriteClient(HCONN, LPVOID, LPDWORD, DWORD); -BOOL WINAPI ServerSupportFunction(HCONN, DWORD, LPVOID, LPDWORD, LPDWORD); -VersionProc IsapiGetExtensionVersion; -HttpExtProc IsapiHttpExtensionProc; -HSE_VERSION_INFO version_info; -} - -char * MakeDateStr(VOID); -char * GetEnv(char *); - - - - -DWORD CALLBACK IsapiThread(void *); -int stress_main(const char *filename, - const char *arg, - const char *postfile, - const char *matchdata); - - - -BOOL bUseTestFiles = FALSE; -char temppath[MAX_PATH]; - -void stripcrlf(char *line) -{ - DWORD l = strlen(line)-1; - if (line[l]==10 || line[l]==13) line[l]=0; - l = strlen(line)-1; - if (line[l]==10 || line[l]==13) line[l]=0; -} - -#define COMPARE_BUF_SIZE 1024 - -BOOL CompareFiles(const char*f1, const char*f2) -{ - FILE *fp1, *fp2; - bool retval; - char buf1[COMPARE_BUF_SIZE], buf2[COMPARE_BUF_SIZE]; - int length1, length2; - - if ((fp1=fopen(f1, "r"))==NULL) { - return FALSE; - } - - if ((fp2=fopen(f2, "r"))==NULL) { - fclose(fp1); - return FALSE; - } - - retval = TRUE; // success oriented - while (true) { - length1 = fread(buf1, 1, sizeof(buf1), fp1); - length2 = fread(buf2, 1, sizeof(buf2), fp2); - - // check for end of file - if (feof(fp1)) { - if (!feof(fp2)) { - retval = FALSE; - } - break; - } else if (feof(fp2)) { - if (!feof(fp1)) { - retval = FALSE; - } - break; - } - - // compare data - if (length1!=length2 - || memcmp(buf1, buf2, length1)!=0) { - retval = FALSE; - break; - } - } - fclose(fp1); - fclose(fp2); - - return retval; -} - - -BOOL CompareStringWithFile(const char *filename, const char *str, unsigned int str_length) -{ - FILE *fp; - bool retval; - char buf[COMPARE_BUF_SIZE]; - unsigned int offset=0, readbytes; - - if ((fp=fopen(filename, "r"))==NULL) { - return FALSE; - } - - retval = TRUE; // success oriented - while (true) { - readbytes = fread(buf, 1, sizeof(buf), fp); - - // check for end of file - if (feof(fp)) { - break; - } - - if (offset+readbytes > str_length - || memcmp(buf, str+offset, readbytes)!=NULL) { - retval = FALSE; - break; - } - } - fclose(fp); - - return retval; -} - - -BOOL ReadGlobalEnvironment(const char *environment) -{ - if (environment) { - FILE *fp = fopen(environment, "r"); - DWORD i=0; - if (fp) { - char line[2048]; - while (fgets(line, sizeof(line)-1, fp)) { - // file.php arg1 arg2 etc. - char *p = strchr(line, '='); - if (p) { - *p=0; - IsapiEnvironment[line]=p+1; - } - } - fclose(fp); - return IsapiEnvironment.GetCount() > 0; - } - } - return FALSE; -} - -BOOL ReadFileList(const char *filelist) -{ - FILE *fp = fopen(filelist, "r"); - if (!fp) { - printf("Unable to open %s\r\n", filelist); - } - char line[2048]; - int i=0; - while (fgets(line, sizeof(line)-1, fp)) { - // file.php arg1 arg2 etc. - stripcrlf(line); - if (strlen(line)>3) { - char *p = strchr(line, ' '); - if (p) { - *p = 0; - // get file - - IsapiFileList.Add(line); - IsapiGetData.Add(p+1); - } else { - // just a filename is all - IsapiFileList.Add(line); - IsapiGetData.Add(""); - } - } - - // future use - IsapiPostData.Add(""); - IsapiMatchData.Add(""); - TestNames.Add(""); - - i++; - } - Results.SetSize(TestNames.GetSize()); - - fclose(fp); - return IsapiFileList.GetSize() > 0; -} - -void DoThreads() { - - if (IsapiFileList.GetSize() == 0) { - printf("No Files to test\n"); - return; - } - - printf("Starting Threads...\n"); - // loop creating threads - DWORD tid; - HANDLE threads[NUM_THREADS]; - for (DWORD i=0; i< NUM_THREADS; i++) { - threads[i]=CreateThread(NULL, 0, IsapiThread, NULL, CREATE_SUSPENDED, &tid); - } - for (i=0; i< NUM_THREADS; i++) { - if (threads[i]) ResumeThread(threads[i]); - } - // wait for threads to finish - WaitForMultipleObjects(NUM_THREADS, threads, TRUE, INFINITE); -} - -void DoFileList(const char *filelist, const char *environment) -{ - // read config files - - if (!ReadFileList(filelist)) { - printf("No Files to test!\r\n"); - return; - } - - ReadGlobalEnvironment(environment); - - DoThreads(); -} - - -/** - * ParseTestFile - * parse a single phpt file and add it to the arrays - */ -BOOL ParseTestFile(const char *path, const char *fn) -{ - // parse the test file - char filename[MAX_PATH]; - _snprintf(filename, sizeof(filename)-1, "%s\\%s", path, fn); - char line[1024]; - memset(line, 0, sizeof(line)); - CString cTest, cSkipIf, cPost, cGet, cFile, cExpect; - printf("Reading %s\r\n", filename); - - enum state {none, test, skipif, post, get, file, expect} parsestate = none; - - FILE *fp = fopen(filename, "r"); - char *tn = _tempnam(temppath,"pht."); - char *en = _tempnam(temppath,"exp."); - FILE *ft = fopen(tn, "w+"); - FILE *fe = fopen(en, "w+"); - if (fp && ft && fe) { - while (fgets(line, sizeof(line)-1, fp)) { - if (line[0]=='-') { - if (_strnicmp(line, "--TEST--", 8)==0) { - parsestate = test; - continue; - } else if (_strnicmp(line, "--SKIPIF--", 10)==0) { - parsestate = skipif; - continue; - } else if (_strnicmp(line, "--POST--", 8)==0) { - parsestate = post; - continue; - } else if (_strnicmp(line, "--GET--", 7)==0) { - parsestate = get; - continue; - } else if (_strnicmp(line, "--FILE--", 8)==0) { - parsestate = file; - continue; - } else if (_strnicmp(line, "--EXPECT--", 10)==0) { - parsestate = expect; - continue; - } - } - switch (parsestate) { - case test: - stripcrlf(line); - cTest = line; - break; - case skipif: - cSkipIf += line; - break; - case post: - cPost += line; - break; - case get: - cGet += line; - break; - case file: - fputs(line, ft); - break; - case expect: - fputs(line, fe); - break; - } - } - - fclose(fp); - fclose(ft); - fclose(fe); - - if (!cTest.IsEmpty()) { - IsapiFileList.Add(tn); - TestNames.Add(cTest); - IsapiGetData.Add(cGet); - IsapiPostData.Add(cPost); - IsapiMatchData.Add(en); - return TRUE; - } - } - return FALSE; -} - - -/** - * GetTestFiles - * Recurse through the path and subdirectories, parse each phpt file - */ -BOOL GetTestFiles(const char *path) -{ - // find all files .phpt under testpath\tests - char FindPath[MAX_PATH]; - WIN32_FIND_DATA fd; - memset(&fd, 0, sizeof(WIN32_FIND_DATA)); - - _snprintf(FindPath, sizeof(FindPath)-1, "%s\\*.*", path); - HANDLE fh = FindFirstFile(FindPath, &fd); - if (fh != INVALID_HANDLE_VALUE) { - do { - if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - !strchr(fd.cFileName, '.')) { - // subdirectory, recurse into it - char NewFindPath[MAX_PATH]; - _snprintf(NewFindPath, sizeof(NewFindPath)-1, "%s\\%s", path, fd.cFileName); - GetTestFiles(NewFindPath); - } else if (strstr(fd.cFileName, ".phpt")) { - // got test file, parse it now - if (ParseTestFile(path, fd.cFileName)) { - printf("Test File Added: %s\\%s\r\n", path, fd.cFileName); - } - } - memset(&fd, 0, sizeof(WIN32_FIND_DATA)); - } while (FindNextFile(fh, &fd) != 0); - FindClose(fh); - } - return IsapiFileList.GetSize() > 0; -} - -void DeleteTempFiles(const char *mask) -{ - char FindPath[MAX_PATH]; - WIN32_FIND_DATA fd; - memset(&fd, 0, sizeof(WIN32_FIND_DATA)); - - _snprintf(FindPath, sizeof(FindPath)-1, "%s\\%s", temppath, mask); - HANDLE fh = FindFirstFile(FindPath, &fd); - if (fh != INVALID_HANDLE_VALUE) { - do { - char NewFindPath[MAX_PATH]; - _snprintf(NewFindPath, sizeof(NewFindPath)-1, "%s\\%s", temppath, fd.cFileName); - DeleteFile(NewFindPath); - memset(&fd, 0, sizeof(WIN32_FIND_DATA)); - } while (FindNextFile(fh, &fd) != 0); - FindClose(fh); - } -} - -void DoTestFiles(const char *filelist, const char *environment) -{ - if (!GetTestFiles(filelist)) { - printf("No Files to test!\r\n"); - return; - } - - Results.SetSize(IsapiFileList.GetSize()); - - ReadGlobalEnvironment(environment); - - DoThreads(); - - printf("\r\nRESULTS:\r\n"); - // show results: - DWORD r = Results.GetSize(); - for (DWORD i=0; i< r; i++) { - TResults result = Results.GetAt(i); - printf("%s\r\nOK: %d FAILED: %d\r\n", TestNames.GetAt(i), result.ok, result.bad); - } - - // delete temp files - printf("Deleting Temp Files\r\n"); - DeleteTempFiles("exp.*"); - DeleteTempFiles("pht.*"); - printf("Done\r\n"); -} - -int main(int argc, char* argv[]) -{ - LPVOID lpMsgBuf; - char *filelist=NULL, *environment=NULL; - - if (argc < 3) { - // look for phpt files in tests - printf("USAGE: stresstest [L|T] filelist [environment]\r\n"); - return 0; - } else { - if (argv[1][0]=='T') bUseTestFiles = TRUE; - if (argc > 1) filelist = argv[2]; - if (argc > 2) environment = argv[3]; - } - - GetTempPath(sizeof(temppath), temppath); - hDll = LoadLibrary("php4isapi.dll"); // Load our DLL - - if (!hDll) { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - fprintf(stderr,"Error: Dll 'php4isapi.dll' not found -%d\n%s\n", GetLastError(), lpMsgBuf); - LocalFree( lpMsgBuf ); - return -1; - } - - // - // Find the exported functions - - IsapiGetExtensionVersion = (VersionProc)GetProcAddress(hDll,"GetExtensionVersion"); - if (!IsapiGetExtensionVersion) { - fprintf(stderr,"Can't Get Extension Version %d\n", GetLastError()); - return -1; - } - IsapiHttpExtensionProc = (HttpExtProc)GetProcAddress(hDll,"HttpExtensionProc"); - if (!IsapiHttpExtensionProc) { - fprintf(stderr,"Can't Get Extension proc %d\n", GetLastError()); - return -1; - } - - // This should really check if the version information matches what we - // expect. - // - if (!IsapiGetExtensionVersion(&version_info) ) { - fprintf(stderr,"Fatal: GetExtensionVersion failed\n"); - return -1; - } - - if (bUseTestFiles) { - char TestPath[MAX_PATH]; - if (filelist != NULL) - _snprintf(TestPath, sizeof(TestPath)-1, "%s\\tests", filelist); - else strcpy(TestPath, "tests"); - DoTestFiles(TestPath, environment); - } else { - DoFileList(filelist, environment); - } - - // cleanup - - - // We should really free memory (e.g., from GetEnv), but we'll be dead - // soon enough - - FreeLibrary(hDll); - return 0; -} - - -DWORD CALLBACK IsapiThread(void *p) -{ - DWORD filecount = IsapiFileList.GetSize(); - - for (DWORD j=0; j<ITERATIONS; j++) { - for (DWORD i=0; i<filecount; i++) { - // execute each file - CString testname = TestNames.GetAt(i); - BOOL ok = FALSE; - if (stress_main(IsapiFileList.GetAt(i), - IsapiGetData.GetAt(i), - IsapiPostData.GetAt(i), - IsapiMatchData.GetAt(i))) { - InterlockedIncrement(&Results[i].ok); - ok = TRUE; - } else { - InterlockedIncrement(&Results[i].bad); - ok = FALSE; - } - - if (testname.IsEmpty()) { - printf("Thread %d File %s\n", GetCurrentThreadId(), IsapiFileList.GetAt(i)); - } else { - printf("tid %d: %s %s\n", GetCurrentThreadId(), testname, ok?"OK":"FAIL"); - } - Sleep(10); - } - } - printf("Thread ending...\n"); - return 0; -} - -/* - * ======================================================================= * - * In the startup of this program, we look at our executable name and * - * replace the ".EXE" with ".DLL" to find the ISAPI DLL we need to load. * - * This means that the executable need only be given the same "name" as * - * the DLL to load. There is no recompilation required. * - * ======================================================================= * -*/ -BOOL stress_main(const char *filename, - const char *arg, - const char *postdata, - const char *matchdata) -{ - - EXTENSION_CONTROL_BLOCK ECB; - DWORD rc; - TIsapiContext context; - - // open output and input files - context.tid = GetCurrentThreadId(); - CString fname; - fname.Format("%08X.out", context.tid); - - context.out = CreateFile(fname, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); - if (context.out==INVALID_HANDLE_VALUE) { - printf("failed to open output file %s\n", fname); - return 0; - } - - // not using post files - context.in = INVALID_HANDLE_VALUE; - - // - // Fill the ECB with the necessary information - // - if (!FillExtensionControlBlock(&ECB, &context) ) { - fprintf(stderr,"Fill Ext Block Failed\n"); - return -1; - } - - // check for command line argument, - // first arg = filename - // this is added for testing php from command line - - context.env.RemoveAll(); - context.env["PATH_TRANSLATED"]= filename; - context.env["SCRIPT_MAP"]= filename; - context.env["CONTENT_TYPE"]= ""; - context.env["CONTENT_LENGTH"]= ""; - context.env["QUERY_STRING"]= arg; - context.env["METHOD"]="GET"; - - char buf[MAX_PATH]; - if (postdata && *postdata !=0) { - ECB.cbAvailable = strlen(postdata); - ECB.cbTotalBytes = ECB.cbAvailable; - ECB.lpbData = (unsigned char *)postdata; - context.env["METHOD"]="POST"; - - _snprintf(buf, sizeof(buf)-1, "%d", ECB.cbTotalBytes); - context.env["CONTENT_LENGTH"]=buf; - - context.env["CONTENT_TYPE"]="application/x-www-form-urlencoded"; - } - ECB.lpszPathTranslated = strdup(filename); - ECB.lpszQueryString = strdup(arg); - - // Call the DLL - // - rc = IsapiHttpExtensionProc(&ECB); - - free(ECB.lpszPathTranslated); - free(ECB.lpszQueryString); - - BOOL ok = TRUE; - - if (context.out != INVALID_HANDLE_VALUE) CloseHandle(context.out); - - // compare the output with the EXPECT section - if (matchdata && *matchdata != 0) { - ok = CompareStringWithFile(fname, matchdata, strlen(matchdata)); - } - - DeleteFile(fname); - //if (rc == HSE_STATUS_PENDING) // We will exit in ServerSupportFunction - // Sleep(INFINITE); - - return ok; - -} -// -// GetServerVariable() is how the DLL calls the main program to figure out -// the environment variables it needs. This is a required function. -// -BOOL WINAPI GetServerVariable(HCONN hConn, LPSTR lpszVariableName, - LPVOID lpBuffer, LPDWORD lpdwSize){ - - DWORD rc; - CString value; - TIsapiContext *c = (TIsapiContext *)hConn; - if (!c) return FALSE; - - if (IsapiEnvironment.Lookup(lpszVariableName, value)) { - rc = value.GetLength(); - strncpy((char *)lpBuffer, value, *lpdwSize-1); - } else if (c->env.Lookup(lpszVariableName, value)) { - rc = value.GetLength(); - strncpy((char *)lpBuffer, value, *lpdwSize-1); - } else - rc = GetEnvironmentVariable(lpszVariableName, (char *)lpBuffer, *lpdwSize) ; - - if (!rc) { // return of 0 indicates the variable was not found - SetLastError(ERROR_NO_DATA); - return FALSE; - } - - if (rc > *lpdwSize) { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return FALSE; - } - - *lpdwSize =rc + 1 ; // GetEnvironmentVariable does not count the NULL - - return TRUE; - -} -// -// Again, we don't have an HCONN, so we simply wrap ReadClient() to -// ReadFile on stdin. The semantics of the two functions are the same -// -BOOL WINAPI ReadClient(HCONN hConn, LPVOID lpBuffer, LPDWORD lpdwSize) { - TIsapiContext *c = (TIsapiContext *)hConn; - if (!c) return FALSE; - - if (c->in != INVALID_HANDLE_VALUE) - return ReadFile(c->in, lpBuffer, (*lpdwSize), lpdwSize, NULL); - - return FALSE; -} -// -// ditto for WriteClient() -// -BOOL WINAPI WriteClient(HCONN hConn, LPVOID lpBuffer, LPDWORD lpdwSize, - DWORD dwReserved) { - TIsapiContext *c = (TIsapiContext *)hConn; - if (!c) return FALSE; - - if (c->out != INVALID_HANDLE_VALUE) - return WriteFile(c->out, lpBuffer, *lpdwSize, lpdwSize, NULL); - - return FALSE; -} -// -// This is a special callback function used by the DLL for certain extra -// functionality. Look at the API help for details. -// -BOOL WINAPI ServerSupportFunction(HCONN hConn, DWORD dwHSERequest, - LPVOID lpvBuffer, LPDWORD lpdwSize, LPDWORD lpdwDataType){ - - char *lpszRespBuf; - char * temp = NULL; - DWORD dwBytes; - BOOL bRet; - - switch(dwHSERequest) { - case (HSE_REQ_SEND_RESPONSE_HEADER) : - lpszRespBuf = (char *)xmalloc(*lpdwSize);//+ 80);//accomodate our header - if (!lpszRespBuf) - return FALSE; - wsprintf(lpszRespBuf,"%s", - //HTTP_VER, - - /* Default response is 200 Ok */ - - //lpvBuffer?lpvBuffer:"200 Ok", - - /* Create a string for the time. */ - //temp=MakeDateStr(), - - //SERVER_VERSION, - - /* If this exists, it is a pointer to a data buffer to - be sent. */ - lpdwDataType?(char *)lpdwDataType:NULL); - - if (temp) xfree(temp); - - dwBytes = strlen(lpszRespBuf); - bRet = WriteClient(0, lpszRespBuf, &dwBytes, 0); - xfree(lpszRespBuf); - - break; - // - // A real server would do cleanup here - case (HSE_REQ_DONE_WITH_SESSION): - //ExitThread(0); - break; - - // - // This sends a redirect (temporary) to the client. - // The header construction is similar to RESPONSE_HEADER above. - // - case (HSE_REQ_SEND_URL_REDIRECT_RESP): - lpszRespBuf = (char *)xmalloc(*lpdwSize +80) ; - if (!lpszRespBuf) - return FALSE; - wsprintf(lpszRespBuf,"%s %s %s\r\n", - HTTP_VER, - "302 Moved Temporarily", - (lpdwSize > 0)?lpvBuffer:0); - xfree(temp); - dwBytes = strlen(lpszRespBuf); - bRet = WriteClient(0, lpszRespBuf, &dwBytes, 0); - xfree(lpszRespBuf); - break; - default: - return FALSE; - break; - } - return bRet; - -} -// -// Makes a string of the date and time from GetSystemTime(). -// This is in UTC, as required by the HTTP spec.` -// -char * MakeDateStr(void){ - SYSTEMTIME systime; - char *szDate= (char *)xmalloc(64); - - char * DaysofWeek[] = {"Sun","Mon","Tue","Wed","Thurs","Fri","Sat"}; - char * Months[] = {"NULL","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug", - "Sep","Oct","Nov","Dec"}; - - GetSystemTime(&systime); - - wsprintf(szDate,"%s, %d %s %d %d:%d.%d", DaysofWeek[systime.wDayOfWeek], - systime.wDay, - Months[systime.wMonth], - systime.wYear, - systime.wHour, systime.wMinute, - systime.wSecond ); - - return szDate; -} -// -// Fill the ECB up -// -BOOL WINAPI FillExtensionControlBlock(EXTENSION_CONTROL_BLOCK *ECB, TIsapiContext *context) { - - char * temp; - ECB->cbSize = sizeof(EXTENSION_CONTROL_BLOCK); - ECB->dwVersion = MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR); - ECB->ConnID = (void *)context; - // - // Pointers to the functions the DLL will call. - // - ECB->GetServerVariable = GetServerVariable; - ECB->ReadClient = ReadClient; - ECB->WriteClient = WriteClient; - ECB->ServerSupportFunction = ServerSupportFunction; - - // - // Fill in the standard CGI environment variables - // - ECB->lpszMethod = GetEnv("REQUEST_METHOD"); - if (!ECB->lpszMethod) ECB->lpszMethod = "GET"; - - ECB->lpszQueryString = GetEnv("QUERY_STRING"); - ECB->lpszPathInfo = GetEnv("PATH_INFO"); - ECB->lpszPathTranslated = GetEnv("PATH_TRANSLATED"); - ECB->cbTotalBytes=( (temp=GetEnv("CONTENT_LENGTH")) ? (atoi(temp)): 0); - ECB->cbAvailable = 0; - ECB->lpbData = (unsigned char *)""; - ECB->lpszContentType = GetEnv("CONTENT_TYPE"); - return TRUE; - -} - -// -// Works like _getenv(), but uses win32 functions instead. -// -char *GetEnv(LPSTR lpszEnvVar) -{ - - char *var, dummy; - DWORD dwLen; - - if (!lpszEnvVar) - return ""; - - dwLen =GetEnvironmentVariable(lpszEnvVar, &dummy, 1); - - if (dwLen == 0) - return ""; - - var = (char *)xmalloc(dwLen); - if (!var) - return ""; - (void)GetEnvironmentVariable(lpszEnvVar, var, dwLen); - - return var; -} diff --git a/sapi/isapi/stresstest/stresstest.dsp b/sapi/isapi/stresstest/stresstest.dsp deleted file mode 100644 index 6099dc4aea..0000000000 --- a/sapi/isapi/stresstest/stresstest.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="stresstest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=stresstest - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "stresstest.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "stresstest.mak" CFG="stresstest - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "stresstest - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "stresstest - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "stresstest - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 2
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /FD /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "stresstest - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 2
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "stresstest - Win32 Release"
-# Name "stresstest - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\stresstest.cpp
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\notes.txt
-# End Source File
-# End Target
-# End Project
diff --git a/sapi/nsapi/CREDITS b/sapi/nsapi/CREDITS deleted file mode 100644 index c41a7bf583..0000000000 --- a/sapi/nsapi/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -NSAPI -Jayakumar Muthukumarasamy diff --git a/sapi/nsapi/Makefile.in b/sapi/nsapi/Makefile.in deleted file mode 100644 index 8299911313..0000000000 --- a/sapi/nsapi/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = nsapi.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/nsapi/config.m4 b/sapi/nsapi/config.m4 deleted file mode 100644 index b03ed8b524..0000000000 --- a/sapi/nsapi/config.m4 +++ /dev/null @@ -1,37 +0,0 @@ -dnl ## $Id$ -*- sh -*- - -AC_MSG_CHECKING(for NSAPI support) -AC_ARG_WITH(nsapi, -[ --with-nsapi=DIR Specify path to the installed Netscape],[ - PHP_NSAPI=$withval -],[ - PHP_NSAPI=no -]) -AC_MSG_RESULT($PHP_NSAPI) - -if test "$PHP_NSAPI" != "no"; then - if test ! -d $PHP_NSAPI/bin ; then - AC_MSG_ERROR(Please specify the path to the root of your Netscape server using --with-nsapi=DIR) - fi - AC_MSG_CHECKING(for NSAPI include files) - if test -d $PHP_NSAPI/include ; then - NSAPI_INCLUDE=$PHP_NSAPI/include - AC_MSG_RESULT(Netscape-Enterprise/3.x style) - elif test -d $PHP_NSAPI/plugins/include ; then - NSAPI_INCLUDE=$PHP_NSAPI/plugins/include - AC_MSG_RESULT(iPlanet/4.x style) - else - AC_MSG_ERROR(Please check you have nsapi.h in either DIR/include or DIR/plugins/include) - fi - PHP_ADD_INCLUDE($NSAPI_INCLUDE) - PHP_BUILD_THREAD_SAFE - AC_DEFINE(HAVE_NSAPI,1,[Whether you have a Netscape Server]) - PHP_SAPI=nsapi - PHP_BUILD_SHARED - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PHP_NSAPI/bin/" -fi - - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/nsapi/nsapi-readme.txt b/sapi/nsapi/nsapi-readme.txt deleted file mode 100644 index 2862a44e02..0000000000 --- a/sapi/nsapi/nsapi-readme.txt +++ /dev/null @@ -1,65 +0,0 @@ -Configuration of your Netscape or iPlanet Web Server for PHP4 -------------------------------------------------------------- - -These instructions are targetted at Netscape Enterprise Web Server -and SUN/Netscape Alliance iPlanet Web Server. On other web servers -your milage may vary. - -Firstly you may need to add some paths to the LD_LIBRARY_PATH -environment for netscape to find all the shared libs. This is -best done in the start script for your netscape server. -Windows users can probably skip this step. The start -script is located in: -<path-to-netscape-server>/https-servername/start - -netscape config files are located in: -<path-to-netscape-server>/https-servername/config - -add the following line to mime.types - -type=magnus-internal/x-httpd-php exts=php - - -Add the following to obj.conf, shlib will vary depending on your OS, for unix it -will be something like "<path-to-netscape-server>/bin/libphp4.so". - -#note place following two lines after mime types init! -Init fn="load-modules" funcs="php4_init,php4_close,php4_execute,php4_auth_trans" shlib="/php4/nsapiPHP4.dll" -Init fn=php4_init errorString="Failed to initialize PHP!" - -<Object name="default"> -. -. -. -.#NOTE this next line should happen after all 'ObjectType' and before all 'AddLog' lines -Service fn="php4_execute" type="magnus-internal/x-httpd-php" -. -. -</Object> - - -<Object name="x-httpd-php"> -ObjectType fn="force-type" type="magnus-internal/x-httpd-php" -Service fn=php4_execute -</Object> - - -Authentication configuration - -PHP authentication cannot be used with any other authentication. ALL AUTHENTICATION IS -PASSED TO YOUR PHP SCRIPT. To configure PHP Authentication for the entire server, add -the following line: - -<Object name="default"> -AuthTrans fn=php4_auth_trans -. -. -. -. -</Object> - -To use PHP Authentication on a single directory, add the following: - -<Object ppath="d:\path\to\authenticated\dir\*"> -AuthTrans fn=php4_auth_trans -</Object> diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c deleted file mode 100644 index 9465db5076..0000000000 --- a/sapi/nsapi/nsapi.c +++ /dev/null @@ -1,545 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Jayakumar Muthukumarasamy <jk@kasenna.com> | - +----------------------------------------------------------------------+ -*/ - -/* - * PHP includes - */ -#define NSAPI 1 - -#include "php.h" -#include "php_variables.h" -#include "ext/standard/info.h" -#include "php_ini.h" -#include "php_globals.h" -#include "SAPI.h" -#include "php_main.h" -#include "php_version.h" -#include "TSRM.h" -#include "ext/standard/php_standard.h" - -/* - * If neither XP_UNIX not XP_WIN32 is defined, try to guess which one. - * Ideally, this should be done by the configure script. - */ -#if !defined(XP_UNIX) && !defined(XP_WIN32) - #if defined(WIN32) - #define XP_WIN32 - #else - #define XP_UNIX - #endif -#endif - -/* - * NSAPI includes - */ -#include "nsapi.h" -#include "base/pblock.h" -#include "base/session.h" -#include "frame/req.h" -#include "frame/protocol.h" /* protocol_start_response */ -#include "base/util.h" /* is_mozilla, getline */ -#include "frame/log.h" /* log_error */ - -/* - * Timeout for net_read(). This should probably go into php.ini - */ -#define NSAPI_READ_TIMEOUT 60 /* 60 seconds */ - -#define NSLS_D struct nsapi_request_context *request_context -#define NSLS_DC , NSLS_D -#define NSLS_C request_context -#define NSLS_CC , NSLS_C -#define NSG(v) (request_context->v) - -/* - * ZTS needs to be defined for NSAPI to work - */ -#if !defined(ZTS) - #error "NSAPI module needs ZTS to be defined" -#endif - -/* - * Structure to encapsulate the NSAPI request in SAPI - */ -typedef struct nsapi_request_context { - pblock *pb; - Session *sn; - Request *rq; - int read_post_bytes; -} nsapi_request_context; - -/* - * Mappings between NSAPI names and environment variables. This - * mapping was obtained from the sample programs at the iplanet - * website. - */ -typedef struct nsapi_equiv { - const char *env_var; - const char *nsapi_eq; -} nsapi_equiv; - -static nsapi_equiv nsapi_headers[] = { - { "CONTENT_LENGTH", "content-length" }, - { "CONTENT_TYPE", "content-type" }, - { "HTTP_ACCEPT", "accept" }, - { "HTTP_ACCEPT_ENCODING", "accept-encoding" }, - { "HTTP_ACCEPT_LANGUAGE", "accept-language" }, - { "HTTP_ACCEPT_CHARSET", "accept-charset" }, - { "HTTP_AUTHORIZATION", "authorization" }, - { "HTTP_COOKIE", "cookie" }, - { "HTTP_IF_MODIFIED_SINCE", "if-modified-since" }, - { "HTTP_REFERER", "referer" }, - { "HTTP_USER_AGENT", "user-agent" }, - { "HTTP_USER_DEFINED", "user-defined" } -}; -static size_t nsapi_headers_size = sizeof(nsapi_headers)/sizeof(nsapi_headers[0]); - -static nsapi_equiv nsapi_reqpb[] = { - { "QUERY_STRING", "query" }, - { "REQUEST_LINE", "clf-request" }, - { "REQUEST_METHOD", "method" }, - { "SCRIPT_NAME", "uri" }, - { "SERVER_PROTOCOL", "protocol" } -}; -static size_t nsapi_reqpb_size = sizeof(nsapi_reqpb)/sizeof(nsapi_reqpb[0]); - -static nsapi_equiv nsapi_vars[] = { - { "PATH_INFO", "path-info" }, - { "PATH_TRANSLATED", "path" }, - { "AUTH_TYPE", "auth-type" }, - { "CLIENT_CERT", "auth-cert" }, - { "REMOTE_USER", "auth-user" } -}; -static size_t nsapi_vars_size = sizeof(nsapi_vars)/sizeof(nsapi_vars[0]); - -static nsapi_equiv nsapi_client[] = { - { "HTTPS_KEYSIZE", "keysize" }, - { "HTTPS_SECRETSIZE", "secret-keysize" }, - { "REMOTE_ADDR", "ip" } -}; -static size_t nsapi_client_size = sizeof(nsapi_client)/sizeof(nsapi_client[0]); - -static int -sapi_nsapi_ub_write(const char *str, unsigned int str_length TSRMLS_DC) -{ - int retval; - nsapi_request_context *rc; - - rc = (nsapi_request_context *)SG(server_context); - retval = net_write(rc->sn->csd, (char *)str, str_length); - if (retval == IO_ERROR /*-1*/ || retval == IO_EOF /*0*/) - php_handle_aborted_connection(); - return retval; -} - -static int -sapi_nsapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers SLS_DC) -{ - char *header_name, *header_content, *p; - nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); - - header_name = sapi_header->header; - header_content = p = strchr(header_name, ':'); - if (p == NULL) { - return 0; - } - - *p = 0; - do { - header_content++; - } while (*header_content==' '); - - if (!strcasecmp(header_name, "Content-Type")) { - param_free(pblock_remove("content-type", rc->rq->srvhdrs)); - pblock_nvinsert("content-type", header_content, rc->rq->srvhdrs); - } else if (!strcasecmp(header_name, "Set-Cookie")) { - pblock_nvinsert("set-cookie", header_content, rc->rq->srvhdrs); - } else { - pblock_nvinsert(header_name, header_content, rc->rq->srvhdrs); - } - - *p = ':'; /* restore '*p' */ - - efree(sapi_header->header); - - return 0; /* don't use the default SAPI mechanism, NSAPI duplicates this functionality */ -} - -static int -sapi_nsapi_send_headers(sapi_headers_struct *sapi_headers SLS_DC) -{ - int retval; - nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); - - /* - * We could probably just do this in the header_handler. But, I - * don't know what the implication of doing it there is. - */ - if (SG(sapi_headers).send_default_content_type) { - param_free(pblock_remove("content-type", rc->rq->srvhdrs)); - pblock_nvinsert("content-type", "text/html", rc->rq->srvhdrs); - } - - protocol_status(rc->sn, rc->rq, SG(sapi_headers).http_response_code, NULL); - retval = protocol_start_response(rc->sn, rc->rq); - if (retval == REQ_PROCEED || retval == REQ_NOACTION) - return SAPI_HEADER_SENT_SUCCESSFULLY; - else - return SAPI_HEADER_SEND_FAILED; -} - -static int -sapi_nsapi_read_post(char *buffer, uint count_bytes SLS_DC) -{ - nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); - char *read_ptr = buffer, *content_length_str = NULL; - uint bytes_read = 0; - int length, content_length = 0; - netbuf *nbuf = rc->sn->inbuf; - - /* - * Yesss! - */ - count_bytes = MIN(count_bytes, SG(request_info).content_length-rc->read_post_bytes); - content_length = SG(request_info).content_length; - -#if 0 - /* - * Determine the content-length. This will tell us the limit we can read. - */ - content_length_str = pblock_findval("content-length", rc->rq->headers); - if (content_length_str != NULL) { - content_length = strtol(content_length_str, 0, 0); - } -#endif - - if (content_length <= 0) - return 0; - - /* - * Gobble any pending data in the netbuf. - */ - length = nbuf->cursize - nbuf->pos; - length = MIN(count_bytes, length); - if (length > 0) { - memcpy(read_ptr, nbuf->inbuf + nbuf->pos, length); - bytes_read += length; - read_ptr += length; - content_length -= length; - nbuf->pos += length; - } - - /* - * Read the remaining from the socket. - */ - while (content_length > 0 && bytes_read < count_bytes) { - int bytes_to_read = count_bytes - bytes_read; - if (content_length < bytes_to_read) - bytes_to_read = content_length; - - length = net_read(rc->sn->csd, read_ptr, bytes_to_read, NSAPI_READ_TIMEOUT); - if (length == IO_ERROR || length == IO_EOF) - break; - - bytes_read += length; - read_ptr += length; - content_length -= length; - } - - if ( bytes_read > 0 ) - rc->read_post_bytes += bytes_read; - return bytes_read; -} - -static char * -sapi_nsapi_read_cookies(SLS_D) -{ - char *cookie_string; - nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); - - cookie_string = pblock_findval("cookie", rc->rq->headers); - return cookie_string; -} - -static void -sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_DC SLS_DC TSRMLS_DC) -{ - nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); - size_t i; - char *value; - char buf[128]; - - for (i = 0; i < nsapi_reqpb_size; i++) { - value = pblock_findval(nsapi_reqpb[i].nsapi_eq, rc->rq->reqpb); - if (value) { - php_register_variable( (char *)nsapi_reqpb[i].env_var, value, track_vars_array TSRMLS_CC ); - } - } - - for (i = 0; i < nsapi_headers_size; i++) { - value = pblock_findval(nsapi_headers[i].nsapi_eq, rc->rq->headers); - if (value) { - php_register_variable( (char *)nsapi_headers[i].env_var, value, track_vars_array TSRMLS_CC ); - } - } - - for (i = 0; i < nsapi_vars_size; i++) { - value = pblock_findval(nsapi_vars[i].nsapi_eq, rc->rq->vars); - if (value) { - php_register_variable( (char *)nsapi_vars[i].env_var, value, track_vars_array TSRMLS_CC ); - } - } - - for (i = 0; i < nsapi_client_size; i++) { - value = pblock_findval(nsapi_client[i].nsapi_eq, rc->sn->client); - if (value) { - php_register_variable( (char *)nsapi_client[i].env_var, value, track_vars_array TSRMLS_CC ); - } - } - - value = session_dns(rc->sn); - if (value) { - php_register_variable("REMOTE_HOST", value, track_vars_array TSRMLS_CC ); - } - sprintf(buf, "%d", conf_getglobals()->Vport); - php_register_variable("SERVER_PORT", buf, track_vars_array TSRMLS_CC ); - php_register_variable("SERVER_NAME", util_hostname(), track_vars_array TSRMLS_CC ); - php_register_variable("SERVER_URL", http_uri2url("", ""), track_vars_array TSRMLS_CC ); - php_register_variable("HTTPS", (security_active ? "ON" : "OFF"), track_vars_array TSRMLS_CC ); -/* php_register_variable("SERVER_SOFTWARE", MAGNUS_VERSION_STRING, track_vars_array TSRMLS_CC ); */ - - /* - * Special PHP_SELF variable. - */ - value = pblock_findval("uri", rc->rq->reqpb); - if ( value != NULL ) { - php_register_variable("PHP_SELF", value, track_vars_array TSRMLS_CC ); - } -} - -static void -nsapi_log_message(char *message) -{ - TSRMLS_FETCH(); - nsapi_request_context *rc = (nsapi_request_context *)SG(server_context); - log_error(LOG_INFORM, "PHP_log_message", rc->sn, rc->rq, - "%s", message); -} - - -static sapi_module_struct nsapi_sapi_module = { - "nsapi", /* name */ - "NSAPI", /* pretty name */ - - php_module_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - NULL, /* activate */ - NULL, /* deactivate */ - - sapi_nsapi_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, /* error handler */ - - sapi_nsapi_header_handler, /* header handler */ - sapi_nsapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ - - sapi_nsapi_read_post, /* read POST data */ - sapi_nsapi_read_cookies, /* read Cookies */ - - sapi_nsapi_register_server_variables, /* register server variables */ - nsapi_log_message, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -static char * -nsapi_strdup(char *str) -{ - if (str != NULL) - return STRDUP(str); - return NULL; -} - -static void -nsapi_free(void *addr) -{ - if (addr != NULL) - FREE(addr); -} - -static void -nsapi_request_ctor(NSLS_D SLS_DC) -{ - char *query_string = pblock_findval("query", NSG(rq)->reqpb); - char *uri = pblock_findval("uri", NSG(rq)->reqpb); - char *path_info = pblock_findval("path-info", NSG(rq)->vars); - char *path_translated = pblock_findval("path", NSG(rq)->vars); - char *request_method = pblock_findval("method", NSG(rq)->reqpb); - char *content_type = pblock_findval("content-type", NSG(rq)->headers); - char *content_length = pblock_findval("content-length", NSG(rq)->headers); - - if ((path_translated == NULL) && (uri != NULL)) - path_translated = request_translate_uri(uri, NSG(sn)); - -#if defined(NSAPI_DEBUG) - log_error(LOG_INFORM, "nsapi_request_ctor", NSG(sn), NSG(rq), - "query_string = %s, " - "uri = %s, " - "path_info = %s, " - "path_translated = %s, " - "request_method = %s, " - "content_type = %s, " - "content_length = %s", - query_string, - uri, - path_info, - path_translated, - request_method, - content_type, - content_length); -#endif - - SG(request_info).query_string = nsapi_strdup(query_string); - SG(request_info).request_uri = nsapi_strdup(uri); - SG(request_info).request_method = nsapi_strdup(request_method); - SG(request_info).path_translated = nsapi_strdup(path_translated); - SG(request_info).content_type = nsapi_strdup(content_type); - SG(request_info).content_length = (content_length == NULL) ? 0 : strtoul(content_length, 0, 0); - SG(sapi_headers).http_response_code = 200; -} - -static void -nsapi_request_dtor(NSLS_D SLS_DC) -{ - nsapi_free(SG(request_info).query_string); - nsapi_free(SG(request_info).request_uri); - nsapi_free(SG(request_info).request_method); - nsapi_free(SG(request_info).path_translated); - nsapi_free(SG(request_info).content_type); -} - -int -nsapi_module_main(NSLS_D SLS_DC) -{ - int result; - zend_file_handle file_handle; - TSRMLS_FETCH(); - - if (php_request_startup(TSRMLS_C) == FAILURE) { - return FAILURE; - } - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - -#if defined(NSAPI_DEBUG) - log_error(LOG_INFORM, "nsapi_module_main", NSG(sn), NSG(rq), - "Parsing [%s]", SG(request_info).path_translated); -#endif - - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); - -#if defined(NSAPI_DEBUG) - log_error(LOG_INFORM, "nsapi_module_main", NSG(sn), NSG(rq), - "PHP request finished Ok"); -#endif - return SUCCESS; -} - -void NSAPI_PUBLIC -php4_close(void *vparam) -{ - if (nsapi_sapi_module.shutdown) { - nsapi_sapi_module.shutdown(&nsapi_sapi_module); - } - tsrm_shutdown(); -} - -int NSAPI_PUBLIC -php4_init(pblock *pb, Session *sn, Request *rq) -{ - php_core_globals *core_globals; - - tsrm_startup(1, 1, 0, NULL); - core_globals = ts_resource(core_globals_id); - - sapi_startup(&nsapi_sapi_module); - nsapi_sapi_module.startup(&nsapi_sapi_module); - - log_error(LOG_INFORM, "php4_init", sn, rq, "Initialized PHP Module\n"); - return REQ_PROCEED; -} - -int NSAPI_PUBLIC -php4_execute(pblock *pb, Session *sn, Request *rq) -{ - int retval; - nsapi_request_context *request_context; - - TSRMLS_FETCH(); - - request_context = (nsapi_request_context *)MALLOC(sizeof(nsapi_request_context)); - request_context->pb = pb; - request_context->sn = sn; - request_context->rq = rq; - request_context->read_post_bytes = 0; - - SG(server_context) = request_context; - - nsapi_request_ctor(NSLS_C SLS_CC); - retval = nsapi_module_main(NSLS_C SLS_CC); - nsapi_request_dtor(NSLS_C SLS_CC); - - FREE(request_context); - - return (retval == SUCCESS) ? REQ_PROCEED : REQ_EXIT; -} - -/********************************************************* -/ authentication -/ -/ we have to make a 'fake' authenticator for netscape so it -/ will pass authentication through to php, and allow us to -/ check authentication with our scripts. -/ -/ php4_auth_trans -/ main function called from netscape server to authenticate -/ a line in obj.conf: -/ funcs=php4_auth_trans shlib="path/to/this/phpnsapi.dll" -/ and: -/ <Object ppath="path/to/be/authenticated/by/php/*"> -/ AuthTrans fn="php4_auth_trans" -/*********************************************************/ -int NSAPI_PUBLIC -php4_auth_trans(pblock * pb, Session * sn, Request * rq) -{ - /*This is a DO NOTHING function that allows authentication information - to be passed through to PHP scripts.*/ - return REQ_PROCEED; -} diff --git a/sapi/nsapi/php4nsapi.dsp b/sapi/nsapi/php4nsapi.dsp deleted file mode 100644 index 9b0b8c9a56..0000000000 --- a/sapi/nsapi/php4nsapi.dsp +++ /dev/null @@ -1,135 +0,0 @@ -# Microsoft Developer Studio Project File - Name="php4nsapi" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php4nsapi - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4nsapi.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4nsapi.mak" CFG="php4nsapi - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4nsapi - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4nsapi - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4nsapi - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4nsapi - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php4nsapi___Win32_Release_TS"
-# PROP BASE Intermediate_Dir "php4nsapi___Win32_Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php4nsapi_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "NDEBUG" /D "XP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "php4nsapi_EXPORTS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 ns-httpd30.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS" /libpath:"..\..\TSRM\Release_TS" /libpath:"..\..\Zend\Release_TS"
-
-!ELSEIF "$(CFG)" == "php4nsapi - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php4nsapi___Win32_Release_TS_inline"
-# PROP BASE Intermediate_Dir "php4nsapi___Win32_Release_TS_inline"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php4nsapi_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "NDEBUG" /D "XP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "php4nsapi_EXPORTS" /D "WIN32" /D "_MBCS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 ns-httpd30.lib php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /version:4.0 /dll /machine:I386 /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Release_TS_inline" /libpath:"..\..\TSRM\Release_TS_inline" /libpath:"..\..\Zend\Release_TS_inline"
-
-!ELSEIF "$(CFG)" == "php4nsapi - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "php4nsapi___Win32_Debug_TS"
-# PROP BASE Intermediate_Dir "php4nsapi___Win32_Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php4nsapi_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\..\..\php_build\nsapi30\include\\" /I "..\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\..\bindlib_w32" /I "..\..\main" /I "..\..\tsrm" /D "_Debug_TS" /D ZEND_DEBUG=1 /D "_DEBUG" /D "XP_WIN32" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "_WINDOWS" /D "_USRDLL" /D "php4nsapi_EXPORTS" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ns-httpd30.lib php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x62000000" /version:4.0 /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\php_build\nsapi30\lib\\" /libpath:"..\..\Debug_TS" /libpath:"..\..\TSRM\Debug_TS" /libpath:"..\..\Zend\Debug_TS"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4nsapi - Win32 Release_TS"
-# Name "php4nsapi - Win32 Release_TS_inline"
-# Name "php4nsapi - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\nsapi.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/sapi/phttpd/CREDITS b/sapi/phttpd/CREDITS deleted file mode 100644 index 134cc54825..0000000000 --- a/sapi/phttpd/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -phttpd -Thies C. Arntzen diff --git a/sapi/phttpd/Makefile.in b/sapi/phttpd/Makefile.in deleted file mode 100644 index 3fa62790f1..0000000000 --- a/sapi/phttpd/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = phttpd.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/phttpd/README b/sapi/phttpd/README deleted file mode 100644 index cdb6f7c381..0000000000 --- a/sapi/phttpd/README +++ /dev/null @@ -1,5 +0,0 @@ -phttpd sapi module. - -THIS IS BY NO MEANS COMPLETE NOR USABLE RIGHT NOW! - -thies@thieso.net 03.01.2000 diff --git a/sapi/phttpd/config.m4 b/sapi/phttpd/config.m4 deleted file mode 100644 index 038fbc8e8a..0000000000 --- a/sapi/phttpd/config.m4 +++ /dev/null @@ -1,24 +0,0 @@ -dnl ## $Id$ -*- sh -*- - -RESULT=no -AC_MSG_CHECKING(for PHTTPD support) -AC_ARG_WITH(phttpd, -[ --with-phttpd=DIR], -[ - if test ! -d $withval ; then - AC_MSG_ERROR(You did not specify a directory) - fi - PHP_BUILD_THREAD_SAFE - PHTTPD_DIR=$withval - PHP_ADD_INCLUDE($PHTTPD_DIR/include) - AC_DEFINE(HAVE_PHTTPD,1,[Whether you have phttpd]) - PHP_SAPI=phttpd - PHP_BUILD_SHARED - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PHTTPD_DIR/modules/" - RESULT=yes -]) -AC_MSG_RESULT($RESULT) - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/phttpd/php.sym b/sapi/phttpd/php.sym deleted file mode 100644 index f10b883a99..0000000000 --- a/sapi/phttpd/php.sym +++ /dev/null @@ -1,4 +0,0 @@ -pm_init -pm_exit -pm_request - diff --git a/sapi/phttpd/php_phttpd.h b/sapi/phttpd/php_phttpd.h deleted file mode 100644 index 09b7a5cb11..0000000000 --- a/sapi/phttpd/php_phttpd.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Thies C. Arntzen <thies@thieso.net> | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_PHTTPD_H -#define PHP_PHTTPD_H - -#include <phttpd.h> - -#endif diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c deleted file mode 100644 index ff5cc6677c..0000000000 --- a/sapi/phttpd/phttpd.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Thies C. Arntzen <thies@thieso.net> | - | Based on aolserver SAPI by Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ -*/ - -#include "php.h" -#include "SAPI.h" -#include "php_main.h" - -#ifdef HAVE_PHTTPD - -#include "ext/standard/info.h" - -#ifndef ZTS -#error PHTTPD module is only useable in thread-safe mode -#endif - -#include "php_phttpd.h" - -typedef struct { - struct connectioninfo *cip; - struct stat sb; -} phttpd_globals_struct; - -static int ph_globals_id; - -#define PHG(v) TSRMG(ph_globals_id, phttpd_globals_struct *, v) - -static int -php_phttpd_startup(sapi_module_struct *sapi_module) -{ -/* - if(php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_aolserver_module) == FAILURE) { -*/ - fprintf(stderr,"***php_phttpd_startup\n"); - - if (php_module_startup(sapi_module)) { - return FAILURE; - } else { - return SUCCESS; - } -} - -static int -php_phttpd_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - int sent_bytes; - - sent_bytes = fd_write(PHG(cip)->fd, str, str_length); - - if (sent_bytes == -1) { - php_handle_aborted_connection(); - } - - return sent_bytes; -} - -static int -php_phttpd_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - char *header_name, *header_content; - char *p; - TSRMLS_FETCH(); - - http_sendheaders(PHG(cip)->fd, PHG(cip), SG(sapi_headers).http_response_code, NULL); - - header_name = sapi_header->header; - header_content = p = strchr(header_name, ':'); - - if (p) { - *p = '\0'; - do { - header_content++; - } while (*header_content == ' '); - - fd_printf(PHG(cip)->fd,"%s: %s\n", header_name, header_content); - - *p = ':'; - } - - sapi_free_header(sapi_header); - - return 0; -} - -static int -php_phttpd_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - TSRMLS_FETCH(); - - if (SG(sapi_headers).send_default_content_type) { - fd_printf(PHG(cip)->fd,"Content-Type: text/html\n"); - } - - fd_putc('\n', PHG(cip)->fd); - - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - -static char * -php_phttpd_sapi_read_cookies(TSRMLS_D) -{ - -/* - int i; - char *http_cookie = NULL; - NTSRMLS_FETCH(); - - i = Ns_SetIFind(NSG(conn->headers), "cookie"); - if(i != -1) { - http_cookie = Ns_SetValue(NSG(conn->headers), i); - } - - return http_cookie; -*/ - fprintf(stderr,"***php_phttpd_sapi_read_cookies\n"); - - return 0; -} - -static int -php_phttpd_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) -{ -/* - uint max_read; - uint total_read = 0; - NTSRMLS_FETCH(); - - max_read = MIN(NSG(data_avail), count_bytes); - - total_read = Ns_ConnRead(NSG(conn), buf, max_read); - - if(total_read == NS_ERROR) { - total_read = -1; - } else { - NSG(data_avail) -= total_read; - } - - return total_read; -*/ - fprintf(stderr,"***php_phttpd_sapi_read_post\n"); - return 0; -} - -static sapi_module_struct phttpd_sapi_module = { - "phttpd", - "PHTTPD", - - php_phttpd_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - NULL, /* activate */ - NULL, /* deactivate */ - - php_phttpd_sapi_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, /* error handler */ - - php_phttpd_sapi_header_handler, /* header handler */ - php_phttpd_sapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ - - php_phttpd_sapi_read_post, /* read POST data */ - php_phttpd_sapi_read_cookies, /* read Cookies */ - - NULL, /* register server variables */ - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -static void -php_phttpd_request_ctor(TSRMLS_D TSRMLS_DC) -{ - memset(&SG(request_info), 0, sizeof(sapi_globals_struct)); /* pfusch! */ - - SG(request_info).query_string = PHG(cip)->hip->request; - SG(request_info).request_method = PHG(cip)->hip->method; - SG(request_info).path_translated = malloc(MAXPATHLEN); - SG(sapi_headers).http_response_code = 200; - if (url_expand(PHG(cip)->hip->url, SG(request_info).path_translated, MAXPATHLEN, &PHG(sb), NULL, NULL) == NULL) { - /* handle error */ - } - -#if 0 - char *server; - Ns_DString ds; - char *root; - int index; - char *tmp; - - server = Ns_ConnServer(NSG(conn)); - - Ns_DStringInit(&ds); - Ns_UrlToFile(&ds, server, NSG(conn->request->url)); - - /* path_translated is the absolute path to the file */ - SG(request_info).path_translated = strdup(Ns_DStringValue(&ds)); - Ns_DStringFree(&ds); - root = Ns_PageRoot(server); - SG(request_info).request_uri = SG(request_info).path_translated + strlen(root); - SG(request_info).content_length = Ns_ConnContentLength(NSG(conn)); - index = Ns_SetIFind(NSG(conn)->headers, "content-type"); - SG(request_info).content_type = index == -1 ? NULL : - Ns_SetValue(NSG(conn)->headers, index); - - tmp = Ns_ConnAuthUser(NSG(conn)); - if(tmp) { - tmp = estrdup(tmp); - } - SG(request_info).auth_user = tmp; - - tmp = Ns_ConnAuthPasswd(NSG(conn)); - if(tmp) { - tmp = estrdup(tmp); - } - SG(request_info).auth_password = tmp; - - NSG(data_avail) = SG(request_info).content_length; -#endif -} - -static void -php_phttpd_request_dtor(TSRMLS_D TSRMLS_DC) -{ - free(SG(request_info).path_translated); -} - - -int php_doit(TSRMLS_D TSRMLS_DC) -{ - struct stat sb; - zend_file_handle file_handle; - struct httpinfo *hip = PHG(cip)->hip; - TSRMLS_FETCH(); - - if (php_request_startup(TSRMLS_C) == FAILURE) { - return -1; - } - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - -/* - php_phttpd_hash_environment(TSRMLS_C); -*/ - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); - - return SG(sapi_headers).http_response_code; -} - -int pm_init(const char **argv) -{ - tsrm_startup(1, 1, 0, NULL); - sapi_startup(&phttpd_sapi_module); - phttpd_sapi_module.startup(&phttpd_sapi_module); - - ts_allocate_id(&ph_globals_id, sizeof(phttpd_globals_struct), NULL, NULL); - - return 0; -} - -void pm_exit(void) -{ - fprintf(stderr,"***pm_exit\n"); -} - -int pm_request(struct connectioninfo *cip) -{ - struct httpinfo *hip = cip->hip; - int status; - TSRMLS_FETCH(); - TSRMLS_FETCH(); - - if (strcasecmp(hip->method, "GET") == 0 || - strcasecmp(hip->method, "HEAD") == 0 || - strcasecmp(hip->method, "POST") == 0) { - PHG(cip) = cip; - - php_phttpd_request_ctor(TSRMLS_C); - status = php_doit(TSRMLS_C); - php_phttpd_request_dtor(TSRMLS_C); - - return status; - } else { - return -2; - } -} - -#endif diff --git a/sapi/pi3web/CREDITS b/sapi/pi3web/CREDITS deleted file mode 100644 index c4541f89da..0000000000 --- a/sapi/pi3web/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -pi3web -Holger Zimmermann diff --git a/sapi/pi3web/Makefile.in b/sapi/pi3web/Makefile.in deleted file mode 100644 index 0195beb789..0000000000 --- a/sapi/pi3web/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = pi3web_sapi.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/pi3web/README b/sapi/pi3web/README deleted file mode 100644 index 8d7e9dc274..0000000000 --- a/sapi/pi3web/README +++ /dev/null @@ -1,50 +0,0 @@ -PHP4 Module -========== -This module requires PHP4 as thread safe shared library. Have a look -into the INSTALL file which accompanies that distribution. - -If you distribute this software bundled with the PHP software in source -or binary form, then you must adhere to the PHP copyright conditions - -the terms are reasonable. - -You should have checked out and built the PHP4 source package from the -PHP CVS tree into the Pi3Web source directory called 'PHP4' first. Then -build PHP4 as Pi3Web module and after that build the Pi3Web PHP4 wrapper: - -1. Checkout PHP4 -================ -cvs -d :pserver:cvsread@cvs.php.net:/repository login -The required password is phpfi - -cvs -z3 -d :pserver:cvsread@cvs.php.net:/repository co php4 - -You must also checkout the TSRM and the ZEND module from the ZEND cvs tree -into the PHP4 root directory - -cvs -d :pserver:cvsread@cvs.zend.com:/repository login -The required password is zend - -cvs -z3 -d :pserver:cvsread@cvs.zend.com:/repository co Zend TSRM - -2. Build PHP4 -============= -2.1 POSIX ---------- -cd ./php4 -./buildconf -./configure --with-pi3web -make - -2.2 Win32 ---------- -other required downloads from the php website - - bison 1.25 - - bindlib32 - - number4.tar.gz -nmake php4dllts.mak - -3. Build Pi3Web PHP4 wrapper -============================ -Run make in the Pi3Web /Source/PHP4 directory. - -For further information refer to http://www.php.net/version4/ diff --git a/sapi/pi3web/config.m4 b/sapi/pi3web/config.m4 deleted file mode 100644 index eb729f75d7..0000000000 --- a/sapi/pi3web/config.m4 +++ /dev/null @@ -1,24 +0,0 @@ -PHP_ARG_WITH(pi3web,for Pi3Web Support, -[ --with-pi3web=DIR Build PHP as a module for use with Pi3Web.]) - -if test "$PHP_PI3WEB" != "no"; then - if test "$PHP_PI3WEB" = "yes"; then - PI3PATH=../.. # the default - else - PI3PATH=$PHP_PI3WEB - fi - test -f "$PI3PATH/PiAPI/PiAPI.h" || AC_MSG_ERROR(Unable to find PiAPI.h in $PI3PATH/PiAPI) - PHP_BUILD_THREAD_SAFE - AC_DEFINE(WITH_PI3WEB,1,[whether you want Pi3Web support]) - PHP_ADD_INCLUDE($PI3PATH/PiAPI) - PHP_ADD_INCLUDE($PI3PATH/Pi2API) - PHP_ADD_INCLUDE($PI3PATH/Pi3API) - PHP_ADD_INCLUDE($PI3PATH/PHP4) - PHP_SAPI=pi3web - PHP_BUILD_SHARED - INSTALL_IT="\$(SHELL) \$(srcdir)/install-sh -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PI3PATH/bin/" -fi - -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: diff --git a/sapi/pi3web/php.sym b/sapi/pi3web/php.sym deleted file mode 100644 index e69de29bb2..0000000000 --- a/sapi/pi3web/php.sym +++ /dev/null diff --git a/sapi/pi3web/php4pi3web.dsp b/sapi/pi3web/php4pi3web.dsp deleted file mode 100644 index ec1c2806a3..0000000000 --- a/sapi/pi3web/php4pi3web.dsp +++ /dev/null @@ -1,136 +0,0 @@ -# Microsoft Developer Studio Project File - Name="php4pi3web" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php4pi3web - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "php4pi3web.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "php4pi3web.mak" CFG="php4pi3web - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php4pi3web - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4pi3web - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php4pi3web - Win32 Release_TS_inline" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "php4pi3web - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php4pi3web_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /debug /machine:I386 /nodefaultlib:"libcmt" /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\Debug_TS"
-
-!ELSEIF "$(CFG)" == "php4pi3web - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "php4pi3web_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcmt.lib" /libpath:"..\..\Release_TS"
-
-!ELSEIF "$(CFG)" == "php4pi3web - Win32 Release_TS_inline"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "php4pi3web___Win32_Release_TS_inline"
-# PROP BASE Intermediate_Dir "php4pi3web___Win32_Release_TS_inline"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS_inline"
-# PROP Intermediate_Dir "Release_TS_inline"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I ".." /I "..\main" /I "..\regex" /I "..\..\bindlib_w32" /I "..\Zend" /I "..\TSRM" /I "..\ext\mysql\libmysql" /I "..\..\..\PiAPI" /I "..\..\..\Pi2API" /I "..\..\..\Pi3API" /D "NDEBUG" /D ZEND_DEBUG=0 /D "_WINDOWS" /D "_USRDLL" /D "PHP4DLLTS_EXPORTS" /D "PHP_EXPORTS" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "SAPI_EXPORTS" /D "MSVC5" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "...\..\include" /I "..\..\win32" /I "..\..\Zend" /I "..\.." /I "..\..\main" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZEND_WIN32_FORCE_INLINE" /D "_WINDOWS" /D "_USRDLL" /D "ZTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "WIN32" /D "_MBCS" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ZendTS.lib TSRM.lib resolv.lib libmysql.lib PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcmt.lib" /out:"..\Release_TS\php4ts.dll" /libpath:"..\TSRM\Release_TS" /libpath:"..\Zend\Release_TS" /libpath:"..\..\bindlib_w32\Release" /libpath:"..\ext\mysql\libmysql\Release_TS" /libpath:"Release_TS" /libpath:"..\..\..\PiAPI" /libpath:"..\..\..\Pi2API" /libpath:"..\..\..\Pi3API"
-# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib wsock32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib PiAPI.lib Pi2API.lib Pi3API.lib /nologo /version:4.0 /dll /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcmt.lib" /libpath:"..\..\Release_TS_inline"
-
-!ENDIF
-
-# Begin Target
-
-# Name "php4pi3web - Win32 Debug_TS"
-# Name "php4pi3web - Win32 Release_TS"
-# Name "php4pi3web - Win32 Release_TS_inline"
-# Begin Group "Source Files"
-
-# PROP Default_Filter ".c"
-# Begin Source File
-
-SOURCE=.\pi3web_sapi.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter ".h"
-# Begin Source File
-
-SOURCE=.\pi3web_sapi.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c deleted file mode 100644 index 12a0178b61..0000000000 --- a/sapi/pi3web/pi3web_sapi.c +++ /dev/null @@ -1,467 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Pi3Web version 2.0 | - +----------------------------------------------------------------------+ - | This file is committed by the Pi3 development group. | - | (pi3web.sourceforge.net) | - | | - | Author: Holger Zimmermann (zimpel@users.sourceforge.net) | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "pi3web_sapi.h" -#include "php.h" -#include "php_main.h" -#include "SAPI.h" -#include "php_globals.h" -#include "ext/standard/info.h" -#include "zend_highlight.h" -#include "zend_indent.h" -#include "zend_alloc.h" -#include "ext/standard/basic_functions.h" -#include "TSRM/TSRM.h" -#include "PiAPI.h" -#include "Pi3API.h" - -#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST STATUS DESCRIPTION") -#define PI3WEB_SERVER_VAR_BUF_SIZE 1024 -#define PI3WEB_POST_DATA_BUF 1024 - -int IWasLoaded=0; - -static char *pi3web_server_variables[] = { - "ALL_HTTP", - "AUTH_TYPE", - "CONTENT_LENGTH", - "CONTENT_TYPE", - "GATEWAY_INTERFACE", - "PATH_INFO", - "PATH_TRANSLATED", - "QUERY_STRING", - "REQUEST_METHOD", - "REMOTE_ADDR", - "REMOTE_HOST", - "REMOTE_USER", - "SCRIPT_NAME", - "SERVER_NAME", - "SERVER_PORT", - "SERVER_PROTOCOL", - "SERVER_SOFTWARE", - NULL -}; - - -static void php_info_pi3web(ZEND_MODULE_INFO_FUNC_ARGS) -{ - char **p = pi3web_server_variables; - char variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE]; - DWORD variable_len; - LPCONTROL_BLOCK lpCB; - TSRMLS_FETCH(); - - lpCB = (LPCONTROL_BLOCK) SG(server_context); - - PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n"); - PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">Pi3Web Server Information</th></tr>\n"); - php_info_print_table_header(2, "Information Field", "Value"); - php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id$"); - php_info_print_table_row(2, "Server Name Stamp", HTTPCore_getServerStamp()); - snprintf(variable_buf, 511, "%d", HTTPCore_debugEnabled()); - php_info_print_table_row(2, "Debug Enabled", variable_buf); - PIPlatform_getCurrentDirectory( variable_buf, PI3WEB_SERVER_VAR_BUF_SIZE); - php_info_print_table_row(2, "Current Path", variable_buf); - if (lpCB->GetServerVariable(lpCB->ConnID, "SERVER_NAME", variable_buf, &variable_len) - && variable_buf[0]) { - php_info_print_table_row(2, "Main Virtual Hostname", variable_buf); - }; - snprintf(variable_buf, 511, "%d", PIPlatform_getProcessId()); - php_info_print_table_row(2, "Server PID", variable_buf); - php_info_print_table_row(2, "Server Platform", PIPlatform_getDescription()); - - PUTS("</table><BR>"); - - PUTS("<table border=0 cellpadding=3 cellspacing=1 width=600 align=center>\n"); - PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">HTTP Request Information</th></tr>\n"); - php_info_print_table_row(2, "HTTP Request Line", lpCB->lpszReq); - PUTS("<tr><th colspan=2 bgcolor=\"" PHP_HEADER_COLOR "\">HTTP Headers</th></tr>\n"); - php_info_print_table_header(2, "Server Variable", "Value"); - while (*p) { - variable_len = PI3WEB_SERVER_VAR_BUF_SIZE; - if (lpCB->GetServerVariable(lpCB->ConnID, *p, variable_buf, &variable_len) - && variable_buf[0]) { - php_info_print_table_row(2, *p, variable_buf); - } else if (PIPlatform_getLastError() == PIAPI_EINVAL) { - char *tmp_variable_buf; - - tmp_variable_buf = (char *) emalloc(variable_len); - if (lpCB->GetServerVariable(lpCB->ConnID, *p, tmp_variable_buf, &variable_len) - && variable_buf[0]) { - php_info_print_table_row(2, *p, tmp_variable_buf); - } - efree(tmp_variable_buf); - } - p++; - } - - PUTS("</table>"); -} - - -static zend_module_entry php_pi3web_module = { - "PI3WEB", - NULL, - NULL, - NULL, - NULL, - NULL, - php_info_pi3web, - STANDARD_MODULE_PROPERTIES -}; - - -static int zend_pi3web_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - DWORD num_bytes = str_length; - LPCONTROL_BLOCK cb; - - cb = (LPCONTROL_BLOCK) SG(server_context); - - if ( !IWasLoaded ) return 0; - cb->WriteClient(cb->ConnID, (char *) str, &num_bytes, 0 ); - - if (num_bytes != str_length) - php_handle_aborted_connection(); - return num_bytes; -} - - -static int sapi_pi3web_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - return SAPI_HEADER_ADD; -} - - - -static void accumulate_header_length(sapi_header_struct *sapi_header, uint *total_length TSRMLS_DC) -{ - *total_length += sapi_header->header_len+2; -} - - -static void concat_header(sapi_header_struct *sapi_header, char **combined_headers_ptr TSRMLS_DC) -{ - memcpy(*combined_headers_ptr, sapi_header->header, sapi_header->header_len); - *combined_headers_ptr += sapi_header->header_len; - **combined_headers_ptr = '\r'; - (*combined_headers_ptr)++; - **combined_headers_ptr = '\n'; - (*combined_headers_ptr)++; -} - - -static int sapi_pi3web_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - uint total_length = 2; /* account for the trailing \r\n */ - char *combined_headers, *combined_headers_ptr; - LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context); - sapi_header_struct default_content_type; - - if ( !IWasLoaded ) return SAPI_HEADER_SENT_SUCCESSFULLY; - - - if (SG(sapi_headers).send_default_content_type) { - sapi_get_default_content_type_header(&default_content_type TSRMLS_CC); - accumulate_header_length(&default_content_type, (void *) &total_length TSRMLS_CC); - } - zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) accumulate_header_length, (void *) &total_length TSRMLS_CC); - - /* Generate headers */ - combined_headers = (char *) emalloc(total_length+1); - combined_headers_ptr = combined_headers; - if (SG(sapi_headers).send_default_content_type) { - concat_header(&default_content_type, (void *) &combined_headers_ptr); - sapi_free_header(&default_content_type); /* we no longer need it */ - } - zend_llist_apply_with_argument(&SG(sapi_headers).headers, (llist_apply_with_arg_func_t) concat_header, (void *) &combined_headers_ptr TSRMLS_CC); - *combined_headers_ptr++ = '\r'; - *combined_headers_ptr++ = '\n'; - *combined_headers_ptr = 0; - - lpCB->dwHttpStatusCode = SG(sapi_headers).http_response_code; - lpCB->SendHeaderFunction(lpCB->ConnID, &total_length, (LPDWORD) combined_headers); - - efree(combined_headers); - if (SG(sapi_headers).http_status_line) { - efree(SG(sapi_headers).http_status_line); - } - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - - -static int php_pi3web_startup(sapi_module_struct *sapi_module) -{ - if (php_module_startup(sapi_module)==FAILURE - || zend_register_module(&php_pi3web_module)==FAILURE) { - return FAILURE; - } else { - return SUCCESS; - } -} - - -static int sapi_pi3web_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context); - DWORD read_from_buf=0; - DWORD read_from_input=0; - DWORD total_read=0; - - if (SG(read_post_bytes) < lpCB->cbAvailable) { - read_from_buf = MIN(lpCB->cbAvailable-SG(read_post_bytes), count_bytes); - memcpy(buffer, lpCB->lpbData+SG(read_post_bytes), read_from_buf); - total_read += read_from_buf; - } - if (read_from_buf<count_bytes - && (SG(read_post_bytes)+read_from_buf) < lpCB->cbTotalBytes) { - DWORD cbRead=0, cbSize; - - read_from_input = MIN(count_bytes-read_from_buf, lpCB->cbTotalBytes-SG(read_post_bytes)-read_from_buf); - while (cbRead < read_from_input) { - cbSize = read_from_input - cbRead; - if (!lpCB->ReadClient(lpCB->ConnID, buffer+read_from_buf+cbRead, &cbSize) || cbSize==0) { - break; - } - cbRead += cbSize; - } - total_read += cbRead; - } - SG(read_post_bytes) += total_read; - return total_read; -} - - -static char *sapi_pi3web_read_cookies(TSRMLS_D) -{ - LPCONTROL_BLOCK lpCB = (LPCONTROL_BLOCK) SG(server_context); - char variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE]; - DWORD variable_len = PI3WEB_SERVER_VAR_BUF_SIZE; - - if (lpCB->GetServerVariable(lpCB->ConnID, "HTTP_COOKIE", variable_buf, &variable_len)) { - return estrndup(variable_buf, variable_len); - } else if (PIPlatform_getLastError()==PIAPI_EINVAL) { - char *tmp_variable_buf = (char *) emalloc(variable_len+1); - - if (lpCB->GetServerVariable(lpCB->ConnID, "HTTP_COOKIE", tmp_variable_buf, &variable_len)) { - tmp_variable_buf[variable_len] = 0; - return tmp_variable_buf; - } else { - efree(tmp_variable_buf); - } - } - return NULL; -} - -static sapi_module_struct pi3web_sapi_module = { - "pi3web", /* name */ - "PI3WEB", /* pretty name */ - - php_pi3web_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - NULL, /* activate */ - NULL, /* deactivate */ - zend_pi3web_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - php_error, /* error handler */ - sapi_pi3web_header_handler, /* header handler */ - sapi_pi3web_send_headers, /* send headers handler */ - NULL, /* send header handler */ - sapi_pi3web_read_post, /* read POST data */ - sapi_pi3web_read_cookies, /* read Cookies */ - NULL, /* register server variables */ - NULL, /* Log message */ - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -static void init_request_info(sapi_globals_struct *sapi_globals, LPCONTROL_BLOCK lpCB) -{ - char *path_end = strrchr(lpCB->lpszFileName, PHP_DIR_SEPARATOR); - if ( path_end ) *path_end = PHP_DIR_SEPARATOR; - - SG(server_context) = lpCB; - SG(request_info).request_method = lpCB->lpszMethod; - SG(request_info).query_string = lpCB->lpszQueryString; - SG(request_info).path_translated = lpCB->lpszPathTranslated; - SG(request_info).request_uri = lpCB->lpszUri; - SG(request_info).content_type = lpCB->lpszContentType; - SG(request_info).content_length = lpCB->cbTotalBytes; - SG(request_info).auth_user = (lpCB->lpszUser) ? (char *)estrdup((const char *)(lpCB->lpszUser)) : 0; - SG(request_info).auth_password = (lpCB->lpszPassword) ? (char *)estrdup((const char *)(lpCB->lpszPassword)) : 0; - SG(sapi_headers).http_response_code = 200; -} - -static void hash_pi3web_variables(TSRMLS_D) -{ - char static_variable_buf[PI3WEB_SERVER_VAR_BUF_SIZE]; - char *variable_buf; - DWORD variable_len = PI3WEB_SERVER_VAR_BUF_SIZE; - char *variable; - char *strtok_buf = NULL; - LPCONTROL_BLOCK lpCB; - - lpCB = (LPCONTROL_BLOCK) SG(server_context); - - if (lpCB->GetServerVariable(lpCB->ConnID, "ALL_HTTP", static_variable_buf, &variable_len)) { - variable_buf = static_variable_buf; - } else { - if (PIPlatform_getLastError()==PIAPI_EINVAL) { - variable_buf = (char *) emalloc(variable_len); - if (!lpCB->GetServerVariable(lpCB->ConnID, "ALL_HTTP", variable_buf, &variable_len)) { - efree(variable_buf); - return; - } - } else { - return; - } - } - variable = php_strtok_r(variable_buf, "\r\n", &strtok_buf); - while (variable) { - char *colon = strchr(variable, ':'); - - if (colon) { - char *value = colon+1; - zval *entry; - ALLOC_ZVAL(entry); - - while (*value==' ') { - value++; - } - *colon = 0; - INIT_PZVAL(entry); - entry->value.str.len = strlen(value); - entry->value.str.val = estrndup(value, entry->value.str.len); - entry->type = IS_STRING; - zend_hash_add(&EG(symbol_table), variable, strlen(variable)+1, &entry, sizeof(zval *), NULL); - *colon = ':'; - } - variable = php_strtok_r(NULL, "\r\n", &strtok_buf); - } - if (variable_buf!=static_variable_buf) { - efree(variable_buf); - } -} - - -DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB) -{ - zend_file_handle file_handle; - char *header_line; - int iRet = PIAPI_COMPLETED; - TSRMLS_FETCH(); - - zend_first_try { - file_handle.filename = lpCB->lpszFileName; - file_handle.free_filename = 0; - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.opened_path = NULL; - - CG(extended_info) = 0; - init_request_info(sapi_globals, lpCB); - php_request_startup(TSRMLS_C); - - hash_pi3web_variables(TSRMLS_C); - - switch ( lpCB->dwBehavior ) { - case PHP_MODE_STANDARD: - iRet = ( php_execute_script( &file_handle TSRMLS_CC ) == SUCCESS ) ? - PIAPI_COMPLETED : PIAPI_ERROR; - break; - case PHP_MODE_HIGHLIGHT: { - zend_syntax_highlighter_ini syntax_highlighter_ini; - if ( open_file_for_scanning( &file_handle TSRMLS_CC ) == SUCCESS ) - { - php_get_highlight_struct( &syntax_highlighter_ini ); - zend_highlight( &syntax_highlighter_ini TSRMLS_CC ); - } - else - { - iRet = PIAPI_ERROR; - }; - }; - break; - case PHP_MODE_INDENT: - header_line = (char *)estrdup("Content-Type: text/plain"); - sapi_add_header_ex(header_line, strlen(header_line), 1, 1 TSRMLS_CC); - if ( open_file_for_scanning( &file_handle TSRMLS_CC ) == SUCCESS ) - { - zend_indent(); - } - else - { - iRet = PIAPI_ERROR; - }; - efree(header_line); - break; - case PHP_MODE_LINT: - iRet = (php_lint_script(&file_handle TSRMLS_CC) == SUCCESS) ? - PIAPI_COMPLETED : PIAPI_ERROR; - break; - default: - iRet = PIAPI_ERROR;; - } - - if (SG(request_info).cookie_data) { - efree(SG(request_info).cookie_data); - }; - - php_request_shutdown(NULL); - } zend_catch { - iRet = PIAPI_ERROR; - } zend_end_try(); - return iRet; -} - -BOOL PHP4_startup() { - tsrm_startup(1, 1, 0, NULL); - sapi_startup(&pi3web_sapi_module); - if (pi3web_sapi_module.startup) { - pi3web_sapi_module.startup(&pi3web_sapi_module); - }; - IWasLoaded = 1; - return IWasLoaded; -}; - -BOOL PHP4_shutdown() { - if (pi3web_sapi_module.shutdown) { - pi3web_sapi_module.shutdown(&pi3web_sapi_module); - }; - sapi_shutdown(); - tsrm_shutdown(); - IWasLoaded = 0; - return !IWasLoaded; -}; - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ diff --git a/sapi/pi3web/pi3web_sapi.h b/sapi/pi3web/pi3web_sapi.h deleted file mode 100644 index e37271bc5f..0000000000 --- a/sapi/pi3web/pi3web_sapi.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef _PI3WEB_SAPI_H_ -#define _PI3WEB_SAPI_H_ - -#ifdef PHP_WIN32 -# include <windows.h> -# include <httpext.h> -# ifdef SAPI_EXPORTS -# define MODULE_API __declspec(dllexport) -# else -# define MODULE_API __declspec(dllimport) -# endif -#else -# define far -# define MODULE_API - - typedef int BOOL; - typedef void far *LPVOID; - typedef LPVOID HCONN; - typedef unsigned long DWORD; - typedef DWORD far *LPDWORD; - typedef char CHAR; - typedef CHAR *LPSTR; - typedef unsigned char BYTE; - typedef BYTE far *LPBYTE; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define PHP_MODE_STANDARD 1 -#define PHP_MODE_HIGHLIGHT 2 -#define PHP_MODE_INDENT 3 -#define PHP_MODE_LINT 4 - -// -// passed to the procedure on a new request -// -typedef struct _CONTROL_BLOCK { - void *pPIHTTP; - DWORD cbSize; // size of this struct. - HCONN ConnID; // Context number not to be modified! - DWORD dwHttpStatusCode; // HTTP Status code - CHAR lpszLogData[80]; // null terminated log info - - LPSTR lpszMethod; // REQUEST_METHOD - LPSTR lpszQueryString; // QUERY_STRING - LPSTR lpszPathInfo; // PATH_INFO - LPSTR lpszPathTranslated; // PATH_TRANSLATED - LPSTR lpszFileName; // FileName to PHP3 physical file - LPSTR lpszUri; // The request URI - LPSTR lpszReq; // The whole HTTP request line - LPSTR lpszUser; // The authenticated user - LPSTR lpszPassword; // The authenticated password - - DWORD cbTotalBytes; // Total bytes indicated from client - DWORD cbAvailable; // Available number of bytes - LPBYTE lpbData; // pointer to cbAvailable bytes - - LPSTR lpszContentType; // Content type of client data - DWORD dwBehavior; // PHP behavior (standard, highlight, intend - - BOOL (* GetServerVariable) ( HCONN hConn, - LPSTR lpszVariableName, - LPVOID lpvBuffer, - LPDWORD lpdwSize ); - - BOOL (* WriteClient) ( HCONN ConnID, - LPVOID Buffer, - LPDWORD lpdwBytes, - DWORD dwReserved ); - - BOOL (* ReadClient) ( HCONN ConnID, - LPVOID lpvBuffer, - LPDWORD lpdwSize ); - - BOOL (* SendHeaderFunction)( HCONN hConn, - LPDWORD lpdwSize, - LPDWORD lpdwDataType ); - -} CONTROL_BLOCK, *LPCONTROL_BLOCK; - -DWORD PHP4_wrapper(LPCONTROL_BLOCK lpCB); -BOOL PHP4_startup(); -BOOL PHP4_shutdown(); - -// the following type declaration is for the server side -typedef DWORD ( * PFN_WRAPPERFUNC )( CONTROL_BLOCK *pCB ); - - - -#ifdef __cplusplus -} -#endif - -#endif // end definition _PI3WEB_SAPI_H_ diff --git a/sapi/roxen/Makefile.in b/sapi/roxen/Makefile.in deleted file mode 100644 index c49bf97ead..0000000000 --- a/sapi/roxen/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = roxen.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/roxen/README b/sapi/roxen/README deleted file mode 100644 index c6ec30d272..0000000000 --- a/sapi/roxen/README +++ /dev/null @@ -1,18 +0,0 @@ -Roxen PHP support. Early version. Don't expect to be able to get it to -work. Requires Pike 0.7.79 and Roxen 1.4. Anything less won't work. - -The module is now thread safe, in a couple of different modes. First -mode, the default, uses a process global PHP lock in the Roxen -module. This means that all PHP-requests are serialized (ie only one -script is executed at any one time). The second option is using ZTS -(Zend Thread Safe mode). Unless --enable-roxen-zts is specified, this -won't be used. - -This solution now works fine and is recommended. Multiple PHP4 -requests will be run in parallell. The maximum number of parallell -PHP4-execution is limited to the number of handle threads Roxen is -started with. - -Support for this module is lacking. Please contact Roxen Internet -Software for support and help. See http://www.roxen.com/company/contact/ -for contact information. diff --git a/sapi/roxen/TODO b/sapi/roxen/TODO deleted file mode 100644 index 4ba171accc..0000000000 --- a/sapi/roxen/TODO +++ /dev/null @@ -1,33 +0,0 @@ -BUGS: - -- fix backtraces -- exit in PHP exits Roxen -- POST newline added? -- Rewriting header handling so that more than one header with the same - name can be set (most importantly, cookies). -- Recursive mutex lock problem: - - And another error (when trying to include a class) - - Recursive mutex locks! - /Usr/local/pike/7.0.54/lib/modules/PHP4.so.Interpreter: - run("/home/www/www.tx.pl/news/test.php",mapping[3],modules/scripting/php4.pike.PHPScript(),modules/scripting/php4.pike.PHPScript.done) - modules/scripting/php4.pike:169: run() - base_server/roxen.pike:569: handler_thread(3). - - And after this every access to any php script (on other virtual sites - also) ends (of course there is no proper output) with this error: - - Php4.Interpreter->run: Tried to run a PHP-script from a PHP - callback!/usr/local/pike/7.0.54/lib/modules/PHP4.so.Interpreter: - run("/home/www/biall.com.pl/index.php3",mapping[2],modules/scripting/php4.pike.PHPScript(),modules/scripting/php4.pike.PHPScript.done) - modules/scripting/php4.pike:169: run() - base_server/roxen.pike:569: handler_thread(3). - - -ADDITIONS: - -- use th_farm -- change cwd in single threaded mode -- per-virtual-server configuration - diff --git a/sapi/roxen/config.m4 b/sapi/roxen/config.m4 deleted file mode 100644 index 842e0547c9..0000000000 --- a/sapi/roxen/config.m4 +++ /dev/null @@ -1,58 +0,0 @@ -dnl ## $Id$ -*- sh -*- - -RESULT=no -AC_MSG_CHECKING(for Roxen/Pike support) -AC_ARG_WITH(roxen, -[ --with-roxen=DIR Build PHP as a Pike module. DIR is the base Roxen - directory, normally /usr/local/roxen/server.], -[ - if test ! -d $withval ; then - AC_MSG_ERROR(You did not specify a directory) - fi - if test -f $withval/bin/roxen; then - PIKE=$withval/bin/roxen - elif test -f $withval/bin/pike; then - PIKE=$withval/bin/pike - else - AC_MSG_ERROR(Couldn't find a pike in $withval/bin/) - fi - if $PIKE -e 'float v; catch(v = __VERSION__ + (__BUILD__/10000.0)); if(v < 0.7079) exit(1); exit(0);'; then - PIKE_MODULE_DIR=`$PIKE --show-paths 2>&1| grep '^Module' | sed -e 's/.*: //'` - PIKE_INCLUDE_DIR=`echo $PIKE_MODULE_DIR | sed -e 's,lib/pike/modules,include/pike,' -e 's,lib/modules,include/pike,'` - if test -z "$PIKE_INCLUDE_DIR" -o -z "$PIKE_MODULE_DIR"; then - AC_MSG_ERROR(Failed to figure out Pike module and include directories) - fi - else - AC_MSG_ERROR(Roxen/PHP requires Pike 0.7.79 or newer) - fi - - PHP_ADD_INCLUDE($PIKE_INCLUDE_DIR) - AC_DEFINE(HAVE_ROXEN,1,[Whether you use Roxen]) - PHP_SAPI=roxen - PHP_BUILD_SHARED - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PIKE_MODULE_DIR/PHP4.so" - RESULT="yes - Pike binary used: $PIKE - Pike include dir: $PIKE_INCLUDE_DIR - Pike module directory: $PIKE_MODULE_DIR" - PIKE_INCLUDE_DIR=" -I$PIKE_INCLUDE_DIR " -]) -AC_MSG_RESULT($RESULT) - -if test "$RESULT" != "no" ; then - RESULT=no - AC_MSG_CHECKING(if Roxen should use ZTS) - AC_ARG_ENABLE(roxen-zts, - [ --enable-roxen-zts Build the Roxen module using Zend Thread Safety.], - [ - PHP_BUILD_THREAD_SAFE - AC_DEFINE(ROXEN_USE_ZTS,1,[Whether to use Roxen in ZTS mode]) - RESULT=yes - - ]) - AC_MSG_RESULT($RESULT) -fi -dnl ## Local Variables: -dnl ## tab-width: 4 -dnl ## End: - diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c deleted file mode 100644 index 81f67c43d0..0000000000 --- a/sapi/roxen/roxen.c +++ /dev/null @@ -1,726 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: David Hedbor <neotron@php.net> | - | Based on aolserver SAPI by Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#include "php.h" -#ifdef HAVE_ROXEN - -#include "php_ini.h" -#include "php_globals.h" -#include "SAPI.h" -#include "php_main.h" -#include "ext/standard/info.h" - -#include "php_version.h" - -#ifndef ZTS -/* Only valid if thread safety is enabled. */ -#undef ROXEN_USE_ZTS -#endif - - -/* Pike Include Files - * - * conflicts with pike avoided by only using long names. Requires a new - * Pike 0.7 since it was implemented for this interface only. - * - */ -#define NO_PIKE_SHORTHAND - -#include <fdlib.h> -#include <program.h> -#include <pike_types.h> -#include <interpret.h> -#include <module_support.h> -#include <error.h> -#include <array.h> -#include <backend.h> -#include <stralloc.h> -#include <mapping.h> -#include <object.h> -#include <threads.h> -#include <builtin_functions.h> -#include <operators.h> - -#undef HIDE_GLOBAL_VARIABLES -#undef REVEAL_GLOBAL_VARIABLES -#define HIDE_GLOBAL_VARIABLES() -#define REVEAL_GLOBAL_VARIABLES() - -/* php_roxen_request is per-request object storage */ - -typedef struct -{ - struct mapping *request_data; - struct object *my_fd_obj; - int my_fd; - char *filename; -} php_roxen_request; - - -/* Defines to get to the data supplied when the script is started. */ - -#ifdef ROXEN_USE_ZTS - -/* ZTS does work now, but it seems like it's faster using the "serialization" - * method I previously used. Thus it's not used unless ROXEN_USE_ZTS is defined. - */ - -/* Per thread storage area id... */ -static int roxen_globals_id; - -# define GET_THIS() php_roxen_request *_request = ts_resource(roxen_globals_id) -# define THIS _request -#else -static php_roxen_request *current_request = NULL; - -# define GET_THIS() current_request = ((php_roxen_request *)Pike_fp->current_storage) -# define THIS current_request -#endif - -/* File descriptor integer. Used to write directly to the FD without - * passing Pike - */ -#define MY_FD (THIS->my_fd) - -/* FD object. Really a PHPScript object from Pike which implements a couple - * of functions to handle headers, writing and buffering. - */ -#define MY_FD_OBJ ((struct object *)(THIS->my_fd_obj)) - -/* Mapping with data supplied from the calling Roxen module. Contains - * a mapping with headers, an FD object etc. - */ -#define REQUEST_DATA ((struct mapping *)(THIS->request_data)) - - -#if defined(_REENTRANT) && !defined(ROXEN_USE_ZTS) -/* Lock used to serialize the PHP execution. If ROXEN_USE_ZTS is defined, we - * are using the PHP thread safe mechanism instead. - */ -static PIKE_MUTEX_T roxen_php_execution_lock; -# define PHP_INIT_LOCK() mt_init(&roxen_php_execution_lock) -# define PHP_LOCK(X) THREADS_ALLOW();mt_lock(&roxen_php_execution_lock);THREADS_DISALLOW() -# define PHP_UNLOCK(X) mt_unlock(&roxen_php_execution_lock); -# define PHP_DESTROY() mt_destroy(&roxen_php_execution_lock) -#else /* !_REENTRANT */ -# define PHP_INIT_LOCK() -# define PHP_LOCK(X) -# define PHP_UNLOCK(X) -# define PHP_DESTROY() -#endif /* _REENTRANT */ - -extern int fd_from_object(struct object *o); -static unsigned char roxen_php_initialized; - -/* This allows calling of pike functions from the PHP callbacks, - * which requires the Pike interpreter to be locked. - */ -#define THREAD_SAFE_RUN(COMMAND, what) do {\ - struct thread_state *state;\ - if((state = thread_state_for_id(th_self()))!=NULL) {\ - if(!state->swapped) {\ - COMMAND;\ - } else {\ - mt_lock(&interpreter_lock);\ - SWAP_IN_THREAD(state);\ - COMMAND;\ - SWAP_OUT_THREAD(state);\ - mt_unlock(&interpreter_lock);\ - }\ - }\ -} while(0) - -struct program *php_program; - - -/* To avoid executing a PHP script from a PHP callback, which would - * create a deadlock, a global thread id is used. If the thread calling the - * php-script is the same as the current thread, it fails. - */ -static int current_thread = -1; - - -/* Low level header lookup. Basically looks for the named header in the mapping - * headers in the supplied options mapping. - */ - -static INLINE struct svalue *lookup_header(char *headername) -{ - struct svalue *headers, *value; - struct pike_string *sind; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - sind = make_shared_string("env"); - headers = low_mapping_string_lookup(REQUEST_DATA, sind); - free_string(sind); - if(!headers || headers->type != PIKE_T_MAPPING) return NULL; - sind = make_shared_string(headername); - value = low_mapping_string_lookup(headers->u.mapping, sind); - free_string(sind); - if(!value) return NULL; - return value; -} - -/* Lookup a header in the mapping and return the value as a string, or - * return the default if it's missing - */ -INLINE static char *lookup_string_header(char *headername, char *default_value) -{ - struct svalue *head = NULL; - THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup"); - if(!head || head->type != PIKE_T_STRING) - return default_value; - return head->u.string->str; -} - -/* Lookup a header in the mapping and return the value as if it's an integer - * and otherwise return the default. - */ -INLINE static int lookup_integer_header(char *headername, int default_value) -{ - struct svalue *head = NULL; - THREAD_SAFE_RUN(head = lookup_header(headername), "header lookup"); - if(!head || head->type != PIKE_T_INT) - return default_value; - return head->u.integer; -} - -/* - * php_roxen_low_ub_write() writes data to the client connection. Might be - * rewritten to do more direct IO to save CPU and the need to lock the * - * interpreter for better threading. - */ - -static int -php_roxen_low_ub_write(const char *str, uint str_length TSRMLS_DC) { - int sent_bytes = 0; - struct pike_string *to_write = NULL; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - - if(!MY_FD_OBJ->prog) { - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - return -1; - } - to_write = make_shared_binary_string(str, str_length); - push_string(to_write); - safe_apply(MY_FD_OBJ, "write", 1); - if(Pike_sp[-1].type == PIKE_T_INT) - sent_bytes = Pike_sp[-1].u.integer; - pop_stack(); - if(sent_bytes != str_length) { - /* This means the connection is closed. Dead. Gone. *sniff* */ - php_handle_aborted_connection(); - } - return sent_bytes; -} - -/* - * php_roxen_sapi_ub_write() calls php_roxen_low_ub_write in a Pike thread - * safe manner. - */ - -static int -php_roxen_sapi_ub_write(const char *str, uint str_length TSRMLS_DC) -{ -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - - int sent_bytes = 0, fd = MY_FD; - if(fd) - { - for(sent_bytes=0;sent_bytes < str_length;) - { - int written; - written = fd_write(fd, str + sent_bytes, str_length - sent_bytes); - if(written < 0) - { - switch(errno) - { - default: - /* This means the connection is closed. Dead. Gone. *sniff* */ - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - return sent_bytes; - case EINTR: - case EWOULDBLOCK: - continue; - } - - } else { - sent_bytes += written; - } - } - } else { - THREAD_SAFE_RUN(sent_bytes = php_roxen_low_ub_write(str, str_length TSRMLS_CC), - "write"); - } - return sent_bytes; -} - -/* php_roxen_set_header() sets a header in the header mapping. Called in a - * thread safe manner from php_roxen_sapi_header_handler. - */ -static void php_roxen_set_header(char *header_name, char *value, char *p) -{ - struct svalue hsval; - struct pike_string *hval, *ind, *hind; - struct mapping *headermap; - struct svalue *s_headermap; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - hval = make_shared_string(value); - ind = make_shared_string(" _headers"); - hind = make_shared_binary_string(header_name, - (int)(p - header_name)); - - s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind); - if(!s_headermap) - { - struct svalue mappie; - mappie.type = PIKE_T_MAPPING; - headermap = allocate_mapping(1); - mappie.u.mapping = headermap; - mapping_string_insert(REQUEST_DATA, ind, &mappie); - free_mapping(headermap); - } else - headermap = s_headermap->u.mapping; - - hsval.type = PIKE_T_STRING; - hsval.u.string = hval; - mapping_string_insert(headermap, hind, &hsval); - - free_string(hval); - free_string(ind); - free_string(hind); -} - -/* - * php_roxen_sapi_header_handler() sets a HTTP reply header to be - * sent to the client. - */ -static int -php_roxen_sapi_header_handler(sapi_header_struct *sapi_header, - sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - char *header_name, *header_content, *p; - header_name = sapi_header->header; - header_content = p = strchr(header_name, ':'); - - if(p) { - do { - header_content++; - } while(*header_content == ' '); - THREAD_SAFE_RUN(php_roxen_set_header(header_name, header_content, p), "header handler"); - } - sapi_free_header(sapi_header); - return 0; -} - -/* - * php_roxen_sapi_send_headers() flushes the headers to the client. - * Called before real content is sent by PHP. - */ - -static int -php_roxen_low_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - struct pike_string *ind; - struct svalue *s_headermap; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - - if(!MY_FD_OBJ->prog) { - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - return SAPI_HEADER_SEND_FAILED; - } - ind = make_shared_string(" _headers"); - s_headermap = low_mapping_string_lookup(REQUEST_DATA, ind); - free_string(ind); - - push_int(SG(sapi_headers).http_response_code); - if(s_headermap && s_headermap->type == PIKE_T_MAPPING) - ref_push_mapping(s_headermap->u.mapping); - else - push_int(0); - safe_apply(MY_FD_OBJ, "send_headers", 2); - pop_stack(); - - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - -static int -php_roxen_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - int res = 0; - THREAD_SAFE_RUN(res = php_roxen_low_send_headers(sapi_headers TSRMLS_CC), "send headers"); - return res; -} - -/* - * php_roxen_sapi_read_post() reads a specified number of bytes from - * the client. Used for POST/PUT requests. - */ - -INLINE static int php_roxen_low_read_post(char *buf, uint count_bytes) -{ - uint total_read = 0; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - TSRMLS_FETCH(); - - if(!MY_FD_OBJ->prog) - { - PG(connection_status) = PHP_CONNECTION_ABORTED; - zend_bailout(); - return -1; - } - push_int(count_bytes); - safe_apply(MY_FD_OBJ, "read_post", 1); - if(Pike_sp[-1].type == PIKE_T_STRING) { - MEMCPY(buf, Pike_sp[-1].u.string->str, - (total_read = Pike_sp[-1].u.string->len)); - buf[total_read] = '\0'; - } else - total_read = 0; - pop_stack(); - return total_read; -} - -static int -php_roxen_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) -{ - uint total_read = 0; - THREAD_SAFE_RUN(total_read = php_roxen_low_read_post(buf, count_bytes), "read post"); - return total_read; -} - -/* - * php_roxen_sapi_read_cookies() returns the Cookie header from - * the HTTP request header - */ - -static char * -php_roxen_sapi_read_cookies(TSRMLS_D) -{ - char *cookies; - cookies = lookup_string_header("HTTP_COOKIE", NULL); - return cookies; -} - -static void php_info_roxen(ZEND_MODULE_INFO_FUNC_ARGS) -{ - /* char buf[512]; */ - php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id$"); - /* php_info_print_table_row(2, "Build date", Ns_InfoBuildDate()); - php_info_print_table_row(2, "Config file path", Ns_InfoConfigFile()); - php_info_print_table_row(2, "Error Log path", Ns_InfoErrorLog()); - php_info_print_table_row(2, "Installation path", Ns_InfoHomePath()); - php_info_print_table_row(2, "Hostname of server", Ns_InfoHostname()); - php_info_print_table_row(2, "Source code label", Ns_InfoLabel()); - php_info_print_table_row(2, "Server platform", Ns_InfoPlatform()); - snprintf(buf, 511, "%s/%s", Ns_InfoServerName(), Ns_InfoServerVersion()); - php_info_print_table_row(2, "Server version", buf); - snprintf(buf, 511, "%d day(s), %02d:%02d:%02d", - uptime / 86400, - (uptime / 3600) % 24, - (uptime / 60) % 60, - uptime % 60); - php_info_print_table_row(2, "Server uptime", buf); - */ - php_info_print_table_end(); -} - -static zend_module_entry php_roxen_module = { - "Roxen", - NULL, - NULL, - NULL, - NULL, - NULL, - php_info_roxen, - STANDARD_MODULE_PROPERTIES -}; - -static int php_roxen_startup(sapi_module_struct *sapi_module) -{ - if(php_module_startup(sapi_module) == FAILURE - || zend_startup_module(&php_roxen_module) == FAILURE) { - return FAILURE; - } else { - return SUCCESS; - } -} - -/* this structure is static (as in "it does not change") */ - -static sapi_module_struct roxen_sapi_module = { - "roxen", - "Roxen", - php_module_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - NULL, /* activate */ - NULL, /* deactivate */ - php_roxen_sapi_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - php_error, /* error handler */ - php_roxen_sapi_header_handler, /* header handler */ - php_roxen_sapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ - php_roxen_sapi_read_post, /* read POST data */ - php_roxen_sapi_read_cookies, /* read Cookies */ - NULL, /* register server variables */ - NULL, /* Log message */ - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -/* - * php_roxen_hash_environment() populates the php script environment - * with a number of variables. HTTP_* variables are created for - * the HTTP header data, so that a script can access these. - */ -#define ADD_STRING(name) \ - MAKE_STD_ZVAL(pval); \ - pval->type = IS_STRING; \ - pval->value.str.len = strlen(buf); \ - pval->value.str.val = estrndup(buf, pval->value.str.len); \ - zend_hash_update(&EG(symbol_table), name, sizeof(name), \ - &pval, sizeof(zval *), NULL) - -static void -php_roxen_hash_environment(TSRMLS_D) -{ - int i; - char buf[512]; - zval *pval; - struct svalue *headers; - struct pike_string *sind; - struct array *indices; - struct svalue *ind, *val; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - sind = make_shared_string("env"); - headers = low_mapping_string_lookup(REQUEST_DATA, sind); - free_string(sind); - if(headers && headers->type == PIKE_T_MAPPING) { - indices = mapping_indices(headers->u.mapping); - for(i = 0; i < indices->size; i++) { - ind = &indices->item[i]; - val = low_mapping_lookup(headers->u.mapping, ind); - if(ind && ind->type == PIKE_T_STRING && - val && val->type == PIKE_T_STRING) { - int buf_len; - buf_len = MIN(511, ind->u.string->len); - strncpy(buf, ind->u.string->str, buf_len); - buf[buf_len] = '\0'; /* Terminate correctly */ - MAKE_STD_ZVAL(pval); - pval->type = IS_STRING; - pval->value.str.len = val->u.string->len; - pval->value.str.val = estrndup(val->u.string->str, pval->value.str.len); - - zend_hash_update(&EG(symbol_table), buf, buf_len + 1, &pval, sizeof(zval *), NULL); - } - } - free_array(indices); - } - - /* - MAKE_STD_ZVAL(pval); - pval->type = IS_LONG; - pval->value.lval = Ns_InfoBootTime(); - zend_hash_update(&EG(symbol_table), "SERVER_BOOTTIME", sizeof("SERVER_BOOTTIME"), &pval, sizeof(zval *), NULL); - */ -} - -/* - * php_roxen_module_main() is called by the per-request handler and - * "executes" the script - */ - -static int php_roxen_module_main(TSRMLS_D) -{ - int res, len; - char *dir; - zend_file_handle file_handle; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = THIS->filename; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - THREADS_ALLOW(); - res = php_request_startup(TSRMLS_C); - THREADS_DISALLOW(); - if(res == FAILURE) { - return 0; - } - php_roxen_hash_environment(TSRMLS_C); - THREADS_ALLOW(); - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); - THREADS_DISALLOW(); - return 1; -} - -/* - * The php_roxen_request_handler() is called per request and handles - * everything for one request. - */ - -void f_php_roxen_request_handler(INT32 args) -{ - struct object *my_fd_obj; - struct mapping *request_data; - struct svalue *done_callback, *raw_fd; - struct pike_string *script, *ind; - int status = 1; -#ifdef ROXEN_USE_ZTS - GET_THIS(); -#endif - TSRMLS_FETCH(); - - if(current_thread == th_self()) - error("PHP4.Interpreter->run: Tried to run a PHP-script from a PHP " - "callback!"); - get_all_args("PHP4.Interpreter->run", args, "%S%m%O%*", &script, - &request_data, &my_fd_obj, &done_callback); - if(done_callback->type != PIKE_T_FUNCTION) - error("PHP4.Interpreter->run: Bad argument 4, expected function.\n"); - PHP_LOCK(THIS); /* Need to lock here or reusing the same object might cause - * problems in changing stuff in that object */ -#ifndef ROXEN_USE_ZTS - GET_THIS(); -#endif - THIS->request_data = request_data; - THIS->my_fd_obj = my_fd_obj; - THIS->filename = script->str; - current_thread = th_self(); - SG(request_info).query_string = lookup_string_header("QUERY_STRING", 0); - SG(server_context) = (void *)1; /* avoid server_context == NULL */ - - /* path_translated is apparently the absolute path to the file, not - the translated PATH_INFO - */ - SG(request_info).path_translated = - lookup_string_header("SCRIPT_FILENAME", NULL); - SG(request_info).request_uri = lookup_string_header("DOCUMENT_URI", NULL); - if(!SG(request_info).request_uri) - SG(request_info).request_uri = lookup_string_header("SCRIPT_NAME", NULL); - SG(request_info).request_method = lookup_string_header("REQUEST_METHOD", "GET"); - SG(request_info).content_length = lookup_integer_header("HTTP_CONTENT_LENGTH", 0); - SG(request_info).content_type = lookup_string_header("HTTP_CONTENT_TYPE", NULL); - SG(sapi_headers).http_response_code = 200; - - /* FIXME: Check for auth stuff needs to be fixed... */ - SG(request_info).auth_user = NULL; - SG(request_info).auth_password = NULL; - - ind = make_shared_binary_string("my_fd", 5); - raw_fd = low_mapping_string_lookup(THIS->request_data, ind); - if(raw_fd && raw_fd->type == PIKE_T_OBJECT) - { - int fd = fd_from_object(raw_fd->u.object); - if(fd == -1) - error("PHP4.Interpreter->run: my_fd object not open or not an FD.\n"); - THIS->my_fd = fd; - } else - THIS->my_fd = 0; - - status = php_roxen_module_main(TSRMLS_C); - current_thread = -1; - - apply_svalue(done_callback, 0); - pop_stack(); - pop_n_elems(args); - push_int(status); - PHP_UNLOCK(THIS); -} - - -/* Clear the object global struct */ -static void clear_struct(struct object *o) -{ - MEMSET(Pike_fp->current_storage, 0, sizeof(php_roxen_request)); -} - - -/* - * pike_module_init() is called by Pike once at startup - * - * This functions allocates basic structures - */ - -void pike_module_init( void ) -{ - if (!roxen_php_initialized) { -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); -#ifdef ROXEN_USE_ZTS - ts_allocate_id(&roxen_globals_id, sizeof(php_roxen_request), NULL, NULL); -#endif -#endif - sapi_startup(&roxen_sapi_module); - php_roxen_startup(&roxen_sapi_module); - roxen_php_initialized = 1; - PHP_INIT_LOCK(); - } - start_new_program(); /* Text */ - ADD_STORAGE(php_roxen_request); - set_init_callback(clear_struct); - pike_add_function("run", f_php_roxen_request_handler, - "function(string, mapping, object, function:int)", 0); - add_program_constant("Interpreter", (php_program = end_program()), 0); -} - -/* - * pike_module_exit() performs the last steps before the - * server exists. Shutdowns basic services and frees memory - */ - -void pike_module_exit(void) -{ - roxen_php_initialized = 0; - roxen_sapi_module.shutdown(&roxen_sapi_module); - if(php_program) free_program(php_program); -#ifdef ZTS - tsrm_shutdown(); -#endif - PHP_DESTROY(); -} -#endif diff --git a/sapi/servlet/CREDITS b/sapi/servlet/CREDITS deleted file mode 100644 index ae4e83e1e2..0000000000 --- a/sapi/servlet/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -Java Servlet -Sam Ruby diff --git a/sapi/servlet/Makefile.in b/sapi/servlet/Makefile.in deleted file mode 100644 index 940866b7fc..0000000000 --- a/sapi/servlet/Makefile.in +++ /dev/null @@ -1,30 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = servlet.c java.c -LTLIBRARY_DEPENDENCIES = phpsrvlt.jar - -EXTRA_CFLAGS = $(JAVA_CFLAGS) -EXTRA_INCLUDES = $(JAVA_INCLUDE) - -include $(top_srcdir)/build/ltlib.mk - -java.c : ../../ext/java/java.c - @cp ../../ext/java/java.c . - -phpsrvlt.jar : servlet.java ../../ext/java/reflect.java - $(mkinstalldirs) net/php - @echo library=php4>net/php/reflect.properties - @echo library=php4>net/php/servlet.properties - @cp formatter.java net/php - @cp servlet.java net/php - @cp ../../ext/java/reflect.java net/php - javac net/php/reflect.java - @test ! -f reflect.class || mv reflect.class net/php # bug in KJC javac - javac -classpath .:$(SERVLET_CLASSPATH):$(CLASSPATH) net/php/servlet.java - @test ! -f servlet.class || mv servlet.class net/php # bug in KJC javac - javac -classpath .:$(SERVLET_CLASSPATH):$(CLASSPATH) net/php/formatter.java - @test ! -f formatter.class || mv formatter.class net/php # bug in KJC javac - $(JAVA_JAR) phpsrvlt.jar net/php/*.class net/php/*.properties - @rm net/php/servlet.* net/php/reflect.* net/php/formatter.* - @rmdir net/php - @rmdir net diff --git a/sapi/servlet/README b/sapi/servlet/README deleted file mode 100644 index 1a93186353..0000000000 --- a/sapi/servlet/README +++ /dev/null @@ -1,42 +0,0 @@ -What is PHP4 sapi/servlet? - - PHP4 sapi/servlet builds upon the mechanism defined by ext/java to enable - the entire PHP processor to be run as a servlet. The primary advanatage - of this from a PHP perspective is that web servers which support servlets - typically take great care in pooling and reusing JVMs. - - Notes: - - 1) While this code is intended to be able to run on any servlet engine, - it has only been tested on Apache's Jakarta/tomcat to date. Bug - reports, success stories and/or patches required to get this code - to run on other engines would be appreciated. - - 2) PHP has a habit of changing the working directory. Sapi/servlet will - eventually change it back, but while PHP is running the servlet engine - may not be able to load any classes from the CLASSPATH which are - specified using a relative directory syntax, or find the work directory - used for administration and JSP compilation tasks. - -Build and execution instructions: - - Most of the configuration hassles associated with ext/java are associated - with starting the JVM, and as such do not apply to sapi/servlet. In - particular, no updates to php.ini are required on any operating system. - - Unix: - Build: - ./configure --with-servlet --with-java - Execute: - add phpsrvlt.jar to CLASSPATH - add directory containing libphp4.so to LD_LIBRARY_PATH - merge/overwrite build/tomcat/examples/WEB-INF/web.xml from sapi/servlet - - Win32: - Build: - add jdsk (or d:\build\tomcat\classes) to CLASSPATH - build sapi\servlet\servlet.dsp - Execute: - add phpsrvlt.jar to CLASSPATH - add directory containing php4ts.dll and phpsrvlt.dll to PATH - merge/overwrite build\tomcat\examples\WEB-INF\web.xml from sapi\servlet diff --git a/sapi/servlet/config.m4 b/sapi/servlet/config.m4 deleted file mode 100644 index bc0badb53c..0000000000 --- a/sapi/servlet/config.m4 +++ /dev/null @@ -1,48 +0,0 @@ -# $Id$ -# config.m4 for servlet sapi - -AC_MSG_CHECKING(for Servlet support) -AC_ARG_WITH(servlet, -[ --with-servlet[=DIR] Include servlet support. DIR is the base install - directory for the JSDK. This SAPI prereqs the - java extension must be built as a shared dl.], -[ - if test "$withval" != "no"; then - - if test "$withval" = "yes"; then - SERVLET_CLASSPATH=. - else - if test -f $withval/lib/servlet.jar; then - SERVLET_CLASSPATH=$withval/lib/servlet.jar - fi - - if test -f $withval/lib/jsdk.jar; then - SERVLET_CLASSPATH=$withval/lib/jsdk.jar - fi - - if test -d $withval/javax; then - SERVLET_CLASSPATH=$withval - fi - - if test -z "$SERVLET_CLASSPATH"; then - AC_MSG_RESULT(no) - AC_MSG_ERROR(unable to find servlet libraries) - fi - fi - - AC_DEFINE(SAPI_SERVLET, 1, [Whether you use Servlet]) - - INSTALL_IT="\$(INSTALL) -m 0755 \$(srcdir)/sapi/servlet/phpsrvlt.jar \$(libdir)" - INSTALL_IT="$INSTALL_IT; \$(INSTALL) -m 0755 $SAPI_SHARED \$(libdir)" - PHP_SAPI=servlet - PHP_BUILD_SHARED - PHP_BUILD_THREAD_SAFE - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi -],[ - AC_MSG_RESULT(no) -]) - -PHP_SUBST(SERVLET_CLASSPATH) diff --git a/sapi/servlet/cookies.php b/sapi/servlet/cookies.php deleted file mode 100644 index bcc4c40aae..0000000000 --- a/sapi/servlet/cookies.php +++ /dev/null @@ -1,41 +0,0 @@ -<html> -<body bgcolor="white"> -<head> -<title>Cookies Example</title> -</head> -<body> -<h3>Cookies Example</h3> - -<? - $cookies = $request->cookies; - - // print out cookies - - if (!current($cookies)) { - echo "Your browser isn't sending any cookies\n"; - } else { - echo "Your browser is sending the following cookies:<br>\n"; - - foreach ($cookies as $cookie) { - echo "Cookie Name: $cookie->name<br>Cookie value: $cookie->value<br>\n"; - } - } - - // set a cookie - - if ($cookieName) { - $response->addCookie(new Java("javax.servlet.http.Cookie", $cookieName, $cookieValue)); - echo "<p>You just sent the following cookie to your browser:<br>\n"; - echo "Name: $cookieName<br>Value: $cookieValue<P>\n"; - } - -?> -<P> -Create a cookie to send to your browser<br> -<form action="<?PHP echo $PHP_SELF ?>" method=POST> -Name: <input type=text length=20 name=cookieName><br> -Value: <input type=text length=20 name=cookieValue><br> -<input type=submit></form> -</body> -</html> - diff --git a/sapi/servlet/date.php b/sapi/servlet/date.php deleted file mode 100644 index 1146d31fab..0000000000 --- a/sapi/servlet/date.php +++ /dev/null @@ -1,28 +0,0 @@ -<html> -<!-- - Copyright (c) 1999 The Apache Software Foundation. All rights - reserved. ---> - -<body bgcolor="white"> -<?php $clock=new Java("dates.JspCalendar"); ?> - -<font size=4> -<ul> -<li> Day of month: is <?php echo $clock->dayOfMonth ?> -<li> Year: is <?php echo $clock->year ?> -<li> Month: is <?php echo $clock->month ?> -<li> Time: is <?php echo $clock->time ?> -<li> Date: is <?php echo $clock->date ?> -<li> Day: is <?php echo $clock->day ?> -<li> Day Of Year: is <?php echo $clock->dayOfYear ?> -<li> Week Of Year: is <?php echo $clock->weekOfYear ?> -<li> era: is <?php echo $clock->era ?> -<li> DST Offset: is <?php echo $clock->dSTOffset ?> -<li> Zone Offset: is <?php echo $clock->zoneOffset ?> -</ul> -</font> - -</body> -</html> - diff --git a/sapi/servlet/formatter.java b/sapi/servlet/formatter.java deleted file mode 100644 index 4827f14e6a..0000000000 --- a/sapi/servlet/formatter.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sam Ruby (rubys@us.ibm.com) | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -package net.php; - -import javax.servlet.*; -import javax.servlet.http.*; - -public class formatter extends servlet { - - public void service(HttpServletRequest request, - HttpServletResponse response) - throws ServletException - { - display_source_mode = true; - super.service(request, response); - } - -} diff --git a/sapi/servlet/jinfo.php b/sapi/servlet/jinfo.php deleted file mode 100644 index f20bbfb27d..0000000000 --- a/sapi/servlet/jinfo.php +++ /dev/null @@ -1,5 +0,0 @@ -<? - - phpinfo(); - -?> diff --git a/sapi/servlet/jver.php b/sapi/servlet/jver.php deleted file mode 100644 index e5e029c6e4..0000000000 --- a/sapi/servlet/jver.php +++ /dev/null @@ -1,17 +0,0 @@ -<html> -<? - - $system = new Java("java.lang.System"); - print "Java version=".$system->getProperty("java.version")." <br>\n"; - print "Java vendor=".$system->getProperty("java.vendor")." <p>\n\n"; - print "OS=".$system->getProperty("os.name")." ". - $system->getProperty("os.version")." on ". - $system->getProperty("os.arch")." <br>\n"; - - $formatter = new Java("java.text.SimpleDateFormat", - "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); - - print $formatter->format(new Java("java.util.Date"))."\n"; - -?> -</html> diff --git a/sapi/servlet/reqheaders.php b/sapi/servlet/reqheaders.php deleted file mode 100644 index db04aed3dc..0000000000 --- a/sapi/servlet/reqheaders.php +++ /dev/null @@ -1,24 +0,0 @@ -<html> -<body bgcolor="white"> -<head> -<title>Request Header Example</title> -</head> -<body> -<h3>Request Header Example</h3> -<table border=0> - -<?php - - $e = $request->headerNames; - while ($e->hasMoreElements()) { - $name = $e->nextElement(); - $value = $request->getHeader($name); - print "<tr><td bgcolor=\"#CCCCCC\">$name\n"; - print "</td><td>$value</td></tr>\n"; - } - -?> - -</table> -</body> -</html> diff --git a/sapi/servlet/reqinfo.php b/sapi/servlet/reqinfo.php deleted file mode 100644 index 37d453baf9..0000000000 --- a/sapi/servlet/reqinfo.php +++ /dev/null @@ -1,29 +0,0 @@ -<html> -<body> -<head> -<title>Request Information Example</title> -</head> -<body bgcolor="white"> -<h3>Request Information Example</h3> -<table border=0><tr><td> -Method: -</td><td> -<?php print $request->method ?> -</td></tr><tr><td> -Request URI: -</td><td> -<?php print $request->requestURI ?> -</td></tr><tr><td> -Protocol: -</td><td> -<?php print $request->protocol ?> -</td></tr><tr><td> -Path Info: -</td><td> -<?php print $request->pathInfo ?> -</td></tr><tr><td> -Remote Address: -</td><td> -<?php print $request->remoteAddr ?> -</table> - diff --git a/sapi/servlet/reqparams.php b/sapi/servlet/reqparams.php deleted file mode 100644 index f968b2753d..0000000000 --- a/sapi/servlet/reqparams.php +++ /dev/null @@ -1,35 +0,0 @@ -<html> -<body> -<head> -<title>Request Parameters Example</title> -</head> -<body bgcolor="white"> -<h3>Request Parameters Example</h3> -Parameters in this request:<br> -<?php - $e = $request->getParameterNames(); - - if (!$e->hasMoreElements()) { - echo "No Parameters, Please enter some"; - } - - while ($e->hasMoreElements()) { - $name = $e->nextElement(); - $value = $request->getParameter($name); - echo "$name = $value<br>\n"; - } - -?> -<P> -<form action="<?php echo $PHP_SELF ?>" method=POST> -First Name: -<input type=text size=20 name=firstname> -<br> -Last Name: -<input type=text size=20 name=lastname> -<br> -<input type=submit> -</form> -</body> -</html> - diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c deleted file mode 100644 index 4bec1bcd04..0000000000 --- a/sapi/servlet/servlet.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sam Ruby (rubys@us.ibm.com) | - +----------------------------------------------------------------------+ -*/ - -#include <jni.h> - -#include "php.h" -#include "php_globals.h" - -#include "SAPI.h" - -#include <stdio.h> -#include "php.h" -#ifdef PHP_WIN32 -#include "win32/time.h" -#include "win32/signal.h" -#include <process.h> -#else -#include "build-defs.h" -#endif -#if HAVE_SYS_TIME_H -#include <sys/time.h> -#endif -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#if HAVE_SIGNAL_H -#include <signal.h> -#endif -#if HAVE_SETLOCALE -#include <locale.h> -#endif -#include "zend.h" -#include "php_ini.h" -#include "php_globals.h" -#include "php_main.h" -#include "fopen_wrappers.h" -#include "ext/standard/php_standard.h" -#include "ext/standard/php_dir.h" -#ifdef PHP_WIN32 -#include <io.h> -#include <fcntl.h> -#include "win32/php_registry.h" -#endif - -#include "zend_compile.h" -#include "zend_execute.h" -#include "zend_highlight.h" -#include "zend_indent.h" - -JNIEXPORT void JNICALL Java_net_php_reflect_setEnv - (JNIEnv *newJenv, jclass self); - -typedef struct { - JNIEnv *jenv; - jobject servlet; - char *cookies; -} servlet_request; - -extern zend_module_entry java_module_entry; - -static zend_module_entry *additional_php_extensions[] = { - &java_module_entry -}; - -#define EXTCOUNT (sizeof(additional_php_extensions)/sizeof(zend_module_entry *)) - -/***************************************************************************/ - -/* - * JNI convenience utilities - */ - -#define SETSTRING(target, source) \ - { const char *UTFString; \ - if (source) { \ - UTFString = (*jenv)->GetStringUTFChars(jenv, source, 0); \ - target = estrdup(UTFString); \ - (*jenv)->ReleaseStringUTFChars(jenv, source, UTFString); \ - } else { \ - target = 0; \ - } } - -#define FREESTRING(target) \ - { if (target) { efree(target); target=0; } } - -void ThrowIOException (JNIEnv *jenv, char *msg) { - jclass iox = (*jenv)->FindClass (jenv, "java/io/IOException"); - (*jenv)->ThrowNew (jenv, iox, (msg?msg:"null") ); -} - -void ThrowServletException (JNIEnv *jenv, char *msg) { - jclass sx = (*jenv)->FindClass (jenv, "javax/servlet/ServletException"); - (*jenv)->ThrowNew (jenv, sx, msg); -} - -/***************************************************************************/ - -/* - * sapi callbacks - */ - -static int sapi_servlet_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - if (!SG(server_context)) { - fprintf(stderr, str); - return 0; - } - - { - JNIEnv *jenv = ((servlet_request*)SG(server_context))->jenv; - jobject servlet = ((servlet_request*)SG(server_context))->servlet; - - jclass servletClass = (*jenv)->GetObjectClass(jenv, servlet); - jmethodID write = (*jenv)->GetMethodID(jenv, servletClass, "write", - "(Ljava/lang/String;)V"); - char *copy = malloc(str_length+1); - jstring arg; - memcpy(copy, str, str_length); - copy[str_length] = 0; - arg=(*jenv)->NewStringUTF(jenv, copy); - free(copy); - (*jenv)->CallVoidMethod(jenv, servlet, write, arg); - (*jenv)->DeleteLocalRef(jenv, arg); - return str_length; - } -} - - -static void sapi_servlet_send_header(sapi_header_struct *sapi_header, void *server_context TSRMLS_DC) -{ - if (!sapi_header) return; - if (!SG(server_context)) return; - - { - JNIEnv *jenv = ((servlet_request*)SG(server_context))->jenv; - jobject servlet = ((servlet_request*)SG(server_context))->servlet; - - jclass servletClass = (*jenv)->GetObjectClass(jenv, servlet); - jmethodID header = (*jenv)->GetMethodID(jenv, servletClass, "header", - "(Ljava/lang/String;)V"); - jstring arg=(*jenv)->NewStringUTF(jenv, sapi_header->header); - (*jenv)->CallVoidMethod(jenv, servlet, header, arg); - (*jenv)->DeleteLocalRef(jenv, arg); - } -} - - -static int sapi_servlet_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - if (count_bytes == 0) { - return 0; - } else { - JNIEnv *jenv = ((servlet_request*)SG(server_context))->jenv; - jobject servlet = ((servlet_request*)SG(server_context))->servlet; - - jclass servletClass = (*jenv)->GetObjectClass(jenv, servlet); - jmethodID readPost = (*jenv)->GetMethodID(jenv, servletClass, - "readPost", "(I)Ljava/lang/String;"); - jstring post = (*jenv)->CallObjectMethod(jenv, servlet, readPost, - count_bytes); - - const char *postAsUTF = (*jenv)->GetStringUTFChars(jenv, post, 0); - uint read_bytes=(*jenv)->GetStringLength(jenv, post); - if (read_bytes>count_bytes) read_bytes=count_bytes; - - memcpy(buffer, postAsUTF, read_bytes); - if (read_bytes<count_bytes) buffer[read_bytes]=0; - - (*jenv)->ReleaseStringUTFChars(jenv, post, postAsUTF); - - return read_bytes; - } -} - - -static char *sapi_servlet_read_cookies(TSRMLS_D) -{ - JNIEnv *jenv = ((servlet_request*)SG(server_context))->jenv; - jobject servlet = ((servlet_request*)SG(server_context))->servlet; - - jclass servletClass = (*jenv)->GetObjectClass(jenv, servlet); - jmethodID readCookies = (*jenv)->GetMethodID(jenv, servletClass, - "readCookies", "()Ljava/lang/String;"); - jstring cookies = (*jenv)->CallObjectMethod(jenv, servlet, readCookies); - - SETSTRING( ((servlet_request*)SG(server_context))->cookies, cookies); - - return ((servlet_request*)SG(server_context))->cookies; -} - -/***************************************************************************/ - -/* - * sapi maintenance - */ - -static sapi_module_struct servlet_sapi_module = { - "java_servlet", /* name */ - "Java Servlet", /* pretty name */ - - php_module_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - NULL, /* activate */ - NULL, /* deactivate */ - - sapi_servlet_ub_write, /* unbuffered write */ - NULL, /* flush */ - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, /* error handler */ - - NULL, /* header handler */ - NULL, /* send headers handler */ - sapi_servlet_send_header, /* send header handler */ - - sapi_servlet_read_post, /* read POST data */ - sapi_servlet_read_cookies, /* read Cookies */ - - NULL, /* register server variables */ - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - - -JNIEXPORT void JNICALL Java_net_php_servlet_startup - (JNIEnv *jenv, jobject self) -{ - -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); -#endif - - sapi_startup(&servlet_sapi_module); - - if (php_module_startup(&servlet_sapi_module)==FAILURE) { - ThrowServletException(jenv,"module startup failure"); - return; - } - - if (php_startup_extensions(additional_php_extensions, EXTCOUNT)==FAILURE) { - ThrowServletException(jenv,"extension startup failure"); - return; - } - -} - - -JNIEXPORT void JNICALL Java_net_php_servlet_shutdown - (JNIEnv *jenv, jobject self) -{ - TSRMLS_FETCH(); - - php_module_shutdown(TSRMLS_C); -#ifdef ZTS - tsrm_shutdown(); -#endif - return; -} - -/***************************************************************************/ - -/* - * define a Java object to PHP - */ - -JNIEXPORT jlong JNICALL Java_net_php_servlet_define - (JNIEnv *jenv, jobject self, jstring name) -{ - pval *pzval; - jlong addr = 0; - const char *nameAsUTF = (*jenv)->GetStringUTFChars(jenv, name, 0); - TSRMLS_FETCH(); - - MAKE_STD_ZVAL(pzval); - addr = (jlong)(long) pzval; - - zend_hash_add(&EG(symbol_table), (char*)nameAsUTF, - strlen(nameAsUTF)+1, &pzval, sizeof(pval *), NULL); - (*jenv)->ReleaseStringUTFChars(jenv, name, nameAsUTF); - - return addr; -} - -/* - * execute a script - */ - -JNIEXPORT void JNICALL Java_net_php_servlet_send - (JNIEnv *jenv, jobject self, - jstring requestMethod, jstring queryString, - jstring requestURI, jstring pathTranslated, - jstring contentType, jint contentLength, - jstring authUser, jboolean display_source_mode) -{ - zend_file_handle file_handle; - int retval; -#ifndef VIRTUAL_DIR - char cwd[MAXPATHLEN]; -#endif - TSRMLS_FETCH(); - - zend_first_try { - SG(server_context) = emalloc(sizeof(servlet_request)); - ((servlet_request*)SG(server_context))->jenv=jenv; - ((servlet_request*)SG(server_context))->servlet=self; - ((servlet_request*)SG(server_context))->cookies=0; - - CG(extended_info) = 0; - - /* - * Initialize the request - */ - SETSTRING( SG(request_info).auth_user, authUser ); - SETSTRING( SG(request_info).request_method, requestMethod ); - SETSTRING( SG(request_info).query_string, queryString ); - SETSTRING( SG(request_info).request_uri, requestURI ); - SETSTRING( SG(request_info).content_type, contentType ); - SG(sapi_headers).http_response_code = 200; - SG(request_info).content_length = contentLength; - SG(request_info).auth_password = NULL; - if (php_request_startup(TSRMLS_C)==FAILURE) { - ThrowServletException(jenv,"request startup failure"); - return; - } - - /* - * Parse the file - */ - SETSTRING( SG(request_info).path_translated, pathTranslated ); -#ifdef VIRTUAL_DIR - retval = php_fopen_primary_script(&file_handle TSRMLS_CC); -#else - /* - * The java runtime doesn't like the working directory to be - * changed, so save it and change it back as quickly as possible - * in the hopes that Java doesn't notice. - */ - getcwd(cwd, MAXPATHLEN); - retval = php_fopen_primary_script(&file_handle TSRMLS_CC); - chdir(cwd); -#endif - - if (retval == FAILURE) { - php_request_shutdown((void *) 0); - php_module_shutdown(TSRMLS_C); - ThrowIOException(jenv, file_handle.filename); - return; - } - - /* - * Execute the request - */ - Java_net_php_reflect_setEnv(jenv, 0); - - if (display_source_mode) { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - if (open_file_for_scanning(&file_handle TSRMLS_CC)==SUCCESS) { - php_get_highlight_struct(&syntax_highlighter_ini); - sapi_send_headers(TSRMLS_C); - zend_highlight(&syntax_highlighter_ini TSRMLS_CC); - } - } else { - php_execute_script(&file_handle TSRMLS_CC); - php_header(); /* Make sure headers have been sent */ - } - - /* - * Clean up - */ - - FREESTRING(SG(request_info).request_method); - FREESTRING(SG(request_info).query_string); - FREESTRING(SG(request_info).request_uri); - FREESTRING(SG(request_info).path_translated); - FREESTRING(SG(request_info).content_type); - FREESTRING(((servlet_request*)SG(server_context))->cookies); - efree(SG(server_context)); - SG(server_context)=0; - - if (!display_source_mode) php_request_shutdown((void *) 0); - } zend_catch { - ThrowServletException(jenv,"bailout"); - } zend_end_try(); -} - diff --git a/sapi/servlet/servlet.dsp b/sapi/servlet/servlet.dsp deleted file mode 100644 index 9822557540..0000000000 --- a/sapi/servlet/servlet.dsp +++ /dev/null @@ -1,290 +0,0 @@ -# Microsoft Developer Studio Project File - Name="servlet" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=servlet - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "servlet.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "servlet.mak" CFG="servlet - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "servlet - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "servlet - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "servlet - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "servlet - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "servlet - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "..\..\Release"
-# PROP BASE Intermediate_Dir "..\..\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\main" /I "$(JAVA_HOME)\include\win32" /I "$(JAVA_HOME)\include" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D ZEND_DEBUG=0 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /dll /machine:I386 /out:"..\..\Release/phpsrvlt.dll" /libpath:"$(JAVA_HOME)\lib" /libpath:"..\..\Release"
-
-!ELSEIF "$(CFG)" == "servlet - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "..\..\Debug"
-# PROP BASE Intermediate_Dir "..\..\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\main" /I "$(JAVA_HOME)\include\win32" /I "$(JAVA_HOME)\include" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /dll /debug /machine:I386 /out:"..\..\Debug/phpsrvlt.dll" /pdbtype:sept /libpath:"$(JAVA_HOME)\lib" /libpath:"..\..\Debug"
-
-!ELSEIF "$(CFG)" == "servlet - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "..\..\Debug_TS"
-# PROP BASE Intermediate_Dir "..\..\Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\..\Zend" /I "..\..\main" /I "$(JAVA_HOME)\include\win32" /I "$(JAVA_HOME)\include" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /FR /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\TSRM" /I "..\..\Zend" /I "..\..\main" /I "$(JAVA_HOME)\include\win32" /I "$(JAVA_HOME)\include" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /D "ZTS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "_DEBUG"
-# ADD RSC /l 0x40d /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /dll /debug /machine:I386 /out:"..\..\Debug_TS/phpsrvlt.dll" /pdbtype:sept /libpath:"$(JAVA_HOME)\lib" /libpath:"..\..\Debug_TS"
-
-!ELSEIF "$(CFG)" == "servlet - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "..\..\Release_TS"
-# PROP BASE Intermediate_Dir "..\..\Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\main" /I "$(JAVA_HOME)\include\win32" /I "$(JAVA_HOME)\include" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\TSRM" /I "..\..\Zend" /I "..\..\main" /I "$(JAVA_HOME)\include\win32" /I "$(JAVA_HOME)\include" /I "..\..\..\bindlib_w32" /D "NDEBUG" /D ZEND_DEBUG=0 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL" /D "ZTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x40d /d "NDEBUG"
-# ADD RSC /l 0x40d /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /dll /machine:I386 /out:"..\..\Release_TS/phpsrvlt.dll" /libpath:"$(JAVA_HOME)\lib" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
-
-!ENDIF
-
-# Begin Target
-
-# Name "servlet - Win32 Release"
-# Name "servlet - Win32 Debug"
-# Name "servlet - Win32 Debug_TS"
-# Name "servlet - Win32 Release_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\..\ext\java\java.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\servlet.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\..\..\win32\winutil.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Java Files"
-
-# PROP Default_Filter "java"
-# Begin Source File
-
-SOURCE=.\servlet.java
-
-!IF "$(CFG)" == "servlet - Win32 Release"
-
-USERDEP__SERVL="..\..\ext\java\reflect.java"
-# Begin Custom Build
-OutDir=.\..\..\Release
-InputPath=.\servlet.java
-
-"$(OutDir)\phpsrvlt.jar" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- if not exist net mkdir net
- if not exist net\php mkdir net\php
- copy *.java net\php > nul
- copy ..\..\ext\java\reflect.java net\php > nul
- echo library=phpsrvlt>net/php/reflect.properties
- echo library=phpsrvlt>net/php/servlet.properties
- $(JAVA_HOME)\bin\javac net\php\servlet.java
- $(JAVA_HOME)\bin\javac net\php\reflect.java
- $(JAVA_HOME)\bin\javac net\php\formatter.java
- $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties
- erase net\php\servlet.*
- erase net\php\formatter.*
- erase net\php\reflect.*
- rmdir net\php
- rmdir net
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "servlet - Win32 Debug"
-
-USERDEP__SERVL="..\..\ext\java\reflect.java"
-# Begin Custom Build
-OutDir=.\..\..\Debug
-InputPath=.\servlet.java
-
-"$(OutDir)\phpsrvlt.jar" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- if not exist net mkdir net
- if not exist net\php mkdir net\php
- copy *.java net\php > nul
- copy ..\..\ext\java\reflect.java net\php > nul
- echo library=phpsrvlt>net/php/reflect.properties
- echo library=phpsrvlt>net/php/servlet.properties
- $(JAVA_HOME)\bin\javac -g net\php\servlet.java
- $(JAVA_HOME)\bin\javac -g net\php\reflect.java
- $(JAVA_HOME)\bin\javac -g net\php\formatter.java
- $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties
- erase net\php\servlet.*
- erase net\php\formatter.*
- erase net\php\reflect.*
- rmdir net\php
- rmdir net
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "servlet - Win32 Debug_TS"
-
-USERDEP__SERVL="..\..\ext\java\reflect.java"
-# Begin Custom Build
-OutDir=.\..\..\Debug_TS
-InputPath=.\servlet.java
-
-"$(OutDir)\phpsrvlt.jar" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- if not exist net mkdir net
- if not exist net\php mkdir net\php
- copy *.java net\php > nul
- copy ..\..\ext\java\reflect.java net\php > nul
- echo library=phpsrvlt>net/php/reflect.properties
- echo library=phpsrvlt>net/php/servlet.properties
- $(JAVA_HOME)\bin\javac -g net\php\servlet.java
- $(JAVA_HOME)\bin\javac -g net\php\reflect.java
- $(JAVA_HOME)\bin\javac -g net\php\formatter.java
- $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties
- erase net\php\servlet.*
- erase net\php\formatter.*
- erase net\php\reflect.*
- rmdir net\php
- rmdir net
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "servlet - Win32 Release_TS"
-
-USERDEP__SERVL="..\..\ext\java\reflect.java"
-# Begin Custom Build
-OutDir=.\..\..\Release_TS
-InputPath=.\servlet.java
-
-"$(OutDir)\phpsrvlt.jar" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- if not exist net mkdir net
- if not exist net\php mkdir net\php
- copy *.java net\php > nul
- copy ..\..\ext\java\reflect.java net\php > nul
- echo library=phpsrvlt>net/php/reflect.properties
- echo library=phpsrvlt>net/php/servlet.properties
- $(JAVA_HOME)\bin\javac net\php\servlet.java
- $(JAVA_HOME)\bin\javac net\php\reflect.java
- $(JAVA_HOME)\bin\javac net\php\formatter.java
- $(JAVA_HOME)\bin\jar c0f $(OutDir)\phpsrvlt.jar net\php\*.class net\php\*.properties
- erase net\php\servlet.*
- erase net\php\formatter.*
- erase net\php\reflect.*
- rmdir net\php
- rmdir net
-
-# End Custom Build
-
-!ENDIF
-
-# End Source File
-# Begin Source File
-
-SOURCE=.\servlet.java
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=.\jtest.php
-# End Source File
-# End Target
-# End Project
diff --git a/sapi/servlet/servlet.java b/sapi/servlet/servlet.java deleted file mode 100644 index 5e6887eaf3..0000000000 --- a/sapi/servlet/servlet.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sam Ruby (rubys@us.ibm.com) | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -package net.php; - -import java.io.IOException; -import java.net.URLEncoder; -import java.util.Enumeration; -import javax.servlet.*; -import javax.servlet.http.*; - -import java.lang.reflect.Method; - -public class servlet extends HttpServlet { - - char slash=System.getProperty("file.separator").charAt(0); - HttpServletRequest request; - HttpServletResponse response; - ServletInputStream stream; - - static int startup_count = 0; - - protected boolean display_source_mode = false; - private Method addHeader; - - /******************************************************************/ - /* native methods */ - /******************************************************************/ - - public native void startup(); - public native long define(String name); - public native void send(String requestMethod, String queryString, - String pathInfo, String pathTranslated, - String contentType, int contentLength, String authUser, - boolean display_source_mode); - public native void shutdown(); - - /******************************************************************/ - /* sapi callbacks */ - /******************************************************************/ - - public String readPost(int bytes) { - String result; - if (!request.getMethod().equals("POST")) { - result = request.getQueryString(); - } else { - Enumeration e = request.getParameterNames(); - result=""; - String concat=""; - while (e.hasMoreElements()) { - String name = (String)e.nextElement(); - String value = request.getParameter(name); - result+=concat+name+"="+URLEncoder.encode(value); - concat="&"; - } - } - if (result == null) return ""; - return result; - } - - public String readCookies() { - reflect.setResult(define("request"), request); - reflect.setResult(define("response"), response); - reflect.setResult(define("PHP_SELF"), request.getRequestURI()); - return request.getHeader("cookie"); - } - - public void header(String data) { - - // try to send the header using the most specific servlet API - // as possible (some servlet engines will add a content type - // header unless the setContentType method is called). - try { - if (data.startsWith("Content-type: ")) { - response.setContentType(data.substring(data.indexOf(" ")+1)); - } else if (data.startsWith("Location: ")) { - response.sendRedirect(data.substring(data.indexOf(" ")+1)); - } else { - int colon = data.indexOf(": "); - if (colon > 0) { - try { - addHeader.invoke(response, new Object[] - { data.substring(0,colon), data.substring(colon+2) } ); - } catch (Exception e) { - e.printStackTrace(System.err); - } - } else { - write(data); - } - } - } catch (IOException e) { - e.printStackTrace(System.err); - } - - } - - public void write(String data) { - try { - response.getWriter().print(data); - } catch (IOException e) { - e.printStackTrace(System.err); - } - } - - /******************************************************************/ - /* servlet interface */ - /******************************************************************/ - - public void init(ServletConfig config) throws ServletException { - super.init(config); - - // first time in, initialize native code - if (0 == startup_count++) { - reflect.loadLibrary("servlet"); - startup(); - } - - // try to find the addHeader method (added in the servlet API 2.2) - // otherwise settle for the setHeader method - try { - Class c = Class.forName("javax.servlet.http.HttpServletResponse"); - Method method[] = c.getDeclaredMethods(); - for (int i=0; i<method.length; i++) { - if (method[i].getName().equals("addHeader")) { - addHeader = method[i]; - break; - } - if (method[i].getName().equals("setHeader")) { - addHeader = method[i]; - } - } - } catch (Exception e) { - e.printStackTrace(System.err); - } - } - - public void service(HttpServletRequest request, - HttpServletResponse response, - String contextPath) - throws ServletException - { - this.request=request; - this.response=response; - - send(request.getMethod(), request.getQueryString(), - request.getRequestURI(), contextPath, - request.getContentType(), request.getContentLength(), - request.getRemoteUser(), display_source_mode); - - try { - if (stream != null) stream.close(); - } catch (IOException e) { - throw new ServletException(e.toString()); - } - } - - public void service(HttpServletRequest request, - HttpServletResponse response) - throws ServletException - { - String servletPath=request.getServletPath(); - String contextPath=getServletContext().getRealPath(servletPath); - service(request, response, contextPath); - } - - public void destroy() { - if (0 == --startup_count) shutdown(); - super.destroy(); - } - -} diff --git a/sapi/servlet/sessions.php b/sapi/servlet/sessions.php deleted file mode 100644 index 463b1b5e92..0000000000 --- a/sapi/servlet/sessions.php +++ /dev/null @@ -1,60 +0,0 @@ -<html> -<body bgcolor="white"> -<head> -<title>Sessions Example</title> -</head> -<body> -<h3>Sessions Example</h3> -<?php - - // print session info - - $session = $request->session; - $created = new Java("java.util.Date", $session->creationTime); - $accessed = new Java("java.util.Date", $session->lastAccessedTime); - - print "Session ID: $session->id<br>\n"; - print "Created: " . $created->toString() . "<br>\n"; - print "Last Accessed: " . $accessed->toString() . "<br>\n"; - - // set session info if needed - - if ($dataName) $session->setAttribute($dataName, $dataValue); - - // print session contents - - print "<P>\n"; - print "The following data is in your session:<br>\n"; - $e = $session->attributeNames; - while ($e->hasMoreElements()) { - $name = $e->nextElement(); - $value = $session->getAttribute($name); - print "$name = $value<br>\n"; - } - -?> -<P> -<form action="<?php echo $PHP_SELF ?>" method=POST> -Name of Session Attribute: -<input type=text size=20 name=dataName> -<br> -Value of Session Attribute: -<input type=text size=20 name=dataValue> -<br> -<input type=submit> -</form> -<P>GET based form:<br> -<form action="<?php echo $PHP_SELF ?>" method=GET> -Name of Session Attribute: -<input type=text size=20 name=dataName> -<br> -Value of Session Attribute: -<input type=text size=20 name=dataValue> -<br> -<input type=submit> -</form> -<p><a href="<?php echo $PHP_SELF ?>?dataName=foo&dataValue=bar" >URL encoded </a> -</body> -</html> -</body> -</html> diff --git a/sapi/servlet/web.xml b/sapi/servlet/web.xml deleted file mode 100644 index 9efa2fd091..0000000000 --- a/sapi/servlet/web.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> - -<!DOCTYPE web-app - PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" - "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd"> - -<web-app> - <servlet> - <servlet-name> - php - </servlet-name> - <servlet-class> - net.php.servlet - </servlet-class> - </servlet> - <servlet-mapping> - <servlet-name> - php - </servlet-name> - <url-pattern> - *.php - </url-pattern> - </servlet-mapping> - - <servlet> - <servlet-name> - php-formatter - </servlet-name> - <servlet-class> - net.php.formatter - </servlet-class> - </servlet> - <servlet-mapping> - <servlet-name> - php-formatter - </servlet-name> - <url-pattern> - *.phps - </url-pattern> - </servlet-mapping> -</web-app> diff --git a/sapi/thttpd/CREDITS b/sapi/thttpd/CREDITS deleted file mode 100644 index 8f02f36f4f..0000000000 --- a/sapi/thttpd/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -thttpd -Sascha Schumann diff --git a/sapi/thttpd/Makefile.in b/sapi/thttpd/Makefile.in deleted file mode 100644 index a18d0f8d18..0000000000 --- a/sapi/thttpd/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = stub.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/thttpd/README b/sapi/thttpd/README deleted file mode 100644 index b46c4dea5c..0000000000 --- a/sapi/thttpd/README +++ /dev/null @@ -1,59 +0,0 @@ -README FOR THTTPD MODULE (by Sascha Schumann) -($Date$) - - This is a SAPI module for PHP 4.0 supporting thttpd, the tiny, - turbo, throttling HTTP server by Jef Poskanzer. - - The module contains a patch against version 2.19 of thttpd. The patch - adds hooks to thttpd to call PHP, if a filename matches *.php. This - patch will be applied when you install PHP. - - This is a functional and stable module (it runs a large application - like IMP 2.2.0 without any problems). Its original intention was to - demonstrate the ability of PHP to work in every web server environment. - - NOTE: All requests will be serialized. That means, one long running - script will block all other requests. Choose another web-server, - if you want to execute arbitrary scripts. - -REQUIRED DOWNLOADS - - 1. thttpd 2.xx - - Full Distribution: - http://www.acme.com/software/thttpd/ - - 2. PHP 4.0.x - - Download: - http://www.php.net/ - - Snapshots from CVS: - http://snaps.php.net/ - - -BUILD INSTRUCTIONS - - 1. Extract software packages - - $ gunzip -c thttpd-2.xx.tar.gz | tar xf - - $ gunzip -c php-*.tar.gz | tar xf - - - 2. Prepare PHP - - $ cd php-* - $ ./configure \ - --with-thttpd=../thttpd-2.xx \ - <further PHP options> - $ make install - $ cd .. - - You can see the list of valid PHP options by executing - - $ ./configure --help - - 3. Configure, compile, install thttpd - - Now follow the thttpd instructions. The Makefile template of - thttpd was changed to automatically use the components - required by PHP. diff --git a/sapi/thttpd/config.m4 b/sapi/thttpd/config.m4 deleted file mode 100644 index 81469e825c..0000000000 --- a/sapi/thttpd/config.m4 +++ /dev/null @@ -1,23 +0,0 @@ -AC_ARG_WITH(thttpd, -[ --with-thttpd=SRCDIR Build PHP as thttpd module],[ - test -d $withval || AC_MSG_RESULT(thttpd directory does not exist ($withval)) - PHP_EXPAND_PATH($withval, THTTPD) - PHP_TARGET_RDYNAMIC - INSTALL_IT="\ - echo 'PHP_LIBS = -L. -lphp4 \$(PHP_LIBS) \$(EXTRA_LIBS)' > $THTTPD/php_makefile; \ - echo 'PHP_LDFLAGS = \$(NATIVE_RPATHS) \$(PHP_LDFLAGS)' >> $THTTPD/php_makefile; \ - echo 'PHP_CFLAGS = \$(COMMON_FLAGS) \$(CFLAGS) \$(CPPFLAGS) \$(EXTRA_CFLAGS)' >> $THTTPD/php_makefile; \ - \$(LN_S) $abs_srcdir/sapi/thttpd/thttpd.c $THTTPD/php_thttpd.c; \ - cp $abs_srcdir/sapi/thttpd/php_thttpd.h $SAPI_STATIC $THTTPD;\ - test -f $THTTPD/php_patched || \ - (cd $THTTPD && patch < $abs_srcdir/sapi/thttpd/thttpd_patch && touch php_patched)" - PHP_THTTPD="yes, using $THTTPD" - PHP_ADD_INCLUDE($THTTPD) - PHP_BUILD_STATIC - PHP_SAPI=thttpd -],[ - PHP_THTTPD=no -]) - -AC_MSG_CHECKING(for thttpd) -AC_MSG_RESULT($PHP_THTTPD) diff --git a/sapi/thttpd/php.sym b/sapi/thttpd/php.sym deleted file mode 100644 index 2214d3964d..0000000000 --- a/sapi/thttpd/php.sym +++ /dev/null @@ -1,3 +0,0 @@ -thttpd_php_request -thttpd_php_init -thttpd_php_shutdown diff --git a/sapi/thttpd/php_thttpd.h b/sapi/thttpd/php_thttpd.h deleted file mode 100644 index a5ebf13cb2..0000000000 --- a/sapi/thttpd/php_thttpd.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ -*/ - -#ifndef PHP_THTTPD_H -#define PHP_THTTPD_H - -#include <sys/types.h> -#include <sys/stat.h> -#include <libhttpd.h> - -void thttpd_php_shutdown(void); -void thttpd_php_init(void); -off_t thttpd_php_request(httpd_conn *hc); - -void thttpd_register_on_close(void (*)(int)); -void thttpd_closed_conn(int fd); -int thttpd_get_fd(void); -void thttpd_set_dont_close(void); - -#endif diff --git a/sapi/thttpd/stub.c b/sapi/thttpd/stub.c deleted file mode 100644 index e69de29bb2..0000000000 --- a/sapi/thttpd/stub.c +++ /dev/null diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c deleted file mode 100644 index ddb531a644..0000000000 --- a/sapi/thttpd/thttpd.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ -*/ - - -#include "php.h" -#include "SAPI.h" -#include "php_main.h" -#include "php_thttpd.h" -#include "php_variables.h" -#include "version.h" - -#include "ext/standard/php_smart_str.h" - -#include <sys/uio.h> - -typedef struct { - httpd_conn *hc; - int post_off; - void (*on_close)(int); -} php_thttpd_globals; - - -#ifdef ZTS -static int thttpd_globals_id; -#define TG(v) TSRMG(thttpd_globals_id, php_thttpd_globals *, v) -#else -static php_thttpd_globals thttpd_globals; -#define TG(v) (thttpd_globals.v) -#endif - -static int sapi_thttpd_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - int n; - uint sent = 0; - - while (str_length > 0) { - n = send(TG(hc)->conn_fd, str, str_length, 0); - - if (n == -1 && errno == EPIPE) - php_handle_aborted_connection(); - if (n == -1 && errno == EAGAIN) - continue; - if (n <= 0) - return n; - - TG(hc)->bytes_sent += n; - str += n; - sent += n; - str_length -= n; - } - - return sent; -} - -#define COMBINE_HEADERS 30 - -static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - char buf[1024]; - struct iovec vec[COMBINE_HEADERS]; - int n = 0; - zend_llist_position pos; - sapi_header_struct *h; - size_t len; - - if (!SG(sapi_headers).http_status_line) { - snprintf(buf, 1023, "HTTP/1.0 %d Something\r\n", SG(sapi_headers).http_response_code); - len = strlen(buf); - vec[n].iov_base = buf; - vec[n].iov_len = len; - } else { - vec[n].iov_base = SG(sapi_headers).http_status_line; - len = strlen(vec[n].iov_base); - vec[n].iov_len = len; - vec[++n].iov_base = "\r\n"; - vec[n].iov_len = 2; - len += 2; - } - TG(hc)->status = SG(sapi_headers).http_response_code; - TG(hc)->bytes_sent += len; - n++; - -#define DEF_CONTENT_TYPE_LINE "Content-Type: text/html\r\n" - if (SG(sapi_headers).send_default_content_type) { - vec[n].iov_base = DEF_CONTENT_TYPE_LINE; - vec[n].iov_len = sizeof(DEF_CONTENT_TYPE_LINE) - 1; - n++; - } - - h = zend_llist_get_first_ex(&sapi_headers->headers, &pos); - while (h) { - vec[n].iov_base = h->header; - vec[n++].iov_len = h->header_len; - if (n >= COMBINE_HEADERS - 1) { - if (writev(TG(hc)->conn_fd, vec, n) == -1 && errno == EPIPE) - php_handle_aborted_connection(); - n = 0; - } - vec[n].iov_base = "\r\n"; - vec[n++].iov_len = 2; - - h = zend_llist_get_next_ex(&sapi_headers->headers, &pos); - } - - vec[n].iov_base = "\r\n"; - vec[n++].iov_len = 2; - - if (n) { - if (writev(TG(hc)->conn_fd, vec, n) == -1 && errno == EPIPE) - php_handle_aborted_connection(); - } - - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - -static int sapi_thttpd_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - size_t read_bytes = 0, tmp; - int c; - - /* to understand this, read cgi_interpose_input() in libhttpd.c */ - c = TG(hc)->read_idx - TG(hc)->checked_idx; - if (c > 0) { - read_bytes = MIN(c, count_bytes); - memcpy(buffer, TG(hc)->read_buf + TG(hc)->checked_idx, read_bytes); - TG(hc)->checked_idx += read_bytes; - count_bytes -= read_bytes; - } - - count_bytes = MIN(count_bytes, - SG(request_info).content_length - SG(read_post_bytes) - TG(post_off)); - - while (read_bytes < count_bytes) { - tmp = recv(TG(hc)->conn_fd, buffer + read_bytes, - count_bytes - read_bytes, 0); - if (tmp <= 0) - break; - read_bytes += tmp; - } - - return read_bytes; -} - -static char *sapi_thttpd_read_cookies(TSRMLS_D) -{ - return TG(hc)->cookie; -} - -#define BUF_SIZE 512 -#define ADD_STRING(name) \ - php_register_variable(name, buf, track_vars_array TSRMLS_CC) - -static void sapi_thttpd_register_variables(zval *track_vars_array TSRMLS_DC) -{ - char buf[BUF_SIZE + 1]; - char *p; - - php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC); - php_register_variable("SERVER_SOFTWARE", SERVER_SOFTWARE, track_vars_array TSRMLS_CC); - php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_CC); - php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array TSRMLS_CC); - - p = inet_ntoa(TG(hc)->client_addr.sa_in.sin_addr); - /* string representation of IPs are never larger than 512 bytes */ - if (p) { - memcpy(buf, p, strlen(p) + 1); - ADD_STRING("REMOTE_ADDR"); - ADD_STRING("REMOTE_HOST"); - } - - snprintf(buf, BUF_SIZE, "%d", TG(hc)->hs->port); - ADD_STRING("SERVER_PORT"); - - snprintf(buf, BUF_SIZE, "/%s", TG(hc)->pathinfo); - ADD_STRING("PATH_INFO"); - - snprintf(buf, BUF_SIZE, "/%s", TG(hc)->origfilename); - ADD_STRING("SCRIPT_NAME"); - -#define CONDADD(name, field) \ - if (TG(hc)->field[0]) { \ - php_register_variable(#name, TG(hc)->field, track_vars_array TSRMLS_CC); \ - } - - CONDADD(HTTP_REFERER, referer); - CONDADD(HTTP_USER_AGENT, useragent); - CONDADD(HTTP_ACCEPT, accept); - CONDADD(HTTP_ACCEPT_ENCODING, accepte); - CONDADD(HTTP_COOKIE, cookie); - CONDADD(CONTENT_TYPE, contenttype); - CONDADD(REMOTE_USER, remoteuser); - CONDADD(SERVER_PROTOCOL, protocol); - - if (TG(hc)->contentlength != -1) { - sprintf(buf, "%ld", (long) TG(hc)->contentlength); - ADD_STRING("CONTENT_LENGTH"); - } - - if (TG(hc)->authorization[0]) - php_register_variable("AUTH_TYPE", "Basic", track_vars_array TSRMLS_CC); -} - -static sapi_module_struct thttpd_sapi_module = { - "thttpd", - "thttpd", - - php_module_startup, - php_module_shutdown_wrapper, - - NULL, /* activate */ - NULL, /* deactivate */ - - sapi_thttpd_ub_write, - NULL, - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, - - NULL, - sapi_thttpd_send_headers, - NULL, - sapi_thttpd_read_post, - sapi_thttpd_read_cookies, - - sapi_thttpd_register_variables, - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -static void thttpd_module_main(TSRMLS_D) -{ - zend_file_handle file_handle; - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - if (php_request_startup(TSRMLS_C) == FAILURE) { - return; - } - - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); -} - -static void thttpd_request_ctor(TSRMLS_D) -{ - int offset; - smart_str s = {0}; - - SG(request_info).query_string = TG(hc)->query?strdup(TG(hc)->query):NULL; - - smart_str_appends_ex(&s, TG(hc)->hs->cwd, 1); - smart_str_appends_ex(&s, TG(hc)->expnfilename, 1); - smart_str_0(&s); - SG(request_info).path_translated = s.c; - - s.c = NULL; - smart_str_appendc_ex(&s, '/', 1); - smart_str_appends_ex(&s, TG(hc)->origfilename, 1); - smart_str_0(&s); - SG(request_info).request_uri = s.c; - SG(request_info).request_method = httpd_method_str(TG(hc)->method); - SG(sapi_headers).http_response_code = 200; - SG(request_info).content_type = TG(hc)->contenttype; - SG(request_info).content_length = TG(hc)->contentlength; - - php_handle_auth_data(TG(hc)->authorization TSRMLS_CC); - - TG(post_off) = TG(hc)->read_idx - TG(hc)->checked_idx; - - /* avoid feeding \r\n from POST data to SAPI */ - offset = TG(post_off) - SG(request_info).content_length; - - if (offset > 0) { - TG(post_off) -= offset; - TG(hc)->read_idx -= offset; - } -} - -static void thttpd_request_dtor(TSRMLS_D) -{ - if (SG(request_info).query_string) - free(SG(request_info).query_string); - free(SG(request_info).request_uri); - free(SG(request_info).path_translated); -} - -#ifdef ZTS - -#ifdef TSRM_ST -#define thread_create_simple_detached(n) st_thread_create(n, NULL, 0, 0) -#define thread_usleep(n) st_usleep(n) -#define thread_exit() st_thread_exit(NULL) -/* No preemption, simple operations are safe */ -#define thread_atomic_inc(n) (++n) -#define thread_atomic_dec(n) (--n) -#else -#error No thread primitives available -#endif - -/* We might want to replace this with a STAILQ */ -typedef struct qreq { - httpd_conn *hc; - struct qreq *next; -} qreq_t; - -static MUTEX_T qr_lock; -static qreq_t *queued_requests; -static qreq_t *last_qr; -static int nr_free_threads; -static int nr_threads; -static int max_threads = 50; - -#define HANDLE_STRINGS() { \ - HANDLE_STR(encodedurl); \ - HANDLE_STR(decodedurl); \ - HANDLE_STR(origfilename); \ - HANDLE_STR(expnfilename); \ - HANDLE_STR(pathinfo); \ - HANDLE_STR(query); \ - HANDLE_STR(referer); \ - HANDLE_STR(useragent); \ - HANDLE_STR(accept); \ - HANDLE_STR(accepte); \ - HANDLE_STR(acceptl); \ - HANDLE_STR(cookie); \ - HANDLE_STR(contenttype); \ - HANDLE_STR(authorization); \ - HANDLE_STR(remoteuser); \ - } - -static httpd_conn *duplicate_conn(httpd_conn *hc, httpd_conn *nhc) -{ - memcpy(nhc, hc, sizeof(*nhc)); - -#define HANDLE_STR(m) nhc->m = nhc->m ? strdup(nhc->m) : NULL - HANDLE_STRINGS(); -#undef HANDLE_STR - - return nhc; -} - -static void destroy_conn(httpd_conn *hc) -{ -#define HANDLE_STR(m) if (hc->m) free(hc->m) - HANDLE_STRINGS(); -#undef HANDLE_STR -} - -static httpd_conn *dequeue_request(void) -{ - httpd_conn *ret = NULL; - qreq_t *m; - - tsrm_mutex_lock(qr_lock); - if (queued_requests) { - m = queued_requests; - ret = m->hc; - if (!(queued_requests = m->next)) - last_qr = NULL; - free(m); - } - tsrm_mutex_unlock(qr_lock); - - return ret; -} - -static void *worker_thread(void *); - -static void queue_request(httpd_conn *hc) -{ - qreq_t *m; - httpd_conn *nhc; - - /* Mark as long-running request */ - hc->file_address = (char *) 1; - - /* - * We cannot synchronously revoke accesses to hc in the worker - * thread, so we need to pass a copy of hc to the worker thread. - */ - nhc = malloc(sizeof *nhc); - duplicate_conn(hc, nhc); - - /* Allocate request queue container */ - m = malloc(sizeof *m); - m->hc = nhc; - m->next = NULL; - - tsrm_mutex_lock(qr_lock); - /* Create new threads when reaching a certain threshhold */ - if (nr_threads < max_threads && nr_free_threads < 2) { - nr_threads++; /* protected by qr_lock */ - - thread_atomic_inc(nr_free_threads); - thread_create_simple_detached(worker_thread); - } - /* Insert container into request queue */ - if (queued_requests) - last_qr->next = m; - else - queued_requests = m; - last_qr = m; - tsrm_mutex_unlock(qr_lock); -} - -static off_t thttpd_real_php_request(httpd_conn *hc TSRMLS_DC); - -static void *worker_thread(void *dummy) -{ - int do_work = 50; - httpd_conn *hc; - - while (do_work) { - hc = dequeue_request(); - - if (!hc) { -/* do_work--; */ - thread_usleep(500000); - continue; - } -/* do_work = 50; */ - - thread_atomic_dec(nr_free_threads); - - thttpd_real_php_request(hc TSRMLS_CC); - shutdown(hc->conn_fd, 0); - destroy_conn(hc); - free(hc); - - thread_atomic_inc(nr_free_threads); - } - thread_atomic_dec(nr_free_threads); - thread_atomic_dec(nr_threads); - thread_exit(); -} - -static void remove_dead_conn(int fd) -{ - qreq_t *m, *prev = NULL; - - tsrm_mutex_lock(qr_lock); - m = queued_requests; - while (m) { - if (m->hc->conn_fd == fd) { - if (prev) - if (!(prev->next = m->next)) - last_qr = prev; - else - if (!(queued_requests = m->next)) - last_qr = NULL; - destroy_conn(m->hc); - free(m->hc); - free(m); - break; - } - prev = m; - m = m->next; - } - tsrm_mutex_unlock(qr_lock); -} - -#endif - -static off_t thttpd_real_php_request(httpd_conn *hc TSRMLS_DC) -{ - TG(hc) = hc; - hc->bytes_sent = 0; - - thttpd_request_ctor(TSRMLS_C); - - thttpd_module_main(TSRMLS_C); - - thttpd_request_dtor(TSRMLS_C); - - return 0; -} - -off_t thttpd_php_request(httpd_conn *hc) -{ -#ifdef ZTS - queue_request(hc); -#else - TSRMLS_FETCH(); - return thttpd_real_php_request(hc TSRMLS_CC); -#endif -} - -void thttpd_register_on_close(void (*arg)(int)) -{ - TSRMLS_FETCH(); - TG(on_close) = arg; -} - -void thttpd_closed_conn(int fd) -{ - TSRMLS_FETCH(); - if (TG(on_close)) TG(on_close)(fd); -} - -int thttpd_get_fd(void) -{ - TSRMLS_FETCH(); - return TG(hc)->conn_fd; -} - -void thttpd_set_dont_close(void) -{ - TSRMLS_FETCH(); - TG(hc)->file_address = (char *) 1; -} - - -void thttpd_php_init(void) -{ -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); - ts_allocate_id(&thttpd_globals_id, sizeof(php_thttpd_globals), NULL, NULL); - qr_lock = tsrm_mutex_alloc(); - thttpd_register_on_close(remove_dead_conn); -#endif - sapi_startup(&thttpd_sapi_module); - thttpd_sapi_module.startup(&thttpd_sapi_module); - { - TSRMLS_FETCH(); - - SG(server_context) = (void *) 1; - } -} - -void thttpd_php_shutdown(void) -{ - TSRMLS_FETCH(); - - if (SG(server_context) != NULL) { - thttpd_sapi_module.shutdown(&thttpd_sapi_module); - sapi_shutdown(); -#ifdef ZTS - tsrm_shutdown(); -#endif - } -} diff --git a/sapi/thttpd/thttpd_patch b/sapi/thttpd/thttpd_patch deleted file mode 100644 index b5ce179ca2..0000000000 --- a/sapi/thttpd/thttpd_patch +++ /dev/null @@ -1,137 +0,0 @@ -diff -ur thttpd-2.21/Makefile.in thttpd-2.21-p/Makefile.in ---- thttpd-2.21/Makefile.in Thu Mar 29 20:36:21 2001 -+++ thttpd-2.21-p/Makefile.in Sun Apr 22 15:59:42 2001 -@@ -46,13 +46,15 @@ - - # You shouldn't need to edit anything below here. - -+include php_makefile -+ - CC = @CC@ - CCOPT = @V_CCOPT@ - DEFS = @DEFS@ - INCLS = -I. - CFLAGS = $(CCOPT) $(DEFS) $(INCLS) --LDFLAGS = @LDFLAGS@ --LIBS = @LIBS@ -+LDFLAGS = @LDFLAGS@ $(PHP_LDFLAGS) -+LIBS = @LIBS@ $(PHP_LIBS) - NETLIBS = @V_NETLIBS@ - INSTALL = @INSTALL@ - -@@ -62,7 +64,7 @@ - @rm -f $@ - $(CC) $(CFLAGS) -c $*.c - --SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c -+SRC = thttpd.c libhttpd.c fdwatch.c mmc.c timers.c match.c tdate_parse.c syslog.c php_thttpd.c - - OBJ = $(SRC:.c=.o) @LIBOBJS@ - -@@ -151,6 +153,9 @@ - - tags: - ctags -wtd *.c *.h -+ -+php_thttpd.o: php_thttpd.c -+ $(CC) $(PHP_CFLAGS) $(CFLAGS) -c php_thttpd.c - - tar: - @name=`sed -n -e '/SERVER_SOFTWARE/!d' -e 's,.*thttpd/,thttpd-,' -e 's, .*,,p' version.h` ; \ -diff -ur thttpd-2.21/libhttpd.c thttpd-2.21-p/libhttpd.c ---- thttpd-2.21/libhttpd.c Sat Apr 21 02:11:32 2001 -+++ thttpd-2.21-p/libhttpd.c Sun Apr 22 16:01:41 2001 -@@ -85,6 +85,8 @@ - #include "match.h" - #include "tdate_parse.h" - -+#include "php_thttpd.h" -+ - #ifndef STDIN_FILENO - #define STDIN_FILENO 0 - #endif -@@ -243,6 +245,8 @@ - free( (void*) hs->cwd ); - if ( hs->cgi_pattern != (char*) 0 ) - free( (void*) hs->cgi_pattern ); -+ if ( hs->php_pattern != (char*) 0 ) -+ free( (void*) hs->php_pattern ); - if ( hs->charset != (char*) 0 ) - free( (void*) hs->charset ); - if ( hs->url_pattern != (char*) 0 ) -@@ -250,6 +254,7 @@ - if ( hs->local_pattern != (char*) 0 ) - free( (void*) hs->local_pattern ); - free( (void*) hs ); -+ thttpd_php_shutdown(); - } - - -@@ -313,6 +318,7 @@ - } - - hs->port = port; -+ hs->php_pattern = strdup("**.php"); - if ( cgi_pattern == (char*) 0 ) - hs->cgi_pattern = (char*) 0; - else -@@ -386,6 +392,8 @@ - return (httpd_server*) 0; - } - -+ thttpd_php_init(); -+ - /* Done initializing. */ - if ( hs->binding_hostname == (char*) 0 ) - syslog( LOG_INFO, "%.80s starting on port %d", SERVER_SOFTWARE, hs->port ); -@@ -2336,7 +2344,10 @@ - { - make_log_entry( hc, nowP ); - -- if ( hc->file_address != (char*) 0 ) -+ if ( hc->file_address == (char*) 1 ) -+ { -+ thttpd_closed_conn(hc->conn_fd); -+ } else if ( hc->file_address != (char*) 0 ) - { - mmc_unmap( hc->file_address, &(hc->sb), nowP ); - hc->file_address = (char*) 0; -@@ -3543,6 +3554,11 @@ - ( hc->sb.st_mode & S_IXOTH ) && - match( hc->hs->cgi_pattern, hc->expnfilename ) ) - return cgi( hc ); -+ -+ if ( hc->hs->php_pattern != (char*) 0 && -+ match( hc->hs->php_pattern, hc->expnfilename)) { -+ return thttpd_php_request( hc ); -+ } - - /* It's not CGI. If it's executable or there's pathinfo, someone's - ** trying to either serve or run a non-CGI file as CGI. Either case -diff -ur thttpd-2.21/libhttpd.h thttpd-2.21-p/libhttpd.h ---- thttpd-2.21/libhttpd.h Fri Apr 13 07:37:17 2001 -+++ thttpd-2.21-p/libhttpd.h Sun Apr 22 15:59:42 2001 -@@ -69,6 +69,7 @@ - char* server_hostname; - int port; - char* cgi_pattern; -+ char* php_pattern; - char* charset; - char* cwd; - int listen4_fd, listen6_fd; -diff -ur thttpd-2.21/thttpd.c thttpd-2.21-p/thttpd.c ---- thttpd-2.21/thttpd.c Sun Apr 15 18:09:20 2001 -+++ thttpd-2.21-p/thttpd.c Sun Apr 22 15:59:42 2001 -@@ -1392,6 +1392,12 @@ - clear_connection( c, tvP ); - return; - } -+ if (hc->file_address == (char *) 1) { -+ tmr_cancel( c->idle_read_timer ); -+ c->idle_read_timer = (Timer*) 0; -+ c->wouldblock_delay = 0; -+ return; -+ } - if ( c->bytes_sent >= c->bytes_to_send ) - { - /* There's nothing to send. */ diff --git a/sapi/tux/CREDITS b/sapi/tux/CREDITS deleted file mode 100644 index 3b7aa70c01..0000000000 --- a/sapi/tux/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -tux -Sascha Schumann diff --git a/sapi/tux/Makefile.in b/sapi/tux/Makefile.in deleted file mode 100644 index 221f50d8c1..0000000000 --- a/sapi/tux/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ - -LTLIBRARY_NAME = libsapi.la -LTLIBRARY_SOURCES = php_tux.c - -include $(top_srcdir)/build/ltlib.mk diff --git a/sapi/tux/README b/sapi/tux/README deleted file mode 100644 index 167e52f3ca..0000000000 --- a/sapi/tux/README +++ /dev/null @@ -1,86 +0,0 @@ -README FOR THE TUX MODULE (by Sascha Schumann) -($Date$) - - This is a SAPI module for the TUX web-server by Ingo Molnar. - - The special thing about TUX is that it is integrated into the Linux - kernel and thus provides high-speed serving of static files. - - The web-server provides a user-space API which allows arbitrary - plug-ins to be made available. - - All requests to the PHP userspace module are currently serialized. - - This module is of alpha quality. Due to incomplete APIs, HTTP - authentication and handling of POST requests has not been - implemented yet. - - SECURITY NOTE: PHP will happily run everything under the - web-root through the parser; so be careful what you put - there. - - Note that requests are served in a chroot'ed environment. - The initialization of PHP does not take place in the chroot'ed - environment, so that e.g. /usr/local/lib/php.ini is treated - as usual. - -REQUIRED DOWNLOADS - - 1. TUX - - http://people.redhat.com/~mingo/TUX-patches/QuickStart-TUX.txt - - 2. PHP 4.0.x - - Download: - http://www.php.net/ - - Snapshots from CVS: - http://snaps.php.net/ - - -BUILD INSTRUCTIONS - - 1. Install TUX as outlined in the QuickStart text. - Create /tux-modules where modules will reside. - - 2. Prepare PHP - - $ cd php-* - $ ./configure \ - --with-tux=/tux-modules \ - <further PHP options> - # make install - - You can see the list of valid PHP options by executing - - $ ./configure --help - - 3. Touch a file in your web-root 'php4.tux'. This will - cause requests to '/php4.tux' to be redirected to the - userspace module php4.tux. - - 4. Start TUX with something like - - # tux -d -t 8 -r /www -m /tux-modules php4.tux - - (daemon mode, eight threads, web-root /www, modules in - /tux-modules, load php4.tux) - - BEFORE running this command, the kernel side of TUX has to - be properly setup. - - 5. Try to access - - http://yourserver/php4.tux?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000 - - It should display the PHP credits page. - - To access a script /foo/bar.php, use - - http://yourserver/php4.tux?/foo/bar.php - - Parameters can be appended: - - http://yourserver/php4.tux?/foo/bar.php&var=value - diff --git a/sapi/tux/config.m4 b/sapi/tux/config.m4 deleted file mode 100644 index 7a0ca55de8..0000000000 --- a/sapi/tux/config.m4 +++ /dev/null @@ -1,15 +0,0 @@ -PHP_TUX=no - -AC_ARG_WITH(tux, -[ --with-tux=MODULEDIR Build PHP as a TUX module (Linux only)],[ - INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $withval/php4.tux.so" - AC_CHECK_HEADERS(tuxmodule.h,[:],[AC_MSG_ERROR([Cannot find tuxmodule.h])]) - PHP_BUILD_SHARED - PHP_SAPI=tux - PHP_TUX=yes -]) - -AC_MSG_CHECKING(for TUX) -AC_MSG_RESULT($PHP_TUX) - -unset PHP_TUX diff --git a/sapi/tux/php.sym b/sapi/tux/php.sym deleted file mode 100644 index b968c5f5a2..0000000000 --- a/sapi/tux/php.sym +++ /dev/null @@ -1,2 +0,0 @@ -TUXAPI_handle_events -TUXAPI_init diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c deleted file mode 100644 index 4d44b40728..0000000000 --- a/sapi/tux/php_tux.c +++ /dev/null @@ -1,429 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | 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. | - +----------------------------------------------------------------------+ - | Author: Sascha Schumann <sascha@schumann.cx> | - +----------------------------------------------------------------------+ -*/ - -#include "php.h" -#include "SAPI.h" -#include "php_main.h" -#include "php_variables.h" - -#include "ext/standard/php_smart_str.h" - -#include "tuxmodule.h" - -#include <sys/uio.h> - -#if 0 -#include <pthread.h> -#endif - -void tux_closed_conn(int fd); - -enum { - PHP_TUX_BACKGROUND_CONN = 1 -}; - -typedef struct { - user_req_t *req; - void (*on_close)(int); - int tux_action; - struct iovec *header_vec; - int number_vec; -} php_tux_globals; - -static php_tux_globals tux_globals; - -#define TG(v) (tux_globals.v) - -static int sapi_tux_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - int n; - uint sent = 0; - - /* combine headers and body */ - if (TG(number_vec)) { - struct iovec *vec = TG(header_vec); - - n = TG(number_vec); - vec[n].iov_base = (void *) str; - vec[n++].iov_len = str_length; - - if (writev(TG(req)->sock, vec, n) == -1 && errno == EPIPE) - php_handle_aborted_connection(); - - TG(number_vec) = 0; - return str_length; - } - - while (str_length > 0) { - n = send(TG(req)->sock, str, str_length, 0); - - if (n == -1 && errno == EPIPE) - php_handle_aborted_connection(); - if (n == -1 && errno == EAGAIN) - continue; - if (n <= 0) - return n; - - TG(req)->bytes_sent += n; - str += n; - sent += n; - str_length -= n; - } - - return sent; -} - -static int sapi_tux_send_headers(sapi_headers_struct *sapi_headers) -{ - char buf[1024]; - struct iovec *vec; - int n = 0; - int max_headers; - zend_llist_position pos; - sapi_header_struct *h; - size_t len; - char *status_line; - int locate_cl; - TSRMLS_FETCH(); - - max_headers = 30; - snprintf(buf, 1023, "HTTP/1.1 %d NA\r\n", SG(sapi_headers).http_response_code); - - vec = malloc(sizeof(struct iovec) * max_headers); - - vec[n].iov_base = strdup(buf); - vec[n++].iov_len = strlen(buf); - - TG(req)->http_status = SG(sapi_headers).http_response_code; - TG(req)->bytes_sent += len; - - if (TG(tux_action) == TUX_ACTION_FINISH_CLOSE_REQ && TG(req)->http_version == HTTP_1_1) - locate_cl = 1; - else - locate_cl = 0; - - h = zend_llist_get_first_ex(&sapi_headers->headers, &pos); - while (h) { - if (locate_cl - && strncasecmp(h->header, "Content-length:", sizeof("Content-length:")-1) == 0) { - TG(tux_action) = TUX_ACTION_FINISH_REQ; - locate_cl = 0; - } - - vec[n].iov_base = h->header; - vec[n++].iov_len = h->header_len; - if (n >= max_headers - 3) { - max_headers *= 2; - vec = realloc(vec, sizeof(struct iovec) * max_headers); - } - vec[n].iov_base = "\r\n"; - vec[n++].iov_len = 2; - - h = zend_llist_get_next_ex(&sapi_headers->headers, &pos); - } - - vec[n].iov_base = "\r\n"; - vec[n++].iov_len = 2; - - TG(number_vec) = n; - TG(header_vec) = vec; - - - return SAPI_HEADER_SENT_SUCCESSFULLY; -} - -static int sapi_tux_read_post(char *buffer, uint count_bytes) -{ -#if 0 - int amount = 0; - TSRMLS_FETCH(); - - TG(req)->objectlen = count_bytes; - TG(req)->object_addr = buffer; - if (tux(TUX_ACTION_READ_POST_DATA, TG(req))) - return 0; - - TG(read_post_data) = 1; - - return TG(req)->objectlen; -#else - return 0; -#endif -} - -static char *sapi_tux_read_cookies(void) -{ - TSRMLS_FETCH(); - - return TG(req)->cookies; -} - -#define BUF_SIZE 512 -#define ADD_STRING(name) \ - php_register_variable(name, buf, track_vars_array TSRMLS_CC) - -static void sapi_tux_register_variables(zval *track_vars_array TSRMLS_DC) -{ - char buf[BUF_SIZE + 1]; - char *p; - - - sprintf(buf, "Server: %s", TUXAPI_version); - sapi_add_header_ex(buf, strlen(buf), 1, 0 TSRMLS_CC); - php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array TSRMLS_CC); - php_register_variable("SERVER_SOFTWARE", TUXAPI_version, track_vars_array TSRMLS_CC); - php_register_variable("GATEWAY_INTERFACE", "CGI/1.1", track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_METHOD", (char *) SG(request_info).request_method, track_vars_array TSRMLS_CC); - php_register_variable("DOCUMENT_ROOT", TUXAPI_docroot, track_vars_array TSRMLS_CC); - php_register_variable("SERVER_NAME", TUXAPI_servername, track_vars_array TSRMLS_CC); - php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array TSRMLS_CC); - php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array TSRMLS_CC); - - p = inet_ntoa(TG(req)->client_host); - /* string representation of IPs are never larger than 512 bytes */ - if (p) { - memcpy(buf, p, strlen(p) + 1); - ADD_STRING("REMOTE_ADDR"); - ADD_STRING("REMOTE_HOST"); - } - - sprintf(buf, "%d", CGI_SERVER_PORT(TG(req))); - ADD_STRING("SERVER_PORT"); - -#if 0 - snprintf(buf, BUF_SIZE, "/%s", TG(hc)->pathinfo); - ADD_STRING("PATH_INFO"); - - snprintf(buf, BUF_SIZE, "/%s", TG(hc)->origfilename); - ADD_STRING("SCRIPT_NAME"); -#endif - -#define CONDADD(name, field) \ - if (TG(req)->field[0]) { \ - php_register_variable(#name, TG(req)->field, track_vars_array TSRMLS_CC); \ - } - - CONDADD(HTTP_REFERER, referer); - CONDADD(HTTP_USER_AGENT, user_agent); - CONDADD(HTTP_ACCEPT, accept); - CONDADD(HTTP_ACCEPT_ENCODING, accept_encoding); - CONDADD(HTTP_ACCEPT_LANGUAGE, accept_language); - CONDADD(HTTP_COOKIE, cookies); - CONDADD(CONTENT_TYPE, content_type); - -#if 0 - if (TG(hc)->contentlength != -1) { - sprintf(buf, "%ld", (long) TG(hc)->contentlength); - ADD_STRING("CONTENT_LENGTH"); - } -#endif - -#if 0 - if (TG(hc)->authorization[0]) - php_register_variable("AUTH_TYPE", "Basic", track_vars_array TSRMLS_CC); -#endif -} - -static sapi_module_struct tux_sapi_module = { - "tux", - "tux", - - php_module_startup, - php_module_shutdown_wrapper, - - NULL, /* activate */ - NULL, /* deactivate */ - - sapi_tux_ub_write, - NULL, - NULL, /* get uid */ - NULL, /* getenv */ - - php_error, - - NULL, - sapi_tux_send_headers, - NULL, - sapi_tux_read_post, - sapi_tux_read_cookies, - - sapi_tux_register_variables, - NULL, /* Log message */ - - NULL, /* Block interruptions */ - NULL, /* Unblock interruptions */ - - STANDARD_SAPI_MODULE_PROPERTIES -}; - -static void tux_module_main(TSRMLS_D) -{ - zend_file_handle file_handle; - - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - if (php_request_startup(TSRMLS_C) == FAILURE) { - return; - } - - php_execute_script(&file_handle TSRMLS_CC); - php_request_shutdown(NULL); -} - -static void tux_request_ctor(TSRMLS_D) -{ - char buf[1024]; - int offset; - size_t filename_len; - size_t cwd_len; - smart_str s = {0}; - char *p; - - TG(header_vec) = NULL; - SG(request_info).query_string = strdup(TG(req)->query); - - smart_str_appends_ex(&s, "/", 1); - smart_str_appends_ex(&s, TG(req)->query, 1); - smart_str_0(&s); - p = strchr(s.c, '&'); - if (p) - *p = '\0'; - SG(request_info).path_translated = s.c; - - s.c = NULL; - smart_str_appendc_ex(&s, '/', 1); - smart_str_appends_ex(&s, TG(req)->objectname, 1); - smart_str_0(&s); - SG(request_info).request_uri = s.c; - SG(request_info).request_method = CGI_REQUEST_METHOD(TG(req)); - SG(sapi_headers).http_response_code = 200; - SG(request_info).content_type = TG(req)->content_type; - SG(request_info).content_length = 0; // TG(req)->contentlength; - -#if 0 - php_handle_auth_data(TG(hc)->authorization TSRMLS_CC); -#endif -} - -static void tux_request_dtor(TSRMLS_D) -{ - if (TG(header_vec)) - free(TG(header_vec)); - if (SG(request_info).query_string) - free(SG(request_info).query_string); - free(SG(request_info).request_uri); - free(SG(request_info).path_translated); -} - -#if 0 -static void *separate_thread(void *bla) -{ - int fd; - int i = 0; - - fd = (int) bla; - - while (i++ < 5) { - send(fd, "test<br>\n", 9, 0); - sleep(1); - } - - tux(TUX_ACTION_CONTINUE_REQ, (user_req_t *) fd); - /* We HAVE to trigger some event on the fd. Otherwise - fast_thread won't wake up, so that the eventloop - won't be entered -> TUX hangs */ - shutdown(fd, 2); - pthread_exit(NULL); -} -#endif - -int TUXAPI_handle_events(user_req_t *req) -{ - TSRMLS_FETCH(); - - if (req->event == PHP_TUX_BACKGROUND_CONN) { - tux_closed_conn(req->sock); - return tux(TUX_ACTION_FINISH_CLOSE_REQ, req); - } - - TG(req) = req; - TG(tux_action) = TUX_ACTION_FINISH_CLOSE_REQ; - - tux_request_ctor(TSRMLS_C); - - tux_module_main(TSRMLS_C); - - tux_request_dtor(TSRMLS_C); - - return tux(TG(tux_action), req); -} - -void tux_register_on_close(void (*arg)(int)) -{ - TG(on_close) = arg; -} - -void tux_closed_conn(int fd) -{ - TSRMLS_FETCH(); - - if (TG(on_close)) TG(on_close)(fd); -} - -int tux_get_fd(void) -{ - TSRMLS_FETCH(); - - return TG(req)->sock; -} - -void tux_set_dont_close(void) -{ - TSRMLS_FETCH(); - - TG(req)->event = PHP_TUX_BACKGROUND_CONN; - tux(TUX_ACTION_POSTPONE_REQ, TG(req)); - TG(tux_action) = TUX_ACTION_EVENTLOOP; -} - -void TUXAPI_init(void) -{ - sapi_startup(&tux_sapi_module); - tux_sapi_module.startup(&tux_sapi_module); - SG(server_context) = (void *) 1; -} - -void doesnotmatter_fini(void) -{ - if (SG(server_context) != NULL) { - tux_sapi_module.shutdown(&tux_sapi_module); - sapi_shutdown(); - } -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 - */ |