Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27348 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11047 invoked by uid 1010); 10 Jan 2007 18:05:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 11032 invoked from network); 10 Jan 2007 18:05:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2007 18:05:40 -0000 Authentication-Results: pb1.pair.com header.from=andrei@gravitonic.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andrei@gravitonic.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gravitonic.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: andrei@gravitonic.com X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from [204.11.219.139] ([204.11.219.139:51971] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/50-04674-3FA25A54 for ; Wed, 10 Jan 2007 13:05:40 -0500 Received: from [66.228.175.145] (borndress-lm.corp.yahoo.com [66.228.175.145]) (authenticated bits=0) by lerdorf.com (8.13.8/8.13.8/Debian-3) with ESMTP id l0AI5aYw009289 for ; Wed, 10 Jan 2007 10:05:36 -0800 Mime-Version: 1.0 (Apple Message framework v624) To: PHP Internals List Message-ID: Content-Type: multipart/mixed; boundary=Apple-Mail-2--980868673 Date: Wed, 10 Jan 2007 10:06:15 -0800 X-Mailer: Apple Mail (2.624) Subject: Renaming php5 stuff to php6 From: andrei@gravitonic.com (Andrei Zmievski) --Apple-Mail-2--980868673 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed I'm surprised we haven't done it yet, but we need to rename all the references to *php5* to *php6* in places like build system and sapi/. I've done the top-level stuff plus sapi/apache. The patch is attached. I'll commit soon, if there are no objections. I didn't modify other sapi/ modules, because I'd rather the maintainers did that. I also left config.w32 and *.dsp files alone, since I don't want to screw up Windows users. -Andrei --Apple-Mail-2--980868673 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="php5-6.diff.txt" Content-Disposition: attachment; filename=php5-6.diff.txt Index: INSTALL =================================================================== RCS file: /repository/php-src/INSTALL,v retrieving revision 1.38 diff -p -u -r1.38 INSTALL --- INSTALL 10 Apr 2006 15:09:14 -0000 1.38 +++ INSTALL 10 Jan 2007 18:02:38 -0000 @@ -218,6 +218,10 @@ Apache 1.3.x on Unix systems LoadModule php5_module libexec/libphp5.so + For PHP 6: + + LoadModule php6_module libexec/libphp6.so + 15. And in the AddModule section of httpd.conf, somewhere under the ClearModuleList, add this: @@ -467,6 +471,10 @@ Apache 2.0 on Unix systems LoadModule php5_module libexec/libphp5.so + For PHP 6: + + LoadModule php6_module libexec/libphp6.so + 15. Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse the .php extension as PHP. You could have any extension(s) parse as PHP by simply adding more, with Index: Makefile.global =================================================================== RCS file: /repository/php-src/Makefile.global,v retrieving revision 1.69 diff -p -u -r1.69 Makefile.global --- Makefile.global 8 Apr 2006 17:34:57 -0000 1.69 +++ Makefile.global 10 Jan 2007 18:02:38 -0000 @@ -13,22 +13,22 @@ all: $(all_targets) build-modules: $(PHP_MODULES) -libphp5.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) +libphp6.la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ - -@$(LIBTOOL) --silent --mode=install cp libphp5.la $(phptempdir)/libphp5.la >/dev/null 2>&1 + -@$(LIBTOOL) --silent --mode=install cp libphp6.la $(phptempdir)/libphp6.la >/dev/null 2>&1 -libs/libphp5.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) - $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp5.so +libs/libphp6.bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) + $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp6.so install: $(all_targets) $(install_targets) install-sapi: $(OVERALL_TARGET) @echo "Installing PHP SAPI module: $(PHP_SAPI)" -@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir) - -@if test ! -r $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME); then \ + -@if test ! -r $(phptempdir)/libphp6.$(SHLIB_DL_SUFFIX_NAME); then \ for i in 0.0.0 0.0 0; do \ - if test -r $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME).$$i; then \ - $(LN_S) $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp5.$(SHLIB_DL_SUFFIX_NAME); \ + if test -r $(phptempdir)/libphp6.$(SHLIB_DL_SUFFIX_NAME).$$i; then \ + $(LN_S) $(phptempdir)/libphp6.$(SHLIB_DL_SUFFIX_NAME).$$i $(phptempdir)/libphp6.$(SHLIB_DL_SUFFIX_NAME); \ break; \ fi; \ done; \ @@ -108,10 +108,10 @@ clean: find . -name \*.la -o -name \*.a | xargs rm -f find . -name \*.so | xargs rm -f find . -name .libs -a -type d|xargs rm -rf - rm -f libphp5.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/* + rm -f libphp6.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/* distclean: clean - rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php5.spec sapi/apache/libphp5.module buildmk.stamp + rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php5.spec sapi/apache/libphp6.module buildmk.stamp $(EGREP) define'.*include/php' $(top_srcdir)/configure | $(SED) 's/.*>//'|xargs rm -f find . -name Makefile | xargs rm -f Index: acinclude.m4 =================================================================== RCS file: /repository/php-src/acinclude.m4,v retrieving revision 1.355 diff -p -u -r1.355 acinclude.m4 --- acinclude.m4 1 Jan 2007 20:10:26 -0000 1.355 +++ acinclude.m4 10 Jan 2007 18:02:38 -0000 @@ -781,7 +781,7 @@ dnl PHP_BUILD_SHARED dnl AC_DEFUN([PHP_BUILD_SHARED],[ PHP_BUILD_PROGRAM - OVERALL_TARGET=libphp5.la + OVERALL_TARGET=libphp6.la php_build_target=shared php_c_pre=$shared_c_pre @@ -798,7 +798,7 @@ dnl PHP_BUILD_STATIC dnl AC_DEFUN([PHP_BUILD_STATIC],[ PHP_BUILD_PROGRAM - OVERALL_TARGET=libphp5.la + OVERALL_TARGET=libphp6.la php_build_target=static ]) @@ -807,7 +807,7 @@ dnl PHP_BUILD_BUNDLE dnl AC_DEFUN([PHP_BUILD_BUNDLE],[ PHP_BUILD_PROGRAM - OVERALL_TARGET=libs/libphp5.bundle + OVERALL_TARGET=libs/libphp6.bundle php_build_target=static ]) Index: configure.in =================================================================== RCS file: /repository/php-src/configure.in,v retrieving revision 1.619 diff -p -u -r1.619 configure.in --- configure.in 25 Dec 2006 15:40:14 -0000 1.619 +++ configure.in 10 Jan 2007 18:02:38 -0000 @@ -236,9 +236,9 @@ dnl SAPI configuration. dnl ------------------------------------------------------------------------- dnl paths to the targets are relative to the build directory -SAPI_SHARED=libs/libphp5.$SHLIB_DL_SUFFIX_NAME -SAPI_STATIC=libs/libphp5.a -SAPI_LIBTOOL=libphp5.la +SAPI_SHARED=libs/libphp6.$SHLIB_DL_SUFFIX_NAME +SAPI_STATIC=libs/libphp6.a +SAPI_LIBTOOL=libphp6.la PHP_CONFIGURE_PART(Configuring SAPI modules) Index: makerpm =================================================================== RCS file: /repository/php-src/makerpm,v retrieving revision 1.10 diff -p -u -r1.10 makerpm --- makerpm 4 Dec 2005 23:27:23 -0000 1.10 +++ makerpm 10 Jan 2007 18:02:38 -0000 @@ -101,7 +101,7 @@ mv php.keepme sapi/cgi/php %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%{_libdir}/apache -install -m 0755 .libs/libphp5.so $RPM_BUILD_ROOT%{_libdir}/apache +install -m 0755 .libs/libphp6.so $RPM_BUILD_ROOT%{_libdir}/apache mkdir -p $RPM_BUILD_ROOT%{_bindir} install -m 0755 sapi/cli/php $RPM_BUILD_ROOT%{_bindir} install -m 0755 sapi/cgi/php $RPM_BUILD_ROOT%{_bindir}/php_cgi @@ -166,7 +166,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) -%{_libdir}/apache/libphp5.so +%{_libdir}/apache/libphp6.so %{_bindir}/php %{_bindir}/php_cgi %{_mandir}/man1/php.1* Index: sapi/apache/.cvsignore =================================================================== RCS file: /repository/php-src/sapi/apache/.cvsignore,v retrieving revision 1.11 diff -p -u -r1.11 .cvsignore --- sapi/apache/.cvsignore 14 Nov 2006 09:40:03 -0000 1.11 +++ sapi/apache/.cvsignore 10 Jan 2007 18:02:38 -0000 @@ -1,4 +1,4 @@ -libphp5.module +libphp6.module *.la *.lo .deps Index: sapi/apache/apMakefile.tmpl =================================================================== RCS file: /repository/php-src/sapi/apache/apMakefile.tmpl,v retrieving revision 1.5 diff -p -u -r1.5 apMakefile.tmpl --- sapi/apache/apMakefile.tmpl 29 Mar 2003 04:52:46 -0000 1.5 +++ sapi/apache/apMakefile.tmpl 10 Jan 2007 18:02:38 -0000 @@ -1,38 +1,38 @@ ## -## Apache 1.3 Makefile template for PHP 5.0 Module -## [src/modules/php5/Makefile.tmpl] +## Apache 1.3 Makefile template for PHP 6.0 Module +## [src/modules/php6/Makefile.tmpl] ## # the parametrized target -LIB=libphp5.$(LIBEXT) +LIB=libphp6.$(LIBEXT) # objects for building the static library -OBJS=mod_php5.o -OBJS_LIB=libmodphp5.a +OBJS=mod_php6.o +OBJS_LIB=libmodphp6.a # objects for building the shared object library -SHLIB_OBJS=mod_php5.so-o -SHLIB_OBJS_LIB=libmodphp5.a +SHLIB_OBJS=mod_php6.so-o +SHLIB_OBJS_LIB=libmodphp6.a # the general targets all: lib lib: $(LIB) # build the static library by merging the object files -libphp5.a: $(OBJS) $(OBJS_LIB) +libphp6.a: $(OBJS) $(OBJS_LIB) cp $(OBJS_LIB) $@ ar r $@ $(OBJS) $(RANLIB) $@ # ugly hack to support older Apache-1.3 betas that don't set $LIBEXT -libphp5.: $(OBJS) $(OBJS_LIB) +libphp6.: $(OBJS) $(OBJS_LIB) cp $(OBJS_LIB) $@ ar r $@ $(OBJS) $(RANLIB) $@ - cp libphp5. libphp5.a + cp libphp6. libphp6.a # build the shared object library by linking the object files -libphp5.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) +libphp6.so: $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) rm -f $@ $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $(SHLIB_OBJS) $(SHLIB_OBJS_LIB) $(LIBS) $(PHP_LIBS) @@ -69,9 +69,9 @@ depend: $(OBJS): Makefile # DO NOT REMOVE -mod_php5.o: mod_php5.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ +mod_php6.o: mod_php6.c $(INCDIR)/httpd.h $(INCDIR)/conf.h \ $(INCDIR)/buff.h \ $(INCDIR)/http_config.h \ $(INCDIR)/http_core.h $(INCDIR)/http_main.h \ $(INCDIR)/http_protocol.h $(INCDIR)/http_request.h \ - $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php5.h + $(INCDIR)/http_log.h $(INCDIR)/util_script.h mod_php6.h Index: sapi/apache/config.m4 =================================================================== RCS file: /repository/php-src/sapi/apache/config.m4,v retrieving revision 1.76 diff -p -u -r1.76 config.m4 --- sapi/apache/config.m4 4 Dec 2005 23:30:40 -0000 1.76 +++ sapi/apache/config.m4 10 Jan 2007 18:02:38 -0000 @@ -74,7 +74,7 @@ AC_ARG_WITH(apxs, *darwin*) MH_BUNDLE_FLAGS="-dynamic -twolevel_namespace -bundle -bundle_loader $APXS_HTTPD" PHP_SUBST(MH_BUNDLE_FLAGS) - SAPI_SHARED=libs/libphp5.so + SAPI_SHARED=libs/libphp6.so build_type=bundle ;; *) @@ -82,26 +82,26 @@ AC_ARG_WITH(apxs, ;; esac - PHP_SELECT_SAPI(apache, $build_type, sapi_apache.c mod_php5.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR) + PHP_SELECT_SAPI(apache, $build_type, sapi_apache.c mod_php6.c php_apache.c, $APACHE_CPPFLAGS -I$APXS_INCLUDEDIR) # Test whether apxs support -S option $APXS -q -S CFLAGS="$APXS_CFLAGS" CFLAGS >/dev/null 2>&1 if test "$?" != "0"; then - APACHE_INSTALL="$APXS -i -a -n php5 $SAPI_SHARED" # Old apxs does not have -S option + APACHE_INSTALL="$APXS -i -a -n php6 $SAPI_SHARED" # Old apxs does not have -S option else APXS_LIBEXECDIR='$(INSTALL_ROOT)'`$APXS -q LIBEXECDIR` if test -z `$APXS -q SYSCONFDIR`; then APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \ $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \ - -i -n php5 $SAPI_SHARED" + -i -n php6 $SAPI_SHARED" else APXS_SYSCONFDIR='$(INSTALL_ROOT)'`$APXS -q SYSCONFDIR` APACHE_INSTALL="\$(mkinstalldirs) '$APXS_LIBEXECDIR' && \ \$(mkinstalldirs) '$APXS_SYSCONFDIR' && \ $APXS -S LIBEXECDIR='$APXS_LIBEXECDIR' \ -S SYSCONFDIR='$APXS_SYSCONFDIR' \ - -i -a -n php5 $SAPI_SHARED" + -i -a -n php6 $SAPI_SHARED" fi fi @@ -123,7 +123,7 @@ AC_ARG_WITH(apache, [ --with-apache[=DIR] Build Apache 1.x module. DIR is the top-level Apache build directory [/usr/local/apache]],[ - APACHE_INSTALL_FILES="\$(srcdir)/sapi/apache/mod_php5.* sapi/apache/libphp5.module" + APACHE_INSTALL_FILES="\$(srcdir)/sapi/apache/mod_php6.* sapi/apache/libphp6.module" if test "$withval" = "yes"; then # Apache's default directory @@ -142,13 +142,13 @@ AC_ARG_WITH(apache, elif test -f $withval/src/main/httpd.h; then APACHE_HAS_REGEX=1 APACHE_INCLUDE="-I$withval/src/main -I$withval/src/os/unix -I$withval/src/ap" - APACHE_TARGET=$withval/src/modules/php5 + APACHE_TARGET=$withval/src/modules/php6 if test ! -d $APACHE_TARGET; then mkdir $APACHE_TARGET fi - PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE) - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir" - PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5" + PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php6.c php_apache.c, $APACHE_INCLUDE) + APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp6.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir" + PHP_LIBS="-Lmodules/php6 -L../modules/php6 -L../../modules/php6 -lmodphp6" AC_MSG_RESULT(yes - Apache 1.3.x) STRONGHOLD= if test -f $withval/src/include/ap_config.h; then @@ -168,13 +168,13 @@ AC_ARG_WITH(apache, elif test -f $withval/src/include/httpd.h; then APACHE_HAS_REGEX=1 APACHE_INCLUDE="-I$withval/src/include -I$withval/src/os/unix" - APACHE_TARGET=$withval/src/modules/php5 + APACHE_TARGET=$withval/src/modules/php6 if test ! -d $APACHE_TARGET; then mkdir $APACHE_TARGET fi - PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE) - PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5" - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir" + PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php6.c php_apache.c, $APACHE_INCLUDE) + PHP_LIBS="-Lmodules/php6 -L../modules/php6 -L../../modules/php6 -lmodphp6" + APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp6.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET; cp $srcdir/sapi/apache/apMakefile.tmpl $APACHE_TARGET/Makefile.tmpl; cp $srcdir/sapi/apache/apMakefile.libdir $APACHE_TARGET/Makefile.libdir" AC_MSG_RESULT(yes - Apache 1.3.x) STRONGHOLD= if test -f $withval/src/include/ap_config.h; then @@ -194,9 +194,9 @@ AC_ARG_WITH(apache, elif test -f $withval/apache/httpd.h; then APACHE_INCLUDE="-I$withval/apache -I$withval/ssl/include" APACHE_TARGET=$withval/apache - PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php5.c php_apache.c, $APACHE_INCLUDE) - PHP_LIBS="-Lmodules/php5 -L../modules/php5 -L../../modules/php5 -lmodphp5" - APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp5.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET" + PHP_SELECT_SAPI(apache, static, sapi_apache.c mod_php6.c php_apache.c, $APACHE_INCLUDE) + PHP_LIBS="-Lmodules/php6 -L../modules/php6 -L../../modules/php6 -lmodphp6" + APACHE_INSTALL="mkdir -p $APACHE_TARGET; cp $SAPI_STATIC $APACHE_TARGET/libmodphp6.a; cp $APACHE_INSTALL_FILES $APACHE_TARGET" STRONGHOLD=-DSTRONGHOLD=1 AC_MSG_RESULT(yes - StrongHold) if test -f $withval/apache/ap_config.h; then @@ -239,13 +239,13 @@ dnl Build as static module if test -n "$APACHE_MODULE"; then PHP_TARGET_RDYNAMIC $php_shtool mkdir -p sapi/apache - PHP_OUTPUT(sapi/apache/libphp5.module) + PHP_OUTPUT(sapi/apache/libphp6.module) fi dnl General if test -n "$APACHE_INSTALL"; then if test "x$APXS" != "x" -a "`uname -sv`" = "AIX 4" -a "$GCC" != "yes"; then - APXS_EXP=-bE:sapi/apache/mod_php5.exp + APXS_EXP=-bE:sapi/apache/mod_php6.exp fi PHP_APACHE_FD_CHECK Index: sapi/apache/libphp5.module.in =================================================================== RCS file: sapi/apache/libphp5.module.in diff -N sapi/apache/libphp5.module.in --- sapi/apache/libphp5.module.in 29 Mar 2003 04:52:46 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ -Name: php5_module -ConfigStart - RULE_WANTHSREGEX=no - RULE_HIDE=yes - PHP_LIBS="@NATIVE_RPATHS@ @PHP_LDFLAGS@ @PHP_LIBS@ @EXTRA_LDFLAGS@ @EXTRA_LIBS@ $LIBS" - PHP_CFLAGS="$CFLAGS @OPENSSL_INCDIR_OPT@ -I@php_abs_top_builddir@/main -I@php_abs_top_builddir@/Zend -I@php_abs_top_builddir@/TSRM -I@php_abs_top_srcdir@ -I@php_abs_top_srcdir@/sapi/apache -I@php_abs_top_srcdir@/main -I@php_abs_top_srcdir@/Zend -I@php_abs_top_srcdir@/TSRM" - my_outfile="Makefile.config" - echo "PHP_CFLAGS=$PHP_CFLAGS" >>$my_outfile - echo "PHP_LIBS=$PHP_LIBS" >>$my_outfile - LIBS=$PHP_LIBS -ConfigEnd Index: sapi/apache/libphp6.module.in =================================================================== RCS file: sapi/apache/libphp6.module.in diff -N sapi/apache/libphp6.module.in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sapi/apache/libphp6.module.in 10 Jan 2007 18:02:38 -0000 @@ -0,0 +1,11 @@ +Name: php6_module +ConfigStart + RULE_WANTHSREGEX=no + RULE_HIDE=yes + PHP_LIBS="@NATIVE_RPATHS@ @PHP_LDFLAGS@ @PHP_LIBS@ @EXTRA_LDFLAGS@ @EXTRA_LIBS@ $LIBS" + PHP_CFLAGS="$CFLAGS @OPENSSL_INCDIR_OPT@ -I@php_abs_top_builddir@/main -I@php_abs_top_builddir@/Zend -I@php_abs_top_builddir@/TSRM -I@php_abs_top_srcdir@ -I@php_abs_top_srcdir@/sapi/apache -I@php_abs_top_srcdir@/main -I@php_abs_top_srcdir@/Zend -I@php_abs_top_srcdir@/TSRM" + my_outfile="Makefile.config" + echo "PHP_CFLAGS=$PHP_CFLAGS" >>$my_outfile + echo "PHP_LIBS=$PHP_LIBS" >>$my_outfile + LIBS=$PHP_LIBS +ConfigEnd Index: sapi/apache/mod_php5.c =================================================================== RCS file: sapi/apache/mod_php5.c diff -N sapi/apache/mod_php5.c --- sapi/apache/mod_php5.c 1 Jan 2007 09:29:36 -0000 1.42 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,1003 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Rasmus Lerdorf | - | (with helpful hints from Dean Gaudet | - | PHP 4.0 patches by Zeev Suraski | - +----------------------------------------------------------------------+ - */ -/* $Id: mod_php5.c,v 1.42 2007/01/01 09:29:36 sebastian Exp $ */ - -#include "php_apache_http.h" -#include "http_conf_globals.h" - -#ifdef NETWARE -#define SIGPIPE SIGINT -#endif - -#undef shutdown - -/* {{{ Prototypes - */ -int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC); -static void php_save_umask(void); -static void php_restore_umask(void); -static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC); -static char *sapi_apache_read_cookies(TSRMLS_D); -static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC); -static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC); -static int send_php(request_rec *r, int display_source_mode, char *filename); -static int send_parsed_php(request_rec * r); -static int send_parsed_php_source(request_rec * r); -static int php_xbithack_handler(request_rec * r); -static void php_init_handler(server_rec *s, pool *p); -/* }}} */ - -#if MODULE_MAGIC_NUMBER >= 19970728 -static void php_child_exit_handler(server_rec *s, pool *p); -#endif - -#if MODULE_MAGIC_NUMBER > 19961007 -#define CONST_PREFIX const -#else -#define CONST_PREFIX -#endif -static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode); -static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); -static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); -static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); -static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode); -static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); - -/* ### these should be defined in mod_php5.h or somewhere else */ -#define USE_PATH 1 -#define IGNORE_URL 2 -#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST POSSIBLE STATUS DESCRIPTION") - -module MODULE_VAR_EXPORT php5_module; - -int saved_umask; -static unsigned char apache_php_initialized; - -typedef struct _php_per_dir_entry { - char *key; - char *value; - uint key_length; - uint value_length; - int type; -} php_per_dir_entry; - -/* some systems are missing these from their header files */ - -/* {{{ php_save_umask - */ -static void php_save_umask(void) -{ - saved_umask = umask(077); - umask(saved_umask); -} -/* }}} */ - -/* {{{ sapi_apache_ub_write - */ -static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC) -{ - int ret=0; - - if (SG(server_context)) { - ret = rwrite(str, str_length, (request_rec *) SG(server_context)); - } - if (ret != str_length) { - php_handle_aborted_connection(); - } - return ret; -} -/* }}} */ - -/* {{{ sapi_apache_flush - */ -static void sapi_apache_flush(void *server_context) -{ - if (server_context) { -#if MODULE_MAGIC_NUMBER > 19970110 - rflush((request_rec *) server_context); -#else - bflush((request_rec *) server_context->connection->client); -#endif - } -} -/* }}} */ - -/* {{{ sapi_apache_read_post - */ -static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC) -{ - int total_read_bytes=0, read_bytes; - request_rec *r = (request_rec *) SG(server_context); - void (*handler)(int); - - /* - * This handles the situation where the browser sends a Expect: 100-continue header - * and needs to recieve confirmation from the server on whether or not it can send - * the rest of the request. RFC 2616 - * - */ - if (!SG(read_post_bytes) && !ap_should_client_block(r)) { - return total_read_bytes; - } - - handler = signal(SIGPIPE, SIG_IGN); - while (total_read_bytessubprocess_env, "HTTP_COOKIE"); -} -/* }}} */ - -/* {{{ sapi_apache_header_handler - */ -static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - char *header_name, *header_content, *p; - request_rec *r = (request_rec *) SG(server_context); - if(!r) { - efree(sapi_header->header); - return 0; - } - - header_name = sapi_header->header; - - header_content = p = strchr(header_name, ':'); - if (!p) { - efree(sapi_header->header); - return 0; - } - - *p = 0; - do { - header_content++; - } while (*header_content==' '); - - if (!strcasecmp(header_name, "Content-Type")) { - r->content_type = pstrdup(r->pool, header_content); - } else if (!strcasecmp(header_name, "Set-Cookie")) { - table_add(r->headers_out, header_name, header_content); - } else if (sapi_header->replace) { - table_set(r->headers_out, header_name, header_content); - } else { - table_add(r->headers_out, header_name, header_content); - } - - *p = ':'; /* a well behaved header handler shouldn't change its original arguments */ - - return SAPI_HEADER_ADD; -} -/* }}} */ - -/* {{{ sapi_apache_send_headers - */ -static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) -{ - request_rec *r = SG(server_context); - const char *sline = SG(sapi_headers).http_status_line; - int sline_len; - - if(r == NULL) { /* server_context is not here anymore */ - return SAPI_HEADER_SEND_FAILED; - } - - r->status = SG(sapi_headers).http_response_code; - - /* httpd requires that r->status_line is set to the first digit of - * the status-code: */ - if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ' && sline[12] == ' ') { - if ((sline_len - 9) > MAX_STATUS_LENGTH) { - r->status_line = ap_pstrndup(r->pool, sline + 9, MAX_STATUS_LENGTH); - } else { - r->status_line = ap_pstrndup(r->pool, sline + 9, sline_len - 9); - } - } - - if(r->status==304) { - send_error_response(r,0); - } else { - send_http_header(r); - } - return SAPI_HEADER_SENT_SUCCESSFULLY; -} -/* }}} */ - -/* {{{ sapi_apache_register_server_variables - */ -static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_DC) -{ - register int i; - array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env); - table_entry *elts = (table_entry *) arr->elts; - zval **path_translated; - HashTable *symbol_table; - int new_val_len; - - for (i = 0; i < arr->nelts; i++) { - char *val; - int val_len; - - if (elts[i].val) { - val = elts[i].val; - } else { - val = ""; - } - val_len = strlen(val); - if (sapi_module.input_filter(PARSE_SERVER, elts[i].key, &val, val_len, &new_val_len TSRMLS_CC)) { - php_register_variable_safe(elts[i].key, val, new_val_len, track_vars_array TSRMLS_CC); - } - } - - /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */ - if (track_vars_array) { - symbol_table = track_vars_array->value.ht; - } else { - symbol_table = NULL; - } - if (symbol_table - && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")) - && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)==SUCCESS) { - php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array TSRMLS_CC); - } - - if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &((request_rec *) SG(server_context))->uri, strlen(((request_rec *) SG(server_context))->uri), &new_val_len TSRMLS_CC)) { - php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array TSRMLS_CC); - } -} -/* }}} */ - -/* {{{ php_apache_startup - */ -static int php_apache_startup(sapi_module_struct *sapi_module) -{ - if (php_module_startup(sapi_module, &apache_module_entry, 1) == FAILURE) { - return FAILURE; - } else { - return SUCCESS; - } -} -/* }}} */ - -/* {{{ php_apache_log_message - */ -static void php_apache_log_message(char *message) -{ - TSRMLS_FETCH(); - - if (SG(server_context)) { -#if MODULE_MAGIC_NUMBER >= 19970831 - aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, "%s", message); -#else - log_error(message, ((request_rec *) SG(server_context))->server); -#endif - } else { - fprintf(stderr, "%s\n", message); - } -} -/* }}} */ - -/* {{{ php_apache_request_shutdown - */ -static void php_apache_request_shutdown(void *dummy) -{ - TSRMLS_FETCH(); - - php_output_set_status(PHP_OUTPUT_DISABLED TSRMLS_CC); - if (AP(in_request)) { - AP(in_request) = 0; - php_request_shutdown(dummy); - } - SG(server_context) = NULL; - /* - * The server context (request) is NOT invalid by the time - * run_cleanups() is called - */ -} -/* }}} */ - -/* {{{ php_apache_sapi_activate - */ -static int php_apache_sapi_activate(TSRMLS_D) -{ - request_rec *r = (request_rec *) SG(server_context); - - /* - * For the Apache module version, this bit of code registers a cleanup - * function that gets triggered when our request pool is destroyed. - * We need this because at any point in our code we can be interrupted - * and that may happen before we have had time to free our memory. - * The php_request_shutdown function needs to free all outstanding allocated - * memory. - */ - block_alarms(); - register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec); - AP(in_request)=1; - unblock_alarms(); - - /* Override the default headers_only value - sometimes "GET" requests should actually only - * send headers. - */ - SG(request_info).headers_only = r->header_only; - return SUCCESS; -} -/* }}} */ - -/* {{{ php_apache_get_stat - */ -static struct stat *php_apache_get_stat(TSRMLS_D) -{ - return &((request_rec *) SG(server_context))->finfo; -} -/* }}} */ - -/* {{{ php_apache_getenv - */ -static char *php_apache_getenv(char *name, size_t name_len TSRMLS_DC) -{ - if (SG(server_context) == NULL) { - return NULL; - } - - return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name); -} -/* }}} */ - -/* {{{ sapi_apache_get_fd - */ -static int sapi_apache_get_fd(int *nfd TSRMLS_DC) -{ -#if PHP_APACHE_HAVE_CLIENT_FD - request_rec *r = SG(server_context); - int fd; - - fd = r->connection->client->fd; - - if (fd >= 0) { - if (nfd) *nfd = fd; - return SUCCESS; - } -#endif - return FAILURE; -} -/* }}} */ - -/* {{{ sapi_apache_force_http_10 - */ -static int sapi_apache_force_http_10(TSRMLS_D) -{ - request_rec *r = SG(server_context); - - r->proto_num = HTTP_VERSION(1,0); - - return SUCCESS; -} -/* }}} */ - -/* {{{ sapi_apache_get_target_uid - */ -static int sapi_apache_get_target_uid(uid_t *obj TSRMLS_DC) -{ - *obj = ap_user_id; - return SUCCESS; -} -/* }}} */ - -/* {{{ sapi_apache_get_target_gid - */ -static int sapi_apache_get_target_gid(gid_t *obj TSRMLS_DC) -{ - *obj = ap_group_id; - return SUCCESS; -} -/* }}} */ - -/* {{{ php_apache_get_request_time - */ -static time_t php_apache_get_request_time(TSRMLS_D) -{ - return ((request_rec *)SG(server_context))->request_time; -} -/* }}} */ - -/* {{{ sapi_module_struct apache_sapi_module - */ -static sapi_module_struct apache_sapi_module = { - "apache", /* name */ - "Apache", /* pretty name */ - - php_apache_startup, /* startup */ - php_module_shutdown_wrapper, /* shutdown */ - - php_apache_sapi_activate, /* activate */ - NULL, /* deactivate */ - - sapi_apache_ub_write, /* unbuffered write */ - sapi_apache_flush, /* flush */ - php_apache_get_stat, /* get uid */ - php_apache_getenv, /* getenv */ - - php_error, /* error handler */ - - sapi_apache_header_handler, /* header handler */ - sapi_apache_send_headers, /* send headers handler */ - NULL, /* send header handler */ - - sapi_apache_read_post, /* read POST data */ - sapi_apache_read_cookies, /* read Cookies */ - - sapi_apache_register_server_variables, /* register server variables */ - php_apache_log_message, /* Log message */ - php_apache_get_request_time, /* Get request time */ - - NULL, /* php.ini path override */ - -#ifdef PHP_WIN32 - NULL, - NULL, -#else - block_alarms, /* Block interruptions */ - unblock_alarms, /* Unblock interruptions */ -#endif - - NULL, /* default post reader */ - NULL, /* treat data */ - NULL, /* exe location */ - 0, /* ini ignore */ - sapi_apache_get_fd, - sapi_apache_force_http_10, - sapi_apache_get_target_uid, - sapi_apache_get_target_gid -}; -/* }}} */ - -/* {{{ php_restore_umask - */ -static void php_restore_umask(void) -{ - umask(saved_umask); -} -/* }}} */ - -/* {{{ init_request_info - */ -static void init_request_info(TSRMLS_D) -{ - request_rec *r = ((request_rec *) SG(server_context)); - char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH"); - const char *authorization=NULL; - char *tmp, *tmp_user; - - SG(request_info).query_string = r->args; - SG(request_info).path_translated = r->filename; - SG(request_info).request_uri = r->uri; - SG(request_info).request_method = (char *)r->method; - SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE"); - SG(request_info).content_length = (content_length ? atoi(content_length) : 0); - SG(sapi_headers).http_response_code = r->status; - SG(request_info).proto_num = r->proto_num; - - if (r->headers_in) { - authorization = table_get(r->headers_in, "Authorization"); - } - - SG(request_info).auth_user = NULL; - SG(request_info).auth_password = NULL; - SG(request_info).auth_digest = NULL; - - if (authorization) { - char *p = getword(r->pool, &authorization, ' '); - if (!strcasecmp(p, "Basic")) { - tmp = uudecode(r->pool, authorization); - tmp_user = getword_nulls_nc(r->pool, &tmp, ':'); - if (tmp_user) { - r->connection->user = pstrdup(r->connection->pool, tmp_user); - r->connection->ap_auth_type = "Basic"; - SG(request_info).auth_user = estrdup(tmp_user); - } - if (tmp) { - SG(request_info).auth_password = estrdup(tmp); - } - } else if (!strcasecmp(p, "Digest")) { - r->connection->ap_auth_type = "Digest"; - SG(request_info).auth_digest = estrdup(authorization); - } - } -} -/* }}} */ - -/* {{{ php_apache_alter_ini_entries - */ -static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_DC) -{ - zend_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, PHP_INI_STAGE_ACTIVATE); - return 0; -} -/* }}} */ - -/* {{{ php_apache_get_default_mimetype - */ -static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC) -{ - - char *mimetype; - /* Assume output will be of the default MIME type. Individual - scripts may change this later. */ - char *tmpmimetype; - tmpmimetype = sapi_get_default_content_type(TSRMLS_C); - mimetype = pstrdup(r->pool, tmpmimetype); - efree(tmpmimetype); - return mimetype; -} -/* }}} */ - -/* {{{ send_php - */ -static int send_php(request_rec *r, int display_source_mode, char *filename) -{ - int retval; - HashTable *per_dir_conf; - TSRMLS_FETCH(); - - if (AP(in_request)) { - zend_file_handle fh; - - fh.filename = r->filename; - fh.opened_path = NULL; - fh.free_filename = 0; - fh.type = ZEND_HANDLE_FILENAME; - - zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh); - return OK; - } - - zend_first_try { - - /* Make sure file exists */ - if (filename == NULL && r->finfo.st_mode == 0) { - return DECLINED; - } - - per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php5_module); - if (per_dir_conf) { - zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC); - } - - /* If PHP parser engine has been turned off with an "engine off" - * directive, then decline to handle this request - */ - if (!AP(engine)) { - r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC); - zend_try { - zend_ini_deactivate(TSRMLS_C); - } zend_end_try(); - return DECLINED; - } - if (filename == NULL) { - filename = r->filename; - } - - /* Apache 1.2 has a more complex mechanism for reading POST data */ -#if MODULE_MAGIC_NUMBER > 19961007 - if ((retval = setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) { - zend_try { - zend_ini_deactivate(TSRMLS_C); - } zend_end_try(); - return retval; - } -#endif - - if (AP(last_modified)) { -#if MODULE_MAGIC_NUMBER < 19970912 - if ((retval = set_last_modified(r, r->finfo.st_mtime))) { - zend_try { - zend_ini_deactivate(TSRMLS_C); - } zend_end_try(); - return retval; - } -#else - update_mtime (r, r->finfo.st_mtime); - set_last_modified(r); - set_etag(r); -#endif - } - /* Assume output will be of the default MIME type. Individual - scripts may change this later in the request. */ - r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC); - - /* Init timeout */ - hard_timeout("send", r); - - SG(server_context) = r; - - php_save_umask(); - add_common_vars(r); - add_cgi_vars(r); - - init_request_info(TSRMLS_C); - apache_php_module_main(r, display_source_mode TSRMLS_CC); - - /* Done, restore umask, turn off timeout, close file and return */ - php_restore_umask(); - kill_timeout(r); - } zend_end_try(); - - return OK; -} -/* }}} */ - -/* {{{ send_parsed_php - */ -static int send_parsed_php(request_rec * r) -{ - int result = send_php(r, 0, NULL); - TSRMLS_FETCH(); - - ap_table_setn(r->notes, "mod_php_memory_usage", - ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC))); - - return result; -} -/* }}} */ - -/* {{{ send_parsed_php_source - */ -static int send_parsed_php_source(request_rec * r) -{ - return send_php(r, 1, NULL); -} -/* }}} */ - -/* {{{ destroy_per_dir_entry - */ -static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry) -{ - free(per_dir_entry->key); - free(per_dir_entry->value); -} -/* }}} */ - -/* {{{ copy_per_dir_entry - */ -static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry) -{ - php_per_dir_entry tmp = *per_dir_entry; - - per_dir_entry->key = (char *) malloc(tmp.key_length+1); - memcpy(per_dir_entry->key, tmp.key, tmp.key_length); - per_dir_entry->key[per_dir_entry->key_length] = 0; - - per_dir_entry->value = (char *) malloc(tmp.value_length+1); - memcpy(per_dir_entry->value, tmp.value, tmp.value_length); - per_dir_entry->value[per_dir_entry->value_length] = 0; -} -/* }}} */ - -/* {{{ should_overwrite_per_dir_entry - */ -static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_per_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData) -{ - php_per_dir_entry *orig_per_dir_entry; - - if (zend_u_hash_find(target_ht, hash_key->type, hash_key->arKey, hash_key->nKeyLength, (void **) &orig_per_dir_entry)==FAILURE) { - return 1; /* does not exist in dest, copy from source */ - } - - if (new_per_dir_entry->type==PHP_INI_SYSTEM - && orig_per_dir_entry->type!=PHP_INI_SYSTEM) { - return 1; - } else { - return 0; - } -} -/* }}} */ - -/* {{{ php_destroy_per_dir_info - */ -static void php_destroy_per_dir_info(HashTable *per_dir_info) -{ - zend_hash_destroy(per_dir_info); - free(per_dir_info); -} -/* }}} */ - -/* {{{ php_create_dir - */ -static void *php_create_dir(pool *p, char *dummy) -{ - HashTable *per_dir_info; - - per_dir_info = (HashTable *) malloc(sizeof(HashTable)); - zend_hash_init_ex(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0); - register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy); - - return per_dir_info; -} -/* }}} */ - -/* {{{ php_merge_dir - */ -static void *php_merge_dir(pool *p, void *basev, void *addv) -{ - /* This function *must* return addv, and not modify basev */ - zend_hash_merge_ex((HashTable *) addv, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL); - return addv; -} -/* }}} */ - -/* {{{ php_apache_value_handler_ex - */ -static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode) -{ - php_per_dir_entry per_dir_entry; - - if (!apache_php_initialized) { - apache_php_initialized = 1; -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); -#endif - sapi_startup(&apache_sapi_module); - php_apache_startup(&apache_sapi_module); - } - per_dir_entry.type = mode; - - if (strcasecmp(arg2, "none") == 0) { - arg2 = ""; - } - - per_dir_entry.key_length = strlen(arg1); - per_dir_entry.value_length = strlen(arg2); - - per_dir_entry.key = (char *) malloc(per_dir_entry.key_length+1); - memcpy(per_dir_entry.key, arg1, per_dir_entry.key_length); - per_dir_entry.key[per_dir_entry.key_length] = 0; - - per_dir_entry.value = (char *) malloc(per_dir_entry.value_length+1); - memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length); - per_dir_entry.value[per_dir_entry.value_length] = 0; - - zend_hash_update(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL); - return NULL; -} -/* }}} */ - -/* {{{ php_apache_value_handler - */ -static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR); -} -/* }}} */ - -/* {{{ php_apache_admin_value_handler - */ -static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM); -} -/* }}} */ - -/* {{{ php_apache_flag_handler_ex - */ -static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode) -{ - char bool_val[2]; - - if (!strcasecmp(arg2, "On") || (arg2[0] == '1' && arg2[1] == '\0')) { - bool_val[0] = '1'; - } else { - bool_val[0] = '0'; - } - bool_val[1] = 0; - - return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode); -} -/* }}} */ - -/* {{{ php_apache_flag_handler - */ -static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR); -} -/* }}} */ - -/* {{{ php_apache_admin_flag_handler - */ -static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) -{ - return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM); -} -/* }}} */ - -/* {{{ php_apache_phpini_set - */ -static CONST_PREFIX char *php_apache_phpini_set(cmd_parms *cmd, HashTable *conf, char *arg) -{ - if (apache_sapi_module.php_ini_path_override) { - return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored"; - } - apache_sapi_module.php_ini_path_override = ap_server_root_relative(cmd->pool, arg); - return NULL; -} -/* }}} */ - -/* {{{ int php_xbithack_handler(request_rec * r) - */ -static int php_xbithack_handler(request_rec * r) -{ - HashTable *per_dir_conf; - TSRMLS_FETCH(); - - if (!(r->finfo.st_mode & S_IXUSR)) { - return DECLINED; - } - per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php5_module); - if (per_dir_conf) { - zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC); - } - if(!AP(xbithack)) { - zend_try { - zend_ini_deactivate(TSRMLS_C); - } zend_end_try(); - return DECLINED; - } - return send_parsed_php(r); -} -/* }}} */ - -/* {{{ apache_php_module_shutdown_wrapper - */ -static void apache_php_module_shutdown_wrapper(void) -{ - apache_php_initialized = 0; - apache_sapi_module.shutdown(&apache_sapi_module); - -#if MODULE_MAGIC_NUMBER >= 19970728 - /* This function is only called on server exit if the apache API - * child_exit handler exists, so shutdown globally - */ - sapi_shutdown(); -#endif - -#ifdef ZTS - tsrm_shutdown(); -#endif -} -/* }}} */ - -#if MODULE_MAGIC_NUMBER >= 19970728 -/* {{{ php_child_exit_handler - */ -static void php_child_exit_handler(server_rec *s, pool *p) -{ -/* apache_php_initialized = 0; */ - apache_sapi_module.shutdown(&apache_sapi_module); - -#ifdef ZTS - tsrm_shutdown(); -#endif -} -/* }}} */ -#endif - -/* {{{ void php_init_handler(server_rec *s, pool *p) - */ -static void php_init_handler(server_rec *s, pool *p) -{ - register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec); - if (!apache_php_initialized) { - apache_php_initialized = 1; -#ifdef ZTS - tsrm_startup(1, 1, 0, NULL); -#endif - sapi_startup(&apache_sapi_module); - php_apache_startup(&apache_sapi_module); - } -#if MODULE_MAGIC_NUMBER >= 19980527 - { - TSRMLS_FETCH(); - if (PG(expose_php)) { - ap_add_version_component("PHP/" PHP_VERSION); - } - } -#endif -} -/* }}} */ - -/* {{{ handler_rec php_handlers[] - */ -handler_rec php_handlers[] = -{ - {"application/x-httpd-php", send_parsed_php}, - {"application/x-httpd-php-source", send_parsed_php_source}, - {"text/html", php_xbithack_handler}, - {NULL} -}; -/* }}} */ - -/* {{{ command_rec php_commands[] - */ -command_rec php_commands[] = -{ - {"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"}, - {"php_flag", php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"}, - {"php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"}, - {"php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"}, - {"PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"}, - {NULL} -}; -/* }}} */ - -/* {{{ odule MODULE_VAR_EXPORT php5_module - */ -module MODULE_VAR_EXPORT php5_module = -{ - STANDARD_MODULE_STUFF, - php_init_handler, /* initializer */ - php_create_dir, /* per-directory config creator */ - php_merge_dir, /* dir merger */ - NULL, /* per-server config creator */ - NULL, /* merge server config */ - php_commands, /* command table */ - php_handlers, /* handlers */ - NULL, /* filename translation */ - NULL, /* check_user_id */ - NULL, /* check auth */ - NULL, /* check access */ - NULL, /* type_checker */ - NULL, /* fixups */ - NULL /* logger */ -#if MODULE_MAGIC_NUMBER >= 19970103 - , NULL /* header parser */ -#endif -#if MODULE_MAGIC_NUMBER >= 19970719 - , NULL /* child_init */ -#endif -#if MODULE_MAGIC_NUMBER >= 19970728 - , php_child_exit_handler /* child_exit */ -#endif -#if MODULE_MAGIC_NUMBER >= 19970902 - , NULL /* post read-request */ -#endif -}; -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ Index: sapi/apache/mod_php5.exp =================================================================== RCS file: sapi/apache/mod_php5.exp diff -N sapi/apache/mod_php5.exp --- sapi/apache/mod_php5.exp 29 Mar 2003 04:52:46 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1 +0,0 @@ -php5_module Index: sapi/apache/mod_php5.h =================================================================== RCS file: sapi/apache/mod_php5.h diff -N sapi/apache/mod_php5.h --- sapi/apache/mod_php5.h 1 Jan 2007 09:29:36 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,54 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Rasmus Lerdorf | - +----------------------------------------------------------------------+ - */ -/* $Id: mod_php5.h,v 1.6 2007/01/01 09:29:36 sebastian Exp $ */ - -#ifndef MOD_PHP5_H -#define MOD_PHP5_H - -#if !defined(WIN32) && !defined(WINNT) -#ifndef MODULE_VAR_EXPORT -#define MODULE_VAR_EXPORT -#endif -#endif - -typedef struct { - long engine; - long last_modified; - long xbithack; - long terminate_child; - zend_bool in_request; -} php_apache_info_struct; - -extern zend_module_entry apache_module_entry; - -#ifdef ZTS -extern int php_apache_info_id; -#define AP(v) TSRMG(php_apache_info_id, php_apache_info_struct *, v) -#else -extern php_apache_info_struct php_apache_info; -#define AP(v) (php_apache_info.v) -#endif - -#endif /* MOD_PHP5_H */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ Index: sapi/apache/mod_php6.c =================================================================== RCS file: sapi/apache/mod_php6.c diff -N sapi/apache/mod_php6.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sapi/apache/mod_php6.c 10 Jan 2007 18:02:38 -0000 @@ -0,0 +1,1003 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 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 | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Rasmus Lerdorf | + | (with helpful hints from Dean Gaudet | + | PHP 4.0 patches by Zeev Suraski | + +----------------------------------------------------------------------+ + */ +/* $Id: mod_php5.c,v 1.42 2007/01/01 09:29:36 sebastian Exp $ */ + +#include "php_apache_http.h" +#include "http_conf_globals.h" + +#ifdef NETWARE +#define SIGPIPE SIGINT +#endif + +#undef shutdown + +/* {{{ Prototypes + */ +int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC); +static void php_save_umask(void); +static void php_restore_umask(void); +static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC); +static char *sapi_apache_read_cookies(TSRMLS_D); +static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC); +static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC); +static int send_php(request_rec *r, int display_source_mode, char *filename); +static int send_parsed_php(request_rec * r); +static int send_parsed_php_source(request_rec * r); +static int php_xbithack_handler(request_rec * r); +static void php_init_handler(server_rec *s, pool *p); +/* }}} */ + +#if MODULE_MAGIC_NUMBER >= 19970728 +static void php_child_exit_handler(server_rec *s, pool *p); +#endif + +#if MODULE_MAGIC_NUMBER > 19961007 +#define CONST_PREFIX const +#else +#define CONST_PREFIX +#endif +static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode); +static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); +static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); +static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); +static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode); +static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2); + +/* ### these should be defined in mod_php6.h or somewhere else */ +#define USE_PATH 1 +#define IGNORE_URL 2 +#define MAX_STATUS_LENGTH sizeof("xxxx LONGEST POSSIBLE STATUS DESCRIPTION") + +module MODULE_VAR_EXPORT php6_module; + +int saved_umask; +static unsigned char apache_php_initialized; + +typedef struct _php_per_dir_entry { + char *key; + char *value; + uint key_length; + uint value_length; + int type; +} php_per_dir_entry; + +/* some systems are missing these from their header files */ + +/* {{{ php_save_umask + */ +static void php_save_umask(void) +{ + saved_umask = umask(077); + umask(saved_umask); +} +/* }}} */ + +/* {{{ sapi_apache_ub_write + */ +static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC) +{ + int ret=0; + + if (SG(server_context)) { + ret = rwrite(str, str_length, (request_rec *) SG(server_context)); + } + if (ret != str_length) { + php_handle_aborted_connection(); + } + return ret; +} +/* }}} */ + +/* {{{ sapi_apache_flush + */ +static void sapi_apache_flush(void *server_context) +{ + if (server_context) { +#if MODULE_MAGIC_NUMBER > 19970110 + rflush((request_rec *) server_context); +#else + bflush((request_rec *) server_context->connection->client); +#endif + } +} +/* }}} */ + +/* {{{ sapi_apache_read_post + */ +static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC) +{ + int total_read_bytes=0, read_bytes; + request_rec *r = (request_rec *) SG(server_context); + void (*handler)(int); + + /* + * This handles the situation where the browser sends a Expect: 100-continue header + * and needs to recieve confirmation from the server on whether or not it can send + * the rest of the request. RFC 2616 + * + */ + if (!SG(read_post_bytes) && !ap_should_client_block(r)) { + return total_read_bytes; + } + + handler = signal(SIGPIPE, SIG_IGN); + while (total_read_bytessubprocess_env, "HTTP_COOKIE"); +} +/* }}} */ + +/* {{{ sapi_apache_header_handler + */ +static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC) +{ + char *header_name, *header_content, *p; + request_rec *r = (request_rec *) SG(server_context); + if(!r) { + efree(sapi_header->header); + return 0; + } + + header_name = sapi_header->header; + + header_content = p = strchr(header_name, ':'); + if (!p) { + efree(sapi_header->header); + return 0; + } + + *p = 0; + do { + header_content++; + } while (*header_content==' '); + + if (!strcasecmp(header_name, "Content-Type")) { + r->content_type = pstrdup(r->pool, header_content); + } else if (!strcasecmp(header_name, "Set-Cookie")) { + table_add(r->headers_out, header_name, header_content); + } else if (sapi_header->replace) { + table_set(r->headers_out, header_name, header_content); + } else { + table_add(r->headers_out, header_name, header_content); + } + + *p = ':'; /* a well behaved header handler shouldn't change its original arguments */ + + return SAPI_HEADER_ADD; +} +/* }}} */ + +/* {{{ sapi_apache_send_headers + */ +static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) +{ + request_rec *r = SG(server_context); + const char *sline = SG(sapi_headers).http_status_line; + int sline_len; + + if(r == NULL) { /* server_context is not here anymore */ + return SAPI_HEADER_SEND_FAILED; + } + + r->status = SG(sapi_headers).http_response_code; + + /* httpd requires that r->status_line is set to the first digit of + * the status-code: */ + if (sline && ((sline_len = strlen(sline)) > 12) && strncmp(sline, "HTTP/1.", 7) == 0 && sline[8] == ' ' && sline[12] == ' ') { + if ((sline_len - 9) > MAX_STATUS_LENGTH) { + r->status_line = ap_pstrndup(r->pool, sline + 9, MAX_STATUS_LENGTH); + } else { + r->status_line = ap_pstrndup(r->pool, sline + 9, sline_len - 9); + } + } + + if(r->status==304) { + send_error_response(r,0); + } else { + send_http_header(r); + } + return SAPI_HEADER_SENT_SUCCESSFULLY; +} +/* }}} */ + +/* {{{ sapi_apache_register_server_variables + */ +static void sapi_apache_register_server_variables(zval *track_vars_array TSRMLS_DC) +{ + register int i; + array_header *arr = table_elts(((request_rec *) SG(server_context))->subprocess_env); + table_entry *elts = (table_entry *) arr->elts; + zval **path_translated; + HashTable *symbol_table; + int new_val_len; + + for (i = 0; i < arr->nelts; i++) { + char *val; + int val_len; + + if (elts[i].val) { + val = elts[i].val; + } else { + val = ""; + } + val_len = strlen(val); + if (sapi_module.input_filter(PARSE_SERVER, elts[i].key, &val, val_len, &new_val_len TSRMLS_CC)) { + php_register_variable_safe(elts[i].key, val, new_val_len, track_vars_array TSRMLS_CC); + } + } + + /* If PATH_TRANSLATED doesn't exist, copy it from SCRIPT_FILENAME */ + if (track_vars_array) { + symbol_table = track_vars_array->value.ht; + } else { + symbol_table = NULL; + } + if (symbol_table + && !zend_hash_exists(symbol_table, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED")) + && zend_hash_find(symbol_table, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &path_translated)==SUCCESS) { + php_register_variable("PATH_TRANSLATED", Z_STRVAL_PP(path_translated), track_vars_array TSRMLS_CC); + } + + if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &((request_rec *) SG(server_context))->uri, strlen(((request_rec *) SG(server_context))->uri), &new_val_len TSRMLS_CC)) { + php_register_variable("PHP_SELF", ((request_rec *) SG(server_context))->uri, track_vars_array TSRMLS_CC); + } +} +/* }}} */ + +/* {{{ php_apache_startup + */ +static int php_apache_startup(sapi_module_struct *sapi_module) +{ + if (php_module_startup(sapi_module, &apache_module_entry, 1) == FAILURE) { + return FAILURE; + } else { + return SUCCESS; + } +} +/* }}} */ + +/* {{{ php_apache_log_message + */ +static void php_apache_log_message(char *message) +{ + TSRMLS_FETCH(); + + if (SG(server_context)) { +#if MODULE_MAGIC_NUMBER >= 19970831 + aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, "%s", message); +#else + log_error(message, ((request_rec *) SG(server_context))->server); +#endif + } else { + fprintf(stderr, "%s\n", message); + } +} +/* }}} */ + +/* {{{ php_apache_request_shutdown + */ +static void php_apache_request_shutdown(void *dummy) +{ + TSRMLS_FETCH(); + + php_output_set_status(PHP_OUTPUT_DISABLED TSRMLS_CC); + if (AP(in_request)) { + AP(in_request) = 0; + php_request_shutdown(dummy); + } + SG(server_context) = NULL; + /* + * The server context (request) is NOT invalid by the time + * run_cleanups() is called + */ +} +/* }}} */ + +/* {{{ php_apache_sapi_activate + */ +static int php_apache_sapi_activate(TSRMLS_D) +{ + request_rec *r = (request_rec *) SG(server_context); + + /* + * For the Apache module version, this bit of code registers a cleanup + * function that gets triggered when our request pool is destroyed. + * We need this because at any point in our code we can be interrupted + * and that may happen before we have had time to free our memory. + * The php_request_shutdown function needs to free all outstanding allocated + * memory. + */ + block_alarms(); + register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec); + AP(in_request)=1; + unblock_alarms(); + + /* Override the default headers_only value - sometimes "GET" requests should actually only + * send headers. + */ + SG(request_info).headers_only = r->header_only; + return SUCCESS; +} +/* }}} */ + +/* {{{ php_apache_get_stat + */ +static struct stat *php_apache_get_stat(TSRMLS_D) +{ + return &((request_rec *) SG(server_context))->finfo; +} +/* }}} */ + +/* {{{ php_apache_getenv + */ +static char *php_apache_getenv(char *name, size_t name_len TSRMLS_DC) +{ + if (SG(server_context) == NULL) { + return NULL; + } + + return (char *) table_get(((request_rec *) SG(server_context))->subprocess_env, name); +} +/* }}} */ + +/* {{{ sapi_apache_get_fd + */ +static int sapi_apache_get_fd(int *nfd TSRMLS_DC) +{ +#if PHP_APACHE_HAVE_CLIENT_FD + request_rec *r = SG(server_context); + int fd; + + fd = r->connection->client->fd; + + if (fd >= 0) { + if (nfd) *nfd = fd; + return SUCCESS; + } +#endif + return FAILURE; +} +/* }}} */ + +/* {{{ sapi_apache_force_http_10 + */ +static int sapi_apache_force_http_10(TSRMLS_D) +{ + request_rec *r = SG(server_context); + + r->proto_num = HTTP_VERSION(1,0); + + return SUCCESS; +} +/* }}} */ + +/* {{{ sapi_apache_get_target_uid + */ +static int sapi_apache_get_target_uid(uid_t *obj TSRMLS_DC) +{ + *obj = ap_user_id; + return SUCCESS; +} +/* }}} */ + +/* {{{ sapi_apache_get_target_gid + */ +static int sapi_apache_get_target_gid(gid_t *obj TSRMLS_DC) +{ + *obj = ap_group_id; + return SUCCESS; +} +/* }}} */ + +/* {{{ php_apache_get_request_time + */ +static time_t php_apache_get_request_time(TSRMLS_D) +{ + return ((request_rec *)SG(server_context))->request_time; +} +/* }}} */ + +/* {{{ sapi_module_struct apache_sapi_module + */ +static sapi_module_struct apache_sapi_module = { + "apache", /* name */ + "Apache", /* pretty name */ + + php_apache_startup, /* startup */ + php_module_shutdown_wrapper, /* shutdown */ + + php_apache_sapi_activate, /* activate */ + NULL, /* deactivate */ + + sapi_apache_ub_write, /* unbuffered write */ + sapi_apache_flush, /* flush */ + php_apache_get_stat, /* get uid */ + php_apache_getenv, /* getenv */ + + php_error, /* error handler */ + + sapi_apache_header_handler, /* header handler */ + sapi_apache_send_headers, /* send headers handler */ + NULL, /* send header handler */ + + sapi_apache_read_post, /* read POST data */ + sapi_apache_read_cookies, /* read Cookies */ + + sapi_apache_register_server_variables, /* register server variables */ + php_apache_log_message, /* Log message */ + php_apache_get_request_time, /* Get request time */ + + NULL, /* php.ini path override */ + +#ifdef PHP_WIN32 + NULL, + NULL, +#else + block_alarms, /* Block interruptions */ + unblock_alarms, /* Unblock interruptions */ +#endif + + NULL, /* default post reader */ + NULL, /* treat data */ + NULL, /* exe location */ + 0, /* ini ignore */ + sapi_apache_get_fd, + sapi_apache_force_http_10, + sapi_apache_get_target_uid, + sapi_apache_get_target_gid +}; +/* }}} */ + +/* {{{ php_restore_umask + */ +static void php_restore_umask(void) +{ + umask(saved_umask); +} +/* }}} */ + +/* {{{ init_request_info + */ +static void init_request_info(TSRMLS_D) +{ + request_rec *r = ((request_rec *) SG(server_context)); + char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH"); + const char *authorization=NULL; + char *tmp, *tmp_user; + + SG(request_info).query_string = r->args; + SG(request_info).path_translated = r->filename; + SG(request_info).request_uri = r->uri; + SG(request_info).request_method = (char *)r->method; + SG(request_info).content_type = (char *) table_get(r->subprocess_env, "CONTENT_TYPE"); + SG(request_info).content_length = (content_length ? atoi(content_length) : 0); + SG(sapi_headers).http_response_code = r->status; + SG(request_info).proto_num = r->proto_num; + + if (r->headers_in) { + authorization = table_get(r->headers_in, "Authorization"); + } + + SG(request_info).auth_user = NULL; + SG(request_info).auth_password = NULL; + SG(request_info).auth_digest = NULL; + + if (authorization) { + char *p = getword(r->pool, &authorization, ' '); + if (!strcasecmp(p, "Basic")) { + tmp = uudecode(r->pool, authorization); + tmp_user = getword_nulls_nc(r->pool, &tmp, ':'); + if (tmp_user) { + r->connection->user = pstrdup(r->connection->pool, tmp_user); + r->connection->ap_auth_type = "Basic"; + SG(request_info).auth_user = estrdup(tmp_user); + } + if (tmp) { + SG(request_info).auth_password = estrdup(tmp); + } + } else if (!strcasecmp(p, "Digest")) { + r->connection->ap_auth_type = "Digest"; + SG(request_info).auth_digest = estrdup(authorization); + } + } +} +/* }}} */ + +/* {{{ php_apache_alter_ini_entries + */ +static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_DC) +{ + zend_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, PHP_INI_STAGE_ACTIVATE); + return 0; +} +/* }}} */ + +/* {{{ php_apache_get_default_mimetype + */ +static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC) +{ + + char *mimetype; + /* Assume output will be of the default MIME type. Individual + scripts may change this later. */ + char *tmpmimetype; + tmpmimetype = sapi_get_default_content_type(TSRMLS_C); + mimetype = pstrdup(r->pool, tmpmimetype); + efree(tmpmimetype); + return mimetype; +} +/* }}} */ + +/* {{{ send_php + */ +static int send_php(request_rec *r, int display_source_mode, char *filename) +{ + int retval; + HashTable *per_dir_conf; + TSRMLS_FETCH(); + + if (AP(in_request)) { + zend_file_handle fh; + + fh.filename = r->filename; + fh.opened_path = NULL; + fh.free_filename = 0; + fh.type = ZEND_HANDLE_FILENAME; + + zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh); + return OK; + } + + zend_first_try { + + /* Make sure file exists */ + if (filename == NULL && r->finfo.st_mode == 0) { + return DECLINED; + } + + per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php6_module); + if (per_dir_conf) { + zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC); + } + + /* If PHP parser engine has been turned off with an "engine off" + * directive, then decline to handle this request + */ + if (!AP(engine)) { + r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC); + zend_try { + zend_ini_deactivate(TSRMLS_C); + } zend_end_try(); + return DECLINED; + } + if (filename == NULL) { + filename = r->filename; + } + + /* Apache 1.2 has a more complex mechanism for reading POST data */ +#if MODULE_MAGIC_NUMBER > 19961007 + if ((retval = setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) { + zend_try { + zend_ini_deactivate(TSRMLS_C); + } zend_end_try(); + return retval; + } +#endif + + if (AP(last_modified)) { +#if MODULE_MAGIC_NUMBER < 19970912 + if ((retval = set_last_modified(r, r->finfo.st_mtime))) { + zend_try { + zend_ini_deactivate(TSRMLS_C); + } zend_end_try(); + return retval; + } +#else + update_mtime (r, r->finfo.st_mtime); + set_last_modified(r); + set_etag(r); +#endif + } + /* Assume output will be of the default MIME type. Individual + scripts may change this later in the request. */ + r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC); + + /* Init timeout */ + hard_timeout("send", r); + + SG(server_context) = r; + + php_save_umask(); + add_common_vars(r); + add_cgi_vars(r); + + init_request_info(TSRMLS_C); + apache_php_module_main(r, display_source_mode TSRMLS_CC); + + /* Done, restore umask, turn off timeout, close file and return */ + php_restore_umask(); + kill_timeout(r); + } zend_end_try(); + + return OK; +} +/* }}} */ + +/* {{{ send_parsed_php + */ +static int send_parsed_php(request_rec * r) +{ + int result = send_php(r, 0, NULL); + TSRMLS_FETCH(); + + ap_table_setn(r->notes, "mod_php_memory_usage", + ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC))); + + return result; +} +/* }}} */ + +/* {{{ send_parsed_php_source + */ +static int send_parsed_php_source(request_rec * r) +{ + return send_php(r, 1, NULL); +} +/* }}} */ + +/* {{{ destroy_per_dir_entry + */ +static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry) +{ + free(per_dir_entry->key); + free(per_dir_entry->value); +} +/* }}} */ + +/* {{{ copy_per_dir_entry + */ +static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry) +{ + php_per_dir_entry tmp = *per_dir_entry; + + per_dir_entry->key = (char *) malloc(tmp.key_length+1); + memcpy(per_dir_entry->key, tmp.key, tmp.key_length); + per_dir_entry->key[per_dir_entry->key_length] = 0; + + per_dir_entry->value = (char *) malloc(tmp.value_length+1); + memcpy(per_dir_entry->value, tmp.value, tmp.value_length); + per_dir_entry->value[per_dir_entry->value_length] = 0; +} +/* }}} */ + +/* {{{ should_overwrite_per_dir_entry + */ +static zend_bool should_overwrite_per_dir_entry(HashTable *target_ht, php_per_dir_entry *new_per_dir_entry, zend_hash_key *hash_key, void *pData) +{ + php_per_dir_entry *orig_per_dir_entry; + + if (zend_u_hash_find(target_ht, hash_key->type, hash_key->arKey, hash_key->nKeyLength, (void **) &orig_per_dir_entry)==FAILURE) { + return 1; /* does not exist in dest, copy from source */ + } + + if (new_per_dir_entry->type==PHP_INI_SYSTEM + && orig_per_dir_entry->type!=PHP_INI_SYSTEM) { + return 1; + } else { + return 0; + } +} +/* }}} */ + +/* {{{ php_destroy_per_dir_info + */ +static void php_destroy_per_dir_info(HashTable *per_dir_info) +{ + zend_hash_destroy(per_dir_info); + free(per_dir_info); +} +/* }}} */ + +/* {{{ php_create_dir + */ +static void *php_create_dir(pool *p, char *dummy) +{ + HashTable *per_dir_info; + + per_dir_info = (HashTable *) malloc(sizeof(HashTable)); + zend_hash_init_ex(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0); + register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy); + + return per_dir_info; +} +/* }}} */ + +/* {{{ php_merge_dir + */ +static void *php_merge_dir(pool *p, void *basev, void *addv) +{ + /* This function *must* return addv, and not modify basev */ + zend_hash_merge_ex((HashTable *) addv, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (merge_checker_func_t) should_overwrite_per_dir_entry, NULL); + return addv; +} +/* }}} */ + +/* {{{ php_apache_value_handler_ex + */ +static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode) +{ + php_per_dir_entry per_dir_entry; + + if (!apache_php_initialized) { + apache_php_initialized = 1; +#ifdef ZTS + tsrm_startup(1, 1, 0, NULL); +#endif + sapi_startup(&apache_sapi_module); + php_apache_startup(&apache_sapi_module); + } + per_dir_entry.type = mode; + + if (strcasecmp(arg2, "none") == 0) { + arg2 = ""; + } + + per_dir_entry.key_length = strlen(arg1); + per_dir_entry.value_length = strlen(arg2); + + per_dir_entry.key = (char *) malloc(per_dir_entry.key_length+1); + memcpy(per_dir_entry.key, arg1, per_dir_entry.key_length); + per_dir_entry.key[per_dir_entry.key_length] = 0; + + per_dir_entry.value = (char *) malloc(per_dir_entry.value_length+1); + memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length); + per_dir_entry.value[per_dir_entry.value_length] = 0; + + zend_hash_update(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL); + return NULL; +} +/* }}} */ + +/* {{{ php_apache_value_handler + */ +static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) +{ + return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR); +} +/* }}} */ + +/* {{{ php_apache_admin_value_handler + */ +static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) +{ + return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM); +} +/* }}} */ + +/* {{{ php_apache_flag_handler_ex + */ +static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode) +{ + char bool_val[2]; + + if (!strcasecmp(arg2, "On") || (arg2[0] == '1' && arg2[1] == '\0')) { + bool_val[0] = '1'; + } else { + bool_val[0] = '0'; + } + bool_val[1] = 0; + + return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode); +} +/* }}} */ + +/* {{{ php_apache_flag_handler + */ +static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) +{ + return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR); +} +/* }}} */ + +/* {{{ php_apache_admin_flag_handler + */ +static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2) +{ + return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM); +} +/* }}} */ + +/* {{{ php_apache_phpini_set + */ +static CONST_PREFIX char *php_apache_phpini_set(cmd_parms *cmd, HashTable *conf, char *arg) +{ + if (apache_sapi_module.php_ini_path_override) { + return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored"; + } + apache_sapi_module.php_ini_path_override = ap_server_root_relative(cmd->pool, arg); + return NULL; +} +/* }}} */ + +/* {{{ int php_xbithack_handler(request_rec * r) + */ +static int php_xbithack_handler(request_rec * r) +{ + HashTable *per_dir_conf; + TSRMLS_FETCH(); + + if (!(r->finfo.st_mode & S_IXUSR)) { + return DECLINED; + } + per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php6_module); + if (per_dir_conf) { + zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC); + } + if(!AP(xbithack)) { + zend_try { + zend_ini_deactivate(TSRMLS_C); + } zend_end_try(); + return DECLINED; + } + return send_parsed_php(r); +} +/* }}} */ + +/* {{{ apache_php_module_shutdown_wrapper + */ +static void apache_php_module_shutdown_wrapper(void) +{ + apache_php_initialized = 0; + apache_sapi_module.shutdown(&apache_sapi_module); + +#if MODULE_MAGIC_NUMBER >= 19970728 + /* This function is only called on server exit if the apache API + * child_exit handler exists, so shutdown globally + */ + sapi_shutdown(); +#endif + +#ifdef ZTS + tsrm_shutdown(); +#endif +} +/* }}} */ + +#if MODULE_MAGIC_NUMBER >= 19970728 +/* {{{ php_child_exit_handler + */ +static void php_child_exit_handler(server_rec *s, pool *p) +{ +/* apache_php_initialized = 0; */ + apache_sapi_module.shutdown(&apache_sapi_module); + +#ifdef ZTS + tsrm_shutdown(); +#endif +} +/* }}} */ +#endif + +/* {{{ void php_init_handler(server_rec *s, pool *p) + */ +static void php_init_handler(server_rec *s, pool *p) +{ + register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec); + if (!apache_php_initialized) { + apache_php_initialized = 1; +#ifdef ZTS + tsrm_startup(1, 1, 0, NULL); +#endif + sapi_startup(&apache_sapi_module); + php_apache_startup(&apache_sapi_module); + } +#if MODULE_MAGIC_NUMBER >= 19980527 + { + TSRMLS_FETCH(); + if (PG(expose_php)) { + ap_add_version_component("PHP/" PHP_VERSION); + } + } +#endif +} +/* }}} */ + +/* {{{ handler_rec php_handlers[] + */ +handler_rec php_handlers[] = +{ + {"application/x-httpd-php", send_parsed_php}, + {"application/x-httpd-php-source", send_parsed_php_source}, + {"text/html", php_xbithack_handler}, + {NULL} +}; +/* }}} */ + +/* {{{ command_rec php_commands[] + */ +command_rec php_commands[] = +{ + {"php_value", php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"}, + {"php_flag", php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"}, + {"php_admin_value", php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"}, + {"php_admin_flag", php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"}, + {"PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file"}, + {NULL} +}; +/* }}} */ + +/* {{{ odule MODULE_VAR_EXPORT php6_module + */ +module MODULE_VAR_EXPORT php6_module = +{ + STANDARD_MODULE_STUFF, + php_init_handler, /* initializer */ + php_create_dir, /* per-directory config creator */ + php_merge_dir, /* dir merger */ + NULL, /* per-server config creator */ + NULL, /* merge server config */ + php_commands, /* command table */ + php_handlers, /* handlers */ + NULL, /* filename translation */ + NULL, /* check_user_id */ + NULL, /* check auth */ + NULL, /* check access */ + NULL, /* type_checker */ + NULL, /* fixups */ + NULL /* logger */ +#if MODULE_MAGIC_NUMBER >= 19970103 + , NULL /* header parser */ +#endif +#if MODULE_MAGIC_NUMBER >= 19970719 + , NULL /* child_init */ +#endif +#if MODULE_MAGIC_NUMBER >= 19970728 + , php_child_exit_handler /* child_exit */ +#endif +#if MODULE_MAGIC_NUMBER >= 19970902 + , NULL /* post read-request */ +#endif +}; +/* }}} */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 + */ Index: sapi/apache/mod_php6.exp =================================================================== RCS file: sapi/apache/mod_php6.exp diff -N sapi/apache/mod_php6.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sapi/apache/mod_php6.exp 10 Jan 2007 18:02:38 -0000 @@ -0,0 +1 @@ +php6_module Index: sapi/apache/mod_php6.h =================================================================== RCS file: sapi/apache/mod_php6.h diff -N sapi/apache/mod_php6.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sapi/apache/mod_php6.h 10 Jan 2007 18:02:38 -0000 @@ -0,0 +1,54 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2007 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 | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Rasmus Lerdorf | + +----------------------------------------------------------------------+ + */ +/* $Id: mod_php5.h,v 1.6 2007/01/01 09:29:36 sebastian Exp $ */ + +#ifndef MOD_PHP6_H +#define MOD_PHP6_H + +#if !defined(WIN32) && !defined(WINNT) +#ifndef MODULE_VAR_EXPORT +#define MODULE_VAR_EXPORT +#endif +#endif + +typedef struct { + long engine; + long last_modified; + long xbithack; + long terminate_child; + zend_bool in_request; +} php_apache_info_struct; + +extern zend_module_entry apache_module_entry; + +#ifdef ZTS +extern int php_apache_info_id; +#define AP(v) TSRMG(php_apache_info_id, php_apache_info_struct *, v) +#else +extern php_apache_info_struct php_apache_info; +#define AP(v) (php_apache_info.v) +#endif + +#endif /* MOD_PHP6_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ Index: sapi/apache/php.sym =================================================================== RCS file: /repository/php-src/sapi/apache/php.sym,v retrieving revision 1.2 diff -p -u -r1.2 php.sym --- sapi/apache/php.sym 29 Mar 2003 04:52:46 -0000 1.2 +++ sapi/apache/php.sym 10 Jan 2007 18:02:38 -0000 @@ -1 +1 @@ -php5_module +php6_module Index: sapi/apache/php_apache_http.h =================================================================== RCS file: /repository/php-src/sapi/apache/php_apache_http.h,v retrieving revision 1.15 diff -p -u -r1.15 php_apache_http.h --- sapi/apache/php_apache_http.h 1 Jan 2007 09:29:36 -0000 1.15 +++ sapi/apache/php_apache_http.h 10 Jan 2007 18:02:38 -0000 @@ -67,4 +67,4 @@ #include "php_ini.h" #include "ext/standard/php_standard.h" -#include "mod_php5.h" +#include "mod_php6.h" Index: sapi/cli/config.m4 =================================================================== RCS file: /repository/php-src/sapi/cli/config.m4,v retrieving revision 1.23 diff -p -u -r1.23 config.m4 --- sapi/cli/config.m4 2 Feb 2006 10:00:09 -0000 1.23 +++ sapi/cli/config.m4 10 Jan 2007 18:02:38 -0000 @@ -26,7 +26,7 @@ if test "$PHP_SAPI_CLI" != "no"; then BUILD_CLI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_CLI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" ;; *netware*) - BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -Lnetware -lphp5lib -o \$(SAPI_CLI_PATH)" + BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -Lnetware -lphp6lib -o \$(SAPI_CLI_PATH)" ;; *) BUILD_CLI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CLI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CLI_PATH)" --Apple-Mail-2--980868673--