summaryrefslogtreecommitdiff
path: root/lang/pear
diff options
context:
space:
mode:
authorseb <seb@pkgsrc.org>2009-10-29 08:29:03 +0000
committerseb <seb@pkgsrc.org>2009-10-29 08:29:03 +0000
commit17a55d1925b66f4e66614d3229bb40c32442b791 (patch)
treef3c7464747882ead0105f95134b065063aff36c6 /lang/pear
parent419c94ab7213c935b1b3392f5fda1a43c8f7ae34 (diff)
downloadpkgsrc-17a55d1925b66f4e66614d3229bb40c32442b791.tar.gz
Update pear from version 1.5.4nb3 to version 1.9.0.
Pkgsrc changes: - Update base pear packages:Archive_Tar-1.3.3, Console_Getopt-1.2.3 Structures_Graph-1.0.3 - Update ${FILESDIR}/go-pear.php from latest version at http://pear.php.net/go-pear - Update ${FILESDIR}/pear.sh from the bundled version - Provide bootstrap PEAR.php via ${FILESDIR}/PEAR.php from http://cvs.php.net/viewvc.cgi/pear-core/PEAR.php?view=co&pathrev=PEAR_1_4 (see FILESDIR/go-pear.php's code) and put it into ${WRKSRC} at the extract phase - Update PLIST Upstream changes: A lot! IMHO more than what can be recorded here. Please see individual releases Changelog since version 1.5.4 at http://pear.php.net/package/PEAR.
Diffstat (limited to 'lang/pear')
-rw-r--r--lang/pear/Makefile19
-rw-r--r--lang/pear/PLIST23
-rw-r--r--lang/pear/distinfo31
-rw-r--r--lang/pear/files/PEAR.php1110
-rw-r--r--lang/pear/files/go-pear.php1118
-rw-r--r--lang/pear/files/pear.sh4
-rw-r--r--lang/pear/patches/patch-aa106
7 files changed, 1863 insertions, 548 deletions
diff --git a/lang/pear/Makefile b/lang/pear/Makefile
index 1e3b345c9d4..42b6a51402d 100644
--- a/lang/pear/Makefile
+++ b/lang/pear/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.10 2009/07/17 18:00:16 adrianp Exp $
+# $NetBSD: Makefile,v 1.11 2009/10/29 08:29:03 seb Exp $
#
-DISTNAME= PEAR-1.5.4
-PKGREVISION= 3
+DISTNAME= PEAR-1.9.0
+#PKGREVISION= 1
PKGNAME= ${PHP_PKG_PREFIX}-${DISTNAME:S/PEAR/pear/}
CATEGORIES= lang
MASTER_SITES= http://download.pear.php.net/package/
@@ -31,21 +31,21 @@ BUNDLE= ${WRKSRC}/install/go-pear-bundle
# everything else that forms a part of the "base" PEAR install
#
-PEAR_SRCS= PEAR-1.5.4${EXTRACT_SUFX}
+PEAR_SRCS= PEAR-1.9.0${EXTRACT_SUFX}
DISTFILES+= ${PEAR_SRCS}
EXTRACT_ONLY+= ${PEAR_SRCS}
-ARCHIVE_SRCS= Archive_Tar-1.3.2${EXTRACT_SUFX}
+ARCHIVE_SRCS= Archive_Tar-1.3.3${EXTRACT_SUFX}
ARCHIVE_WRKSRC= ${WRKDIR}/${ARCHIVE_SRCS:S/${EXTRACT_SUFX}//}
DISTFILES+= ${ARCHIVE_SRCS}
EXTRACT_ONLY+= ${ARCHIVE_SRCS}
-CONSOLE_SRCS= Console_Getopt-1.2.2${EXTRACT_SUFX}
+CONSOLE_SRCS= Console_Getopt-1.2.3${EXTRACT_SUFX}
CONSOLE_WRKSRC= ${WRKDIR}/${CONSOLE_SRCS:S/${EXTRACT_SUFX}//}
DISTFILES+= ${CONSOLE_SRCS}
EXTRACT_ONLY+= ${CONSOLE_SRCS}
-STRUCTURES_SRCS= Structures_Graph-1.0.2${EXTRACT_SUFX}
+STRUCTURES_SRCS= Structures_Graph-1.0.3${EXTRACT_SUFX}
DISTFILES+= ${STRUCTURES_SRCS}
#
# end of base components
@@ -65,12 +65,15 @@ SUBST_SED.pear+= -e "s|@php_dir@|${PREFIX}/lib/php|g"
SUBST_SED.pear+= -e "s|@SH@|${SH}|g"
SUBST_MESSAGE.pear= Fixing pear installation script.
+INSTALLATION_DIRS+= share/examples/pear
+
post-extract:
${RM} ${WRKSRC}/INSTALL
${MKDIR} ${WRKSRC}/install
${MKDIR} ${BUNDLE}
${CP} ${FILESDIR}/go-pear.php ${WRKSRC}/install
${CP} ${FILESDIR}/pear.sh ${WRKSRC}
+ ${CP} ${FILESDIR}/PEAR.php ${BUNDLE}
do-build:
${GZCAT} ${DISTDIR}/${ARCHIVE_SRCS} > \
@@ -84,10 +87,8 @@ do-build:
${CP} ${ARCHIVE_WRKSRC}/Archive/Tar.php ${BUNDLE}
${CP} ${CONSOLE_WRKSRC}/Console/Getopt.php ${BUNDLE}
- ${CP} ${WRKSRC}/PEAR.php ${BUNDLE}
do-install:
- ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/share/examples/pear
${PREFIX}/bin/php ${DESTDIR}${WRKSRC}/install/go-pear.php local
${INSTALL_SCRIPT} ${WRKSRC}/pear.sh ${DESTDIR}${PREFIX}/bin/pear
${INSTALL_DATA} ${WRKSRC}/pear.conf \
diff --git a/lang/pear/PLIST b/lang/pear/PLIST
index 6fa6f0ef8e3..077b4c12665 100644
--- a/lang/pear/PLIST
+++ b/lang/pear/PLIST
@@ -1,10 +1,12 @@
-@comment $NetBSD: PLIST,v 1.4 2009/06/14 20:34:14 joerg Exp $
+@comment $NetBSD: PLIST,v 1.5 2009/10/29 08:29:03 seb Exp $
bin/pear
bin/peardev
bin/pecl
lib/php/.channels/.alias/pear.txt
lib/php/.channels/.alias/pecl.txt
+lib/php/.channels/.alias/phpdocs.txt
lib/php/.channels/__uri.reg
+lib/php/.channels/doc.php.net.reg
lib/php/.channels/pear.php.net.reg
lib/php/.channels/pecl.php.net.reg
lib/php/.depdb
@@ -49,17 +51,19 @@ lib/php/PEAR/Command/Test.php
lib/php/PEAR/Command/Test.xml
lib/php/PEAR/Common.php
lib/php/PEAR/Config.php
-lib/php/PEAR/Dependency.php
lib/php/PEAR/Dependency2.php
lib/php/PEAR/DependencyDB.php
lib/php/PEAR/Downloader.php
lib/php/PEAR/Downloader/Package.php
lib/php/PEAR/ErrorStack.php
lib/php/PEAR/Exception.php
+lib/php/PEAR/FixPHP5PEARWarnings.php
lib/php/PEAR/Frontend.php
lib/php/PEAR/Frontend/CLI.php
lib/php/PEAR/Installer.php
lib/php/PEAR/Installer/Role.php
+lib/php/PEAR/Installer/Role/Cfg.php
+lib/php/PEAR/Installer/Role/Cfg.xml
lib/php/PEAR/Installer/Role/Common.php
lib/php/PEAR/Installer/Role/Data.php
lib/php/PEAR/Installer/Role/Data.xml
@@ -75,6 +79,8 @@ lib/php/PEAR/Installer/Role/Src.php
lib/php/PEAR/Installer/Role/Src.xml
lib/php/PEAR/Installer/Role/Test.php
lib/php/PEAR/Installer/Role/Test.xml
+lib/php/PEAR/Installer/Role/Www.php
+lib/php/PEAR/Installer/Role/Www.xml
lib/php/PEAR/PackageFile.php
lib/php/PEAR/PackageFile/Generator/v1.php
lib/php/PEAR/PackageFile/Generator/v2.php
@@ -88,8 +94,8 @@ lib/php/PEAR/Packager.php
lib/php/PEAR/REST.php
lib/php/PEAR/REST/10.php
lib/php/PEAR/REST/11.php
+lib/php/PEAR/REST/13.php
lib/php/PEAR/Registry.php
-lib/php/PEAR/Remote.php
lib/php/PEAR/RunTest.php
lib/php/PEAR/Task/Common.php
lib/php/PEAR/Task/Postinstallscript.php
@@ -103,6 +109,7 @@ lib/php/PEAR/Task/Windowseol/rw.php
lib/php/PEAR/Validate.php
lib/php/PEAR/Validator/PECL.php
lib/php/PEAR/XMLParser.php
+lib/php/PEAR5.php
lib/php/Structures/Graph.php
lib/php/Structures/Graph/Manipulator/AcyclicTest.php
lib/php/Structures/Graph/Manipulator/TopologicalSorter.php
@@ -111,11 +118,9 @@ lib/php/System.php
lib/php/data/PEAR/package.dtd
lib/php/data/PEAR/template.spec
lib/php/data/Structures_Graph/LICENSE
-lib/php/data/Structures_Graph/genpackage.xml.pl
-lib/php/data/Structures_Graph/package.sh
-lib/php/data/Structures_Graph/publish.sh
lib/php/doc/Archive_Tar/docs/Archive_Tar.txt
lib/php/doc/PEAR/INSTALL
+lib/php/doc/PEAR/LICENSE
lib/php/doc/PEAR/README
lib/php/doc/Structures_Graph/docs/generate.sh
lib/php/doc/Structures_Graph/docs/html/Structures_Graph/Structures_Graph.html
@@ -140,9 +145,9 @@ lib/php/doc/Structures_Graph/docs/html/todolist.html
lib/php/doc/Structures_Graph/docs/tutorials/Structures_Graph/Structures_Graph.pkg
lib/php/pearcmd.php
lib/php/peclcmd.php
-lib/php/test/Structures_Graph/tests/README
-lib/php/test/Structures_Graph/tests/all-tests.php
+lib/php/test/Structures_Graph/tests/AllTests.php
lib/php/test/Structures_Graph/tests/testCase/BasicGraph.php
share/examples/pear/pear.conf
-@pkgdir lib/php/.registry/.channel.__uri
@pkgdir lib/php/.registry/.channel.pecl.php.net
+@pkgdir lib/php/.registry/.channel.doc.php.net
+@pkgdir lib/php/.registry/.channel.__uri
diff --git a/lang/pear/distinfo b/lang/pear/distinfo
index 6ba054ad573..b6c57f12f67 100644
--- a/lang/pear/distinfo
+++ b/lang/pear/distinfo
@@ -1,15 +1,18 @@
-$NetBSD: distinfo,v 1.4 2008/09/15 11:54:21 adrianp Exp $
+$NetBSD: distinfo,v 1.5 2009/10/29 08:29:03 seb Exp $
-SHA1 (Archive_Tar-1.3.2.tgz) = 40a16c6fe6cee12d9fd87d487785db2949ffa9ff
-RMD160 (Archive_Tar-1.3.2.tgz) = cec105d1cdefd502f209c24c217645cec723d7a2
-Size (Archive_Tar-1.3.2.tgz) = 17150 bytes
-SHA1 (Console_Getopt-1.2.2.tgz) = 3158237f6cd8ed34a269c67cbe546156c03cff0b
-RMD160 (Console_Getopt-1.2.2.tgz) = fb8a955ef2c41618305e03c9a4164c3a465c5e86
-Size (Console_Getopt-1.2.2.tgz) = 4252 bytes
-SHA1 (PEAR-1.5.4.tgz) = f03a8bfbd68bd1834829a67346711fd157da3685
-RMD160 (PEAR-1.5.4.tgz) = 2e3ede082a7f6b085cfd414ddaf5b0d9dad1372f
-Size (PEAR-1.5.4.tgz) = 293070 bytes
-SHA1 (Structures_Graph-1.0.2.tgz) = 300aa0a2effb0b39c4fa8a63a834748ae99c2855
-RMD160 (Structures_Graph-1.0.2.tgz) = 8eb53f6da109b90bab5d8101e99183a1ae116404
-Size (Structures_Graph-1.0.2.tgz) = 30947 bytes
-SHA1 (patch-aa) = b7938a5143f27f167a3065f6331bd34cd0d65153
+SHA1 (Archive_Tar-1.3.3.tgz) = b49de079aee8c087c19b718534503234670598cb
+RMD160 (Archive_Tar-1.3.3.tgz) = 3abe03b42ee81b6ddf5449db6277806f664aec6b
+Size (Archive_Tar-1.3.3.tgz) = 18119 bytes
+SHA1 (Console_Getopt-1.2.3.tgz) = 2f4ea028f478123164c3f6588f8a505dc35915df
+RMD160 (Console_Getopt-1.2.3.tgz) = d1624dbcb223395ded9e46285f896d6f5bb5ca74
+Size (Console_Getopt-1.2.3.tgz) = 4011 bytes
+SHA1 (PEAR-1.9.0.tgz) = a268b9af85a3daad047c77947838932f2737e6aa
+RMD160 (PEAR-1.9.0.tgz) = cfac92b7569676783b44a38309f8a156f49a35e8
+Size (PEAR-1.9.0.tgz) = 291634 bytes
+SHA1 (Structures_Graph-1.0.3.tgz) = 13761cc4788f6c272730abe110a5a5048be18643
+RMD160 (Structures_Graph-1.0.3.tgz) = 835cfc8c4cd7475f5486c710abe5dd9737c1b476
+Size (Structures_Graph-1.0.3.tgz) = 30191 bytes
+SHA1 (XML_Util-1.2.1.tgz) = 8072216577fb9ad684f15e0388ab0b1c0b57e2d4
+RMD160 (XML_Util-1.2.1.tgz) = 9d9dd43889312f46f39c9a43a800a8f2d8f6e9b2
+Size (XML_Util-1.2.1.tgz) = 17729 bytes
+SHA1 (patch-aa) = 8d4d9762c26e878ab78e465eace3c4bac1a7ef5f
diff --git a/lang/pear/files/PEAR.php b/lang/pear/files/PEAR.php
new file mode 100644
index 00000000000..4fb2543cf50
--- /dev/null
+++ b/lang/pear/files/PEAR.php
@@ -0,0 +1,1110 @@
+<?php
+/**
+ * PEAR, the PHP Extension and Application Repository
+ *
+ * PEAR class and PEAR_Error class
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
+ * the PHP License and are unable to obtain it through the web, please
+ * send a note to license@php.net so we can mail you a copy immediately.
+ *
+ * @category pear
+ * @package PEAR
+ * @author Sterling Hughes <sterling@php.net>
+ * @author Stig Bakken <ssb@php.net>
+ * @author Tomas V.V.Cox <cox@idecnet.com>
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2006 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version CVS: Id: PEAR.php,v 1.97 2006/01/06 04:47:36 cellog Exp
+ * @link http://pear.php.net/package/PEAR
+ * @since File available since Release 0.1
+ */
+
+/*
+ * $NetBSD: PEAR.php,v 1.1 2009/10/29 08:29:03 seb Exp $
+ *
+ * This is http://cvs.php.net/viewvc.cgi/pear-core/PEAR.php?view=co&pathrev=PEAR_1_4
+ *
+ * See $bootstrap_files definition in go-pear.php
+ *
+ */
+
+/**#@+
+ * ERROR constants
+ */
+define('PEAR_ERROR_RETURN', 1);
+define('PEAR_ERROR_PRINT', 2);
+define('PEAR_ERROR_TRIGGER', 4);
+define('PEAR_ERROR_DIE', 8);
+define('PEAR_ERROR_CALLBACK', 16);
+/**
+ * WARNING: obsolete
+ * @deprecated
+ */
+define('PEAR_ERROR_EXCEPTION', 32);
+/**#@-*/
+define('PEAR_ZE2', (function_exists('version_compare') &&
+ version_compare(zend_version(), "2-dev", "ge")));
+
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ define('OS_WINDOWS', true);
+ define('OS_UNIX', false);
+ define('PEAR_OS', 'Windows');
+} else {
+ define('OS_WINDOWS', false);
+ define('OS_UNIX', true);
+ define('PEAR_OS', 'Unix'); // blatant assumption
+}
+
+// instant backwards compatibility
+if (!defined('PATH_SEPARATOR')) {
+ if (OS_WINDOWS) {
+ define('PATH_SEPARATOR', ';');
+ } else {
+ define('PATH_SEPARATOR', ':');
+ }
+}
+
+$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
+$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
+$GLOBALS['_PEAR_destructor_object_list'] = array();
+$GLOBALS['_PEAR_shutdown_funcs'] = array();
+$GLOBALS['_PEAR_error_handler_stack'] = array();
+
+@ini_set('track_errors', true);
+
+/**
+ * Base class for other PEAR classes. Provides rudimentary
+ * emulation of destructors.
+ *
+ * If you want a destructor in your class, inherit PEAR and make a
+ * destructor method called _yourclassname (same name as the
+ * constructor, but with a "_" prefix). Also, in your constructor you
+ * have to call the PEAR constructor: $this->PEAR();.
+ * The destructor method will be called without parameters. Note that
+ * at in some SAPI implementations (such as Apache), any output during
+ * the request shutdown (in which destructors are called) seems to be
+ * discarded. If you need to get any debug information from your
+ * destructor, use error_log(), syslog() or something similar.
+ *
+ * IMPORTANT! To use the emulated destructors you need to create the
+ * objects by reference: $obj =& new PEAR_child;
+ *
+ * @category pear
+ * @package PEAR
+ * @author Stig Bakken <ssb@php.net>
+ * @author Tomas V.V. Cox <cox@idecnet.com>
+ * @author Greg Beaver <cellog@php.net>
+ * @copyright 1997-2006 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/PEAR
+ * @see PEAR_Error
+ * @since Class available since PHP 4.0.2
+ * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear
+ */
+class PEAR
+{
+ // {{{ properties
+
+ /**
+ * Whether to enable internal debug messages.
+ *
+ * @var bool
+ * @access private
+ */
+ var $_debug = false;
+
+ /**
+ * Default error mode for this object.
+ *
+ * @var int
+ * @access private
+ */
+ var $_default_error_mode = null;
+
+ /**
+ * Default error options used for this object when error mode
+ * is PEAR_ERROR_TRIGGER.
+ *
+ * @var int
+ * @access private
+ */
+ var $_default_error_options = null;
+
+ /**
+ * Default error handler (callback) for this object, if error mode is
+ * PEAR_ERROR_CALLBACK.
+ *
+ * @var string
+ * @access private
+ */
+ var $_default_error_handler = '';
+
+ /**
+ * Which class to use for error objects.
+ *
+ * @var string
+ * @access private
+ */
+ var $_error_class = 'PEAR_Error';
+
+ /**
+ * An array of expected errors.
+ *
+ * @var array
+ * @access private
+ */
+ var $_expected_errors = array();
+
+ // }}}
+
+ // {{{ constructor
+
+ /**
+ * Constructor. Registers this object in
+ * $_PEAR_destructor_object_list for destructor emulation if a
+ * destructor object exists.
+ *
+ * @param string $error_class (optional) which class to use for
+ * error objects, defaults to PEAR_Error.
+ * @access public
+ * @return void
+ */
+ function PEAR($error_class = null)
+ {
+ $classname = strtolower(get_class($this));
+ if ($this->_debug) {
+ print "PEAR constructor called, class=$classname\n";
+ }
+ if ($error_class !== null) {
+ $this->_error_class = $error_class;
+ }
+ while ($classname && strcasecmp($classname, "pear")) {
+ $destructor = "_$classname";
+ if (method_exists($this, $destructor)) {
+ global $_PEAR_destructor_object_list;
+ $_PEAR_destructor_object_list[] = &$this;
+ if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
+ register_shutdown_function("_PEAR_call_destructors");
+ $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
+ }
+ break;
+ } else {
+ $classname = get_parent_class($classname);
+ }
+ }
+ }
+
+ // }}}
+ // {{{ destructor
+
+ /**
+ * Destructor (the emulated type of...). Does nothing right now,
+ * but is included for forward compatibility, so subclass
+ * destructors should always call it.
+ *
+ * See the note in the class desciption about output from
+ * destructors.
+ *
+ * @access public
+ * @return void
+ */
+ function _PEAR() {
+ if ($this->_debug) {
+ printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
+ }
+ }
+
+ // }}}
+ // {{{ getStaticProperty()
+
+ /**
+ * If you have a class that's mostly/entirely static, and you need static
+ * properties, you can use this method to simulate them. Eg. in your method(s)
+ * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
+ * You MUST use a reference, or they will not persist!
+ *
+ * @access public
+ * @param string $class The calling classname, to prevent clashes
+ * @param string $var The variable to retrieve.
+ * @return mixed A reference to the variable. If not set it will be
+ * auto initialised to NULL.
+ */
+ function &getStaticProperty($class, $var)
+ {
+ static $properties;
+ return $properties[$class][$var];
+ }
+
+ // }}}
+ // {{{ registerShutdownFunc()
+
+ /**
+ * Use this function to register a shutdown method for static
+ * classes.
+ *
+ * @access public
+ * @param mixed $func The function name (or array of class/method) to call
+ * @param mixed $args The arguments to pass to the function
+ * @return void
+ */
+ function registerShutdownFunc($func, $args = array())
+ {
+ // if we are called statically, there is a potential
+ // that no shutdown func is registered. Bug #6445
+ if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
+ register_shutdown_function("_PEAR_call_destructors");
+ $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
+ }
+ $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
+ }
+
+ // }}}
+ // {{{ isError()
+
+ /**
+ * Tell whether a value is a PEAR error.
+ *
+ * @param mixed $data the value to test
+ * @param int $code if $data is an error object, return true
+ * only if $code is a string and
+ * $obj->getMessage() == $code or
+ * $code is an integer and $obj->getCode() == $code
+ * @access public
+ * @return bool true if parameter is an error
+ */
+ function isError($data, $code = null)
+ {
+ if (is_a($data, 'PEAR_Error')) {
+ if (is_null($code)) {
+ return true;
+ } elseif (is_string($code)) {
+ return $data->getMessage() == $code;
+ } else {
+ return $data->getCode() == $code;
+ }
+ }
+ return false;
+ }
+
+ // }}}
+ // {{{ setErrorHandling()
+
+ /**
+ * Sets how errors generated by this object should be handled.
+ * Can be invoked both in objects and statically. If called
+ * statically, setErrorHandling sets the default behaviour for all
+ * PEAR objects. If called in an object, setErrorHandling sets
+ * the default behaviour for that object.
+ *
+ * @param int $mode
+ * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
+ * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
+ * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
+ *
+ * @param mixed $options
+ * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
+ * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
+ *
+ * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
+ * to be the callback function or method. A callback
+ * function is a string with the name of the function, a
+ * callback method is an array of two elements: the element
+ * at index 0 is the object, and the element at index 1 is
+ * the name of the method to call in the object.
+ *
+ * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
+ * a printf format string used when printing the error
+ * message.
+ *
+ * @access public
+ * @return void
+ * @see PEAR_ERROR_RETURN
+ * @see PEAR_ERROR_PRINT
+ * @see PEAR_ERROR_TRIGGER
+ * @see PEAR_ERROR_DIE
+ * @see PEAR_ERROR_CALLBACK
+ * @see PEAR_ERROR_EXCEPTION
+ *
+ * @since PHP 4.0.5
+ */
+
+ function setErrorHandling($mode = null, $options = null)
+ {
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $setmode = &$this->_default_error_mode;
+ $setoptions = &$this->_default_error_options;
+ } else {
+ $setmode = &$GLOBALS['_PEAR_default_error_mode'];
+ $setoptions = &$GLOBALS['_PEAR_default_error_options'];
+ }
+
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $setmode = $mode;
+ $setoptions = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $setmode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $setoptions = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ }
+
+ // }}}
+ // {{{ expectError()
+
+ /**
+ * This method is used to tell which errors you expect to get.
+ * Expected errors are always returned with error mode
+ * PEAR_ERROR_RETURN. Expected error codes are stored in a stack,
+ * and this method pushes a new element onto it. The list of
+ * expected errors are in effect until they are popped off the
+ * stack with the popExpect() method.
+ *
+ * Note that this method can not be called statically
+ *
+ * @param mixed $code a single error code or an array of error codes to expect
+ *
+ * @return int the new depth of the "expected errors" stack
+ * @access public
+ */
+ function expectError($code = '*')
+ {
+ if (is_array($code)) {
+ array_push($this->_expected_errors, $code);
+ } else {
+ array_push($this->_expected_errors, array($code));
+ }
+ return sizeof($this->_expected_errors);
+ }
+
+ // }}}
+ // {{{ popExpect()
+
+ /**
+ * This method pops one element off the expected error codes
+ * stack.
+ *
+ * @return array the list of error codes that were popped
+ */
+ function popExpect()
+ {
+ return array_pop($this->_expected_errors);
+ }
+
+ // }}}
+ // {{{ _checkDelExpect()
+
+ /**
+ * This method checks unsets an error code if available
+ *
+ * @param mixed error code
+ * @return bool true if the error code was unset, false otherwise
+ * @access private
+ * @since PHP 4.3.0
+ */
+ function _checkDelExpect($error_code)
+ {
+ $deleted = false;
+
+ foreach ($this->_expected_errors AS $key => $error_array) {
+ if (in_array($error_code, $error_array)) {
+ unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
+ $deleted = true;
+ }
+
+ // clean up empty arrays
+ if (0 == count($this->_expected_errors[$key])) {
+ unset($this->_expected_errors[$key]);
+ }
+ }
+ return $deleted;
+ }
+
+ // }}}
+ // {{{ delExpect()
+
+ /**
+ * This method deletes all occurences of the specified element from
+ * the expected error codes stack.
+ *
+ * @param mixed $error_code error code that should be deleted
+ * @return mixed list of error codes that were deleted or error
+ * @access public
+ * @since PHP 4.3.0
+ */
+ function delExpect($error_code)
+ {
+ $deleted = false;
+
+ if ((is_array($error_code) && (0 != count($error_code)))) {
+ // $error_code is a non-empty array here;
+ // we walk through it trying to unset all
+ // values
+ foreach($error_code as $key => $error) {
+ if ($this->_checkDelExpect($error)) {
+ $deleted = true;
+ } else {
+ $deleted = false;
+ }
+ }
+ return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
+ } elseif (!empty($error_code)) {
+ // $error_code comes alone, trying to unset it
+ if ($this->_checkDelExpect($error_code)) {
+ return true;
+ } else {
+ return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
+ }
+ } else {
+ // $error_code is empty
+ return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
+ }
+ }
+
+ // }}}
+ // {{{ raiseError()
+
+ /**
+ * This method is a wrapper that returns an instance of the
+ * configured error class with this object's default error
+ * handling applied. If the $mode and $options parameters are not
+ * specified, the object's defaults are used.
+ *
+ * @param mixed $message a text error message or a PEAR error object
+ *
+ * @param int $code a numeric error code (it is up to your class
+ * to define these if you want to use codes)
+ *
+ * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
+ * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
+ * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
+ *
+ * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
+ * specifies the PHP-internal error level (one of
+ * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
+ * If $mode is PEAR_ERROR_CALLBACK, this
+ * parameter specifies the callback function or
+ * method. In other error modes this parameter
+ * is ignored.
+ *
+ * @param string $userinfo If you need to pass along for example debug
+ * information, this parameter is meant for that.
+ *
+ * @param string $error_class The returned error object will be
+ * instantiated from this class, if specified.
+ *
+ * @param bool $skipmsg If true, raiseError will only pass error codes,
+ * the error message parameter will be dropped.
+ *
+ * @access public
+ * @return object a PEAR error object
+ * @see PEAR::setErrorHandling
+ * @since PHP 4.0.5
+ */
+ function &raiseError($message = null,
+ $code = null,
+ $mode = null,
+ $options = null,
+ $userinfo = null,
+ $error_class = null,
+ $skipmsg = false)
+ {
+ // The error is yet a PEAR error object
+ if (is_object($message)) {
+ $code = $message->getCode();
+ $userinfo = $message->getUserInfo();
+ $error_class = $message->getType();
+ $message->error_message_prefix = '';
+ $message = $message->getMessage();
+ }
+
+ if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
+ if ($exp[0] == "*" ||
+ (is_int(reset($exp)) && in_array($code, $exp)) ||
+ (is_string(reset($exp)) && in_array($message, $exp))) {
+ $mode = PEAR_ERROR_RETURN;
+ }
+ }
+ // No mode given, try global ones
+ if ($mode === null) {
+ // Class error handler
+ if (isset($this) && isset($this->_default_error_mode)) {
+ $mode = $this->_default_error_mode;
+ $options = $this->_default_error_options;
+ // Global error handler
+ } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
+ $mode = $GLOBALS['_PEAR_default_error_mode'];
+ $options = $GLOBALS['_PEAR_default_error_options'];
+ }
+ }
+
+ if ($error_class !== null) {
+ $ec = $error_class;
+ } elseif (isset($this) && isset($this->_error_class)) {
+ $ec = $this->_error_class;
+ } else {
+ $ec = 'PEAR_Error';
+ }
+ if ($skipmsg) {
+ $a = &new $ec($code, $mode, $options, $userinfo);
+ return $a;
+ } else {
+ $a = &new $ec($message, $code, $mode, $options, $userinfo);
+ return $a;
+ }
+ }
+
+ // }}}
+ // {{{ throwError()
+
+ /**
+ * Simpler form of raiseError with fewer options. In most cases
+ * message, code and userinfo are enough.
+ *
+ * @param string $message
+ *
+ */
+ function &throwError($message = null,
+ $code = null,
+ $userinfo = null)
+ {
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $a = &$this->raiseError($message, $code, null, null, $userinfo);
+ return $a;
+ } else {
+ $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
+ return $a;
+ }
+ }
+
+ // }}}
+ function staticPushErrorHandling($mode, $options = null)
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ $def_mode = &$GLOBALS['_PEAR_default_error_mode'];
+ $def_options = &$GLOBALS['_PEAR_default_error_options'];
+ $stack[] = array($def_mode, $def_options);
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $def_mode = $mode;
+ $def_options = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $def_mode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $def_options = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ $stack[] = array($mode, $options);
+ return true;
+ }
+
+ function staticPopErrorHandling()
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ $setmode = &$GLOBALS['_PEAR_default_error_mode'];
+ $setoptions = &$GLOBALS['_PEAR_default_error_options'];
+ array_pop($stack);
+ list($mode, $options) = $stack[sizeof($stack) - 1];
+ array_pop($stack);
+ switch ($mode) {
+ case PEAR_ERROR_EXCEPTION:
+ case PEAR_ERROR_RETURN:
+ case PEAR_ERROR_PRINT:
+ case PEAR_ERROR_TRIGGER:
+ case PEAR_ERROR_DIE:
+ case null:
+ $setmode = $mode;
+ $setoptions = $options;
+ break;
+
+ case PEAR_ERROR_CALLBACK:
+ $setmode = $mode;
+ // class/object method callback
+ if (is_callable($options)) {
+ $setoptions = $options;
+ } else {
+ trigger_error("invalid error callback", E_USER_WARNING);
+ }
+ break;
+
+ default:
+ trigger_error("invalid error mode", E_USER_WARNING);
+ break;
+ }
+ return true;
+ }
+
+ // {{{ pushErrorHandling()
+
+ /**
+ * Push a new error handler on top of the error handler options stack. With this
+ * you can easily override the actual error handler for some code and restore
+ * it later with popErrorHandling.
+ *
+ * @param mixed $mode (same as setErrorHandling)
+ * @param mixed $options (same as setErrorHandling)
+ *
+ * @return bool Always true
+ *
+ * @see PEAR::setErrorHandling
+ */
+ function pushErrorHandling($mode, $options = null)
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $def_mode = &$this->_default_error_mode;
+ $def_options = &$this->_default_error_options;
+ } else {
+ $def_mode = &$GLOBALS['_PEAR_default_error_mode'];
+ $def_options = &$GLOBALS['_PEAR_default_error_options'];
+ }
+ $stack[] = array($def_mode, $def_options);
+
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $this->setErrorHandling($mode, $options);
+ } else {
+ PEAR::setErrorHandling($mode, $options);
+ }
+ $stack[] = array($mode, $options);
+ return true;
+ }
+
+ // }}}
+ // {{{ popErrorHandling()
+
+ /**
+ * Pop the last error handler used
+ *
+ * @return bool Always true
+ *
+ * @see PEAR::pushErrorHandling
+ */
+ function popErrorHandling()
+ {
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
+ array_pop($stack);
+ list($mode, $options) = $stack[sizeof($stack) - 1];
+ array_pop($stack);
+ if (isset($this) && is_a($this, 'PEAR')) {
+ $this->setErrorHandling($mode, $options);
+ } else {
+ PEAR::setErrorHandling($mode, $options);
+ }
+ return true;
+ }
+
+ // }}}
+ // {{{ loadExtension()
+
+ /**
+ * OS independant PHP extension load. Remember to take care
+ * on the correct extension name for case sensitive OSes.
+ *
+ * @param string $ext The extension name
+ * @return bool Success or not on the dl() call
+ */
+ function loadExtension($ext)
+ {
+ if (!extension_loaded($ext)) {
+ // if either returns true dl() will produce a FATAL error, stop that
+ if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
+ return false;
+ }
+ if (OS_WINDOWS) {
+ $suffix = '.dll';
+ } elseif (PHP_OS == 'HP-UX') {
+ $suffix = '.sl';
+ } elseif (PHP_OS == 'AIX') {
+ $suffix = '.a';
+ } elseif (PHP_OS == 'OSX') {
+ $suffix = '.bundle';
+ } else {
+ $suffix = '.so';
+ }
+ return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
+ }
+ return true;
+ }
+
+ // }}}
+}
+
+// {{{ _PEAR_call_destructors()
+
+function _PEAR_call_destructors()
+{
+ global $_PEAR_destructor_object_list;
+ if (is_array($_PEAR_destructor_object_list) &&
+ sizeof($_PEAR_destructor_object_list))
+ {
+ reset($_PEAR_destructor_object_list);
+ if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) {
+ $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
+ }
+ while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
+ $classname = get_class($objref);
+ while ($classname) {
+ $destructor = "_$classname";
+ if (method_exists($objref, $destructor)) {
+ $objref->$destructor();
+ break;
+ } else {
+ $classname = get_parent_class($classname);
+ }
+ }
+ }
+ // Empty the object list to ensure that destructors are
+ // not called more than once.
+ $_PEAR_destructor_object_list = array();
+ }
+
+ // Now call the shutdown functions
+ if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
+ foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
+ call_user_func_array($value[0], $value[1]);
+ }
+ }
+}
+
+// }}}
+/**
+ * Standard PEAR error class for PHP 4
+ *
+ * This class is supserseded by {@link PEAR_Exception} in PHP 5
+ *
+ * @category pear
+ * @package PEAR
+ * @author Stig Bakken <ssb@php.net>
+ * @author Tomas V.V. Cox <cox@idecnet.com>
+ * @author Gregory Beaver <cellog@php.net>
+ * @copyright 1997-2006 The PHP Group
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/manual/en/core.pear.pear-error.php
+ * @see PEAR::raiseError(), PEAR::throwError()
+ * @since Class available since PHP 4.0.2
+ */
+class PEAR_Error
+{
+ // {{{ properties
+
+ var $error_message_prefix = '';
+ var $mode = PEAR_ERROR_RETURN;
+ var $level = E_USER_NOTICE;
+ var $code = -1;
+ var $message = '';
+ var $userinfo = '';
+ var $backtrace = null;
+
+ // }}}
+ // {{{ constructor
+
+ /**
+ * PEAR_Error constructor
+ *
+ * @param string $message message
+ *
+ * @param int $code (optional) error code
+ *
+ * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN,
+ * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
+ * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
+ *
+ * @param mixed $options (optional) error level, _OR_ in the case of
+ * PEAR_ERROR_CALLBACK, the callback function or object/method
+ * tuple.
+ *
+ * @param string $userinfo (optional) additional user/debug info
+ *
+ * @access public
+ *
+ */
+ function PEAR_Error($message = 'unknown error', $code = null,
+ $mode = null, $options = null, $userinfo = null)
+ {
+ if ($mode === null) {
+ $mode = PEAR_ERROR_RETURN;
+ }
+ $this->message = $message;
+ $this->code = $code;
+ $this->mode = $mode;
+ $this->userinfo = $userinfo;
+ if (function_exists("debug_backtrace")) {
+ if (@!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
+ $this->backtrace = debug_backtrace();
+ }
+ }
+ if ($mode & PEAR_ERROR_CALLBACK) {
+ $this->level = E_USER_NOTICE;
+ $this->callback = $options;
+ } else {
+ if ($options === null) {
+ $options = E_USER_NOTICE;
+ }
+ $this->level = $options;
+ $this->callback = null;
+ }
+ if ($this->mode & PEAR_ERROR_PRINT) {
+ if (is_null($options) || is_int($options)) {
+ $format = "%s";
+ } else {
+ $format = $options;
+ }
+ printf($format, $this->getMessage());
+ }
+ if ($this->mode & PEAR_ERROR_TRIGGER) {
+ trigger_error($this->getMessage(), $this->level);
+ }
+ if ($this->mode & PEAR_ERROR_DIE) {
+ $msg = $this->getMessage();
+ if (is_null($options) || is_int($options)) {
+ $format = "%s";
+ if (substr($msg, -1) != "\n") {
+ $msg .= "\n";
+ }
+ } else {
+ $format = $options;
+ }
+ die(sprintf($format, $msg));
+ }
+ if ($this->mode & PEAR_ERROR_CALLBACK) {
+ if (is_callable($this->callback)) {
+ call_user_func($this->callback, $this);
+ }
+ }
+ if ($this->mode & PEAR_ERROR_EXCEPTION) {
+ trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
+ eval('$e = new Exception($this->message, $this->code);throw($e);');
+ }
+ }
+
+ // }}}
+ // {{{ getMode()
+
+ /**
+ * Get the error mode from an error object.
+ *
+ * @return int error mode
+ * @access public
+ */
+ function getMode() {
+ return $this->mode;
+ }
+
+ // }}}
+ // {{{ getCallback()
+
+ /**
+ * Get the callback function/method from an error object.
+ *
+ * @return mixed callback function or object/method array
+ * @access public
+ */
+ function getCallback() {
+ return $this->callback;
+ }
+
+ // }}}
+ // {{{ getMessage()
+
+
+ /**
+ * Get the error message from an error object.
+ *
+ * @return string full error message
+ * @access public
+ */
+ function getMessage()
+ {
+ return ($this->error_message_prefix . $this->message);
+ }
+
+
+ // }}}
+ // {{{ getCode()
+
+ /**
+ * Get error code from an error object
+ *
+ * @return int error code
+ * @access public
+ */
+ function getCode()
+ {
+ return $this->code;
+ }
+
+ // }}}
+ // {{{ getType()
+
+ /**
+ * Get the name of this error/exception.
+ *
+ * @return string error/exception name (type)
+ * @access public
+ */
+ function getType()
+ {
+ return get_class($this);
+ }
+
+ // }}}
+ // {{{ getUserInfo()
+
+ /**
+ * Get additional user-supplied information.
+ *
+ * @return string user-supplied information
+ * @access public
+ */
+ function getUserInfo()
+ {
+ return $this->userinfo;
+ }
+
+ // }}}
+ // {{{ getDebugInfo()
+
+ /**
+ * Get additional debug information supplied by the application.
+ *
+ * @return string debug information
+ * @access public
+ */
+ function getDebugInfo()
+ {
+ return $this->getUserInfo();
+ }
+
+ // }}}
+ // {{{ getBacktrace()
+
+ /**
+ * Get the call backtrace from where the error was generated.
+ * Supported with PHP 4.3.0 or newer.
+ *
+ * @param int $frame (optional) what frame to fetch
+ * @return array Backtrace, or NULL if not available.
+ * @access public
+ */
+ function getBacktrace($frame = null)
+ {
+ if (defined('PEAR_IGNORE_BACKTRACE')) {
+ return null;
+ }
+ if ($frame === null) {
+ return $this->backtrace;
+ }
+ return $this->backtrace[$frame];
+ }
+
+ // }}}
+ // {{{ addUserInfo()
+
+ function addUserInfo($info)
+ {
+ if (empty($this->userinfo)) {
+ $this->userinfo = $info;
+ } else {
+ $this->userinfo .= " ** $info";
+ }
+ }
+
+ // }}}
+ // {{{ toString()
+
+ /**
+ * Make a string representation of this object.
+ *
+ * @return string a string with an object summary
+ * @access public
+ */
+ function toString() {
+ $modes = array();
+ $levels = array(E_USER_NOTICE => 'notice',
+ E_USER_WARNING => 'warning',
+ E_USER_ERROR => 'error');
+ if ($this->mode & PEAR_ERROR_CALLBACK) {
+ if (is_array($this->callback)) {
+ $callback = (is_object($this->callback[0]) ?
+ strtolower(get_class($this->callback[0])) :
+ $this->callback[0]) . '::' .
+ $this->callback[1];
+ } else {
+ $callback = $this->callback;
+ }
+ return sprintf('[%s: message="%s" code=%d mode=callback '.
+ 'callback=%s prefix="%s" info="%s"]',
+ strtolower(get_class($this)), $this->message, $this->code,
+ $callback, $this->error_message_prefix,
+ $this->userinfo);
+ }
+ if ($this->mode & PEAR_ERROR_PRINT) {
+ $modes[] = 'print';
+ }
+ if ($this->mode & PEAR_ERROR_TRIGGER) {
+ $modes[] = 'trigger';
+ }
+ if ($this->mode & PEAR_ERROR_DIE) {
+ $modes[] = 'die';
+ }
+ if ($this->mode & PEAR_ERROR_RETURN) {
+ $modes[] = 'return';
+ }
+ return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
+ 'prefix="%s" info="%s"]',
+ strtolower(get_class($this)), $this->message, $this->code,
+ implode("|", $modes), $levels[$this->level],
+ $this->error_message_prefix,
+ $this->userinfo);
+ }
+
+ // }}}
+}
+
+/*
+ * Local Variables:
+ * mode: php
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ */
+?>
diff --git a/lang/pear/files/go-pear.php b/lang/pear/files/go-pear.php
index 4384909d739..c798c5afca2 100644
--- a/lang/pear/files/go-pear.php
+++ b/lang/pear/files/go-pear.php
@@ -1,103 +1,41 @@
-<?php //; echo; echo "YOU NEED TO RUN THIS SCRIPT WITH PHP NOW!"; echo; echo "Try this: lynx -source http://pear.php.net/go-pear | php -q"; echo; exit # -*- PHP -*-
-# +----------------------------------------------------------------------+
-# | PHP Version 5 |
-# +----------------------------------------------------------------------+
-# | Copyright (c) 1997-2005 The PHP Group |
-# +----------------------------------------------------------------------+
-# | This source file is subject to version 2.02 of the PHP license, |
-# | that is bundled with this package in the file LICENSE, and is |
-# | available at through the world-wide-web at |
-# | http://www.php.net/license/2_02.txt. |
-# | If you did not receive a copy of the PHP license and are unable to |
-# | obtain it through the world-wide-web, please send a note to |
-# | license@php.net so we can mail you a copy immediately. |
-# +----------------------------------------------------------------------+
-# | Authors: Tomas V.V.Cox <cox@idecnet.com> |
-# | Stig Bakken <ssb@php.net> |
-# | Christian Dickmann <dickmann@php.net> |
-# | Pierre-Alain Joye <pierre@php.net> |
-# | Greg Beaver <cellog@php.net> |
-# +----------------------------------------------------------------------+
+<?php //; echo; echo "YOU NEED TO RUN THIS SCRIPT WITH PHP!"; echo; echo "Point your webbrowser to it or run: php -q go-pear.php"; echo; exit # -*- PHP -*-
#
-# $Id: go-pear.php,v 1.1.1.1 2007/05/05 21:21:47 adrianp Exp $
+# The PEAR installation wizard, both webbased or command line.
#
-# Id: go-pear,v 1.104 2007/03/17 21:43:08 cellog Exp
+# Webbased installation:
+# 1) Download this file and save it as go-pear.php
+# 2) Put go-pear.php on your webserver, where you would put your website
+# 3) Open http://yourdomain.example.org/go-pear.php in your browser
+# 4) Follow the instructions, done!
#
-# Automatically download all the files needed to run the "pear" command
-# (the PEAR package installer). Requires PHP 4.1.0 or newer.
+# Command-line installation (for advanced users):
+# 1) Download this file and save it as go-pear.php
+# 2) Open a terminal/command prompt and type: php -q go-pear.php
+# 3) Follow the instructions, done!
#
-# Installation: Linux
-#
-# This script can either be directly launched or passed via lynx like this.
-#
-# $ lynx -source http://pear.php.net/go-pear | php
-#
-# The above assumes your php binary is named php and that it's
-# executable through your PATH:
-#
-# Installation: Windows
-#
-# On Windows, go-pear uses stdin for user input, so you must download
-# go-pear first and then run it:
-#
-# Note: In PHP 4.2.0-4.2.3, the PHP CLI binary is named php-cli.exe while since
-# PHP 4.3.0, it's simply named php.exe in the cli/ folder of your PHP directory.
-# The CGI is also named php.exe but it sits directly in your PHP directory.
-#
-# > cli/php -r "readfile('http://pear.php.net/go-pear');" > go-pear
-# > cli/php go-pear
-#
-# In PHP 5.0.0+, the PHP CLI binary is php.exe
-#
-# > php -r "readfile('http://pear.php.net/go-pear');" > go-pear
-# > php go-pear
-#
-# Installation: Notes
-#
-# - If using the CGI version of PHP, append the -q option to suppress
-# headers in the output.
-# - By default, go-pear will install a system-wide configuration file. For
-# a local install use:
-# > php go-pear local
-#
-# - Once the go-pear script is initiated, you will see instructions on
-# how to continue installing PEAR. The first thing you should see is:
-#
-# Welcome to go-pear!
-#
-# Installation: Web browser
-#
-# You can now use go-pear via a webbrowser, thanks to Christian Dickmann. It is
-# still beta codes, but feel free to test it:
-# 1.: Download the go-pear script by using the "Save target as ..." function
-# of your browser here.
-#
-# 2.: Place the go-pear file somewhere under the document root of your webserver.
-# The easiest way is to create a new directory for pear and to put the file in there.
-# Be sure your web server is setup to recognize PHP, and that you use an appropriate
-# extension. For example, you might name this file gopear.php
-#
-# 3.: Access go-pear through your webserver and follow the instructions. Please
-# make sure that PHP has write access to the dir you want to install PEAR into.
-# For example: http://localhost/pear/gopear.php
-#
-# 4.: After running go-pear you get a link to the Web Frontend of the PEAR installer.
-# I suggest bookmarking this link.
-#
-# 5.: Protect the Web Frontend directory and the go-pear script with a password.
-# Use .htaccess on Apache webservers for example.
-#
-#
-function dump($var) {
- if (defined('WEBINSTALLER') && WEBINSTALLER == 'cgi') {
- echo '<pre>';
- print_r($var);
- echo '</pre>';
- } else {
- print_r($var);
- echo "\n";
- }
-}
+# Notes:
+# * Get the latest go-pear version from http://pear.php.net/go-pear
+# * This installer requires PHP 4.3.0 or newer.
+# * On windows, the PHP CLI binary is php.exe, don't forget the -q option if using the CGI binary.
+# * The default for the command-line installation is a system-wide configuration file, For a local install use: php -q go-pear.php local
+
+/**
+ * go-pear is the online PEAR installer: just download it and run it
+ * (through a browser or command line), it will set up a minimal PEAR
+ * installation that will be ready for immediate use.
+ *
+ * @license http://www.php.net/license/2_02.txt PHP License 2.02
+ * @version CVS: Id: go-pear 281637 2009-06-04 08:51:45Z clockwerx
+ * @link http://pear.php.net/package/pearweb_gopear
+ * @author Tomas V.V.Cox <cox@idecnet.com>
+ * @author Stig Bakken <ssb@php.net>
+ * @author Christian Dickmann <dickmann@php.net>
+ * @author Pierre-Alain Joye <pierre@php.net>
+ * @author Greg Beaver <cellog@php.net>
+ * @author Tias Guns <tias@ulyssis.org>
+ */
+
+/* $NetBSD: go-pear.php,v 1.2 2009/10/29 08:29:03 seb Exp $ */
$sapi_name = php_sapi_name();
@@ -106,8 +44,6 @@ if (!$safe_mode) {
set_time_limit(0);
}
-
-
@ob_end_clean();
ob_implicit_flush(true);
define('WEBINSTALLER', ($sapi_name != 'cli' && !(substr($sapi_name,0,3)=='cgi' && !isset($_SERVER['GATEWAY_INTERFACE']))));
@@ -118,19 +54,7 @@ ini_set('magic_quotes_runtime', false);
error_reporting( E_ALL & ~E_NOTICE);
define('WINDOWS', (substr(PHP_OS, 0, 3) == 'WIN'));
-define('GO_PEAR_VER', '0.6.0');
-
-if (!function_exists('file_get_contents')) {
- function file_get_contents($filename)
- {
- $fp = fopen($filename, 'rb');
- $ret = '';
- while (!feof($fp)) {
- $ret .= fread($fp, 8092);;
- }
- return $ret;
- }
-}
+define('GO_PEAR_VER', '1.1.2');
define('WIN32GUI', !WEBINSTALLER && WINDOWS && $sapi_name=='cli' && which('cscript'));
@@ -141,9 +65,10 @@ if ( WEBINSTALLER && WINDOWS ) {
$php_sapi_name = win32DetectPHPSAPI();
if($php_sapi_name=='cgi'){
$msg = nl2br("
-Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.
-Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the
-instructions) or use the CLI (cli\php.exe) in the console.
+Sorry! The PEAR installer actually does not work on Windows platform
+using CGI and Apache. Please install the module SAPI (see
+http://www.php.net/manual/en/install.apache.php for the instructions) or
+use the CLI (cli\php.exe) in the console.
");
displayHTML('error', $msg);
}
@@ -163,17 +88,13 @@ if (WEBINSTALLER && isset($_GET['action']) && $_GET['action'] == 'img' && isset(
}
// Check if PHP version is sufficient
-if (function_exists("version_compare") && version_compare(phpversion(), "4.2.0",'<')) {
+if (function_exists("version_compare") && version_compare(phpversion(), "4.3.0",'<')) {
die("Sorry! Your PHP version is too old. PEAR and this script requires at
-least PHP 4.2.0 for stable operation.
+least PHP 4.3.0 for stable operation.
It may be that you have a newer version of PHP installed in your web
server, but an older version installed as the 'php' command. In this
case, you need to rebuilt PHP from source.
-
-If your source is 4.2.x, you need to run 'configure' with the
---enable-cli option, rebuild and copy sapi/cli/php somewhere.
-
If your source is 4.3.x or newer, just make sure you don't run
'configure' with --disable-cli, rebuilt and copy sapi/cli/php.
@@ -182,31 +103,40 @@ Please upgrade PHP to a newer version, and try again. See you then.
");
}
+$gopear_bundle_dir = dirname(__FILE__).'/go-pear-bundle';
+
+$bootstrap_files = array(
+ 'PEAR.php' => 'http://cvs.php.net/viewvc.cgi/pear-core/PEAR.php?view=co&pathrev=PEAR_1_4',
+ 'Archive/Tar.php' => 'http://cvs.php.net/viewvc.cgi/pear/Archive_Tar/Archive/Tar.php?view=co&pathrev=RELEASE_1_3_2',
+ 'Console/Getopt.php' => 'http://cvs.php.net/viewvc.cgi/pear-core/Console/Getopt.php?view=co&pathrev=PEAR_1_4',
+ );
+
+$bootstrap_pkgs = array( // uses URL like http://pear.php.net/get/%s
+ 'PEAR',
+ 'Structures_Graph'
+);
+
$installer_packages = array(
- 'PEAR-stable',
+ 'PEAR',
+ 'Structures_Graph-stable',
'Archive_Tar-stable',
'Console_Getopt-stable',
- 'Structures_Graph-stable',
- );
-
-if (WEBINSTALLER) {
- $installer_packages[] = 'HTML_Template_IT-stable';
- $installer_packages[] = 'Net_UserAgent_Detect-stable';
- $installer_packages[] = 'PEAR_Frontend_Web-alpha';
-}
+);
$pfc_packages = array(
- 'MDB2',
+ 'PEAR_Frontend_Web-beta' => 'Webbased PEAR Installer',
+ 'PEAR_Frontend_Gtk2' => 'Graphical PEAR installer based on PHP-Gtk2',
+ 'MDB2' => 'database abstraction layer.',
);
$config_desc = array(
- 'prefix' => 'Installation prefix',
+ 'prefix' => 'Installation prefix ($prefix)',
+ 'temp_dir' => 'Temporary files directory',
'bin_dir' => 'Binaries directory',
'php_dir' => 'PHP code directory ($php_dir)',
'doc_dir' => 'Documentation base directory',
'data_dir' => 'Data base directory',
'test_dir' => 'Tests base directory',
- 'temp_dir' => 'Temporary files directory'
);
if(!WEBINSTALLER && WINDOWS){
@@ -235,20 +165,15 @@ detect_install_dirs();
if (WEBINSTALLER) {
@session_start();
- /*
- See bug #23069
- */
- if ( WINDOWS ) {
- $php_sapi_name = win32DetectPHPSAPI();
- if($php_sapi_name=='cgi'){
- $msg = "
- Sorry! The PEAR installer actually does not work on Windows platform using CGI and Apache.
- Please install the module SAPI (see http://www.php.net/manual/en/install.apache.php for the
- instructions) or use the CLI (cli\php.exe) in the console.
- ";
- displayHTML('error', $msg);
- exit();
- }
+ // If welcome, just welcome
+ if (!isset($_GET['step'])) {
+ $_GET['step'] = 'Welcome';
+ /* clean up old sessions datas */
+ session_destroy();
+ }
+ if ($_GET['step'] == 'Welcome') {
+ displayHTML('Welcome');
+ exit();
}
if (!isset($_SESSION['go-pear']) || isset($_GET['restart'])) {
@@ -268,47 +193,63 @@ if (WEBINSTALLER) {
'webfrontend_file' => '$prefix/index.php',
),
'install_pfc' => true,
+ 'install_optional_packages' => array(),
'DHTML' => true,
);
}
- if (!isset($_GET['step'])) {
- $_GET['step'] = 'Welcome';
- /* clean up old sessions datas */
- session_destroy();
- }
+ // save submited values
if ($_GET['step'] == 'install') {
$_SESSION['go-pear']['http_proxy'] = strip_magic_quotes($_POST['proxy']['host']).':'.strip_magic_quotes($_POST['proxy']['port']);
if ($_SESSION['go-pear']['http_proxy'] == ':') {
$_SESSION['go-pear']['http_proxy'] = '';
};
- $www_errors = array();
+ $config_errors = array();
foreach($_POST['config'] as $key => $value) {
$_POST['config'][$key] = strip_magic_quotes($value);
- if($key!='cache_ttl'){
+ if ($key != 'cache_ttl' && $key != 'php_bin') {
if ( empty($_POST['config'][$key]) ) {
- if (WEBINSTALLER && $key!='php_bin' ) {
- $www_errors[$key] = 'Please fill this path, you can use $prefix, $php_dir or a full path.';
- }
+ $config_errors[$key] = 'Please fill this path, you can use $prefix, $php_dir or a full path.';
}
}
}
- if( sizeof($www_errors)>0){
+ if( sizeof($config_errors)>0){
$_GET['step'] = 'config';
}
$_SESSION['go-pear']['config'] = $_POST['config'];
$_SESSION['go-pear']['install_pfc'] = (isset($_POST['install_pfc']) && $_POST['install_pfc'] == 'on');
+ // webinstaller allows to choose pfc packages individually
+ foreach ($pfc_packages as $key => $value) {
+ $pos = array_search($key, $_SESSION['go-pear']['install_optional_packages']);
+ if (isset($_POST[$key]) && $_POST[$key] == 'on' && $pos === false) {
+ $_SESSION['go-pear']['install_optional_packages'][] = $key;
+ }
+ if (!isset($_POST[$key]) && $pos !== false) {
+ unset($_SESSION['go-pear']['install_optional_packages'][$pos]);
+ }
+ }
$_SESSION['go-pear']['DHTML'] = isset($_POST['BCmode']) ? false : true;
}
+ // export session values
$http_proxy = $_SESSION['go-pear']['http_proxy'];
+ $GLOBALS['config_vars'] = array_keys($config_desc);
+ array_unshift($GLOBALS['config_vars'], '');
+ unset($GLOBALS['config_vars'][0]); // make indices run from 1...
foreach($_SESSION['go-pear']['config'] as $var => $value) {
$$var = $value;
}
$install_pfc = $_SESSION['go-pear']['install_pfc'];
+ $install_optional_packages = $_SESSION['go-pear']['install_optional_packages'];
+
+ if ($_GET['step'] == 'config') {
+ displayHTML('config');
+ exit();
+ }
+ // Anything past this step has something to do with the installation
}
if (!WEBINSTALLER) {
@@ -333,8 +274,8 @@ Use 'php " . $_SERVER['argv'][0] . " local' to install a local copy of PEAR.
Go-pear will install the 'pear' command and all the files needed by
it. This command is your tool for PEAR installation and maintenance.
$local
-Go-pear also lets you download and install the PEAR packages bundled
-with PHP: " . implode(', ', $pfc_packages) . ".
+Go-pear also lets you download and install the following optional PEAR
+packages: " . implode(', ', array_keys($pfc_packages)) . ".
If you wish to abort, press Control-C now, or press Enter to continue: ";
@@ -369,26 +310,6 @@ $first = key($config_vars);
end($config_vars);
$last = key($config_vars);
-if (WEBINSTALLER) {
- if ( isset($www_errors) && sizeof($www_errors) ) {
- displayHTML('config');
- exit();
- } else {
- if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'] == true && $_GET['step'] == 'install') {
- $_GET['step'] = 'preinstall';
- }
- if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') {
- displayHTML($_GET['step']);
- exit;
- }
- if ($_GET['step'] == 'install-progress') {
- displayHTMLHeader();
- echo "Starting installation ...<br/>";
- }
- ob_start();
- }
-}
-
$progress = 0;
/*
@@ -494,7 +415,7 @@ If you have a CLI (or CGI) php.exe available, we strongly recommand to use it.
}
if (!empty($tmp) ) {
- $$var = $tmp;
+ $$var = parse_dirname($tmp);
}
} elseif ($tmp == 'all') {
foreach ($config_vars as $n => $var) {
@@ -509,24 +430,27 @@ If you have a CLI (or CGI) php.exe available, we strongly recommand to use it.
}
}
+####
+# Installation stuff
+####
+
+// expand all subvars in the config vars
foreach ($config_vars as $n => $var) {
for ($m = 1; $m <= count($config_vars); $m++) {
$var2 = $config_vars[$m];
$$var = str_replace('$'.$var2, $$var2, $$var);
}
+ $$var = parse_dirname($$var);
}
-
-####
-# Temp stuff
-####
-if (!empty($temp_dir)) {
- $_found = temp_dir($temp_dir);
-} else {
- $_found = temp_dir();
-}
-
-if (!$_found) {
+ // temp dir stuff (separate for windows bugs)
+ if (!empty($temp_dir)) {
+ $_found = temp_dir($temp_dir);
+ } else {
+ $_found = temp_dir();
+ }
+ if (!$_found) {
+ if (!WEBINSTALLER) {
print "
******************************************************************************
@@ -534,54 +458,118 @@ FATAL ERROR! We cannot initialize the temp directory. Please be sure to give
full write access to this directory and the install directory.
";
+ if (!empty($temp_dir)) {
+ print "'$temp_dir' was given.";
+ }
+ exit();
- if (!empty($temp_dir)) {
- print "'$temp_dir' was given.";
+ } else { // WEBINSTALLER
+ if (!is_dir($temp_dir)) {
+ $config_errors['temp_dir'] = 'FATAL ERROR! This directory does not exist and we can not create it. Create the directory manually or make sure we have full permission in its parent directory.';
+ if (!WINDOWS) {
+ $config_errors['temp_dir'] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br />
+<tt>mkdir '.dirname($temp_dir).' && chmod 0777 '.dirname($temp_dir).'</tt></p>';
+ }
+ } else { // is_dir(temp_dir)
+ $config_errors['temp_dir'] = 'FATAL ERROR! This directory exists, but we have no write permission in it.';
+ if (!WINDOWS) {
+ $config_errors['temp_dir'] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br />
+<tt>chmod 0777 '.$temp_dir.'</tt></p>';
+ }
+ }
+ }
+ }
+ if (@is_dir($ptmp)) {
+ chdir($ptmp);
}
- exit();
-}
-
-$foo = $ptmp;
-$ptmp = tempnam($ptmp, 'gope');
+ // check every dir, existence and permissions
+ foreach ($config_vars as $var) {
+ if (!preg_match('/_dir$/', $var) || $var == 'temp_dir') {
+ continue;
+ }
-if (WINDOWS) {
- $ptmp = str_replace($foo,'',$ptmp);
- $foo = str_replace("\\\\",'/',$foo);
- $s = substr($ptmp,0,1);
- if($s == "\\" || $s == '/' ){
- $ptmp = $foo . '/' . substr($ptmp,1);
- } else {
- $ptmp = $foo . '/' . $ptmp;
+ $dir = $$var;
+ if (!@is_dir($dir)) {
+ if (!mkdir_p($dir)) {
+ if (!WEBINSTALLER) {
+ $root = WINDOWS ? 'administrator' : 'root';
+ bail("Unable to create {$config_desc[$var]} $dir.
+Run this script as $root or pick another location.\n");
+ } else { // WEBINSTALLER
+ $config_errors[$var] = 'ERROR! This directory does not exist and we can not create it. Create the directory manually or make sure we have full permission in its parent directory.';
+ if (!WINDOWS) {
+ $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br />
+<tt>mkdir '.dirname($dir).' && chmod 0777 '.dirname($dir).'</tt></p>';
+ }
+ }
+ }
+ }
+ if (WEBINSTALLER && @is_dir($dir) && !is_writable($dir)) {
+ $config_errors[$var] = 'ERROR! This directory exists, but we have no write permission in it.';
+ if (!WINDOWS) {
+ $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br />
+<tt>chmod 0777 '.$dir.'</tt></p>';
+ }
+ }
}
-}
-rm_rf($ptmp);
-mkdir_p($ptmp, 0700);
-$ok = @chdir($ptmp);
-
-foreach ($config_vars as $var) {
- $dir = $$var;
+ // check every file, existence and permissions
+ foreach ($config_vars as $var) {
+ if (!preg_match('/_file$/', $var)) {
+ continue;
+ }
- if (!preg_match('/_dir$/', $var)) {
- continue;
+ $file = $$var;
+ $dir = dirname($file);
+ if (!file_exists($file) && !is_writable($dir)) {
+ if (!WEBINSTALLER) {
+ $root = WINDOWS ? 'administrator' : 'root';
+ bail("Unable to create {$config_desc[$var]} $file.
+Run this script as $root or pick another location.\n");
+ } else { // WEBINSTALLER
+ $config_errors[$var] = 'ERROR! This file does not exist and we can not create it. Make sure we have full permission in its parent directory.';
+ if (!WINDOWS) {
+ $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br />
+<tt>chmod 0777 '.$dir.'</tt></p>';
+ }
+ }
+ } elseif (WEBINSTALLER && file_exists($file) && !is_writable($file)) {
+ $config_errors[$var] = 'ERROR! This file exists, but we have no write permission on it.';
+ if (!WINDOWS) {
+ $config_errors[$var] .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br />
+<tt>chmod 0777 '.$file.'</tt></p>';
+ }
+ }
}
- if (!@is_dir($dir)) {
- if (!mkdir_p($dir)) {
- $root = WINDOWS ? 'administrator' : 'root';
- bail("Unable to create {$config_desc[$var]} $dir.
-Run this script as $root or pick another location.\n");
+if (WEBINSTALLER) {
+ if ( isset($config_errors) && sizeof($config_errors) ) {
+ displayHTML('config');
+ exit();
+ } else {
+ if (isset($_SESSION['go-pear']['DHTML']) && $_SESSION['go-pear']['DHTML'] == true && $_GET['step'] == 'install') {
+ $_GET['step'] = 'preinstall';
+ }
+ if ($_GET['step'] != 'install' && $_GET['step'] != 'install-progress') {
+ displayHTML($_GET['step']);
+ exit;
+ }
+ if ($_GET['step'] == 'install-progress') {
+ displayHTMLHeader();
+ echo "Starting installation ...<br/>";
}
+ ob_start();
}
}
if (!WEBINSTALLER) {
$msg = "The following PEAR packages are bundled with PHP: " .
- implode(', ', $pfc_packages);
+ implode(', ', array_keys($pfc_packages));
print "\n" . wordwrap($msg, 75) . ".\n";
print "Would you like to install these as well? [Y/n] : ";
$install_pfc = !stristr(fgets($tty, 1024), "n");
+ $install_optional_packages = array();
print "\n";
}
@@ -621,23 +609,25 @@ if (!$have_gzip) {
};
if ($install_pfc) {
- $to_install = array_merge($installer_packages, $pfc_packages);
+ $to_install = array_merge($installer_packages, array_keys($pfc_packages));
} else {
$to_install = $installer_packages;
-}
-
-displayHTMLProgress($progress = 5);
-if (file_exists(dirname(__FILE__).'/go-pear-bundle') || is_dir(dirname(__FILE__).'/go-pear-bundle')) {
- $dh = @opendir(dirname(__FILE__).'/go-pear-bundle');
-} else {
- $dh = false;
+ // webinstaller allows to choose pfc packages individually
+ foreach ($pfc_packages as $pkg => $desc) {
+ if (in_array($pkg, $install_optional_packages)) {
+ array_push($to_install, $pkg);
+ }
+ }
}
+// gopear_bundle usage
$local_dir = array();
-if ($dh) {
+if (file_exists($gopear_bundle_dir) || is_dir($gopear_bundle_dir)) {
+ $dh = @opendir($gopear_bundle_dir);
+
while($file = @readdir($dh)) {
- if ($file == '.' || $file == '..' || !is_file(dirname(__FILE__).'/go-pear-bundle/'.$file)) {
+ if ($file == '.' || $file == '..' || !is_file($gopear_bundle_dir.'/'.$file)) {
continue;
}
$_pos = strpos($file, '-');
@@ -647,121 +637,105 @@ if ($dh) {
$local_dir[substr($file, 0, $_pos)] = $file;
}
}
+ closedir($dh);
+ unset($dh, $file, $_pos);
}
-foreach ($installer_packages as $pkg) {
- $pkg_basename = substr($pkg, 0, strpos($pkg, '-'));
- if (isset($local_dir[$pkg_basename])) {
- echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
- copy(dirname(__FILE__) . '/go-pear-bundle/' . $local_dir[$pkg_basename], $local_dir[$pkg_basename]);
- $tarball[$pkg_basename] = $local_dir[$pkg_basename];
- echo "ok\n";
- displayHTMLProgress($progress += round(65 / count($to_install)));
- continue;
- }
-
- $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
- print $msg;
- $url = sprintf($urltemplate, $pkg);
-
- $pkg = str_replace('-stable', '', $pkg);
-
- $tarball[$pkg] = download_url($url, null, $http_proxy);
- print "ok\n";
- displayHTMLProgress($progress += round(65 / count($to_install)));
-}
-
-print 'Bootstrapping: PEAR...................';
-if (in_array('PEAR.php', $local_dir)) {
- copy(dirname(__FILE__).'/go-pear-bundle/PEAR.php', 'PEAR.php');
- echo "(local) ";
-} else {
- $url = 'http://cvs.php.net/viewcvs.cgi/pear-core/PEAR.php?view=co&pathrev=PEAR_1_4';
- echo "(remote) ";
- download_url($url, 'PEAR.php', $http_proxy);
-}
-
-include_once 'PEAR.php';
-print "ok\n";
-
-print 'Bootstrapping: Archive_Tar............';
-$r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Archive_Tar'], 12), 0, -4));
-
-/* force to a known revision */
-$url = "http://cvs.php.net/viewcvs.cgi/pear/Archive_Tar/Archive/Tar.php?view=co&pathrev=RELEASE_1_3_2";
-mkdir('Archive', 0700);
+print "\n".'Bootstrapping Installer...................'."\n";
+displayHTMLProgress($progress = 5);
-if (in_array('Tar.php', $local_dir)) {
- copy(dirname(__FILE__).'/go-pear-bundle/Tar.php', 'Archive/Tar.php');
- echo "(local) ";
-} else {
- download_url($url, 'Archive/Tar.php', $http_proxy);
- echo "(remote) ";
+// Bootstrap needed ?
+$nobootstrap = false;
+if (is_dir($php_dir)) {
+ $nobootstrap = true;
+ foreach ($bootstrap_files as $file => $url) {
+ $nobootstrap &= is_file($php_dir.'/'.$file);
+ }
}
-print "ok\n";
-print 'Bootstrapping: Console_Getopt.........';
-$r = 'RELEASE_' . ereg_replace('[^A-Za-z0-9]', '_', substr(substr($tarball['Console_Getopt'], 15), 0, -4));
-$url = "http://cvs.php.net/viewcvs.cgi/pear-core/Console/Getopt.php?view=co&pathrev=PEAR_1_4";
-mkdir('Console', 0700);
-if (in_array('Getopt.php', $local_dir)) {
- copy(dirname(__FILE__).'/go-pear-bundle/Getopt.php', 'Console/Getopt.php');
- echo "(local) ";
+if ($nobootstrap) {
+ print('Using previously install ... ');
+ if (function_exists('set_include_path')) {
+ set_include_path($php_dir);
+ } else {
+ ini_set('include_path', $php_dir);
+ }
+ include_once 'PEAR.php';
+ print "ok\n";
} else {
- download_url($url, 'Console/Getopt.php', $http_proxy);
- echo "(remote) ";
-}
-print "ok\n";
-
-if ($install_pfc) {
- foreach ($pfc_packages as $pkg) {
- foreach($local_dir as $file) {
- if (substr($file, 0, strlen($pkg)) == $pkg) {
- echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
- copy(dirname(__FILE__).'/go-pear-bundle/'.$file, $file);
- $tarball[$pkg] = $file;
- echo "ok\n";
- displayHTMLProgress($progress += round(65 / count($to_install)));
- continue 2;
- };
- };
+ foreach($bootstrap_files as $name => $url) {
+ $file = basename($name);
+ $dir = dirname($name);
+
+ print 'Bootstrapping '.$name.'............';
+ displayHTMLProgress($progress += round(14 / count($bootstrap_files)));
+ if ($dir != '' && $dir != '.') {
+ mkdir($dir, 0700);
+ }
- $msg = str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
- print $msg;
- $url = sprintf($urltemplate, $pkg);
- $tarball[$pkg] = download_url($url, null, $http_proxy);
+ if (in_array($file, $local_dir)) {
+ copy($gopear_bundle_dir.'/'.$file, $name);
+ echo '(local) ';
+ } else {
+ download_url($url, $name, $http_proxy);
+ echo '(remote) ';
+ }
+ include_once $name;
print "ok\n";
- displayHTMLProgress($progress += round(65 / count($to_install)));
}
}
-
-displayHTMLProgress($progress = 70);
+unset($nobootstrap, $file, $url, $name, $dir);
PEAR::setErrorHandling(PEAR_ERROR_DIE, "\n%s\n");
-print 'Extracting installer..................';
-
-$dot = strrpos($tarball['Structures_Graph'], '.');
-$pkg = substr($tarball['Structures_Graph'], 0, $dot);
-$ext = substr($tarball['Structures_Graph'], $dot + 1);
-
-include_once 'Archive/Tar.php';
-
-$tar = &new Archive_Tar($tarball['Structures_Graph'], $have_gzip);
-if (!$tar->extractModify($ptmp, $pkg)) {
- bail("failed!\n");
+print "\n".'Extracting installer..................'."\n";
+displayHTMLProgress($progress = 20);
+
+// Extract needed ?
+$noextract = false;
+if (is_dir($php_dir)) {
+ $noextract = @include_once 'PEAR/Registry.php';
+
+ if ($noextract) {
+ $registry = new PEAR_Registry($php_dir);
+ foreach ($bootstrap_pkgs as $pkg) {
+ $noextract &= $registry->packageExists($pkg);
+ }
+ }
}
-$dot = strrpos($tarball['PEAR'], '.');
-$pkg = substr($tarball['PEAR'], 0, $dot);
-$ext = substr($tarball['PEAR'], $dot + 1);
+if ($noextract) {
+ print('Using previously installed installer ... ');
+ print "ok\n";
+} else {
+ $bootstrap_pkgs_tarballs = array();
+ foreach ($bootstrap_pkgs as $pkg) {
+ $tarball = null;
+ if (isset($local_dir[$pkg])) {
+ echo str_pad("Using local package: $pkg", max(38,21+strlen($pkg)+4), '.');
+ copy($gopear_bundle_dir.'/'.$local_dir[$pkg], $local_dir[$pkg]);
+ $tarball = $local_dir[$pkg];
+ } else {
+ print str_pad("Downloading package: $pkg", max(38,21+strlen($pkg)+4), '.');
+ $url = sprintf($urltemplate, $pkg);
+ $pkg = str_replace('-stable', '', $pkg);
+ $tarball = download_url($url, null, $http_proxy);
+ }
+ displayHTMLProgress($progress += round(19 / count($bootstrap_pkgs)));
-$tar = &new Archive_Tar($tarball['PEAR'], $have_gzip);
-if (!$tar->extractModify($ptmp, $pkg)) {
- bail("failed!\n");
+ $fullpkg = substr($tarball, 0, strrpos($tarball, '.'));
+ $tar = &new Archive_Tar($tarball, $have_gzip);
+ if (!$tar->extractModify($ptmp, $fullpkg)) {
+ bail("Extraction for $fullpkg failed!\n");
+ }
+ $bootstrap_pkgs_tarballs[$pkg] = $tarball;
+ print "ok\n";
+ }
}
-print "ok\n";
+unset($noextract, $registry, $pkg, $tarball, $url, $fullpkg, $tar);
+
-$tarball['PEAR'] = 'package.xml'; // :-)
+print "\n".'Preparing installer..................'."\n";
+displayHTMLProgress($progress = 40);
// Default for sig_bin
putenv('PHP_PEAR_SIG_BIN=""');
@@ -770,7 +744,6 @@ putenv('PHP_PEAR_SIG_KEYDIR=""');
putenv('PHP_PEAR_DOWNLOAD_DIR=' . $temp_dir . '/download');
putenv('PHP_PEAR_TEMP_DIR=' . $temp_dir);
-include_once "PEAR.php";
include_once "PEAR/Config.php";
include_once "PEAR/Command.php";
include_once "PEAR/Registry.php";
@@ -784,34 +757,70 @@ if (WEBINSTALLER || isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local'
$config->set('preferred_state', 'stable');
foreach ($config_vars as $var) {
- $config->set($var, $$var);
+ if (isset($$var) && $$var != '') {
+ $config->set($var, $$var);
+ }
}
$config->set('download_dir', $temp_dir . '/download');
$config->set('temp_dir', $temp_dir);
+$config->set('http_proxy', $http_proxy);
$config->store();
$registry = new PEAR_Registry($php_dir);
PEAR_Command::setFrontendType('CLI');
-$install = &PEAR_Command::factory('install', $config);
-$install_options = array(
- 'nodeps' => true,
- 'force' => true,
-);
+PEAR::staticPushErrorHandling(PEAR_ERROR_DIE); //fail silently
+$ch_cmd = &PEAR_Command::factory('update-channels', $config);
+$ch_cmd->run('update-channels', $options, array());
+PEAR::staticPopErrorHandling(); // reset error handling
+unset($ch_cmd);
-foreach ($tarball as $pkg => $src) {
- $options = $install_options;
- if ($registry->packageExists($pkg)) {
- $options['upgrade'] = true;
- }
- $install->run('install', $options, array($src));
+print "\n".'Installing selected packages..................'."\n";
+displayHTMLProgress($progress = 45);
- displayHTMLProgress($progress += round(29 / count($tarball)));
+$install = &PEAR_Command::factory('install', $config);
+foreach ($to_install as $pkg) {
+ $pkg_basename = substr($pkg, 0, strpos($pkg, '-'));
+
+ if (in_array($pkg, $installer_packages)) {
+ $options = array('nodeps' => true);
+ } else {
+ $options = array('onlyreqdeps' => true);
+ }
+ if ($registry->packageExists($pkg) || $registry->packageExists($pkg_basename)) {
+ print(str_pad("Package: $pkg", max(50,9+strlen($pkg)+4), '.').' already installed ... ok'."\n");
+ displayHTMLProgress($progress += round(50 / count($to_install)));
+ continue;
+ }
+
+ $pkg_basename = substr($pkg, 0, strpos($pkg, '-'));
+ if (in_array($pkg_basename, $bootstrap_pkgs)) {
+ print(str_pad("Installing bootstrap package: $pkg_basename", max(50,30+strlen($pkg_basename)+4), '.')."...");
+ displayHTMLProgress($progress += round(25 / count($to_install)));
+ $install->run('install', $options, array($bootstrap_pkgs_tarballs[$pkg_basename]));
+ } elseif (isset($local_dir[$pkg_basename])) {
+ print(str_pad("Installing local package: $pkg", max(50,26+strlen($pkg)+4), '.')."...");
+ displayHTMLProgress($progress += round(25 / count($to_install)));
+ $install->run('install', $options, array($gopear_bundle_dir.'/'.$local_dir[$pkg_basename]));
+ } else { // no local copy
+ print(str_pad("Downloading and installing package: $pkg", max(50,36+strlen($pkg)+4), '.')."...");
+ displayHTMLProgress($progress += round(25 / count($to_install)));
+ $install->run('install', $options, array($pkg));
+ }
+ displayHTMLProgress($progress += round(25 / count($to_install)));
}
+unset($pkg, $pkg_basename, $options, $bootstrap_pkgs_tarballs);
+/* TODO: Memory exhaustion in webinstaller : / (8Mb)
+print "\n".'Making sure every package is at the latest version........';
+$install->run('upgrade-all', array('soft' => true), array());
+print "ok\n";
+*/
+unset($config, $registry, $install);
displayHTMLProgress($progress = 99);
+
// Base installation finished
ini_restore("include_path");
@@ -910,7 +919,6 @@ to see what packages are installed, or 'pear help' for help.
For more information about PEAR, see:
http://pear.php.net/faq.php
- http://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1
http://pear.php.net/manual/
Thanks for using go-pear!
@@ -920,14 +928,16 @@ Thanks for using go-pear!
}
if (WEBINSTALLER) {
- print "Writing WebFrontend file ... ";
+ print "\n".'Writing WebFrontend file ... ';
@unlink($webfrontend_file); //Delete old one
copy ( $doc_dir.DIRECTORY_SEPARATOR.
'PEAR_Frontend_Web'.DIRECTORY_SEPARATOR.
'docs'.DIRECTORY_SEPARATOR.
- 'example.php',
+ 'index.php.txt',
$webfrontend_file
);
+ print "ok\n";
+
if ($_GET['step'] == 'install-progress') {
displayHTMLProgress($progress = 100);
ob_end_clean();
@@ -972,6 +982,44 @@ if (WINDOWS && !WEBINSTALLER) {
win32CreateRegEnv();
}
// Set of functions following
+/**
+ * Parse the given dirname
+ * eg. expands '~' etc
+ *
+ * @param string $dir directory, from input
+ * @return string parsed directory
+ */
+function parse_dirname($dir)
+{
+ if (!isset($_ENV['HOME'])) {
+ if (strpos($dir, '~') === 0) {
+ if (WEBINSTALLER) {
+ die('<p><em>Can\'t use the \'~\' symbol for homedir substitution, write the directory out in full.</em></p>');
+ } else {
+ die('Can\'t use the \'~\' symbol for homedir substitution, write the directory out in full.');
+ }
+ }
+ return $dir;
+ }
+
+ $home_root = $_ENV['HOME'];
+ // first strip last slash, if available
+ if (substr($home_root, -1) == DIRECTORY_SEPARATOR) {
+ $home_root = substr($home_root, 0, -1);
+ }
+ if (strpos($dir, '~/') === 0) {
+ // eg ~/ = /home/tias/
+ $dir = substr_replace($dir, $home_root, 0, 1);
+ } elseif (strpos($dir, '~') === 0) {
+ // eg ~tias/ = /home/tias/
+ // then delete user-dir
+ $home_root = dirname($home_root) . DIRECTORY_SEPARATOR;
+ $dir = substr_replace($dir, $home_root, 0, 1);
+ }
+
+ return $dir;
+}
+
// {{{ download_url()
@@ -997,6 +1045,7 @@ function download_url($url, $destfile = null, $proxy = null)
}
if (!$fp) {
bail("download of $url failed: $errstr ($errno)\n");
+ // If valid URL but error, no CURL extentions installed
}
if (empty($proxy)) {
$path = $tmp['path'];
@@ -1035,9 +1084,7 @@ function download_url($url, $destfile = null, $proxy = null)
}
}
- if ($content_length) {
- displayHTMLSetDownload($destfile);
- };
+ displayHTMLSetDownload($destfile);
$wp = fopen($destfile, "wb");
if (!$wp) {
bail("could not open $destfile for writing\n");
@@ -1052,8 +1099,11 @@ function download_url($url, $destfile = null, $proxy = null)
displayHTMLDownloadProgress($progress * 10);
};
}
+ displayHTMLDownloadProgress(100);
fclose($fp);
fclose($wp);
+
+ displayHTMLSetDownload('');
return $destfile;
}
@@ -1155,9 +1205,10 @@ function mkdir_p($dir, $mode = 0777)
}
if ($ok) {
$ok = @mkdir($dir, $mode);
- if (!$ok) {
- print "mkdir failed: <$dir>\n";
- }
+ // This is handled in the caller function (eg. webfrontend or not)
+ //if (!$ok) {
+ // print "mkdir failed: <$dir>\n";
+ //}
}
return $ok;
}
@@ -1207,12 +1258,13 @@ function temp_dir($default=false)
}
/* try it really, is_writable is buggy with openbasedir */
- $fh = fopen(realpath($default) . "/test","wb");
+ $fh = @fopen(realpath($default) . "/test","wb");
if ($fh) {
- $ptmp = $default;
+ // desparately try to set temp dir any possible way, see bug #13167
+ $ptmp = $_temp = $temp_dir = $default;
+ putenv('TMPDIR='.$default);
return true;
} else {
- $ptmp = "failed";
return false;
}
}
@@ -1260,7 +1312,7 @@ function temp_dir($default=false)
// If for some reason the user has no rights to access to
// the standard tempdir, we assume that he has the right
// to access his prefix and choose $prefix/tmp as tempdir
- if (!$_temp) {
+ if (!$_temp || !is_writable($_temp)) {
print "System's Tempdir failed, trying to use \$prefix/tmp ...";
$res = mkdir_p($prefix.'/tmp');
if (!$res) {
@@ -1367,12 +1419,14 @@ function detect_install_dirs($_prefix = null) {
}
} else {
if ($_prefix === null) {
- $prefix = dirname(PHP_BINDIR);
+ #$prefix = dirname(PHP_BINDIR);
+ $prefix = dirname(__FILE__);
} else {
$prefix = $_prefix;
}
$bin_dir = '$prefix/bin';
- $php_dir = '$prefix/share/pear';
+ #$php_dir = '$prefix/share/pear';
+ $php_dir = '$prefix/PEAR';
$doc_dir = '$php_dir/docs';
$data_dir = '$php_dir/data';
$test_dir = '$php_dir/tests';
@@ -1472,7 +1526,10 @@ function displayHTMLHeader()
color: #006600;
}
.red {
- color: #006600;
+ color: #ff0000;
+ }
+ .grey {
+ color: #a9a9a9;
}
span.headline {
@@ -1594,6 +1651,10 @@ function displayHTMLHeader()
form {
margin-bottom : 0;
}
+ hr {
+ text-align: left;
+ width: 80%;
+ }
-->
</style>
<meta name="description" content="This is the Web Interface of the PEAR Installer" />
@@ -1630,7 +1691,7 @@ function displayHTML($page = 'Welcome', $data = array())
&nbsp;
</td>
<td align="left" valign="middle">
- <span class="Headline">Go-PEAR</span>
+ <span class="Headline">Go-PEAR Installer</span>
</td>
</tr>
@@ -1652,21 +1713,41 @@ function displayHTML($page = 'Welcome', $data = array())
<table width="200" border="0" cellpadding="4" cellspacing="0">
<tr valign="top">
<td style="font-size: 90%" align="left" width="200">
- <br><br>
- <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
- <a href="<?php echo basename(__FILE__); ?>?step=Welcome&restart=1" <?php if ($page == 'Welcome') echo ' class="green"'; ?>>
- Welcome to Go-PEAR
- </a><br/>
-
- <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
- <a href="<?php echo basename(__FILE__); ?>?step=config" <?php if ($page == 'config') echo ' class="green"'; ?>>
- Configuration
- </a><br/>
-
- <img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=smallpear" border="0">
-<?php if ($page == 'install') echo '<span class="green">'; ?>
- Complete installation<br/>
-<?php if ($page == 'install') echo '</span>'; ?>
+ <p><br />
+ <?php
+ $menus = array('Welcome' => 'Welcome to Go-PEAR',
+ 'config' => 'Configuration',
+ 'preinstall' => 'Installation',
+ 'install' => 'Completed');
+ $after_current = false;
+
+ // Menu robustness (a bit low, but better then never)
+ if ($page == 'error') {
+ $_GET['last'] = $_GET['step'];
+ $after_current = true;
+ } elseif (!array_key_exists($page, $menus)) {
+ $page = 'Welcome';
+ }
+
+ foreach ($menus as $menu => $descr) {
+ print('<img src="'.basename(__FILE__).'?action=img&amp;img=smallpear" alt="" />');
+
+ if (!$after_current) {
+ $class = '';
+ if ($page == $menu) {
+ $class = 'green';
+ }
+ if (!isSet($_GET['last'])) { $_GET['last'] = $page; }
+ print('<a href="'.basename(__FILE__).'?step='.$menu.'&last='.$_GET['last'].'" class="'.$class.'">'.$descr.'</a><br />');
+
+ if ($_GET['last'] == $menu) {
+ $after_current = true;
+ }
+ } else {
+ print('<span class="grey">'.$descr.'</span><br />');
+ }
+ }
+ ?>
</td>
</tr>
@@ -1694,7 +1775,7 @@ function displayHTML($page = 'Welcome', $data = array())
$value = preg_replace('/(ok)$/', '<span class="green">\1</span>', $value);
}
if (preg_match('/failed$/', $value)) {
- $value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
+ $value = preg_replace('/(failed)$/', '<span class="red">\1</span>', $value);
}
if (preg_match('/^install ok:/', $value)) {
$value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
@@ -1707,89 +1788,138 @@ function displayHTML($page = 'Welcome', $data = array())
} elseif ($page == 'Welcome') {
?>
<span class="title">Welcome to go-pear <?php echo GO_PEAR_VER; ?>!</span><br/>
- <br/>
- Go-pear will install the Web Frontend of the PEAR Installer and all the needed <br/>
- files. This frontend is your tool for PEAR installation and maintenance.<br/>
- <br/>
- Go-pear also lets you download and install the PEAR packages bundled<br/>
- with PHP: <?php echo implode(', ', $GLOBALS['pfc_packages']); ?>.<br/>
- <br/>
- <a href="<?php echo basename(__FILE__); ?>?step=config" class="green">Next &gt;&gt;</a>
+ <p>
+ Go-pear will install Pear, its Web Frontend and all the needed files. This<br/>
+ frontend is your tool for PEAR installation and maintenance.
+ </p>
+ <p>
+ Go-pear also lets you download and install the following optional PEAR<br/>
+ packages: <?php echo implode(', ', array_keys($GLOBALS['pfc_packages'])); ?>.
+ </p>
+
+ <a href="<?php echo basename(__FILE__); ?>?step=config&restart=1" class="green">Next &gt;&gt;</a>
<?php
} elseif ($page == 'config') {
if (!empty($GLOBALS['http_proxy'])) {
- list($proxy_host, $proxy_port) = explode(':', $GLOBALS['http_proxy']);
+ $tmp_proxy = parse_url($GLOBALS['http_proxy']);
+
+ $proxy_host = $tmp_proxy['scheme'] . '://';
+ if ($tmp_proxy['user'] != '') {
+ $proxy_host .= $tmp_proxy['user'];
+ if ($tmp_proxy['pass'] != '') {
+ $proxy_host .= ':' . $tmp_proxy['pass'];
+ }
+ $proxy_host .= '@';
+ }
+ $proxy_host .= $tmp_proxy['host'];
+ $proxy_port = $tmp_proxy['port'];
} else {
$proxy_host = $proxy_port = '';
}
?>
<form action="<?php echo basename(__FILE__);?>?step=install" method="post">
- <span class="title">Configuration</span><br/>
- <br/>
- HTTP proxy (host:port):
- <input type="text" name="proxy[host]" value="<?php echo $proxy_host;?>">
- <input type="text" name="proxy[port]" value="<?php echo $proxy_port;?>" size="6">
- <br/><br/><hr/><br/>
- Below is a suggested file layout for your new PEAR installation. <br/>
- <br/>
- <table border="0">
- <TR>
- <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
- <TD>
+ <!-- Packages stuff -->
+ <span class="title">Packages</span>
+ <p>
+ The following PEAR packages will be installed. You can select some optional<br />
+ packages to be installed by go-pear too:<br />
+ </p>
+ <table border="0">
+ <tr>
+ <th>&nbsp;</th><th>Package</th><th width="65%">Description</th>
+ </tr><tr>
+ <td>(required)</td><td>PEAR core</td><td>PEAR Base System</td>
+ </tr>
+
+ <?php
+ // automatically install frontend
+ $frontend = 'PEAR_Frontend_Web-beta';
+ print('<tr><td>(required)<input type="hidden" name="'.$frontend.'" value="on" /></td><td>'.$frontend.'</td><td>'.$GLOBALS['pfc_packages'][$frontend].'</td></tr>');
+ unset($GLOBALS['pfc_packages'][$frontend]);
+
+ foreach ($GLOBALS['pfc_packages'] as $var => $descr) {
+ $checked = '';
+ if (in_array($var, $GLOBALS['install_optional_packages'])) { $checked = ' checked'; }
+ printf('<tr><td align="center"><input type="checkbox" name="%s"%s></td><td>%s</td><td>%s</td></tr>',
+ $var,
+ $checked,
+ $var,
+ $descr);
+ }
+ ?>
+ </table>
+ <hr />
+
+ <!-- Configuration stuff -->
+ <span class="title">Configuration</span>
+ <p>
+ Below is a suggested file layout for your new PEAR installation.
+ </p>
+
+ <!--
+ <p>
+ <table border="0">
+ <tr>
+ <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" /></td>
+ <td>
<span class="green">
<b>Note:</b> Make sure that PHP has the permission to access the specified<br/>
- directories.<br/><br/>
+ directories.
</span>
- </TD>
- </TR>
+ </td>
+ </tr>
</table>
- <TABLE border="0">
+ </p>
+ -->
+
+ <table border="0" width="80%">
<?php
- // Display error messages
- if (isset($GLOBALS['www_errors']) && sizeof($GLOBALS['www_errors']) ) {
- $www_errors = $GLOBALS['www_errors'];
- echo "<tr><td>";
- echo '<span class="red">ERROR(S):</span>';
- echo "</td></tr>";
- foreach ($www_errors as $n => $var) {
- echo "<tr><td>";
- echo '<span class="red">'.$GLOBALS['config_desc'][$n].': </span>';
- echo "</td><td>";
- echo '<span class="red">'.$www_errors[$n].'</span>';
- echo "<br>\n";
- echo "</td></tr>\n";
+ foreach ($GLOBALS['config_vars'] as $n => $var) {
+ $error_class = '';
+ if (is_array($GLOBALS['config_errors']) && array_key_exists($var, $GLOBALS['config_errors'])) {
+ // www_error for this var
+ $error_class = ' class="red"';
}
- }
- foreach ($GLOBALS['config_vars'] as $n => $var) {
- printf('<tr><td>%d. %s</td><td><input type="text" name="config[%s]" value="%s"></td></tr>',
+ printf('<tr><td>%d. %s</td><td><input type="text" name="config[%s]" value="%s"%s></td></tr>',
$n,
$GLOBALS['config_desc'][$var],
$var,
- $GLOBALS[$var]);
+ $_SESSION['go-pear']['config'][$var],
+ $error_class);
+
+ // prefix dir, check perm (uses GLOBALS: resolved subvars)
+ if ($n == 1 && is_dir($GLOBALS[$var]) && !is_writable($GLOBALS[$var])) {
+ $error = '<em>WARNING!</em> No permission to create subdirectories in this prefix dir. Unless you fix this, the default configuration will not work.';
+ if (!WINDOWS) {
+ $error .= '<p>You can grant this permission by logging on to the server and issuing the following command:<br />
+<tt>chmod 0777 '.$GLOBALS[$var].'</tt></p>';
+ }
+ print('<tr><td colspan="2" class="green">'.$error.'</td></tr>');
+ }
+
+
+ if (is_array($GLOBALS['config_errors']) && array_key_exists($var, $GLOBALS['config_errors'])) {
+ // www_error for this var
+ print('<tr><td colspan="2" class="red">'.$GLOBALS['config_errors'][$var].'</td></tr>');
+ }
}
?>
- </TABLE>
- <br/><hr/><br/>
- The following PEAR packages are common ones, and can be installed<br/>
- by go-pear too: <br/>
-<?php echo implode(', ', $GLOBALS['pfc_packages']);?>.<br/>
- <input type="checkbox" name="install_pfc" <?php if($GLOBALS['install_pfc']) ?>> Install those too<br/>
- <br/><br/>
- <table border="0">
- <TR>
- <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
- <TD>
- <span class="green">
- <b>Note:</b> Installation might take some time, because go-pear has to download<br/>
- all needed files from pear.php.net. Just be patient and wait for the next<br/>
- page to load.<br/>
- </span>
- </TD>
- </TR>
</table>
- <br>
- <input type="checkbox" name="BCmode" id="BCmode" checked> Compatibility-Mode for old non-DOM Browsers<br/>
+ </p>
+ <hr />
+
+ <!-- Optional stuff -->
+ <span class="title">Optional:</span>
+
+ <ul>
+ <p>
+ <li />HTTP proxy (host:port)
+ <input type="text" name="proxy[host]" value="<?php echo $proxy_host;?>"> : <input type="text" name="proxy[port]" value="<?php echo $proxy_port;?>" size="6">
+ </p>
+
+ <p>
+ <li />Compatibility-Mode for old non-DOM Browsers <input type="checkbox" name="BCmode" id="BCmode" checked>
<script type="text/javascript">
<!--
if (document.getElementById('BCmode')) {
@@ -1797,27 +1927,48 @@ function displayHTML($page = 'Welcome', $data = array())
};
// -->
</script>
+ </p>
+ </ul>
<?php
if (WINDOWS && phpversion() == '4.1.1') {
?>
+ <p>
<table border="0">
- <TR>
- <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
- <TD>
+ <tr>
+ <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" alt="" /></td>
+ <td>
<span style="color: #ff0000">
<b>Warning:</b> Your PHP version (4.1.1) might be imcompatible with go-pear due to a bug<br/>
in your PHP binary. If the installation crashes you might want to update your PHP version.</br>
</span>
- </TD>
- </TR>
+ </td>
+ </tr>
</table>
+ </p>
<?php
}
?>
- <br/>
+ <hr />
+ <!-- Closing note -->
+ <p>
+ <table border="0">
+ <tr>
+ <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" alt="" /></td>
+ <td>
+ <span class="green">
+ <b>Note:</b> Installation might take some time, because go-pear has to<br/>
+ download all needed files from pear.php.net. Just be patient and wait for<br/>
+ the next page to load.<br/>
+ </span>
+ </td>
+ </tr>
+ </table>
+ </p>
+
<input type="submit" value="Install" onClick="javascript: submitButton.value='Downloading and installing ... please wait ...'" name="submitButton">
</form>
+
<?php
} elseif ($page == 'install') {
?>
@@ -1826,9 +1977,10 @@ function displayHTML($page = 'Welcome', $data = array())
displayHTMLInstallationSummary($data);
} elseif ($page == 'preinstall') {
?>
- <span class="title">Installation in progress ...</span><br/>
- <br/>
- <script language="javascript">
+ <p>
+ <span class="title">Installation in progress ...</span></br >
+ <i>(If the page stops loading before the end of the installation, then just reload it)</i></p>
+ <script type="text/javascript">
<!--
var progress;
@@ -1885,6 +2037,14 @@ function displayHTML($page = 'Welcome', $data = array())
prog.innerHTML = 'Downloading '+value+' ...';
};
+ function unsetdownloadfile()
+ {
+ setdownloadprogress(0);
+
+ prog = document.getElementById('download_file');
+ prog.innerHTML = '';
+ };
+
function setdownloadprogress(value)
{
downloadprogress = value;
@@ -1941,7 +2101,7 @@ function displayHTML($page = 'Welcome', $data = array())
<td bgcolor="#ffffff" height="20" id="installation_progress" class="green">0 %</td>
</tr>
</table>
- <br>
+ <br />
<table border="0">
<tr>
<td bgcolor="#cccccc" width="10" height="20" id="download_progress_cell_0">&nbsp;</td>
@@ -1960,7 +2120,7 @@ function displayHTML($page = 'Welcome', $data = array())
<td bgcolor="#ffffff" height="20" id="download_file" class="green"></td>
</tr>
</table>
- <br>
+ <br />
<iframe src="<?php echo basename(__FILE__); ?>?step=install-progress&amp;<?php echo SID;?>" width="700" height="700" frameborder="0" marginheight="0" marginwidth="0"></iframe>
</td>
</tr>
@@ -2001,7 +2161,7 @@ function displayHTMLFooter()
function displayHTMLInstallationSummary($data = '')
{
$next = NULL;
- $file = $GLOBALS['webfrontend_file'];
+ $file = $GLOBALS['webfrontend_file'];
$doc_root = strip_magic_quotes($_SERVER['DOCUMENT_ROOT']);
$file_dir = dirname(__FILE__);
if ( WINDOWS ) {
@@ -2012,29 +2172,40 @@ function displayHTMLInstallationSummary($data = '')
if ($doc_root && substr($file, 0, strlen($doc_root)) == $doc_root) {
$next = substr($file, strlen($doc_root));
- } elseif ($file_dir && substr($file, 0, strlen($file_dir)) == $file_dir) {
+ // need leading / (file - docroot = path from docroot)
+ if (substr($next, 0, 1) != '/') {
+ $next = '/'.$next;
+ }
+ } else if ($file_dir && substr($file, 0, strlen($file_dir)) == $file_dir) {
$next = substr($file, strlen($file_dir));
+ // strip leading / (file - file_dir = path from go-pear file)
+ if (substr($next, 0, 1) == '/') {
+ $next = substr($next, 1, strlen($next));
+ }
}
if ($data) {
echo "<br/>".$data;
}
?>
- <br/>
+ <p>
+ <span class="title">Installation Completed !</span>
+ </p>
+
<table border="0">
- <TR>
- <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
- <TD>
+ <tr>
+ <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" alt="" /></td>
+ <td>
<span class="green">
<b>Note:</b> To use PEAR without any problems you need to add your<br/>
- PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br>
+ PEAR Installation path (<?php echo $GLOBALS['php_dir']; ?>)<br />
to your <a href="http://www.php.net/manual/en/configuration.directives.php#ini.include_path">include_path</a>.<br/>
<br/>
Using a .htaccess file or directly edit httpd.conf would be working solutions<br/>
for Apache running servers, too.<br/>
</span>
- </TD>
- </TR>
+ </td>
+ </tr>
</table>
<br/>
For more information about PEAR, see:<br/>
@@ -2047,16 +2218,16 @@ function displayHTMLInstallationSummary($data = '')
if ($next === NULL) {
?>
<table border="0">
- <TR>
- <TD valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" border="0"></TD>
- <TD>
+ <tr>
+ <td valign="top"><img src="<?php echo basename(__FILE__); ?>?action=img&amp;img=note" alt="" /></td>
+ <td>
<span style="color: #ff0000">
- <b>Warning:</b> Go-PEAR was not able to determine the URL to the newly<br/>
- installed Web Frontend of the PEAR Installer. Please access it manually.<br/>
- Since you specified the prefix, you should know how to do so.<br/>
+ <b>Warning:</b> Can not determine the URL of the freshly installed Web Frontend<br />
+ (file: <?php echo $file ?>).<br />
+ Please access it manually !
</span>
- </TD>
- </TR>
+ </td>
+ </tr>
</table>
<?php
} else {
@@ -2127,14 +2298,17 @@ function displayHTMLProgress($progress)
$value = preg_replace('/(failed)$/', '<span style="color: #ff0000">\1</span>', $value);
};
if (preg_match('/^install ok:/', $value)) {
- $value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value);
+ //$value = preg_replace('/^(install ok:)/', '<span class="green">\1</span>', $value).'<br />';
+ //$msg = array($value); // if install succeeded: don't show the irritatingly verbose pear installer
+ $msg = array('<span class="green">ok</span><br />');
+ break;
};
if (preg_match('/^Warning:/', $value)) {
$value = '<span style="color: #ff0000">'.$value.'</span>';
};
$msg[$key] = $value;
};
- $msg = implode('<br>', $msg);
+ $msg = implode('<br />', $msg);
$msg.='<script type="text/javascript"> parent.setprogress('.((int) $progress).'); </script>';
@@ -2170,7 +2344,11 @@ function displayHTMLSetDownload($file)
$msg = ob_get_contents();
ob_end_clean();
- echo '<script type="text/javascript"> parent.setdownloadfile("'.$file.'"); </script>';
+ if ($file != null && $file != '') {
+ echo '<script type="text/javascript"> parent.setdownloadfile("'.$file.'"); </script>';
+ } else {
+ echo '<script type="text/javascript"> parent.unsetdownloadfile(); </script>';
+ }
ob_start();
echo $msg;
@@ -2494,3 +2672,5 @@ php.ini <$pathIni> include_path updated.
}
return true;
}
+
+?>
diff --git a/lang/pear/files/pear.sh b/lang/pear/files/pear.sh
index 513b638a38b..ae84cdbbf4f 100644
--- a/lang/pear/files/pear.sh
+++ b/lang/pear/files/pear.sh
@@ -1,6 +1,6 @@
#!@SH@
#
-# $Id: pear.sh,v 1.2 2008/12/20 14:42:50 adrianp Exp $
+# $Id: pear.sh,v 1.3 2009/10/29 08:29:03 seb Exp $
# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
@@ -27,4 +27,4 @@ else
fi
fi
-exec $PHP -C -q $INCARG -d output_buffering=1 -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" $INCDIR/pearcmd.php "$@"
+exec $PHP -C -q $INCARG -d output_buffering=1 -d variables_order=EGPCS -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" $INCDIR/pearcmd.php "$@"
diff --git a/lang/pear/patches/patch-aa b/lang/pear/patches/patch-aa
index 785b7f32771..f67a3c73649 100644
--- a/lang/pear/patches/patch-aa
+++ b/lang/pear/patches/patch-aa
@@ -1,9 +1,9 @@
-$NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
+$NetBSD: patch-aa,v 1.4 2009/10/29 08:29:03 seb Exp $
---- install/go-pear.php.orig 2008-09-15 12:40:50.000000000 +0100
+--- install/go-pear.php.orig 2009-10-17 09:56:43.000000000 +0000
+++ install/go-pear.php
-@@ -311,6 +311,8 @@ if (WEBINSTALLER) {
- $install_pfc = $_SESSION['go-pear']['install_pfc'];
+@@ -252,6 +252,8 @@ if (WEBINSTALLER) {
+ // Anything past this step has something to do with the installation
}
+/*
@@ -11,7 +11,7 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
if (!WEBINSTALLER) {
$tty = WINDOWS ? @fopen('\con', 'r') : @fopen('/dev/tty', 'r');
-@@ -355,6 +357,8 @@ If you wish to abort, press Control-C no
+@@ -296,6 +298,8 @@ If you wish to abort, press Control-C no
}
}
@@ -20,7 +20,7 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
$origpwd = getcwd();
$config_vars = array_keys($config_desc);
-@@ -426,6 +430,8 @@ we strongly recommand to use it.
+@@ -347,6 +351,8 @@ we strongly recommand to use it.
}
}
@@ -29,34 +29,34 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
while (!WEBINSTALLER) {
print "
Below is a suggested file layout for your new PEAR installation. To
-@@ -509,6 +515,8 @@ If you have a CLI (or CGI) php.exe avail
+@@ -430,6 +436,8 @@ If you have a CLI (or CGI) php.exe avail
}
}
+*/
+
- foreach ($config_vars as $n => $var) {
- for ($m = 1; $m <= count($config_vars); $m++) {
- $var2 = $config_vars[$m];
-@@ -576,6 +584,8 @@ Run this script as $root or pick another
- }
+ ####
+ # Installation stuff
+ ####
+@@ -564,13 +572,17 @@ if (WEBINSTALLER) {
}
-+/*
-+
if (!WEBINSTALLER) {
++/*
$msg = "The following PEAR packages are bundled with PHP: " .
- implode(', ', $pfc_packages);
-@@ -585,6 +595,8 @@ if (!WEBINSTALLER) {
+ implode(', ', array_keys($pfc_packages));
+ print "\n" . wordwrap($msg, 75) . ".\n";
+ print "Would you like to install these as well? [Y/n] : ";
+ $install_pfc = !stristr(fgets($tty, 1024), "n");
++*/
+ $install_optional_packages = array();
++/*
print "\n";
++*/
}
-+*/
-+
####
- # Download
- ####
-@@ -595,6 +607,8 @@ if (function_exists('set_include_path'))
+@@ -583,6 +595,8 @@ if (function_exists('set_include_path'))
ini_set('include_path', $ptmp);
}
@@ -65,16 +65,16 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
if (!extension_loaded('zlib') && !WEBINSTALLER) { // In Web context we could be in multithread env which makes dl() end up with a fatal error.
if (WINDOWS) {
@dl('php_zlib.dll');
-@@ -620,6 +634,8 @@ if (!$have_gzip) {
+@@ -608,6 +622,8 @@ if (!$have_gzip) {
print "Downloading uncompressed packages\n";
};
+*/
+
if ($install_pfc) {
- $to_install = array_merge($installer_packages, $pfc_packages);
+ $to_install = array_merge($installer_packages, array_keys($pfc_packages));
} else {
-@@ -776,7 +792,7 @@ include_once "PEAR/Command.php";
+@@ -749,7 +765,7 @@ include_once "PEAR/Command.php";
include_once "PEAR/Registry.php";
if (WEBINSTALLER || isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == 'local') {
@@ -83,17 +83,38 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
} else {
$config = &PEAR_Config::singleton();
}
-@@ -810,10 +826,17 @@ foreach ($tarball as $pkg => $src) {
- displayHTMLProgress($progress += round(29 / count($tarball)));
- }
-
+@@ -781,7 +797,11 @@ displayHTMLProgress($progress = 45);
+
+ $install = &PEAR_Command::factory('install', $config);
+ foreach ($to_install as $pkg) {
+- $pkg_basename = substr($pkg, 0, strpos($pkg, '-'));
++ if (strpos($pkg, '-')) {
++ $pkg_basename = substr($pkg, 0, strpos($pkg, '-'));
++ } else {
++ $pkg_basename = $pkg;
++ }
+
+ if (in_array($pkg, $installer_packages)) {
+ $options = array('nodeps' => true);
+@@ -794,7 +814,6 @@ foreach ($to_install as $pkg) {
+ continue;
+ }
+
+- $pkg_basename = substr($pkg, 0, strpos($pkg, '-'));
+ if (in_array($pkg_basename, $bootstrap_pkgs)) {
+ print(str_pad("Installing bootstrap package: $pkg_basename", max(50,30+strlen($pkg_basename)+4), '.')."...");
+ displayHTMLProgress($progress += round(25 / count($to_install)));
+@@ -817,12 +836,17 @@ print "\n".'Making sure every package is
+ $install->run('upgrade-all', array('soft' => true), array());
+ print "ok\n";
+ */
+$config->set('download_dir', '/tmp' . '/download');
+$config->set('temp_dir', '/tmp');
+$config->store();
-+$install = &PEAR_Command::factory('install', $config);
-+
+ unset($config, $registry, $install);
displayHTMLProgress($progress = 99);
+
// Base installation finished
+/*
@@ -101,7 +122,7 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
ini_restore("include_path");
if (!WEBINSTALLER) {
-@@ -971,6 +994,9 @@ if ( WINDOWS ) {
+@@ -981,6 +1005,9 @@ if ( WINDOWS ) {
if (WINDOWS && !WEBINSTALLER) {
win32CreateRegEnv();
}
@@ -109,19 +130,20 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
+*/
+
// Set of functions following
-
- // {{{ download_url()
-@@ -1367,16 +1393,18 @@ function detect_install_dirs($_prefix =
- }
+ /**
+ * Parse the given dirname
+@@ -1420,17 +1447,19 @@ function detect_install_dirs($_prefix =
} else {
if ($_prefix === null) {
-- $prefix = dirname(PHP_BINDIR);
+ #$prefix = dirname(PHP_BINDIR);
+- $prefix = dirname(__FILE__);
+ $prefix = "@PREFIX@";
} else {
$prefix = $_prefix;
}
$bin_dir = '$prefix/bin';
-- $php_dir = '$prefix/share/pear';
+ #$php_dir = '$prefix/share/pear';
+- $php_dir = '$prefix/PEAR';
- $doc_dir = '$php_dir/docs';
+ $php_dir = '$prefix/lib/php';
+ $doc_dir = '$php_dir/doc';
@@ -129,24 +151,18 @@ $NetBSD: patch-aa,v 1.3 2008/09/15 11:54:21 adrianp Exp $
- $test_dir = '$php_dir/tests';
- $temp_dir = '$prefix/temp';
+ $test_dir = '$php_dir/test';
-+ $temp_dir = '@WRKSRC@/tmp';
++ $temp_dir = '@WRKSRC@/tmp';
+
+/*
// check if the user has installed PHP with PHP or GNU layout
if (@is_dir("$prefix/lib/php/.registry")) {
-@@ -1389,6 +1417,9 @@ function detect_install_dirs($_prefix =
+@@ -1443,6 +1472,8 @@ function detect_install_dirs($_prefix =
} elseif (@is_dir("$prefix/share/php/.registry")) {
$php_dir = '$prefix/share/php';
}
-+
+*/
+
}
}
-@@ -2494,3 +2525,4 @@ php.ini <$pathIni> include_path updated.
- }
- return true;
- }
-+?>