diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-03-18 11:28:21 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-03-18 11:28:21 +0100 |
commit | 038ba12e8724d537040e88ec794354b0c063f0a6 (patch) | |
tree | a7181b4f4d10e3a154522d4b96fdf42f4597bf2a /sapi | |
parent | fd5a0b31640419ca63d1ddeaffd6d3cf2a741814 (diff) | |
download | php-038ba12e8724d537040e88ec794354b0c063f0a6.tar.gz |
Imported Upstream version 5.3.6upstream/5.3.6
Diffstat (limited to 'sapi')
57 files changed, 1071 insertions, 707 deletions
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c index 7cc8cdd65..fda7364c7 100644 --- a/sapi/aolserver/aolserver.c +++ b/sapi/aolserver/aolserver.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -22,7 +22,7 @@ * - CGI/1.1 conformance */ -/* $Id: aolserver.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: aolserver.c 306939 2011-01-01 02:19:59Z felipe $ */ /* conflict between PHP and AOLserver headers */ #define Debug php_Debug @@ -205,7 +205,7 @@ static void php_info_aolserver(ZEND_MODULE_INFO_FUNC_ARGS) int i; php_info_print_table_start(); - php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c 293036 2010-01-03 09:23:27Z sebastian $"); + php_info_print_table_row(2, "SAPI module version", "$Id: aolserver.c 306939 2011-01-01 02:19:59Z felipe $"); 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()); diff --git a/sapi/apache/libpre.c b/sapi/apache/libpre.c index 15f7a10dd..033ea5461 100644 --- a/sapi/apache/libpre.c +++ b/sapi/apache/libpre.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: libpre.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: libpre.c 306939 2011-01-01 02:19:59Z felipe $ */ #ifdef NETWARE diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c index 70e49a752..ebcd69f7f 100644 --- a/sapi/apache/mod_php5.c +++ b/sapi/apache/mod_php5.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php5.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: mod_php5.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php_apache_http.h" #include "http_conf_globals.h" diff --git a/sapi/apache/mod_php5.h b/sapi/apache/mod_php5.h index adbb7831b..1360731f9 100644 --- a/sapi/apache/mod_php5.h +++ b/sapi/apache/mod_php5.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -15,7 +15,7 @@ | Author: Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php5.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: mod_php5.h 306939 2011-01-01 02:19:59Z felipe $ */ #ifndef MOD_PHP5_H #define MOD_PHP5_H diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index 8701bbf68..0f73b848c 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ | David Sklar <sklar@student.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_apache.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: php_apache.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php_apache_http.h" diff --git a/sapi/apache/php_apache_http.h b/sapi/apache/php_apache_http.h index 44d09275f..693d1b721 100644 --- a/sapi/apache/php_apache_http.h +++ b/sapi/apache/php_apache_http.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_apache_http.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_apache_http.h 306939 2011-01-01 02:19:59Z felipe $ */ #define NO_REGEX_EXTRA_H diff --git a/sapi/apache/sapi_apache.c b/sapi/apache/sapi_apache.c index 2447b8f2f..13827d648 100644 --- a/sapi/apache/sapi_apache.c +++ b/sapi/apache/sapi_apache.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -19,7 +19,7 @@ | Stig Bakken <ssb@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: sapi_apache.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: sapi_apache.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php_apache_http.h" diff --git a/sapi/apache2filter/apache_config.c b/sapi/apache2filter/apache_config.c index b9626cb62..3b53f010d 100644 --- a/sapi/apache2filter/apache_config.c +++ b/sapi/apache2filter/apache_config.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apache_config.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: apache_config.c 306939 2011-01-01 02:19:59Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h index 6ec8c3767..72eaa3f17 100644 --- a/sapi/apache2filter/php_apache.h +++ b/sapi/apache2filter/php_apache.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_apache.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_apache.h 306939 2011-01-01 02:19:59Z felipe $ */ #ifndef PHP_APACHE_H #define PHP_APACHE_H diff --git a/sapi/apache2filter/php_functions.c b/sapi/apache2filter/php_functions.c index 159e5c5c8..8b5ba8331 100644 --- a/sapi/apache2filter/php_functions.c +++ b/sapi/apache2filter/php_functions.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_functions.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_functions.c 306939 2011-01-01 02:19:59Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 08e42308e..f2c7a87d8 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: sapi_apache2.c 294571 2010-02-05 18:59:05Z rasmus $ */ +/* $Id: sapi_apache2.c 306939 2011-01-01 02:19:59Z felipe $ */ #include <fcntl.h> diff --git a/sapi/apache2handler/apache_config.c b/sapi/apache2handler/apache_config.c index 15e25b5fa..3e97b5957 100644 --- a/sapi/apache2handler/apache_config.c +++ b/sapi/apache2handler/apache_config.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: apache_config.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: apache_config.c 306939 2011-01-01 02:19:59Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS diff --git a/sapi/apache2handler/mod_php5.c b/sapi/apache2handler/mod_php5.c index 56ec28b2f..56bfdad35 100644 --- a/sapi/apache2handler/mod_php5.c +++ b/sapi/apache2handler/mod_php5.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_php5.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: mod_php5.c 306939 2011-01-01 02:19:59Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h index a7ad1cc86..2ee8bd896 100644 --- a/sapi/apache2handler/php_apache.h +++ b/sapi/apache2handler/php_apache.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_apache.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_apache.h 306939 2011-01-01 02:19:59Z felipe $ */ #ifndef PHP_APACHE_H #define PHP_APACHE_H diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index b54fe6aac..b7cc64054 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_functions.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: php_functions.c 306939 2011-01-01 02:19:59Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 63a8a47f5..18f21247a 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: sapi_apache2.c 298951 2010-05-04 09:51:03Z pajoye $ */ +/* $Id: sapi_apache2.c 306939 2011-01-01 02:19:59Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c index 95e1d0ac8..79a733b4b 100644 --- a/sapi/apache_hooks/mod_php5.c +++ b/sapi/apache_hooks/mod_php5.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ | PHP 4.0 patches by Zeev Suraski <zeev@zend.com> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php5.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: mod_php5.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php_apache_http.h" diff --git a/sapi/apache_hooks/mod_php5.h b/sapi/apache_hooks/mod_php5.h index 229ba3e81..08ec4eb41 100644 --- a/sapi/apache_hooks/mod_php5.h +++ b/sapi/apache_hooks/mod_php5.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -15,7 +15,7 @@ | Author: Rasmus Lerdorf <rasmus@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: mod_php5.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: mod_php5.h 306939 2011-01-01 02:19:59Z felipe $ */ #ifndef MOD_PHP5_H #define MOD_PHP5_H diff --git a/sapi/apache_hooks/php_apache.c b/sapi/apache_hooks/php_apache.c index ce1e26975..8be927699 100644 --- a/sapi/apache_hooks/php_apache.c +++ b/sapi/apache_hooks/php_apache.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ | David Sklar <sklar@student.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_apache.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: php_apache.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php_apache_http.h" diff --git a/sapi/apache_hooks/sapi_apache.c b/sapi/apache_hooks/sapi_apache.c index 7612a1878..f1b948be9 100644 --- a/sapi/apache_hooks/sapi_apache.c +++ b/sapi/apache_hooks/sapi_apache.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -19,7 +19,7 @@ | Stig Bakken <ssb@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: sapi_apache.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: sapi_apache.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php_apache_http.h" diff --git a/sapi/caudium/caudium.c b/sapi/caudium/caudium.c index 4b59c5781..e0c4847f3 100644 --- a/sapi/caudium/caudium.c +++ b/sapi/caudium/caudium.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: caudium.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: caudium.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" #ifdef HAVE_CAUDIUM @@ -444,7 +444,7 @@ 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: caudium.c 293036 2010-01-03 09:23:27Z sebastian $"); + php_info_print_table_row(2, "SAPI module version", "$Id: caudium.c 306939 2011-01-01 02:19:59Z felipe $"); /* 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()); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 0a9432464..1ecbcb142 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cgi_main.c 300854 2010-06-29 11:37:13Z felipe $ */ +/* $Id: cgi_main.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" #include "php_globals.h" @@ -1930,9 +1930,9 @@ consult the installation file that came with this distribution, or visit \n\ SG(request_info).no_headers = 1; } #if ZEND_DEBUG - php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif php_request_shutdown((void *) 0); fcgi_shutdown(); diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c index 304b1d01a..c6f96f3e2 100644 --- a/sapi/cgi/fastcgi.c +++ b/sapi/cgi/fastcgi.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fastcgi.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: fastcgi.c 307579 2011-01-19 08:38:25Z dmitry $ */ #include "php.h" #include "fastcgi.h" @@ -605,28 +605,39 @@ static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *e { char buf[128]; char *tmp = buf; - int buf_size = sizeof(buf); - int name_len, val_len; + size_t buf_size = sizeof(buf); + unsigned int name_len, val_len; char *s; int ret = 1; while (p < end) { name_len = *p++; if (name_len >= 128) { + if (p + 3 >= end) { + ret = 0; + break; + } name_len = ((name_len & 0x7f) << 24); name_len |= (*p++ << 16); name_len |= (*p++ << 8); name_len |= *p++; } + if (p >= end) { + ret = 0; + break; + } val_len = *p++; if (val_len >= 128) { + if (p + 3 >= end) { + ret = 0; + break; + } val_len = ((val_len & 0x7f) << 24); val_len |= (*p++ << 16); val_len |= (*p++ << 8); val_len |= *p++; } - if (name_len + val_len < 0 || - name_len + val_len > end - p) { + if (name_len + val_len > end - p) { /* Malformated request */ ret = 0; break; diff --git a/sapi/cgi/fastcgi.h b/sapi/cgi/fastcgi.h index 76217379b..226b68f3e 100644 --- a/sapi/cgi/fastcgi.h +++ b/sapi/cgi/fastcgi.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fastcgi.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: fastcgi.h 306939 2011-01-01 02:19:59Z felipe $ */ /* FastCGI protocol */ diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index dced2630d..1d0a0ed1a 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli.c 303357 2010-09-14 10:36:21Z pajoye $ */ +/* $Id: php_cli.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" #include "php_globals.h" @@ -832,7 +832,7 @@ int main(int argc, char *argv[]) } request_started = 1; - php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2010 The PHP Group\n%s", + php_printf("PHP %s (%s) (built: %s %s) %s\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, #if ZEND_DEBUG && defined(HAVE_GCOV) "(DEBUG GCOV)", diff --git a/sapi/cli/php_cli_readline.c b/sapi/cli/php_cli_readline.c index f76f94885..4b601ee55 100644 --- a/sapi/cli/php_cli_readline.c +++ b/sapi/cli/php_cli_readline.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli_readline.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_cli_readline.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" diff --git a/sapi/cli/php_cli_readline.h b/sapi/cli/php_cli_readline.h index ce68321bc..93d869603 100644 --- a/sapi/cli/php_cli_readline.h +++ b/sapi/cli/php_cli_readline.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_cli_readline.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_cli_readline.h 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" diff --git a/sapi/continuity/capi.c b/sapi/continuity/capi.c index 9e9421112..720727bb7 100644 --- a/sapi/continuity/capi.c +++ b/sapi/continuity/capi.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -110,7 +110,7 @@ PHP_MSHUTDOWN_FUNCTION(continuity) PHP_MINFO_FUNCTION(continuity) { php_info_print_table_start(); - php_info_print_table_row(2, "Continuity Module Revision", "$Revision: 293036 $"); + php_info_print_table_row(2, "Continuity Module Revision", "$Revision: 306939 $"); php_info_print_table_row(2, "Server Version", conFget_build()); #ifdef CONTINUITY_CDPEXT php_info_print_table_row(2,"CDP Extensions", "enabled"); diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c index 85040b19f..563d3e10c 100644 --- a/sapi/embed/php_embed.c +++ b/sapi/embed/php_embed.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -15,7 +15,7 @@ | Author: Edin Kadribasic <edink@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_embed.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_embed.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php_embed.h" #include "ext/standard/php_standard.h" diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h index 983b1aaad..c5e731d5e 100644 --- a/sapi/embed/php_embed.h +++ b/sapi/embed/php_embed.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -15,7 +15,7 @@ | Author: Edin Kadribasic <edink@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_embed.h 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php_embed.h 306939 2011-01-01 02:19:59Z felipe $ */ #ifndef _PHP_EMBED_H_ #define _PHP_EMBED_H_ diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index d96fcfcea..a1644ed12 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <stdarg.h> #include <errno.h> +#include <limits.h> #ifdef FPM_AUTOCONFIG_H #include <fpm_autoconfig.h> @@ -402,44 +403,113 @@ static inline int fcgi_make_header(fcgi_header *hdr, fcgi_request_type type, int return pad; } +static inline size_t fcgi_get_params_len( int *result, unsigned char *p, unsigned char *end) +{ + size_t ret = 0; + + if (p < end) { + *result = p[0]; + if (*result < 128) { + ret = 1; + } + else if (p + 3 < end) { + *result = ((*result & 0x7f) << 24); + *result |= (p[1] << 16); + *result |= (p[2] << 8); + *result |= p[3]; + ret = 4; + } + } + if (*result < 0) { + ret = 0; + } + return ret; +} + +static inline int fcgi_param_get_eff_len( unsigned char *p, unsigned char *end, uint *eff_len) +{ + int ret = 1; + int zero_found = 0; + *eff_len = 0; + for (; p != end; ++p) { + if (*p == '\0') { + zero_found = 1; + } + else { + if (zero_found) { + ret = 0; + break; + } + if (*eff_len < ((uint)-1)) { + ++*eff_len; + } + else { + ret = 0; + break; + } + } + } + return ret; +} + static int fcgi_get_params(fcgi_request *req, unsigned char *p, unsigned char *end) { char buf[128]; char *tmp = buf; - int buf_size = sizeof(buf); + size_t buf_size = sizeof(buf); int name_len, val_len; + uint eff_name_len, eff_val_len; char *s; int ret = 1; + size_t bytes_consumed; while (p < end) { - name_len = *p++; - if (name_len >= 128) { - name_len = ((name_len & 0x7f) << 24); - name_len |= (*p++ << 16); - name_len |= (*p++ << 8); - name_len |= *p++; + bytes_consumed = fcgi_get_params_len(&name_len, p, end); + if (!bytes_consumed) { + /* Malformated request */ + ret = 0; + break; } - val_len = *p++; - if (val_len >= 128) { - val_len = ((val_len & 0x7f) << 24); - val_len |= (*p++ << 16); - val_len |= (*p++ << 8); - val_len |= *p++; + p += bytes_consumed; + bytes_consumed = fcgi_get_params_len(&val_len, p, end); + if (!bytes_consumed) { + /* Malformated request */ + ret = 0; + break; } - if (name_len + val_len < 0 || - name_len + val_len > end - p) { + p += bytes_consumed; + if (name_len > (INT_MAX - val_len) || /* would the addition overflow? */ + name_len + val_len > end - p) { /* would we exceed the buffer? */ /* Malformated request */ ret = 0; break; } - if (name_len+1 >= buf_size) { - buf_size = name_len + 64; + if (!fcgi_param_get_eff_len(p, p+name_len, &eff_name_len) || + !fcgi_param_get_eff_len(p+name_len, p+name_len+val_len, &eff_val_len)) { + /* Malicious request */ + ret = 0; + break; + } + if (eff_name_len >= buf_size-1) { + if (eff_name_len > ((uint)-1)-64) { + ret = 0; + break; + } + buf_size = eff_name_len + 64; tmp = (tmp == buf ? emalloc(buf_size): erealloc(tmp, buf_size)); + if (tmp == NULL) { + ret = 0; + break; + } + } + memcpy(tmp, p, eff_name_len); + tmp[eff_name_len] = 0; + s = estrndup((char*)p + name_len, eff_val_len); + if (s == NULL) { + ret = 0; + break; } - memcpy(tmp, p, name_len); - tmp[name_len] = 0; - s = estrndup((char*)p + name_len, val_len); - zend_hash_update(req->env, tmp, name_len+1, &s, sizeof(char*), NULL); + zend_hash_update(req->env, tmp, eff_name_len+1, &s, sizeof(char*), NULL); p += name_len + val_len; } if (tmp != buf && tmp != NULL) { diff --git a/sapi/fpm/fpm/fpm.c b/sapi/fpm/fpm/fpm.c index 17a215c88..0cfaabd41 100644 --- a/sapi/fpm/fpm/fpm.c +++ b/sapi/fpm/fpm/fpm.c @@ -21,7 +21,20 @@ #include "fpm_stdio.h" #include "zlog.h" -struct fpm_globals_s fpm_globals; +struct fpm_globals_s fpm_globals = { + .parent_pid = 0, + .argc = 0, + .argv = NULL, + .config = NULL, + .prefix = NULL, + .running_children = 0, + .error_log_fd = 0, + .log_level = 0, + .listening_socket = 0, + .max_requests = 0, + .is_child = 0, + .test_successful = 0 + }; int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf) /* {{{ */ { @@ -43,7 +56,12 @@ int fpm_init(int argc, char **argv, char *config, char *prefix, int test_conf) / 0 > fpm_sockets_init_main() || 0 > fpm_worker_pool_init_main() || 0 > fpm_event_init_main()) { - return -1; + + if (fpm_globals.test_successful) { + exit(0); + } else { + return -1; + } } if (0 > fpm_conf_write_pid()) { diff --git a/sapi/fpm/fpm/fpm.h b/sapi/fpm/fpm/fpm.h index 63e3bacca..f06d9ed6a 100644 --- a/sapi/fpm/fpm/fpm.h +++ b/sapi/fpm/fpm/fpm.h @@ -22,6 +22,7 @@ struct fpm_globals_s { int listening_socket; /* for this child */ int max_requests; /* for this child */ int is_child; + int test_successful; }; extern struct fpm_globals_s fpm_globals; diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index f38227c2f..5d6fe770c 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -1218,6 +1218,7 @@ int fpm_conf_init_main(int test_conf) /* {{{ */ fpm_conf_dump(); } zlog(ZLOG_NOTICE, "configuration file %s test is successful\n", fpm_globals.config); + fpm_globals.test_successful = 1; return -1; } diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 8f0d76007..13d21ecc3 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -1085,6 +1085,7 @@ static void init_request_info(TSRMLS_D) char *env_path_translated = sapi_cgibin_getenv("PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1 TSRMLS_CC); char *script_path_translated = env_script_filename; char *ini; + int apache_was_here = 0; /* some broken servers do not have script_filename or argv0 * an example, IIS configured in some ways. then they do more @@ -1130,6 +1131,30 @@ static void init_request_info(TSRMLS_D) env_path_info = _sapi_cgibin_putenv("PATH_INFO", env_path_info TSRMLS_CC); } +#define APACHE_PROXY_FCGI_PREFIX "proxy:fcgi://" + /* Fix proxy URLs in SCRIPT_FILENAME generated by Apache mod_proxy_fcgi: + * proxy:fcgi://localhost:9000/some-dir/info.php/test + * should be changed to: + * /some-dir/info.php/test + * See: http://bugs.php.net/bug.php?id=54152 + * https://issues.apache.org/bugzilla/show_bug.cgi?id=50851 + */ + if (env_script_filename && + strncasecmp(env_script_filename, APACHE_PROXY_FCGI_PREFIX, sizeof(APACHE_PROXY_FCGI_PREFIX) - 1) == 0) { + /* advance to first character of hostname */ + char *p = env_script_filename + (sizeof(APACHE_PROXY_FCGI_PREFIX) - 1); + while (*p != '\0' && *p != '/') { + p++; /* move past hostname and port */ + } + if (*p != '\0') { + /* Copy path portion in place to avoid memory leak. Note + * that this also affects what script_path_translated points + * to. */ + memmove(env_script_filename, p, strlen(p) + 1); + apache_was_here = 1; + } + } + if (CGIG(fix_pathinfo)) { struct stat st; char *real_path = NULL; @@ -1201,11 +1226,21 @@ static void init_request_info(TSRMLS_D) * we have to play the game of hide and seek to figure * out what SCRIPT_NAME should be */ - int slen = len - strlen(pt); + int ptlen = strlen(pt); + int slen = len - ptlen; int pilen = env_path_info ? strlen(env_path_info) : 0; - char *path_info = env_path_info ? env_path_info + pilen - slen : NULL; + int tflag = 0; + char *path_info; + if (apache_was_here) { + /* recall that PATH_INFO won't exist */ + path_info = script_path_translated + ptlen; + tflag = (slen != 0 && (!orig_path_info || strcmp(orig_path_info, path_info) != 0)); + } else { + path_info = env_path_info ? env_path_info + pilen - slen : NULL; + tflag = (orig_path_info != path_info); + } - if (orig_path_info != path_info) { + if (tflag) { if (orig_path_info) { char old; @@ -1729,6 +1764,7 @@ int main(int argc, char *argv[]) SG(request_info).path_translated = NULL; #endif + cgi_sapi_module.additional_functions = additional_functions; cgi_sapi_module.executable_location = argv[0]; /* startup after we get the above ini override se we get things right */ diff --git a/sapi/fpm/fpm/fpm_php.c b/sapi/fpm/fpm/fpm_php.c index eeba71301..384682b7e 100644 --- a/sapi/fpm/fpm/fpm_php.c +++ b/sapi/fpm/fpm/fpm_php.c @@ -160,6 +160,12 @@ char *fpm_php_script_filename(TSRMLS_D) /* {{{ */ } /* }}} */ +char *fpm_php_request_uri(TSRMLS_D) /* {{{ */ +{ + return (char *) SG(request_info).request_uri; +} +/* }}} */ + char *fpm_php_request_method(TSRMLS_D) /* {{{ */ { return (char *) SG(request_info).request_method; diff --git a/sapi/fpm/fpm/fpm_php.h b/sapi/fpm/fpm/fpm_php.h index 81e533267..891e83bfc 100644 --- a/sapi/fpm/fpm/fpm_php.h +++ b/sapi/fpm/fpm/fpm_php.h @@ -35,6 +35,7 @@ struct fpm_worker_pool_s; int fpm_php_init_child(struct fpm_worker_pool_s *wp); char *fpm_php_script_filename(TSRMLS_D); +char *fpm_php_request_uri(TSRMLS_D); char *fpm_php_request_method(TSRMLS_D); size_t fpm_php_content_length(TSRMLS_D); void fpm_php_soft_quit(); diff --git a/sapi/fpm/fpm/fpm_request.c b/sapi/fpm/fpm/fpm_request.c index 590548e57..6ba9e5170 100644 --- a/sapi/fpm/fpm/fpm_request.c +++ b/sapi/fpm/fpm/fpm_request.c @@ -26,6 +26,7 @@ void fpm_request_accepting() /* {{{ */ slot = fpm_shm_slots_acquire(0, 0); slot->request_stage = FPM_REQUEST_ACCEPTING; fpm_clock_get(&slot->tv); + memset(slot->request_uri, 0, sizeof(slot->request_uri)); memset(slot->request_method, 0, sizeof(slot->request_method)); slot->content_length = 0; memset(slot->script_filename, 0, sizeof(slot->script_filename)); @@ -51,6 +52,7 @@ void fpm_request_info() /* {{{ */ { TSRMLS_FETCH(); struct fpm_shm_slot_s *slot; + char *request_uri = fpm_php_request_uri(TSRMLS_C); char *request_method = fpm_php_request_method(TSRMLS_C); char *script_filename = fpm_php_script_filename(TSRMLS_C); @@ -58,8 +60,12 @@ void fpm_request_info() /* {{{ */ slot->request_stage = FPM_REQUEST_INFO; fpm_clock_get(&slot->tv); + if (request_uri) { + strlcpy(slot->request_uri, request_uri, sizeof(slot->request_uri)); + } + if (request_method) { - cpystrn(slot->request_method, request_method, sizeof(slot->request_method)); + strlcpy(slot->request_method, request_method, sizeof(slot->request_method)); } slot->content_length = fpm_php_content_length(TSRMLS_C); @@ -67,7 +73,7 @@ void fpm_request_info() /* {{{ */ /* if cgi.fix_pathinfo is set to "1" and script cannot be found (404) the sapi_globals.request_info.path_translated is set to NULL */ if (script_filename) { - cpystrn(slot->script_filename, script_filename, sizeof(slot->script_filename)); + strlcpy(slot->script_filename, script_filename, sizeof(slot->script_filename)); } fpm_shm_slots_release(slot); @@ -136,8 +142,9 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now, fpm_trace_signal(child->pid); - zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' executing too slow (%d.%06d sec), logging", - child->wp->config->name, (int) child->pid, purified_script_filename, (int) tv.tv_sec, (int) tv.tv_usec); + zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' (request: \"%s %s\") executing too slow (%d.%06d sec), logging", + child->wp->config->name, (int) child->pid, purified_script_filename, slot_c.request_method, slot_c.request_uri, + (int) tv.tv_sec, (int) tv.tv_usec); } else #endif @@ -145,8 +152,9 @@ void fpm_request_check_timed_out(struct fpm_child_s *child, struct timeval *now, str_purify_filename(purified_script_filename, slot_c.script_filename, sizeof(slot_c.script_filename)); fpm_pctl_kill(child->pid, FPM_PCTL_TERM); - zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' execution timed out (%d.%06d sec), terminating", - child->wp->config->name, (int) child->pid, purified_script_filename, (int) tv.tv_sec, (int) tv.tv_usec); + zlog(ZLOG_WARNING, "[pool %s] child %d, script '%s' (request: \"%s %s\") execution timed out (%d.%06d sec), terminating", + child->wp->config->name, (int) child->pid, purified_script_filename, slot_c.request_method, slot_c.request_uri, + (int) tv.tv_sec, (int) tv.tv_usec); } } } diff --git a/sapi/fpm/fpm/fpm_shm_slots.h b/sapi/fpm/fpm/fpm_shm_slots.h index 4596c6fad..d74f17622 100644 --- a/sapi/fpm/fpm/fpm_shm_slots.h +++ b/sapi/fpm/fpm/fpm_shm_slots.h @@ -19,6 +19,7 @@ struct fpm_shm_slot_s { enum fpm_request_stage_e request_stage; struct timeval accepted; struct timeval tv; + char request_uri[128]; char request_method[16]; size_t content_length; /* used with POST only */ char script_filename[256]; diff --git a/sapi/fpm/fpm/fpm_sockets.c b/sapi/fpm/fpm/fpm_sockets.c index baa9f9803..d89315026 100644 --- a/sapi/fpm/fpm/fpm_sockets.c +++ b/sapi/fpm/fpm/fpm_sockets.c @@ -286,7 +286,7 @@ static int fpm_socket_af_unix_listening_socket(struct fpm_worker_pool_s *wp) /* struct sockaddr_un sa_un; memset(&sa_un, 0, sizeof(sa_un)); - cpystrn(sa_un.sun_path, wp->config->listen_address, sizeof(sa_un.sun_path)); + strlcpy(sa_un.sun_path, wp->config->listen_address, sizeof(sa_un.sun_path)); sa_un.sun_family = AF_UNIX; return fpm_sockets_get_listening_socket(wp, (struct sockaddr *) &sa_un, sizeof(struct sockaddr_un)); } diff --git a/sapi/fpm/fpm/fpm_str.h b/sapi/fpm/fpm/fpm_str.h index 2755dc50a..65db5455a 100644 --- a/sapi/fpm/fpm/fpm_str.h +++ b/sapi/fpm/fpm/fpm_str.h @@ -5,29 +5,6 @@ #ifndef FPM_STR_H #define FPM_STR_H 1 -static inline char *cpystrn(char *dst, const char *src, size_t dst_size) /* {{{ */ -{ - char *d, *end; - - if (!dst_size) { - return dst; - } - - d = dst; - end = dst + dst_size - 1; - - for (; d < end; ++d, ++src) { - if (!(*d = *src)) { - return d; - } - } - - *d = '\0'; - - return d; -} -/* }}} */ - static inline char *str_purify_filename(char *dst, char *src, size_t size) /* {{{ */ { char *d, *end; diff --git a/sapi/fpm/fpm/zlog.c b/sapi/fpm/fpm/zlog.c index b99ad850d..ddf552b50 100644 --- a/sapi/fpm/fpm/zlog.c +++ b/sapi/fpm/fpm/zlog.c @@ -43,8 +43,11 @@ size_t zlog_print_time(struct timeval *tv, char *timebuf, size_t timebuf_len) /* struct tm t; size_t len; - len = strftime(timebuf, timebuf_len, "%b %d %H:%M:%S", localtime_r((const time_t *) &tv->tv_sec, &t)); - len += snprintf(timebuf + len, timebuf_len - len, ".%06d", (int) tv->tv_usec); + len = strftime(timebuf, timebuf_len, "[%d-%b-%Y %H:%M:%S", localtime_r((const time_t *) &tv->tv_sec, &t)); + if (zlog_level == ZLOG_DEBUG) { + len += snprintf(timebuf + len, timebuf_len - len, ".%06d", (int) tv->tv_usec); + } + len += snprintf(timebuf + len, timebuf_len - len, "]"); return len; } /* }}} */ @@ -87,9 +90,9 @@ void zlog_ex(const char *function, int line, int flags, const char *fmt, ...) /* gettimeofday(&tv, 0); len = zlog_print_time(&tv, buf, buf_size); if (zlog_level == ZLOG_DEBUG) { - len += snprintf(buf + len, buf_size - len, " [%s] pid %d, %s(), line %d: ", level_names[flags & ZLOG_LEVEL_MASK], getpid(), function, line); + len += snprintf(buf + len, buf_size - len, " %s: pid %d, %s(), line %d: ", level_names[flags & ZLOG_LEVEL_MASK], getpid(), function, line); } else { - len += snprintf(buf + len, buf_size - len, " [%s] ", level_names[flags & ZLOG_LEVEL_MASK]); + len += snprintf(buf + len, buf_size - len, " %s: ", level_names[flags & ZLOG_LEVEL_MASK]); } if (len > buf_size - 1) { diff --git a/sapi/isapi/php5isapi.c b/sapi/isapi/php5isapi.c index 60e37b9c6..b013ba286 100644 --- a/sapi/isapi/php5isapi.c +++ b/sapi/isapi/php5isapi.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ | Ben Mansell <ben@zeus.com> (Zeus Support) | +----------------------------------------------------------------------+ */ -/* $Id: php5isapi.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: php5isapi.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" #include <httpext.h> diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 6058e5b60..f828b1fc3 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: lsapi_main.c 300764 2010-06-26 16:03:39Z felipe $ */ +/* $Id: lsapi_main.c 306212 2010-12-10 22:51:08Z gwang $ */ #include "php.h" #include "SAPI.h" @@ -75,7 +75,8 @@ static int lsapi_mode = 1; static char *php_self = ""; static char *script_filename = ""; static int source_highlight = 0; - +static char * argv0 = NULL; +static int engine = 1; #ifdef ZTS zend_compiler_globals *compiler_globals; zend_executor_globals *executor_globals; @@ -90,40 +91,65 @@ zend_module_entry litespeed_module_entry; */ static int php_lsapi_startup(sapi_module_struct *sapi_module) { - if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { - return FAILURE; - } - return SUCCESS; + if (php_module_startup(sapi_module, NULL, 0)==FAILURE) { + return FAILURE; + } + argv0 = sapi_module->executable_location; + return SUCCESS; } /* }}} */ +/* {{{ sapi_lsapi_ini_defaults */ + +/* overwriteable ini defaults must be set in sapi_cli_ini_defaults() */ +#define INI_DEFAULT(name,value)\ + ZVAL_STRING(tmp, value, 0);\ + zend_hash_update(configuration_hash, name, sizeof(name), tmp, sizeof(zval), (void**)&entry);\ + Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry)) + +static void sapi_lsapi_ini_defaults(HashTable *configuration_hash) +{ + zval *tmp, *entry; + +#if PHP_MAJOR_VERSION > 4 +/* + MAKE_STD_ZVAL(tmp); + + INI_DEFAULT("register_long_arrays", "0"); + + FREE_ZVAL(tmp); +*/ +#endif + +} +/* }}} */ /* {{{ sapi_lsapi_ub_write */ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC) { - int ret; - int remain; - if ( lsapi_mode ) { - ret = LSAPI_Write( str, str_length ); - if ( ret < str_length ) { - php_handle_aborted_connection(); - return str_length - ret; - } - } else { - remain = str_length; - while( remain > 0 ) { - ret = write( 1, str, remain ); - if ( ret <= 0 ) { - php_handle_aborted_connection(); - return str_length - remain; - } - str += ret; - remain -= ret; - } - } - return str_length; + int ret; + int remain; + if ( lsapi_mode ) { + ret = LSAPI_Write( str, str_length ); + if ( ret < str_length ) { + php_handle_aborted_connection(); + return str_length - ret; + } + } else { + remain = str_length; + while( remain > 0 ) { + ret = write( 1, str, remain ); + if ( ret <= 0 ) { + php_handle_aborted_connection(); + return str_length - remain; + } + str += ret; + remain -= ret; + } + } + return str_length; } /* }}} */ @@ -132,11 +158,11 @@ static int sapi_lsapi_ub_write(const char *str, uint str_length TSRMLS_DC) */ static void sapi_lsapi_flush( void * server_context ) { - if ( lsapi_mode ) { - if ( LSAPI_Flush() == -1) { - php_handle_aborted_connection(); - } - } + if ( lsapi_mode ) { + if ( LSAPI_Flush() == -1) { + php_handle_aborted_connection(); + } + } } /* }}} */ @@ -145,8 +171,12 @@ static void sapi_lsapi_flush( void * server_context ) */ static int sapi_lsapi_deactivate(TSRMLS_D) { - LSAPI_Finish(); - return SUCCESS; + if ( SG(request_info).path_translated ) + { + efree( SG(request_info).path_translated ); + } + + return SUCCESS; } /* }}} */ @@ -157,46 +187,92 @@ static int sapi_lsapi_deactivate(TSRMLS_D) */ static char *sapi_lsapi_getenv( char * name, size_t name_len TSRMLS_DC ) { - if ( lsapi_mode ) { - return LSAPI_GetEnv( name ); - } else { - return getenv( name ); - } + if ( lsapi_mode ) { + return LSAPI_GetEnv( name ); + } else { + return getenv( name ); + } } /* }}} */ +/* +static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, + void * arg ) +{ + php_register_variable_safe((char *)pKey, (char *)pValue, valLen, (zval *)arg TSRMLS_CC); + return 1; +} +*/ static int add_variable( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) + void * arg ) { - php_register_variable_safe((char *)pKey, (char *)pValue, valLen, (zval *)arg TSRMLS_CC); - return 1; + zval * gpc_element, **gpc_element_p; + HashTable * symtable1 = Z_ARRVAL_P((zval * )arg); + register char * pKey1 = (char *)pKey; + + MAKE_STD_ZVAL(gpc_element); + Z_STRLEN_P( gpc_element ) = valLen; + Z_STRVAL_P( gpc_element ) = estrndup(pValue, valLen); + Z_TYPE_P( gpc_element ) = IS_STRING; +#if PHP_MAJOR_VERSION > 4 + zend_symtable_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); +#else + zend_hash_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); +#endif + return 1; } +static int add_variable_magic_quote( const char * pKey, int keyLen, const char * pValue, int valLen, + void * arg ) +{ + zval * gpc_element, **gpc_element_p; + HashTable * symtable1 = Z_ARRVAL_P((zval * )arg); + register char * pKey1 = (char *)pKey; + + MAKE_STD_ZVAL(gpc_element); + Z_STRLEN_P( gpc_element ) = valLen; + Z_STRVAL_P( gpc_element ) = php_addslashes((char *)pValue, valLen, &Z_STRLEN_P( gpc_element ), 0 ); + Z_TYPE_P( gpc_element ) = IS_STRING; +#if PHP_MAJOR_VERSION > 4 + zend_symtable_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); +#else + zend_hash_update( symtable1, pKey1, keyLen + 1, &gpc_element, sizeof( zval *), (void **) &gpc_element_p ); +#endif + return 1; +} /* {{{ sapi_lsapi_register_variables */ static void sapi_lsapi_register_variables(zval *track_vars_array TSRMLS_DC) { - - if ( lsapi_mode ) { - LSAPI_ForeachHeader( add_variable, track_vars_array ); - LSAPI_ForeachEnv( add_variable, track_vars_array ); - php_import_environment_variables(track_vars_array TSRMLS_CC); - - php_register_variable("PHP_SELF", (SG(request_info).request_uri ? SG(request_info).request_uri:""), track_vars_array TSRMLS_CC); - } else { - php_import_environment_variables(track_vars_array TSRMLS_CC); - - php_register_variable("PHP_SELF", php_self, track_vars_array TSRMLS_CC); - php_register_variable("SCRIPT_NAME", php_self, track_vars_array TSRMLS_CC); - php_register_variable("SCRIPT_FILENAME", script_filename, track_vars_array TSRMLS_CC); - php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array TSRMLS_CC); - php_register_variable("DOCUMENT_ROOT", "", track_vars_array TSRMLS_CC); - - } + char * php_self = ""; + if ( lsapi_mode ) { + if ( (SG(request_info).request_uri ) ) + php_self = (SG(request_info).request_uri ); + + if (!PG(magic_quotes_gpc)) { + LSAPI_ForeachHeader( add_variable, track_vars_array ); + LSAPI_ForeachEnv( add_variable, track_vars_array ); + add_variable("PHP_SELF", 8, php_self, strlen( php_self ), track_vars_array ); + } else { + LSAPI_ForeachHeader( add_variable_magic_quote, track_vars_array ); + LSAPI_ForeachEnv( add_variable_magic_quote, track_vars_array ); + add_variable_magic_quote("PHP_SELF", 8, php_self, strlen( php_self ), track_vars_array ); + } + php_import_environment_variables(track_vars_array TSRMLS_CC); + } else { + php_import_environment_variables(track_vars_array TSRMLS_CC); + + php_register_variable("PHP_SELF", php_self, track_vars_array TSRMLS_CC); + php_register_variable("SCRIPT_NAME", php_self, track_vars_array TSRMLS_CC); + php_register_variable("SCRIPT_FILENAME", script_filename, track_vars_array TSRMLS_CC); + php_register_variable("PATH_TRANSLATED", script_filename, track_vars_array TSRMLS_CC); + php_register_variable("DOCUMENT_ROOT", "", track_vars_array TSRMLS_CC); + + } } /* }}} */ @@ -205,11 +281,11 @@ static void sapi_lsapi_register_variables(zval *track_vars_array TSRMLS_DC) */ static int sapi_lsapi_read_post(char *buffer, uint count_bytes TSRMLS_DC) { - if ( lsapi_mode ) { - return LSAPI_ReadReqBody( buffer, count_bytes ); - } else { - return 0; - } + if ( lsapi_mode ) { + return LSAPI_ReadReqBody( buffer, count_bytes ); + } else { + return 0; + } } /* }}} */ @@ -220,11 +296,11 @@ static int sapi_lsapi_read_post(char *buffer, uint count_bytes TSRMLS_DC) */ static char *sapi_lsapi_read_cookies(TSRMLS_D) { - if ( lsapi_mode ) { - return LSAPI_GetHeader( H_COOKIE ); - } else { - return NULL; - } + if ( lsapi_mode ) { + return LSAPI_GetHeader( H_COOKIE ); + } else { + return NULL; + } } /* }}} */ @@ -233,33 +309,33 @@ static char *sapi_lsapi_read_cookies(TSRMLS_D) */ static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) { - sapi_header_struct *h; - zend_llist_position pos; - if ( lsapi_mode ) { - LSAPI_SetRespStatus( SG(sapi_headers).http_response_code ); - - h = zend_llist_get_first_ex(&sapi_headers->headers, &pos); - while (h) { - if ( h->header_len > 0 ) { - LSAPI_AppendRespHeader(h->header, h->header_len); - } - h = zend_llist_get_next_ex(&sapi_headers->headers, &pos); - } - if (SG(sapi_headers).send_default_content_type) { - char *hd; - int len; - char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; - - hd = sapi_get_default_content_type(TSRMLS_C); - len = snprintf( headerBuf, SAPI_LSAPI_MAX_HEADER_LENGTH - 1, - "Content-type: %s", hd ); - efree(hd); - - LSAPI_AppendRespHeader( headerBuf, len ); - } - } - LSAPI_FinalizeRespHeaders(); - return SAPI_HEADER_SENT_SUCCESSFULLY; + sapi_header_struct *h; + zend_llist_position pos; + if ( lsapi_mode ) { + LSAPI_SetRespStatus( SG(sapi_headers).http_response_code ); + + h = zend_llist_get_first_ex(&sapi_headers->headers, &pos); + while (h) { + if ( h->header_len > 0 ) { + LSAPI_AppendRespHeader(h->header, h->header_len); + } + h = zend_llist_get_next_ex(&sapi_headers->headers, &pos); + } + if (SG(sapi_headers).send_default_content_type) { + char *hd; + int len; + char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; + + hd = sapi_get_default_content_type(TSRMLS_C); + len = snprintf( headerBuf, SAPI_LSAPI_MAX_HEADER_LENGTH - 1, + "Content-type: %s", hd ); + efree(hd); + + LSAPI_AppendRespHeader( headerBuf, len ); + } + } + LSAPI_FinalizeRespHeaders(); + return SAPI_HEADER_SENT_SUCCESSFULLY; } @@ -270,8 +346,8 @@ static int sapi_lsapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) */ static void sapi_lsapi_log_message(char *message) { - int len = strlen( message ); - LSAPI_Write_Stderr( message, len); + int len = strlen( message ); + LSAPI_Write_Stderr( message, len); } /* }}} */ @@ -280,158 +356,247 @@ static void sapi_lsapi_log_message(char *message) */ static sapi_module_struct lsapi_sapi_module = { - "litespeed", - "LiteSpeed", + "litespeed", + "LiteSpeed V5.5", - php_lsapi_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ + php_lsapi_startup, /* startup */ + php_module_shutdown_wrapper, /* shutdown */ - NULL, /* activate */ - sapi_lsapi_deactivate, /* deactivate */ + NULL, /* activate */ + sapi_lsapi_deactivate, /* deactivate */ - sapi_lsapi_ub_write, /* unbuffered write */ - sapi_lsapi_flush, /* flush */ - NULL, /* get uid */ - sapi_lsapi_getenv, /* getenv */ + sapi_lsapi_ub_write, /* unbuffered write */ + sapi_lsapi_flush, /* flush */ + NULL, /* get uid */ + sapi_lsapi_getenv, /* getenv */ - php_error, /* error handler */ + php_error, /* error handler */ - NULL, /* header handler */ - sapi_lsapi_send_headers, /* send headers handler */ - NULL, /* send header handler */ + NULL, /* header handler */ + sapi_lsapi_send_headers, /* send headers handler */ + NULL, /* send header handler */ - sapi_lsapi_read_post, /* read POST data */ - sapi_lsapi_read_cookies, /* read Cookies */ + sapi_lsapi_read_post, /* read POST data */ + sapi_lsapi_read_cookies, /* read Cookies */ - sapi_lsapi_register_variables, /* register server variables */ - sapi_lsapi_log_message, /* Log message */ + sapi_lsapi_register_variables, /* register server variables */ + sapi_lsapi_log_message, /* Log message */ - NULL, /* php.ini path override */ - NULL, /* block interruptions */ - NULL, /* unblock interruptions */ - NULL, /* default post reader */ - NULL, /* treat data */ - NULL, /* executable location */ + NULL, /* php.ini path override */ + NULL, /* block interruptions */ + NULL, /* unblock interruptions */ + NULL, /* default post reader */ + NULL, /* treat data */ + NULL, /* executable location */ - 0, /* php.ini ignore */ + 0, /* php.ini ignore */ - STANDARD_SAPI_MODULE_PROPERTIES + STANDARD_SAPI_MODULE_PROPERTIES }; /* }}} */ static int init_request_info( TSRMLS_D ) { - char * pContentType = LSAPI_GetHeader( H_CONTENT_TYPE ); - char * pAuth; - - SG(request_info).content_type = pContentType ? pContentType : ""; - SG(request_info).request_method = LSAPI_GetRequestMethod(); - SG(request_info).query_string = LSAPI_GetQueryString(); - SG(request_info).request_uri = LSAPI_GetScriptName(); - SG(request_info).content_length = LSAPI_GetReqBodyLen(); - SG(request_info).path_translated = LSAPI_GetScriptFileName(); + char * pContentType = LSAPI_GetHeader( H_CONTENT_TYPE ); + char * pAuth; + + SG(request_info).content_type = pContentType ? pContentType : ""; + SG(request_info).request_method = LSAPI_GetRequestMethod(); + SG(request_info).query_string = LSAPI_GetQueryString(); + SG(request_info).request_uri = LSAPI_GetScriptName(); + SG(request_info).content_length = LSAPI_GetReqBodyLen(); + SG(request_info).path_translated = estrdup( LSAPI_GetScriptFileName()); + + /* It is not reset by zend engine, set it to 0. */ + SG(sapi_headers).http_response_code = 0; + + pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); + php_handle_auth_data(pAuth TSRMLS_CC); +} + +static char s_cur_chdir[4096] = ""; - /* It is not reset by zend engine, set it to 0. */ - SG(sapi_headers).http_response_code = 0; - - pAuth = LSAPI_GetHeader( H_AUTHORIZATION ); - php_handle_auth_data(pAuth TSRMLS_CC); +static int lsapi_chdir_primary_script( zend_file_handle * file_handle ) +{ +#if PHP_MAJOR_VERSION > 4 + char * p; + char ch; + + SG(options) |= SAPI_OPTION_NO_CHDIR; + getcwd( s_cur_chdir, sizeof( s_cur_chdir ) ); + + p = strrchr( file_handle->filename, '/' ); + if ( *p ) + { + *p = 0; + if ( strcmp( file_handle->filename, s_cur_chdir ) != 0 ) { + chdir( file_handle->filename ); + } + *p++ = '/'; + ch = *p; + *p = 0; + if ( !CWDG(cwd).cwd || + ( strcmp( file_handle->filename, CWDG(cwd).cwd ) != 0 ) ) { + CWDG(cwd).cwd_length = p - file_handle->filename; + CWDG(cwd).cwd = (char *) realloc(CWDG(cwd).cwd, CWDG(cwd).cwd_length+1); + memmove( CWDG(cwd).cwd, file_handle->filename, CWDG(cwd).cwd_length+1 ); + } + *p = ch; + } + /* virtual_file_ex(&CWDG(cwd), file_handle->filename, NULL, CWD_REALPATH); */ +#else + VCWD_CHDIR_FILE( file_handle->filename ); +#endif + return 0; } -static int lsapi_module_main(int show_source TSRMLS_DC) +static int lsapi_fopen_primary_script( zend_file_handle * file_handle ) +{ + FILE * fp; + char * p; + fp = fopen( SG(request_info).path_translated, "rb" ); + if ( !fp ) + { + return -1; + } + file_handle->type = ZEND_HANDLE_FP; + file_handle->handle.fp = fp; + file_handle->filename = SG(request_info).path_translated; + file_handle->free_filename = 0; + file_handle->opened_path = NULL; + + lsapi_chdir_primary_script( file_handle ); + + return 0; +} + +static int lsapi_execute_script( zend_file_handle * file_handle TSRMLS_DC) { - zend_file_handle file_handle = {0}; + char *p; + int len; + file_handle->type = ZEND_HANDLE_FILENAME; + file_handle->handle.fd = 0; + file_handle->filename = SG(request_info).path_translated; + file_handle->free_filename = 0; + file_handle->opened_path = NULL; + + p = argv0; + *p++ = ':'; + len = strlen( SG(request_info).path_translated ); + if ( len > 45 ) + len = len - 45; + else + len = 0; + memccpy( p, SG(request_info).path_translated + len, 0, 46 ); + + php_execute_script(file_handle TSRMLS_CC); + return 0; - if (php_request_startup(TSRMLS_C) == FAILURE ) { - return -1; - } - if (show_source) { - zend_syntax_highlighter_ini syntax_highlighter_ini; +} - php_get_highlight_struct(&syntax_highlighter_ini); - highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); - } else { - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.handle.fd = 0; - file_handle.filename = SG(request_info).path_translated; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - php_execute_script(&file_handle TSRMLS_CC); - } - zend_try { - php_request_shutdown(NULL); - } zend_end_try(); - return 0; +static int lsapi_module_main(int show_source TSRMLS_DC) +{ + zend_file_handle file_handle = {0}; + + if (php_request_startup(TSRMLS_C) == FAILURE ) { + return -1; + } + if (show_source) { + zend_syntax_highlighter_ini syntax_highlighter_ini; + + php_get_highlight_struct(&syntax_highlighter_ini); + highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); + } else { + lsapi_execute_script( &file_handle TSRMLS_CC); + } + zend_try { + php_request_shutdown(NULL); + *argv0 = 0; + } zend_end_try(); + return 0; } static int alter_ini( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) + void * arg ) { - int type = ZEND_INI_PERDIR; - if ( '\001' == *pKey ) { - ++pKey; - if ( *pKey == 4 ) { - type = ZEND_INI_SYSTEM; - } - ++pKey; - --keyLen; - zend_alter_ini_entry((char *)pKey, keyLen, - (char *)pValue, valLen, - type, PHP_INI_STAGE_ACTIVATE); - } - return 1; + int type = ZEND_INI_PERDIR; + if ( '\001' == *pKey ) { + ++pKey; + if ( *pKey == 4 ) { + type = ZEND_INI_SYSTEM; + } + ++pKey; + --keyLen; + if (( keyLen == 7 )&&( strncasecmp( pKey, "engine", 6 )== 0 )) + { + if ( *pValue == '0' ) + engine = 0; + } + else + zend_alter_ini_entry((char *)pKey, keyLen, + (char *)pValue, valLen, + type, PHP_INI_STAGE_ACTIVATE); + } + return 1; } static void override_ini() { - LSAPI_ForeachSpecialEnv( alter_ini, NULL ); + LSAPI_ForeachSpecialEnv( alter_ini, NULL ); } static int processReq( TSRMLS_D ) { - int ret = 0; - zend_first_try { - /* avoid server_context==NULL checks */ - SG(server_context) = (void *) 1; - - init_request_info( TSRMLS_C ); - - override_ini(); - - if ( lsapi_module_main( source_highlight TSRMLS_CC ) == -1 ) { - ret = -1; - } - } zend_end_try(); - return ret; + int ret = 0; + zend_first_try { + /* avoid server_context==NULL checks */ + SG(server_context) = (void *) 1; + + engine = 1; + override_ini(); + + if ( engine ) { + init_request_info( TSRMLS_C ); + + if ( lsapi_module_main( source_highlight TSRMLS_CC ) == -1 ) { + ret = -1; + } + } else { + LSAPI_AppendRespHeader( "status: 403", 11 ); + LSAPI_AppendRespHeader( "content-type: text/html", 23 ); + LSAPI_Write( "Forbidden: PHP engine is disable.\n", 34 ); + } + } zend_end_try(); + return ret; } static void cli_usage( TSRMLS_D ) { - static const char * usage = - "Usage: php\n" - " php -[b|c|h|i|q|s|v|?] [<file>] [args...]\n" - " Run in LSAPI mode, only '-b', '-s' and '-c' are effective\n" - " Run in Command Line Interpreter mode when parameters are specified\n" - "\n" - " -b <address:port>|<port> Bind Path for external LSAPI Server mode\n" - " -c <path>|<file> Look for php.ini file in this directory\n" - " -h This help\n" - " -i PHP information\n" - " -q Quiet-mode. Suppress HTTP Header output.\n" - " -s Display colour syntax highlighted source.\n" - " -v Version number\n" - " -? This help\n" - "\n" - " args... Arguments passed to script.\n"; - php_output_startup(); - php_output_activate(TSRMLS_C); - php_printf( usage ); + static const char * usage = + "Usage: php\n" + " php -[b|c|h|i|q|s|v|?] [<file>] [args...]\n" + " Run in LSAPI mode, only '-b', '-s' and '-c' are effective\n" + " Run in Command Line Interpreter mode when parameters are specified\n" + "\n" + " -b <address:port>|<port> Bind Path for external LSAPI Server mode\n" + " -c <path>|<file> Look for php.ini file in this directory\n" + " -h This help\n" + " -i PHP information\n" + " -q Quiet-mode. Suppress HTTP Header output.\n" + " -s Display colour syntax highlighted source.\n" + " -v Version number\n" + " -? This help\n" + "\n" + " args... Arguments passed to script.\n"; + php_output_startup(); + php_output_activate(TSRMLS_C); + php_printf( usage ); #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); #else @@ -440,249 +605,249 @@ static void cli_usage( TSRMLS_D ) } static int parse_opt( int argc, char * argv[], int *climode, - char **php_ini_path, char ** php_bind ) -{ - char ** p = &argv[1]; - char ** argend= &argv[argc]; - int c; - while (( p < argend )&&(**p == '-' )) { - c = *((*p)+1); - ++p; - switch( c ) { - case 'b': - if ( p >= argend ) { - fprintf( stderr, "TCP or socket address must be specified following '-b' option.\n"); - return -1; - } - *php_bind = *p++; - break; - - case 'c': - if ( p >= argend ) { - fprintf( stderr, "<path> or <file> must be specified following '-c' option.\n"); - - return -1; - } - *php_ini_path = *p++; - break; - case 's': - source_highlight = 1; - break; - case 'h': - case 'i': - case 'q': - case 'v': - case '?': - default: - *climode = 1; - break; - } - } - if ( p - argv < argc ) { - *climode = 1; - } - return 0; + char **php_ini_path, char ** php_bind ) +{ + char ** p = &argv[1]; + char ** argend= &argv[argc]; + int c; + while (( p < argend )&&(**p == '-' )) { + c = *((*p)+1); + ++p; + switch( c ) { + case 'b': + if ( p >= argend ) { + fprintf( stderr, "TCP or socket address must be specified following '-b' option.\n"); + return -1; + } + *php_bind = *p++; + break; + + case 'c': + if ( p >= argend ) { + fprintf( stderr, "<path> or <file> must be specified following '-c' option.\n"); + + return -1; + } + *php_ini_path = *p++; + break; + case 's': + source_highlight = 1; + break; + case 'h': + case 'i': + case 'q': + case 'v': + case '?': + default: + *climode = 1; + break; + } + } + if ( p - argv < argc ) { + *climode = 1; + } + return 0; } static int cli_main( int argc, char * argv[] ) { - static const char * ini_defaults[] = { - "report_zend_debug", "0", - "display_errors", "1", - "register_argc_argv", "1", - "html_errors", "0", - "implicit_flush", "1", - "output_buffering", "0", - "max_execution_time", "0", - NULL - }; - - const char ** ini; - char ** p = &argv[1]; - char ** argend= &argv[argc]; - int ret = 0; - int c; - lsapi_mode = 0; /* enter CLI mode */ + static const char * ini_defaults[] = { + "report_zend_debug", "0", + "display_errors", "1", + "register_argc_argv", "1", + "html_errors", "0", + "implicit_flush", "1", + "output_buffering", "0", + "max_execution_time", "0", + NULL + }; + + const char ** ini; + char ** p = &argv[1]; + char ** argend= &argv[argc]; + int ret = 0; + int c; + lsapi_mode = 0; /* enter CLI mode */ #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 */ + _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 - zend_first_try { - SG(server_context) = (void *) 1; - - zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */ - CG(in_compilation) = 0; /* not initialized but needed for several options */ - EG(uninitialized_zval_ptr) = NULL; - - for( ini = ini_defaults; *ini; ini+=2 ) { - zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1, - (char *)*(ini+1), strlen( *(ini+1) ), - PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); - } - - while (( p < argend )&&(**p == '-' )) { - c = *((*p)+1); - ++p; - switch( c ) { - case 'q': - break; - case 'i': - if (php_request_startup(TSRMLS_C) != FAILURE) { - php_print_info(0xFFFFFFFF TSRMLS_CC); + zend_first_try { + SG(server_context) = (void *) 1; + + zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */ + CG(in_compilation) = 0; /* not initialized but needed for several options */ + EG(uninitialized_zval_ptr) = NULL; + + for( ini = ini_defaults; *ini; ini+=2 ) { + zend_alter_ini_entry( (char *)*ini, strlen( *ini )+1, + (char *)*(ini+1), strlen( *(ini+1) ), + PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE); + } + + while (( p < argend )&&(**p == '-' )) { + c = *((*p)+1); + ++p; + switch( c ) { + case 'q': + break; + case 'i': + if (php_request_startup(TSRMLS_C) != FAILURE) { + php_print_info(0xFFFFFFFF TSRMLS_CC); #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); #else php_end_ob_buffers(1 TSRMLS_CC); #endif - php_request_shutdown( NULL ); - } - ret = 1; - break; - case 'v': - if (php_request_startup(TSRMLS_C) != FAILURE) { + php_request_shutdown( NULL ); + } + ret = 1; + break; + case 'v': + if (php_request_startup(TSRMLS_C) != FAILURE) { #if ZEND_DEBUG - php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); #else php_end_ob_buffers(1 TSRMLS_CC); #endif - php_request_shutdown( NULL ); - } - ret = 1; - break; - case 'c': - ++p; - /* fall through */ - case 's': - break; - - case 'h': - case '?': - default: - cli_usage(TSRMLS_C); - ret = 1; - break; - - } - } - if ( !ret ) { - if ( *p ) { - zend_file_handle file_handle = {0}; - - file_handle.type = ZEND_HANDLE_FP; - file_handle.handle.fp = VCWD_FOPEN(*p, "rb"); - - if ( file_handle.handle.fp ) { - script_filename = *p; - php_self = *p; - - SG(request_info).path_translated = *p; - SG(request_info).argc = argc - (p - argv); - SG(request_info).argv = p; - - if (php_request_startup(TSRMLS_C) == FAILURE ) { - fclose( file_handle.handle.fp ); - ret = 2; - } else { - if (source_highlight) { - zend_syntax_highlighter_ini syntax_highlighter_ini; - - php_get_highlight_struct(&syntax_highlighter_ini); - highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); - } else { - file_handle.filename = *p; - file_handle.free_filename = 0; - file_handle.opened_path = NULL; - - php_execute_script(&file_handle TSRMLS_CC); - } - - php_request_shutdown( NULL ); - } - } else { - php_printf("Could not open input file: %s.\n", *p); - } - } else { - cli_usage(TSRMLS_C); - } - } - - }zend_end_try(); - - php_module_shutdown(TSRMLS_C); + php_request_shutdown( NULL ); + } + ret = 1; + break; + case 'c': + ++p; + /* fall through */ + case 's': + break; + + case 'h': + case '?': + default: + cli_usage(TSRMLS_C); + ret = 1; + break; + + } + } + if ( !ret ) { + if ( *p ) { + zend_file_handle file_handle = {0}; + + file_handle.type = ZEND_HANDLE_FP; + file_handle.handle.fp = VCWD_FOPEN(*p, "rb"); + + if ( file_handle.handle.fp ) { + script_filename = *p; + php_self = *p; + + SG(request_info).path_translated = estrdup(*p); + SG(request_info).argc = argc - (p - argv); + SG(request_info).argv = p; + + if (php_request_startup(TSRMLS_C) == FAILURE ) { + fclose( file_handle.handle.fp ); + ret = 2; + } else { + if (source_highlight) { + zend_syntax_highlighter_ini syntax_highlighter_ini; + + php_get_highlight_struct(&syntax_highlighter_ini); + highlight_file(SG(request_info).path_translated, &syntax_highlighter_ini TSRMLS_CC); + } else { + file_handle.filename = *p; + file_handle.free_filename = 0; + file_handle.opened_path = NULL; + + php_execute_script(&file_handle TSRMLS_CC); + } + + php_request_shutdown( NULL ); + } + } else { + php_printf("Could not open input file: %s.\n", *p); + } + } else { + cli_usage(TSRMLS_C); + } + } + + }zend_end_try(); + + php_module_shutdown(TSRMLS_C); #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif - return ret; + return ret; } static int s_stop; void litespeed_cleanup(int signal) { - s_stop = signal; + s_stop = signal; } void start_children( int children ) { - struct sigaction act, old_term, old_quit, old_int, old_usr1; - int running = 0; - int status; - pid_t pid; - - /* Create a process group */ - setsid(); - - /* Set up handler to kill children upon exit */ - act.sa_flags = 0; - act.sa_handler = litespeed_cleanup; - if( sigaction( SIGTERM, &act, &old_term ) || - sigaction( SIGINT, &act, &old_int ) || - sigaction( SIGUSR1, &act, &old_usr1 ) || - sigaction( SIGQUIT, &act, &old_quit )) { - perror( "Can't set signals" ); - exit( 1 ); - } - s_stop = 0; - while( 1 ) { - while((!s_stop )&&( running < children )) { - pid = fork(); - switch( pid ) { - case 0: /* children process */ - - /* don't catch our signals */ - sigaction( SIGTERM, &old_term, 0 ); - sigaction( SIGQUIT, &old_quit, 0 ); - sigaction( SIGINT, &old_int, 0 ); - sigaction( SIGUSR1, &old_usr1, 0 ); - return ; - case -1: - perror( "php (pre-forking)" ); - exit( 1 ); - break; - default: /* parent process */ - running++; - break; - } - } - if ( s_stop ) { - break; - } - pid = wait( &status ); - running--; - } - kill( -getpgrp(), SIGUSR1 ); - exit( 0 ); + struct sigaction act, old_term, old_quit, old_int, old_usr1; + int running = 0; + int status; + pid_t pid; + + /* Create a process group */ + setsid(); + + /* Set up handler to kill children upon exit */ + act.sa_flags = 0; + act.sa_handler = litespeed_cleanup; + if( sigaction( SIGTERM, &act, &old_term ) || + sigaction( SIGINT, &act, &old_int ) || + sigaction( SIGUSR1, &act, &old_usr1 ) || + sigaction( SIGQUIT, &act, &old_quit )) { + perror( "Can't set signals" ); + exit( 1 ); + } + s_stop = 0; + while( 1 ) { + while((!s_stop )&&( running < children )) { + pid = fork(); + switch( pid ) { + case 0: /* children process */ + + /* don't catch our signals */ + sigaction( SIGTERM, &old_term, 0 ); + sigaction( SIGQUIT, &old_quit, 0 ); + sigaction( SIGINT, &old_int, 0 ); + sigaction( SIGUSR1, &old_usr1, 0 ); + return ; + case -1: + perror( "php (pre-forking)" ); + exit( 1 ); + break; + default: /* parent process */ + running++; + break; + } + } + if ( s_stop ) { + break; + } + pid = wait( &status ); + running--; + } + kill( -getpgrp(), SIGUSR1 ); + exit( 0 ); } @@ -690,98 +855,124 @@ void start_children( int children ) #include <fcntl.h> int main( int argc, char * argv[] ) { - int ret; - int bindFd; - - char * php_ini_path = NULL; - char * php_bind = NULL; - char * p; - int n; - int climode = 0; - + int ret; + int bindFd; + + char * php_ini_path = NULL; + char * php_bind = NULL; + char * p; + int n; + int climode = 0; + struct timeval tv_req_begin; + struct timeval tv_req_end; + int slow_script_msec = 0; + char time_buf[40]; + #ifdef HAVE_SIGNAL_H #if defined(SIGPIPE) && defined(SIG_IGN) - signal(SIGPIPE, SIG_IGN); + signal(SIGPIPE, SIG_IGN); #endif #endif #ifdef ZTS - tsrm_startup(1, 1, 0, NULL); + tsrm_startup(1, 1, 0, NULL); #endif - if (argc > 1 ) { - if ( parse_opt( argc, argv, &climode, - &php_ini_path, &php_bind ) == -1 ) { - return 1; - } - } - if ( climode ) { - lsapi_sapi_module.phpinfo_as_text = 1; - } - sapi_startup(&lsapi_sapi_module); + if (argc > 1 ) { + if ( parse_opt( argc, argv, &climode, + &php_ini_path, &php_bind ) == -1 ) { + return 1; + } + } + if ( climode ) { + lsapi_sapi_module.phpinfo_as_text = 1; + } + argv0 = argv[0] + strlen( argv[0] ); + sapi_startup(&lsapi_sapi_module); #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); + 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); - SG(request_info).path_translated = NULL; + SG(request_info).path_translated = NULL; #endif - lsapi_sapi_module.executable_location = argv[0]; + lsapi_sapi_module.executable_location = argv[0]; + + if ( php_ini_path ) { + lsapi_sapi_module.php_ini_path_override = php_ini_path; + } - if ( php_ini_path ) { - lsapi_sapi_module.php_ini_path_override = php_ini_path; - } - if (php_module_startup(&lsapi_sapi_module, &litespeed_module_entry, 1) == FAILURE) { + lsapi_sapi_module.ini_defaults = sapi_lsapi_ini_defaults; + + if (php_module_startup(&lsapi_sapi_module, &litespeed_module_entry, 1) == FAILURE) { #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif - return FAILURE; - } - - if ( climode ) { - return cli_main(argc, argv); - } - - - if ( php_bind ) { - bindFd = LSAPI_CreateListenSock( php_bind, 10 ); - if ( bindFd == -1 ) { - fprintf( stderr, - "Failed to bind socket [%s]: %s\n", php_bind, strerror( errno ) ); - exit( 2 ); - } - if ( bindFd != 0 ) { - dup2( bindFd, 0 ); - close( bindFd ); - } - } - - LSAPI_Init(); + return FAILURE; + } + + if ( climode ) { + return cli_main(argc, argv); + } + + if ( php_bind ) { + bindFd = LSAPI_CreateListenSock( php_bind, 10 ); + if ( bindFd == -1 ) { + fprintf( stderr, + "Failed to bind socket [%s]: %s\n", php_bind, strerror( errno ) ); + exit( 2 ); + } + if ( bindFd != 0 ) { + dup2( bindFd, 0 ); + close( bindFd ); + } + } + + LSAPI_Init(); - LSAPI_Init_Env_Parameters( NULL ); - - if ( php_bind ) { - LSAPI_No_Check_ppid(); - } - - while( LSAPI_Prefork_Accept_r( &g_req ) >= 0 ) { - ret = processReq(TSRMLS_C); - LSAPI_Finish(); - if ( ret ) { - break; - } - } - php_module_shutdown(TSRMLS_C); + LSAPI_Init_Env_Parameters( NULL ); + + slow_script_msec = LSAPI_Get_Slow_Req_Msecs(); + + if ( php_bind ) { + LSAPI_No_Check_ppid(); + } + + while( LSAPI_Prefork_Accept_r( &g_req ) >= 0 ) { + if ( slow_script_msec ) { + gettimeofday( &tv_req_begin, NULL ); + } + ret = processReq(TSRMLS_C); + if ( slow_script_msec ) { + gettimeofday( &tv_req_end, NULL ); + n = ((long) tv_req_end.tv_sec - tv_req_begin.tv_sec ) * 1000 + + (tv_req_end.tv_usec - tv_req_begin.tv_usec) / 1000; + if ( n > slow_script_msec ) + { + strftime( time_buf, 30, "%d/%b/%Y:%H:%M:%S", localtime( &tv_req_end.tv_sec ) ); + fprintf( stderr, "[%s] Slow PHP script: %d ms\n URL: %s %s\n Query String: %s\n Script: %s\n", + time_buf, n, LSAPI_GetRequestMethod(), + LSAPI_GetScriptName(), LSAPI_GetQueryString(), + LSAPI_GetScriptFileName() ); + + } + } + LSAPI_Finish(); + if ( ret ) { + break; + } + } + php_module_shutdown(TSRMLS_C); #ifdef ZTS - tsrm_shutdown(); + tsrm_shutdown(); #endif - return ret; + return ret; } @@ -798,45 +989,45 @@ PHP_FUNCTION(litespeed_response_headers); PHP_MINFO_FUNCTION(litespeed); zend_function_entry litespeed_functions[] = { - PHP_FE(litespeed_request_headers, arginfo_litespeed__void) - PHP_FE(litespeed_response_headers, arginfo_litespeed__void) - PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_litespeed__void) - PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_litespeed__void) - PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_litespeed__void) - {NULL, NULL, NULL} + PHP_FE(litespeed_request_headers, arginfo_litespeed__void) + PHP_FE(litespeed_response_headers, arginfo_litespeed__void) + PHP_FALIAS(getallheaders, litespeed_request_headers, arginfo_litespeed__void) + PHP_FALIAS(apache_request_headers, litespeed_request_headers, arginfo_litespeed__void) + PHP_FALIAS(apache_response_headers, litespeed_response_headers, arginfo_litespeed__void) + {NULL, NULL, NULL} }; static PHP_MINIT_FUNCTION(litespeed) { - /* REGISTER_INI_ENTRIES(); */ - return SUCCESS; + /* REGISTER_INI_ENTRIES(); */ + return SUCCESS; } static PHP_MSHUTDOWN_FUNCTION(litespeed) { - /* UNREGISTER_INI_ENTRIES(); */ - return SUCCESS; + /* UNREGISTER_INI_ENTRIES(); */ + return SUCCESS; } zend_module_entry litespeed_module_entry = { - STANDARD_MODULE_HEADER, - "litespeed", - litespeed_functions, - PHP_MINIT(litespeed), - PHP_MSHUTDOWN(litespeed), - NULL, - NULL, - NULL, - NO_VERSION_YET, - STANDARD_MODULE_PROPERTIES + STANDARD_MODULE_HEADER, + "litespeed", + litespeed_functions, + PHP_MINIT(litespeed), + PHP_MSHUTDOWN(litespeed), + NULL, + NULL, + NULL, + NO_VERSION_YET, + STANDARD_MODULE_PROPERTIES }; static int add_associate_array( const char * pKey, int keyLen, const char * pValue, int valLen, - void * arg ) + void * arg ) { - add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue, 1 ); - return 1; + add_assoc_string_ex( (zval *)arg, (char *)pKey, keyLen+1, (char *)pValue, 1 ); + return 1; } @@ -844,13 +1035,13 @@ static int add_associate_array( const char * pKey, int keyLen, const char * pVal Fetch all HTTP request headers */ PHP_FUNCTION(litespeed_request_headers) { - /* TODO: */ - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; - } - array_init(return_value); + /* TODO: */ + if (ZEND_NUM_ARGS() > 0) { + WRONG_PARAM_COUNT; + } + array_init(return_value); - LSAPI_ForeachOrgHeader( add_associate_array, return_value ); + LSAPI_ForeachOrgHeader( add_associate_array, return_value ); } /* }}} */ @@ -861,40 +1052,40 @@ PHP_FUNCTION(litespeed_request_headers) Fetch all HTTP response headers */ PHP_FUNCTION(litespeed_response_headers) { - sapi_header_struct *h; - zend_llist_position pos; - char * p; - int len; - char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; - - if (ZEND_NUM_ARGS() > 0) { - WRONG_PARAM_COUNT; - } - - if (!&SG(sapi_headers).headers) { - RETURN_FALSE; - } - array_init(return_value); - - h = zend_llist_get_first_ex(&SG(sapi_headers).headers, &pos); - while (h) { - if ( h->header_len > 0 ) { - p = strchr( h->header, ':' ); - len = p - h->header; - if (( p )&&( len > 0 )) { - memmove( headerBuf, h->header, len ); - while( len > 0 && (isspace( headerBuf[len-1])) ) { - --len; - } - headerBuf[len] = 0; - if ( len ) { - while( isspace(*++p)); - add_assoc_string_ex(return_value, headerBuf, len+1, p, 1 ); - } - } - } - h = zend_llist_get_next_ex(&SG(sapi_headers).headers, &pos); - } + sapi_header_struct *h; + zend_llist_position pos; + char * p; + int len; + char headerBuf[SAPI_LSAPI_MAX_HEADER_LENGTH]; + + if (ZEND_NUM_ARGS() > 0) { + WRONG_PARAM_COUNT; + } + + if (!&SG(sapi_headers).headers) { + RETURN_FALSE; + } + array_init(return_value); + + h = zend_llist_get_first_ex(&SG(sapi_headers).headers, &pos); + while (h) { + if ( h->header_len > 0 ) { + p = strchr( h->header, ':' ); + len = p - h->header; + if (( p )&&( len > 0 )) { + memmove( headerBuf, h->header, len ); + while( len > 0 && (isspace( headerBuf[len-1])) ) { + --len; + } + headerBuf[len] = 0; + if ( len ) { + while( isspace(*++p)); + add_assoc_string_ex(return_value, headerBuf, len+1, p, 1 ); + } + } + } + h = zend_llist_get_next_ex(&SG(sapi_headers).headers, &pos); + } } /* }}} */ diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index febe6b768..56ea94aad 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: lsapilib.c 276590 2009-02-27 23:33:01Z gwang $ */ +/* $Id: lsapilib.c 306212 2010-12-10 22:51:08Z gwang $ */ /* Copyright (c) 2007, Lite Speed Technologies Inc. @@ -86,6 +86,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. static int g_inited = 0; static int g_running = 1; static int s_ppid; +static int s_slow_req_msecs = 0; LSAPI_Request g_req = { -1, -1 }; void Flush_RespBuf_r( LSAPI_Request * pReq ); @@ -507,11 +508,13 @@ static int parseRequest( LSAPI_Request * pReq, int totalLen ) return 0; } +static int s_accept_notify = 0; + static struct lsapi_packet_header ack = {'L', 'S', LSAPI_REQ_RECEIVED, LSAPI_ENDIAN, {LSAPI_PACKET_HEADER_LEN} }; -static inline int notify_req_received( LSAPI_Request * pReq ) +static inline int notify_req_received( int fd ) { - if ( write( pReq->m_fd, &ack, LSAPI_PACKET_HEADER_LEN ) + if ( write( fd, &ack, LSAPI_PACKET_HEADER_LEN ) < LSAPI_PACKET_HEADER_LEN ) { return -1; } @@ -567,7 +570,10 @@ static int readReq( LSAPI_Request * pReq ) pReq->m_bufProcessed = packetLen; pReq->m_reqState = LSAPI_ST_REQ_BODY | LSAPI_ST_RESP_HEADER; - return notify_req_received( pReq ); + if ( !s_accept_notify ) + return notify_req_received( pReq->m_fd ); + else + return 0; } @@ -677,6 +683,10 @@ int LSAPI_Accept_r( LSAPI_Request * pReq ) setsockopt(pReq->m_fd, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay)); } + + if ( s_accept_notify ) + return notify_req_received( pReq->m_fd ); + } } else { return -1; @@ -1239,13 +1249,14 @@ int LSAPI_ForeachHeader_r( LSAPI_Request * pReq, while( pCur < pEnd ) { pKey = pReq->m_pHttpHeader + pCur->nameOff; keyLen = pCur->nameLen; - pKeyEnd = pKey + keyLen; - memcpy( achHeaderName, "HTTP_", 5 ); - p = &achHeaderName[5]; if ( keyLen > 250 ) { keyLen = 250; } + pKeyEnd = pKey + keyLen; + memcpy( achHeaderName, "HTTP_", 5 ); + p = &achHeaderName[5]; + while( pKey < pKeyEnd ) { char ch = *pKey++; if ( ch == '-' ) { @@ -1629,6 +1640,9 @@ static int lsapi_accept( int fdListen ) setsockopt( fd, IPPROTO_TCP, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay)); } + + if ( s_accept_notify ) + notify_req_received( fd ); } return fd; @@ -2073,6 +2087,15 @@ void LSAPI_Set_Server_Max_Idle_Secs( int serverMaxIdle ) } } +void LSAPI_Set_Slow_Req_Msecs( int msecs ) +{ + s_slow_req_msecs = msecs; +} + +int LSAPI_Get_Slow_Req_Msecs() +{ + return s_slow_req_msecs; +} void LSAPI_No_Check_ppid() { @@ -2126,6 +2149,18 @@ void LSAPI_Init_Env_Parameters( fn_select_t fp ) avoidFork = atoi( p ); } + p = getenv( "LSAPI_ACCEPT_NOTIFY" ); + if ( p ) { + s_accept_notify = atoi( p ); + } + + p = getenv( "LSAPI_SLOW_REQ_MSECS" ); + if ( p ) { + n = atoi( p ); + LSAPI_Set_Slow_Req_Msecs( n ); + } + + #if defined( RLIMIT_CORE ) p = getenv( "LSAPI_ALLOW_CORE_DUMP" ); if ( !p ) { diff --git a/sapi/litespeed/lsapilib.h b/sapi/litespeed/lsapilib.h index b7b82e359..8a604fbf1 100644 --- a/sapi/litespeed/lsapilib.h +++ b/sapi/litespeed/lsapilib.h @@ -343,6 +343,11 @@ void LSAPI_Set_Max_Process_Time( int secs ); void LSAPI_Init_Env_Parameters( fn_select_t fp ); +void LSAPI_Set_Slow_Req_Msecs( int msecs ); + +int LSAPI_Get_Slow_Req_Msecs( ); + + #if defined (c_plusplus) || defined (__cplusplus) } #endif diff --git a/sapi/milter/php_milter.c b/sapi/milter/php_milter.c index 1a7fcf2d4..89352073f 100644 --- a/sapi/milter/php_milter.c +++ b/sapi/milter/php_milter.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_milter.c 296107 2010-03-12 10:28:59Z jani $ */ +/* $Id: php_milter.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" #include "php_globals.h" @@ -1111,7 +1111,7 @@ int main(int argc, char *argv[]) } SG(headers_sent) = 1; SG(request_info).no_headers = 1; - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2011 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); php_end_ob_buffers(1 TSRMLS_CC); exit(1); break; diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index 53f5f836d..b770f2dcc 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: nsapi.c 300707 2010-06-23 19:06:33Z srinatar $ */ +/* $Id: nsapi.c 306939 2011-01-01 02:19:59Z felipe $ */ /* * PHP includes @@ -312,7 +312,7 @@ PHP_MSHUTDOWN_FUNCTION(nsapi) PHP_MINFO_FUNCTION(nsapi) { php_info_print_table_start(); - php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 300707 $"); + php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 306939 $"); php_info_print_table_row(2, "Server Software", system_version()); php_info_print_table_row(2, "Sub-requests with nsapi_virtual()", (nsapi_servact_service)?((zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0))?"not supported with zlib.output_compression":"enabled"):"not supported on this platform" ); diff --git a/sapi/phttpd/php_phttpd.h b/sapi/phttpd/php_phttpd.h index 168c58af6..0a0d2e53c 100644 --- a/sapi/phttpd/php_phttpd.h +++ b/sapi/phttpd/php_phttpd.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c index 11df607db..65773dda2 100644 --- a/sapi/phttpd/phttpd.c +++ b/sapi/phttpd/phttpd.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/pi3web/pi3web_sapi.c b/sapi/pi3web/pi3web_sapi.c index f6cd9b614..f0135af33 100644 --- a/sapi/pi3web/pi3web_sapi.c +++ b/sapi/pi3web/pi3web_sapi.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pi3web_sapi.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: pi3web_sapi.c 306939 2011-01-01 02:19:59Z felipe $ */ #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS @@ -57,7 +57,7 @@ static void php_info_pi3web(ZEND_MODULE_INFO_FUNC_ARGS) 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: pi3web_sapi.c 293036 2010-01-03 09:23:27Z sebastian $"); + php_info_print_table_row(2, "Pi3Web SAPI module version", "$Id: pi3web_sapi.c 306939 2011-01-01 02:19:59Z felipe $"); 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); diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c index 614a89e29..723ffdd47 100644 --- a/sapi/roxen/roxen.c +++ b/sapi/roxen/roxen.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: roxen.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: roxen.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" #ifdef HAVE_ROXEN @@ -438,7 +438,7 @@ 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: roxen.c 293036 2010-01-03 09:23:27Z sebastian $"); + php_info_print_table_row(2, "SAPI module version", "$Id: roxen.c 306939 2011-01-01 02:19:59Z felipe $"); /* 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()); diff --git a/sapi/thttpd/php_thttpd.h b/sapi/thttpd/php_thttpd.h index 43e9ad807..e5d1c56e5 100644 --- a/sapi/thttpd/php_thttpd.h +++ b/sapi/thttpd/php_thttpd.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index f2530ecf5..0e78c49e5 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: thttpd.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: thttpd.c 306939 2011-01-01 02:19:59Z felipe $ */ #include "php.h" #include "SAPI.h" diff --git a/sapi/tux/php_tux.c b/sapi/tux/php_tux.c index df66a76e7..8a1f44e15 100644 --- a/sapi/tux/php_tux.c +++ b/sapi/tux/php_tux.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/webjames/php_webjames.h b/sapi/webjames/php_webjames.h index a0532c7a3..1860352fc 100644 --- a/sapi/webjames/php_webjames.h +++ b/sapi/webjames/php_webjames.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/sapi/webjames/webjames.c b/sapi/webjames/webjames.c index bbe5084e6..5a975ecd3 100644 --- a/sapi/webjames/webjames.c +++ b/sapi/webjames/webjames.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-2011 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | |