summaryrefslogtreecommitdiff
path: root/pear/PEAR
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2002-03-13 18:39:43 +0000
committerSVN Migration <svn@php.net>2002-03-13 18:39:43 +0000
commit8d6817e7f142091b1c30de30f349c3fde9d7e094 (patch)
tree45704599905d4a7445ad446fc5337374a3390dbf /pear/PEAR
parent94e6810a2a3e189cf729bdbae8f45cd9d7987ad6 (diff)
downloadphp-git-help.tar.gz
This commit was manufactured by cvs2svn to create tag 'help'.help
Diffstat (limited to 'pear/PEAR')
-rw-r--r--pear/PEAR/Autoloader.php167
-rw-r--r--pear/PEAR/Command.php156
-rw-r--r--pear/PEAR/Command/Common.php68
-rw-r--r--pear/PEAR/Command/Install.php99
-rw-r--r--pear/PEAR/CommandResponse.php123
-rw-r--r--pear/PEAR/Common.php428
-rw-r--r--pear/PEAR/Config.php722
-rw-r--r--pear/PEAR/Dependency.php246
-rw-r--r--pear/PEAR/Installer.php397
-rw-r--r--pear/PEAR/Packager.php165
-rw-r--r--pear/PEAR/Registry.php383
-rw-r--r--pear/PEAR/Remote.php102
-rw-r--r--pear/PEAR/Uploader.php60
-rw-r--r--pear/PEAR/WebInstaller.php631
14 files changed, 0 insertions, 3747 deletions
diff --git a/pear/PEAR/Autoloader.php b/pear/PEAR/Autoloader.php
deleted file mode 100644
index bc24dbb470..0000000000
--- a/pear/PEAR/Autoloader.php
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-
-if (!extension_loaded("overload")) {
- // die hard without ext/overload
- die("Rebuild PHP with the `overload' extension to use PEAR_Autoloader");
-}
-
-require_once "PEAR.php";
-
-/**
- * This class is for objects where you want to separate the code for
- * some methods into separate classes. This is useful if you have a
- * class with not-frequently-used methods that contain lots of code
- * that you would like to avoid always parsing.
- *
- * The PEAR_Autoloader class provides autoloading and aggregation.
- * The autoloading lets you set up in which classes the separated
- * methods are found. Aggregation is the technique used to import new
- * methods, an instance of each class providing separated methods is
- * stored and called every time the aggregated method is called.
- *
- * @author Stig Sæther Bakken <ssb@fast.no>
- */
-class PEAR_Autoloader extends PEAR
-{
- /**
- * Map of methods and classes where they are defined
- *
- * @var array
- *
- * @access private
- */
- var $_autoload_map = array();
-
- /**
- * Map of methods and aggregate objects
- *
- * @var array
- *
- * @access private
- */
- var $_method_map = array();
-
- /**
- * Add one or more autoload entries.
- *
- * @param string $method which method to autoload
- *
- * @param string $classname (optional) which class to find the method in.
- * If the $method parameter is an array, this
- * parameter may be omitted (and will be ignored
- * if not), and the $method parameter will be
- * treated as an associative array with method
- * names as keys and class names as values.
- *
- * @return void
- *
- * @access public
- */
- function addAutoload($method, $classname = null)
- {
- if (is_array($method)) {
- $this->_autoload_map = array_merge($this->_autoload_map, $method);
- } else {
- $this->_autoload_map[$method] = $classname;
- }
- }
-
- /**
- * Remove an autoload entry.
- *
- * @param string $method which method to remove the autoload entry for
- *
- * @return bool TRUE if an entry was removed, FALSE if not
- *
- * @access public
- */
- function removeAutoload($method)
- {
- $ok = isset($this->_autoload_map[$method]);
- unset($this->_autoload_map[$method]);
- return $ok;
- }
-
- /**
- * Add an aggregate object to this object. If the specified class
- * is not defined, loading it will be attempted following PEAR's
- * file naming scheme. All the methods in the class will be
- * aggregated, except private ones (name starting with an
- * underscore) and constructors.
- *
- * @param string $classname what class to instantiate for the object.
- *
- * @return void
- *
- * @access public
- */
- function addAggregateObject($classname)
- {
- $classname = strtolower($classname);
- if (!class_exists($classname)) {
- $include_file = preg_replace('/[^a-z0-9]/i', '_', $classname);
- include_once $include_file;
- }
- $obj =& new $classname;
- $methods = get_class_methods($classname);
- foreach ($methods as $method) {
- // don't import priviate methods and constructors
- if ($method{0} != '_' && $method != $classname) {
- $this->_method_map[$method] = $obj;
- }
- }
- }
-
- /**
- * Remove an aggregate object.
- *
- * @param string $classname the class of the object to remove
- *
- * @return bool TRUE if an object was removed, FALSE if not
- *
- * @access public
- */
- function removeAggregateObject($classname)
- {
- $ok = false;
- $classname = strtolower($classname);
- reset($this->_method_map);
- while (list($method, $obj) = each($this->_method_map)) {
- if (get_class($obj) == $classname) {
- unset($this->_method_map[$method]);
- $ok = true;
- }
- }
- return $ok;
- }
-
- /**
- * Overloaded object call handler, called each time an
- * undefined/aggregated method is invoked. This method repeats
- * the call in the right aggregate object and passes on the return
- * value.
- *
- * @param string $method which method that was called
- *
- * @param string $args An array of the parameters passed in the
- * original call
- *
- * @return mixed The return value from the aggregated method, or a PEAR
- * error if the called method was unknown.
- */
- function __call($method, $args, &$retval)
- {
- if (empty($this->_method_map[$method]) && isset($this->_autoload_map[$method])) {
- $this->addAggregateObject($this->_autoload_map[$method]);
- }
- if (isset($this->_method_map[$method])) {
- $retval = call_user_func_array(array($this->_method_map[$method], $method), $args);
- return true;
- }
- return false;
- }
-}
-
-overload("PEAR_Autoloader");
-
-?>
diff --git a/pear/PEAR/Command.php b/pear/PEAR/Command.php
deleted file mode 100644
index 49807d0339..0000000000
--- a/pear/PEAR/Command.php
+++ /dev/null
@@ -1,156 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-
-require_once "PEAR.php";
-
-/**
- * List of commands and what classes they are implemented in.
- * @var array command => implementing class
- */
-$GLOBALS['_PEAR_Command_commandlist'] = array();
-
-/**
- * PEAR command class, a simple factory class for administrative
- * commands.
- *
- * How to implement command classes:
- *
- * - The class must be called PEAR_Command_Nnn, installed in the
- * "PEAR/Common" subdir, with a method called getCommands() that
- * returns an array of the commands implemented by the class (see
- * PEAR/Command/Install.php for an example).
- *
- * - The class must implement a run() function that is called with three
- * params:
- *
- * (string) command name
- * (array) assoc array with options, freely defined by each
- * command, for example:
- * array('force' => true)
- * (array) list of the other parameters
- *
- * The run() function returns a PEAR_CommandResponse object. Use
- * these methods to get information:
- *
- * int getStatus() Returns PEAR_COMMAND_(SUCCESS|FAILURE|PARTIAL)
- * *_PARTIAL means that you need to issue at least
- * one more command to complete the operation
- * (used for example for validation steps).
- *
- * string getMessage() Returns a message for the user. Remember,
- * no HTML or other interface-specific markup.
- *
- * If something unexpected happens, run() returns a PEAR error.
- *
- * - DON'T OUTPUT ANYTHING! Return text for output instead.
- *
- * - DON'T USE HTML! The text you return will be used from both Gtk,
- * web and command-line interfaces, so for now keep everything to
- * plain text.
- *
- * - DON'T USE EXIT OR DIE! Always use pear errors. From static
- * classes do PEAR::raiseError(), from other classes do
- * $this->raiseError().
- */
-class PEAR_Command
-{
- /**
- * Get the right object for executing a command.
- *
- * @param object Instance of PEAR_Config object
- * @param string The name of the command
- *
- * @return object the command object or a PEAR error
- *
- * @access public
- */
- function factory(&$config, $command)
- {
- if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
- PEAR_Command::registerCommands();
- }
- if (isset($GLOBALS['_PEAR_Command_commandlist'][$command])) {
- $class = $GLOBALS['_PEAR_Command_commandlist'][$command];
- $obj =& new $class($config);
- return $obj;
- }
- return PEAR::raiseError("unknown command: $command");
- }
-
- /**
- * Scan through the Command directory looking for classes
- * and see what commands they implement.
- *
- * @param bool (optional) if FALSE (default), the new list of
- * commands should replace the current one. If TRUE,
- * new entries will be merged with old.
- *
- * @param string (optional) where (what directory) to look for
- * classes, defaults to the Command subdirectory of
- * the directory from where this file (__FILE__) is
- * included.
- *
- * @return bool TRUE on success, a PEAR error on failure
- *
- * @access public
- */
- function registerCommands($merge = false, $dir = null)
- {
- if ($dir === null) {
- $dir = dirname(__FILE__) . '/Command';
- }
- $dp = @opendir($dir);
- if (empty($dp)) {
- return PEAR::raiseError("PEAR_Command::registerCommands: opendir($dir) failed");
- }
- if (!$merge) {
- $GLOBALS['_PEAR_Command_commandlist'] = array();
- }
- while ($entry = readdir($dp)) {
- if ($entry{0} == '.' || substr($entry, -4) != '.php' || $entry == 'Common.php') {
- continue;
- }
- $class = "PEAR_Command_".substr($entry, 0, -4);
- $file = "$dir/$entry";
- include_once $file;
- $implements = call_user_func(array($class, "getCommands"));
- foreach ($implements as $command) {
- $GLOBALS['_PEAR_Command_commandlist'][$command] = $class;
- }
- }
- return true;
- }
-
- /**
- * Get the list of currently supported commands, and what
- * classes implement them.
- *
- * @return array command => implementing class
- *
- * @access public
- */
- function getCommands()
- {
- return $GLOBALS['_PEAR_Command_commandlist'];
- }
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Command/Common.php b/pear/PEAR/Command/Common.php
deleted file mode 100644
index e54c1694f1..0000000000
--- a/pear/PEAR/Command/Common.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once "PEAR.php";
-require_once "PEAR/CommandResponse.php";
-
-class PEAR_Command_Common extends PEAR
-{
- /**
- * PEAR_Config object used to pass user system and configuration
- * on when executing commands
- *
- * @var object
- */
- var $config;
-
- /**
- * PEAR_Command_Common constructor.
- *
- * @access public
- */
- function PEAR_Command_Common()
- {
- parent::PEAR();
- $this->config = PEAR_Config::singleton();
- }
-
- /**
- * Return a PEAR_CommandResponse object with parameters
- * filled in.
- *
- * @param int status code
- * @param string message text
- * @param string (optional) message character encoding
- *
- * @return object a PEAR_CommandResponse object
- *
- * @access public
- *
- * @see PEAR_CommandResponse
- */
- function &makeResponse($status, $message, $encoding = null)
- {
- $obj =& new PEAR_CommandResponse($status, $message, $encoding);
- return $obj;
- }
-
-
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php
deleted file mode 100644
index 0d99f85b1a..0000000000
--- a/pear/PEAR/Command/Install.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once "PEAR/Command/Common.php";
-require_once "PEAR/Installer.php";
-
-/**
- * PEAR commands for installation or deinstallation/upgrading of
- * packages.
- *
- */
-class PEAR_Command_Install extends PEAR_Command_Common
-{
- /** Stack of executing commands, to make run() re-entrant
- * @var array
- */
- var $command_stack; // XXX UNUSED to make run() re-entrant
-
- /** Currently executing command.
- * @var string
- */
- var $command; // XXX UNUSED
-
- /**
- * PEAR_Command_Install constructor.
- *
- * @access public
- */
- function PEAR_Command_Install()
- {
- parent::PEAR_Command_Common();
- }
-
- /**
- * Return a list of all the commands defined by this class.
- * @return array list of commands
- * @access public
- */
- function getCommands()
- {
- return array('install', 'uninstall', 'upgrade');
- }
-
- function run($command, $options, $params)
- {
- $installer =& new PEAR_Installer($options['php_dir'],
- $options['ext_dir'],
- $options['doc_dir']);
- $installer->debug = @$options['verbose'];
- $status = PEAR_COMMAND_SUCCESS;
- ob_start();
- switch ($command) {
- case 'install':
- case 'upgrade': {
- if ($command == 'upgrade') {
- $options['upgrade'] = true;
- }
- if ($installer->install($params[0], $options, $this->config)) {
- print "install ok\n";
- } else {
- print "install failed\n";
- $status = PEAR_COMMAND_FAILURE;
- }
- break;
- }
- case 'uninstall': {
- if ($installer->uninstall($params[0], $uninstall_options)) {
- print "uninstall ok\n";
- } else {
- print "uninstall failed\n";
- $status = PEAR_COMMAND_FAILURE;
- }
- break;
- }
- }
- $output = ob_get_contents();
- ob_end_clean();
- return $this->makeResponse($status, $output);
- }
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/CommandResponse.php b/pear/PEAR/CommandResponse.php
deleted file mode 100644
index 27715505b9..0000000000
--- a/pear/PEAR/CommandResponse.php
+++ /dev/null
@@ -1,123 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once "PEAR.php";
-
-define('PEAR_COMMAND_FAILURE', 0);
-define('PEAR_COMMAND_SUCCESS', 1);
-define('PEAR_COMMAND_PARTIAL', 2);
-
-/**
- * PEAR_CommandResponse is for returning an "environment-neutral"
- * response to the application when a PEAR command is done. This
- * means that there should be no HTML markup etc. in the message. The
- * application should try rendering the message "as-is" with
- * linebreaks and preferably a fixed-width font.
- */
-class PEAR_CommandResponse extends PEAR
-{
- /** Status code (one of the PEAR_COMMAND_* constants
- * @var int
- */
- var $status = null;
-
- /** Message for user, in plain text.
- * @var string
- */
- var $message = '';
-
- /** Character set/encoding of $message.
- * @var string
- */
- var $encoding = 'ISO-8859-1';
-
- /**
- * Constructor. Not very exciting.
- *
- * @param int Command status, one of:
- * PEAR_COMMAND_SUCCESS : the command was successful
- * PEAR_COMMAND_FAILURE : the command failed
- * PEAR_COMMAND_PARTIAL : the command was successful,
- * but requires some other command to complete the
- * operation (for example if the user must confirm
- * something).
- * @param string Message for the user.
- * @param string (optional) What character encoding the message
- * is in, defaults to ISO-8859-1.
- * @access public
- */
- function PEAR_CommandRepsonse($status, $message, $encoding = null)
- {
- if ($encoding !== null) {
- $this->setEncoding($encoding);
- }
- $this->status = $status;
- $this->message = $message;
- }
-
- /**
- * Get the response status code.
- * @return int response status code
- * @access public
- */
- function getStatus()
- {
- return $this->status;
- }
-
- /**
- * Get the response message.
- * @return string response message
- * @access public
- */
- function getMessage()
- {
- return $this->message;
- }
-
- /**
- * Get the response message charset encoding.
- * @return string response message charset encoding
- * @access public
- */
- function getEncoding()
- {
- return $this->encoding;
- }
-
- /**
- * Set the response message charset encoding.
- * @param string Which encoding to use, valid charsets are currently
- * ISO-8859-{1-15} and UTF-8.
- * @return bool true if the encoding was valid, false if not
- * @access public
- */
- function setEncoding($encoding)
- {
- if (preg_match('/^ISO-8859-([1-9]|1[1-5])$/i', $encoding) ||
- strcasecmp('UTF-8', $encoding) == 0) {
- $this->encoding = $encoding;
- return true;
- }
- return false;
- }
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php
deleted file mode 100644
index 929a97917e..0000000000
--- a/pear/PEAR/Common.php
+++ /dev/null
@@ -1,428 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 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: Stig Bakken <ssb@fast.no> |
-// | Tomas V.V.Cox <cox@idecnet.com> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once 'PEAR.php';
-require_once 'Archive/Tar.php';
-require_once 'System.php';
-
-/**
- * TODO:
- * - check in inforFromDescFile that the minimal data needed is present
- * (pack name, version, files, others?)
- * - inherance of dir attribs to files may fail under certain circumstances
- */
-class PEAR_Common extends PEAR
-{
- // {{{ properties
-
- /** stack of elements, gives some sort of XML context */
- var $element_stack = array();
-
- /** name of currently parsed XML element */
- var $current_element;
-
- /** array of attributes of the currently parsed XML element */
- var $current_attributes = array();
-
- /** list of temporary files created by this object */
- var $_tempfiles = array();
-
- /** assoc with information about a package */
- var $pkginfo = array();
-
- /**
- * Permitted maintainer roles
- * @var array
- */
- var $maintainer_roles = array('lead','developer','contributor','helper');
-
- /**
- * Permitted release states
- * @var array
- */
- var $releases_states = array('alpha','beta','stable','snapshot');
-
- // }}}
-
- // {{{ constructor
-
- function PEAR_Common()
- {
- $GLOBALS['_PEAR_Common_tempfiles'] = array();
- $this->_tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
- $this->PEAR();
- }
-
- // }}}
- // {{{ destructor
-
- function _PEAR_Common()
- {
- // doesn't work due to bug #14744
- //$tempfiles = $this->_tempfiles;
- $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
- while (is_array($tempfiles) &&
- $file = array_shift($tempfiles))
- {
- if (@is_dir($file)) {
- System::rm("-rf $file");
- } elseif (file_exists($file)) {
- unlink($file);
- }
- }
- }
-
- // }}}
- // {{{ addTempFile()
-
- function addTempFile($file)
- {
- $this->_tempfiles[] = $file;
- }
-
- // }}}
- // {{{ mkDirHier()
-
- function mkDirHier($dir)
- {
- $this->log(2, "+ create dir $dir");
- return System::mkDir("-p $dir");
- }
-
- // }}}
- // {{{ log()
-
- function log($level, $msg)
- {
- if ($this->debug >= $level) {
- print "$msg\n";
- }
- }
-
- // }}}
- // {{{ mkTempDir()
-
- function mkTempDir()
- {
- if (!$tmpdir = System::mktemp('-d pear')) {
- return false;
- }
- $this->addTempFile($tmpdir);
- return $tmpdir;
- }
-
- // }}}
- // {{{ _element_start()
-
- function _element_start($xp, $name, $attribs)
- {
- array_push($this->element_stack, $name);
- $this->current_element = $name;
- $spos = sizeof($this->element_stack) - 2;
- $this->prev_element = ($spos >= 0) ? $this->element_stack[$spos] : '';
- $this->current_attributes = $attribs;
- $this->cdata = '';
- switch ($name) {
- case 'dir':
- if (isset($this->dir_names)) {
- $this->dir_names[] = $attribs['name'];
- } else {
- // Don't add the root dir
- $this->dir_names = array();
- }
- if (isset($attribs['baseinstalldir'])) {
- $this->dir_install = $attribs['baseinstalldir'];
- }
- if (isset($attribs['role'])) {
- $this->dir_role = $attribs['role'];
- }
- break;
- case 'libfile':
- $this->lib_atts = $attribs;
- $this->lib_atts['role'] = 'extension';
- break;
- case 'maintainers':
- $this->pkginfo['maintainers'] = array();
- $this->m_i = 0; // maintainers array index
- break;
- case 'maintainer':
- // compatibility check
- if (!isset($this->pkginfo['maintainers'])) {
- $this->pkginfo['maintainers'] = array();
- $this->m_i = 0;
- }
- $this->pkginfo['maintainers'][$this->m_i] = array();
- $this->current_maintainer =& $this->pkginfo['maintainers'][$this->m_i];
- break;
- case 'changelog':
- $this->pkginfo['changelog'] = array();
- $this->c_i = 0; // changelog array index
- $this->in_changelog = true;
- break;
- case 'release':
- if ($this->in_changelog) {
- $this->pkginfo['changelog'][$this->c_i] = array();
- $this->current_release =& $this->pkginfo['changelog'][$this->c_i];
- }
- break;
- case 'deps':
- $this->pkginfo['release_deps'] = array();
- break;
- case 'dep':
- // dependencies array index
- $this->d_i = (isset($this->d_i)) ? $this->d_i + 1 : 0;
- $this->pkginfo['release_deps'][$this->d_i] = $attribs;
- break;
- }
- }
-
- // }}}
- // {{{ _element_end()
-
- function _element_end($xp, $name)
- {
- $data = trim($this->cdata);
- switch ($name) {
- case 'name':
- switch ($this->prev_element) {
- case 'package':
- $this->pkginfo['package'] = ereg_replace('[^a-zA-Z0-9._]', '_', $data);
- break;
- case 'maintainer':
- $this->current_maintainer['name'] = $data;
- break;
- }
- break;
- case 'summary':
- $this->pkginfo['summary'] = $data;
- break;
- case 'description':
- $this->pkginfo['description'] = $data;
- break;
- case 'user':
- $this->current_maintainer['handle'] = $data;
- break;
- case 'email':
- $this->current_maintainer['email'] = $data;
- break;
- case 'role':
- if (!in_array($data, $this->maintainer_roles)) {
- trigger_error("The maintainer role: '$data' is not valid", E_USER_WARNING);
- } else {
- $this->current_maintainer['role'] = $data;
- }
- break;
- case 'version':
- $data = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $data);
- if ($this->in_changelog) {
- $this->current_release['version'] = $data;
- } else {
- $this->pkginfo['version'] = $data;
- }
- break;
- case 'date':
- if ($this->in_changelog) {
- $this->current_release['release_date'] = $data;
- } else {
- $this->pkginfo['release_date'] = $data;
- }
- break;
- case 'notes':
- if ($this->in_changelog) {
- $this->current_release['release_notes'] = $data;
- } else {
- $this->pkginfo['release_notes'] = $data;
- }
- break;
- case 'state':
- if (!in_array($data, $this->releases_states)) {
- trigger_error("The release state: '$data' is not valid", E_USER_WARNING);
- } elseif ($this->in_changelog) {
- $this->current_release['release_state'] = $data;
- } else {
- $this->pkginfo['release_state'] = $data;
- }
- break;
- case 'license':
- $this->pkginfo['release_license'] = $data;
- break;
- case 'sources':
- $this->lib_sources[] = $data;
- break;
- case 'dep':
- if ($data = trim($data)) {
- $this->pkginfo['release_deps'][$this->d_i]['name'] = $data;
- }
- break;
- case 'dir':
- array_pop($this->dir_names);
- break;
- case 'file':
- $this->current_file = $data;
- $path = '';
- if (!empty($this->dir_names)) {
- foreach ($this->dir_names as $dir) {
- $path .= $dir . DIRECTORY_SEPARATOR;
- }
- }
- $path .= $this->current_file;
- $this->filelist[$path] = $this->current_attributes;
- // Set the baseinstalldir only if the file don't have this attrib
- if (!isset($this->filelist[$path]['baseinstalldir']) &&
- isset($this->dir_install))
- {
- $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
- }
- // Set the Role
- if (!isset($this->filelist[$path]['role']) && isset($this->dir_role)) {
- $this->filelist[$path]['role'] = $this->dir_role;
- }
- break;
- case 'libfile':
- $this->lib_name = $data;
- $path = '';
- if (!empty($this->dir_names)) {
- foreach ($this->dir_names as $dir) {
- $path .= $dir . DIRECTORY_SEPARATOR;
- }
- }
- $path .= $this->lib_name;
- $this->filelist[$path] = $this->lib_atts;
- // Set the baseinstalldir only if the file don't have this attrib
- if (!isset($this->filelist[$path]['baseinstalldir']) &&
- isset($this->dir_install))
- {
- $this->filelist[$path]['baseinstalldir'] = $this->dir_install;
- }
- if (isset($this->lib_sources)) {
- $this->filelist[$path]['sources'] = $this->lib_sources;
- }
- unset($this->lib_atts);
- unset($this->lib_sources);
- break;
- case 'maintainer':
- $this->m_i++;
- break;
- case 'release':
- if ($this->in_changelog) {
- $this->c_i++;
- }
- break;
- case 'changelog':
- $this->in_changelog = false;
- break;
- case 'summary':
- $this->pkginfo['summary'] = $data;
- break;
- }
- array_pop($this->element_stack);
- $spos = sizeof($this->element_stack) - 1;
- $this->current_element = ($spos > 0) ? $this->element_stack[$spos] : '';
- }
-
- // }}}
- // {{{ _pkginfo_cdata()
-
- function _pkginfo_cdata($xp, $data)
- {
- $this->cdata .= $data;
- }
-
- // }}}
- // {{{ infoFromDescriptionFile()
-
- function infoFromDescriptionFile($descfile)
- {
- if (!@is_file($descfile) || !is_readable($descfile) ||
- (!$fp = @fopen($descfile, 'r'))) {
- return $this->raiseError("Unable to open $descfile");
- }
- $xp = @xml_parser_create();
- if (!$xp) {
- return $this->raiseError('Unable to create XML parser');
- }
- xml_set_object($xp, $this);
- xml_set_element_handler($xp, '_element_start', '_element_end');
- xml_set_character_data_handler($xp, '_pkginfo_cdata');
- xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
-
- $this->element_stack = array();
- $this->pkginfo = array();
- $this->current_element = false;
- $this->destdir = '';
- $this->pkginfo['filelist'] = array();
- $this->filelist =& $this->pkginfo['filelist'];
- $this->in_changelog = false;
-
- // read the whole thing so we only get one cdata callback
- // for each block of cdata
- $data = fread($fp, filesize($descfile));
- if (!xml_parse($xp, $data, 1)) {
- $msg = sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xp)),
- xml_get_current_line_number($xp));
- xml_parser_free($xp);
- return $this->raiseError($msg);
- }
-
- xml_parser_free($xp);
-
- foreach ($this->pkginfo as $k => $v) {
- if (!is_array($v)) {
- $this->pkginfo[$k] = trim($v);
- }
- }
- return $this->pkginfo;
- }
- // }}}
- // {{{ infoFromTgzFile()
-
- /**
- * Returns info from a tgz pear package
- */
- function infoFromTgzFile($file)
- {
- if (!@is_file($file)) {
- return $this->raiseError('tgz :: could not open file');
- }
- $tar = new Archive_Tar($file, true);
- $content = $tar->listContent();
- if (!is_array($content)) {
- return $this->raiseError('tgz :: could not get contents of package');
- }
- $xml = null;
- foreach ($content as $file) {
- $name = $file['filename'];
- if (ereg('^.*/package.xml$', $name, $match)) {
- $xml = $match[0];
- }
- }
- $tmpdir = System::mkTemp('-d pear');
- $this->addTempFile($tmpdir);
- if (!$xml || !$tar->extractList($xml, $tmpdir)) {
- return $this->raiseError('tgz :: could not extract the package.xml file');
- }
- return $this->infoFromDescriptionFile("$tmpdir/$xml");
-
- // }}}
- }
-}
-?> \ No newline at end of file
diff --git a/pear/PEAR/Config.php b/pear/PEAR/Config.php
deleted file mode 100644
index e8b4b610d8..0000000000
--- a/pear/PEAR/Config.php
+++ /dev/null
@@ -1,722 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once 'PEAR.php';
-
-/**
- * Last created PEAR_Config instance.
- * @var object
- */
-$GLOBALS['_PEAR_Config_last_instance'] = null;
-
-define('PEAR_CONFIG_DEFAULT_DOCDIR',
- PHP_DATADIR.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR.'doc');
-/**
- * This is a class for storing simple configuration values keeping
- * track of which are system-defined, user-defined or defaulted. By
- * default, only user-defined settings are stored back to the user's
- * configuration file.
- *
- * Configuration member is a simple associative array. Used keys:
- *
- * master_server which server to query for mirror lists etc.
- * server which server/mirror we're currently using
- * username PEAR username
- * password PEAR password (stored base64-encoded)
- * php_dir Where to install .php files
- * ext_dir Directory to install compiled libs in
- * doc_dir Directory to install documentation in
- *
- */
-class PEAR_Config extends PEAR
-{
- // {{{ properties
-
- /**
- * Array of config files used.
- *
- * @var array layer => config file
- */
- var $files = array(
- 'system' => '',
- 'user' => '',
- );
-
- var $layers = array();
-
- /**
- * Configuration data, two-dimensional array where the first
- * dimension is the config layer ('user', 'system' and 'default'),
- * and the second dimension is keyname => value.
- *
- * The order in the first dimension is important! Earlier
- * layers will shadow later ones when a config value is
- * requested (if a 'user' value exists, it will be returned first,
- * then 'system' and finally 'default').
- *
- * @var array layer => array(keyname => value, ...)
- */
- var $configuration = array(
- 'user' => array(),
- 'system' => array(),
- 'default' => array(),
- );
-
- /**
- * Information about the configuration data. Stores the type,
- * default value and a documentation string for each configuration
- * value.
- *
- * @var array layer => array(infotype => value, ...)
- */
- var $configuration_info = array(
- 'master_server' => array(
- 'type' => 'string',
- 'default' => 'pear.php.net',
- 'doc' => 'name of the main PEAR server',
- ),
- 'php_dir' => array(
- 'type' => 'directory',
- 'default' => PEAR_INSTALL_DIR,
- 'doc' => 'directory where .php files are installed',
- ),
- 'ext_dir' => array(
- 'type' => 'directory',
- 'default' => PEAR_EXTENSION_DIR,
- 'doc' => 'directory where loadable extensions are installed',
- ),
- 'doc_dir' => array(
- 'type' => 'directory',
- 'default' => PEAR_CONFIG_DEFAULT_DOCDIR,
- 'doc' => 'directory where documentation is located',
- ),
- 'username' => array(
- 'type' => 'string',
- 'default' => '',
- 'doc' => '(maintainers) your PEAR account name',
- ),
- 'password' => array(
- 'type' => 'password',
- 'default' => '',
- 'doc' => '(maintainers) your PEAR account password',
- ),
- 'verbose' => array(
- 'type' => 'integer',
- 'default' => 1,
- 'doc' => 'verbosity level',
- ),
- 'testset1' => array(
- 'type' => 'set',
- 'default' => 'foo',
- 'doc' => 'test set',
- 'valid_set' => array('foo', 'bar'),
- ),
- );
-
- // }}}
-
- // {{{ PEAR_Config([file], [defaults_file])
-
- /**
- * Constructor.
- *
- * @param string (optional) file to read user-defined options from
- * @param string (optional) file to read system-wide defaults from
- *
- * @access public
- *
- * @see PEAR_Config::singleton
- */
- function PEAR_Config($user_file = '', $system_file = '')
- {
- $this->PEAR();
- $sl = DIRECTORY_SEPARATOR;
- if (empty($user_file)) {
- if (OS_WINDOWS) {
- $user_file = PHP_SYSCONFDIR . $sl . 'pear.ini';
- } else {
- $user_file = getenv('HOME') . $sl . '.pearrc';
- }
- }
- if (empty($system_file)) {
- if (OS_WINDOWS) {
- $system_file = PHP_SYSCONFDIR . $sl . 'pearsys.ini';
- } else {
- $system_file = PHP_SYSCONFDIR . $sl . 'pear.conf';
- }
- }
- $this->layers = array_keys($this->configuration);
- $this->files['user'] = $user_file;
- $this->files['system'] = $system_file;
- $GLOBALS['_PEAR_Config_last_instance'] = &$this;
- if ($user_file && file_exists($user_file)) {
- $this->readConfigFile($user_file);
- }
- if ($system_file && file_exists($system_file)) {
- $this->mergeConfigFile($system_file, false, 'system');
- }
- foreach ($this->configuration_info as $key => $info) {
- $this->configuration['default'][$key] = $info['default'];
- }
- }
-
- // }}}
- // {{{ singleton([file], [defaults_file])
-
- /**
- * Static singleton method. If you want to keep only one instance
- * of this class in use, this method will give you a reference to
- * the last created PEAR_Config object if one exists, or create a
- * new object.
- *
- * @param string (optional) file to read user-defined options from
- * @param string (optional) file to read system-wide defaults from
- *
- * @return object an existing or new PEAR_Config instance
- *
- * @access public
- *
- * @see PEAR_Config::PEAR_Config
- */
- function &singleton($user_file = '', $system_file = '')
- {
- if (empty($GLOBALS['_PEAR_Config_last_instance'])) {
- $obj =& new PEAR_Config($user_file, $system_file);
- $GLOBALS['_PEAR_Config_last_instance'] = &$obj;
- }
- return $GLOBALS['_PEAR_Config_last_instance'];
- }
-
- // }}}
- // {{{ readConfigFile([file], [layer])
-
- /**
- * Reads configuration data from a file. All existing values in
- * the config layer are discarded and replaced with data from the
- * file.
- *
- * @param string (optional) file to read from, if NULL or not
- * specified, the last-used file for the same layer (second param)
- * is used
- *
- * @param string (optional) config layer to insert data into
- * ('user' or 'system')
- *
- * @return bool TRUE on success or a PEAR error on failure
- *
- * @access public
- */
- function readConfigFile($file = null, $layer = 'user')
- {
- if (empty($this->files[$layer])) {
- return $this->raiseError("unknown config file type `$layer'");
- }
- if ($file === null) {
- $file = $this->files[$layer];
- }
- $data = $this->_readConfigDataFrom($file);
- if (PEAR::isError($data)) {
- return $data;
- }
- $this->_decodeInput($data);
- $this->configuration[$layer] = $data;
- return true;
- }
-
- // }}}
- // {{{ mergeConfigFile(file, [override], [layer])
-
- /**
- * Merges data into a config layer from a file. Does the same
- * thing as readConfigFile, except it does not replace all
- * existing values in the config layer.
- *
- * @param string file to read from
- *
- * @param bool (optional) whether to overwrite existing data
- * (default TRUE)
- *
- * @param string config layer to insert data into ('user' or
- * 'system')
- *
- * @return bool TRUE on success or a PEAR error on failure
- *
- * @access public.
- */
- function mergeConfigFile($file, $override = true, $layer = 'user')
- {
- if (empty($this->files[$layer])) {
- return $this->raiseError("unknown config file type `$layer'");
- }
- if ($file === null) {
- $file = $this->files[$layer];
- }
- $data = $this->_readConfigDataFrom($file);
- if (PEAR::isError($data)) {
- return $data;
- }
- $this->_decodeInput($data);
- if ($override) {
- $this->configuration[$layer] = array_merge($this->configuration[$layer], $data);
- } else {
- $this->configuration[$layer] = array_merge($data, $this->configuration[$layer]);
- }
- return true;
- }
-
- // }}}
- // {{{ writeConfigFile([file], [layer])
-
- /**
- * Writes data into a config layer from a file.
- *
- * @param string file to read from
- *
- * @param bool (optional) whether to overwrite existing data
- * (default TRUE)
- *
- * @param string config layer to insert data into ('user' or
- * 'system')
- *
- * @return bool TRUE on success or a PEAR error on failure
- *
- * @access public.
- */
- function writeConfigFile($file = null, $layer = 'user')
- {
- if ($layer == 'both' || $layer == 'all') {
- foreach ($this->files as $type => $file) {
- $err = $this->writeConfigFile($file, $type);
- if (PEAR::isError($err)) {
- return $err;
- }
- }
- return true;
- }
- if (empty($this->files[$layer])) {
- return $this->raiseError("unknown config file type `$layer'");
- }
- if ($file === null) {
- $file = $this->files[$layer];
- }
- $data = $this->configuration[$layer];
- $this->_encodeOutput($data);
- if (!@is_writeable($file)) {
- return $this->raiseError("no write access to $file!");
- }
- $fp = @fopen($file, "w");
- if (!$fp) {
- return $this->raiseError("PEAR_Config::writeConfigFile fopen('$file','w') failed");
- }
- $contents = "#PEAR_Config 0.9\n" . serialize($data);
- if (!@fwrite($fp, $contents)) {
- return $this->raiseError("PEAR_Config::writeConfigFile: fwrite failed");
- }
- return true;
- }
-
- // }}}
- // {{{ _readConfigDataFrom(file)
-
- /**
- * Reads configuration data from a file and returns the parsed data
- * in an array.
- *
- * @param string file to read from
- *
- * @return array configuration data or a PEAR error on failure
- *
- * @access private
- */
- function _readConfigDataFrom($file)
- {
- $fp = @fopen($file, "r");
- if (!$fp) {
- return $this->raiseError("PEAR_Config::readConfigFile fopen('$file','r') failed");
- }
- $size = filesize($file);
- $contents = fread($fp, $size);
- $version = '0.1';
- if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, &$matches)) {
- $version = $matches[1];
- $contents = substr($contents, strlen($matches[0]));
- }
- if (version_compare($version, '1', '<')) {
- $data = unserialize($contents);
- if (!is_array($data)) {
- if (strlen(trim($contents)) > 0) {
- $error = "PEAR_Config: bad data in $file";
-// if (isset($this)) {
- return $this->raiseError($error);
-// } else {
-// return PEAR::raiseError($error);
- } else {
- $data = array();
- }
- }
- // add parsing of newer formats here...
- } else {
- return $this->raiseError("$file: unknown version `$version'");
- }
- return $data;
- }
-
- // }}}
- // {{{ _encodeOutput(&data)
-
- /**
- * Encodes/scrambles configuration data before writing to files.
- * Currently, 'password' values will be base64-encoded as to avoid
- * that people spot cleartext passwords by accident.
- *
- * @param array (reference) array to encode values in
- *
- * @return bool TRUE on success
- *
- * @access private
- */
- function _encodeOutput(&$data)
- {
- foreach ($data as $key => $value) {
- if (!isset($this->configuration_info[$key])) {
- continue;
- }
- $type = $this->configuration_info[$key]['type'];
- switch ($type) {
- // we base64-encode passwords so they are at least
- // not shown in plain by accident
- case 'password': {
- $data[$key] = base64_encode($data[$key]);
- break;
- }
- }
- }
- return true;
- }
-
- // }}}
- // {{{ _decodeInput(&data)
-
- /**
- * Decodes/unscrambles configuration data after reading from files.
- *
- * @param array (reference) array to encode values in
- *
- * @return bool TRUE on success
- *
- * @access private
- *
- * @see PEAR_Config::_encodeOutput
- */
- function _decodeInput(&$data)
- {
- if (!is_array($data)) {
- return true;
- }
- foreach ($data as $key => $value) {
- if (!isset($this->configuration_info[$key])) {
- continue;
- }
- $type = $this->configuration_info[$key]['type'];
- switch ($type) {
- case 'password': {
- $data[$key] = base64_decode($data[$key]);
- break;
- }
- }
- }
- return true;
- }
-
- // }}}
- // {{{ get(key)
-
- /**
- * Returns a configuration value, prioritizing layers as per the
- * layers property.
- *
- * @param string config key
- *
- * @return mixed the config value, or NULL if not found
- *
- * @access public
- */
- function get($key)
- {
- foreach ($this->layers as $layer) {
- if (isset($this->configuration[$layer][$key])) {
- return $this->configuration[$layer][$key];
- }
- }
- return null;
- }
-
- // }}}
- // {{{ set(key, value, [layer])
-
- /**
- * Set a config value in a specific layer (defaults to 'user').
- * Enforces the types defined in the configuration_info array. An
- * integer config variable will be cast to int, and a set config
- * variable will be validated against its legal values.
- *
- * @param string config key
- *
- * @param string config value
- *
- * @param string (optional) config layer
- *
- * @return bool TRUE on success, FALSE on failure
- *
- * @access public
- */
- function set($key, $value, $layer = 'user')
- {
- if (empty($this->configuration_info[$key])) {
- return false;
- }
- extract($this->configuration_info[$key]);
- switch ($type) {
- case 'integer': {
- $value = (int)$value;
- break;
- }
- case 'set': {
- // If a valid_set is specified, require the value to
- // be in the set. If there is no valid_set, accept
- // any value.
- if ($valid_set) {
- reset($valid_set);
- if ((key($valid_set) === 0 && !in_array($value, $valid_set)) ||
- empty($valid_set[$value]))
- {
- return false;
- }
- }
- break;
- }
- }
- $this->configuration[$layer][$key] = $value;
- return true;
- }
-
- // }}}
- // {{{ getType(key)
-
- /**
- * Get the type of a config value.
- *
- * @param string config key
- *
- * @return string type, one of "string", "integer", "file",
- * "directory", "set" or "password".
- *
- * @access public
- *
- */
- function getType($key)
- {
- if (isset($this->configuration_info[$key])) {
- return $this->configuration_info[$key]['type'];
- }
- return false;
- }
-
- // }}}
- // {{{ getDocs(key)
-
- /**
- * Get the documentation for a config value.
- *
- * @param string config key
- *
- * @return string documentation string
- *
- * @access public
- *
- */
- function getDocs($key)
- {
- if (isset($this->configuration_info[$key])) {
- return $this->configuration_info[$key]['doc'];
- }
- return false;
- }
-
- // }}}
- // {{{ getSetValues(key)
-
- /**
- * Get the list of allowed set values for a config value. Returns
- * NULL for config values that are not sets.
- *
- * @param string config key
- *
- * @return array enumerated array of set values, or NULL if the
- * config key is unknown or not a set
- *
- * @access public
- *
- */
- function getSetValues($key)
- {
- if (isset($this->configuration_info[$key]) &&
- isset($this->configuration_info[$key]['type']) &&
- $this->configuration_info[$key]['type'] == 'set')
- {
- $valid_set = $this->configuration_info[$key]['valid_set'];
- reset($valid_set);
- if (key($valid_set) === 0) {
- return $valid_set;
- }
- return array_keys($valid_set);
- }
- return false;
- }
-
- // }}}
- // {{{ getKeys()
-
- /**
- * Get all the current config keys.
- *
- * @return array simple array of config keys
- *
- * @access public
- */
- function getKeys()
- {
- $keys = array();
- foreach ($this->layers as $layer) {
- $keys = array_merge($keys, $this->configuration[$layer]);
- }
- return array_keys($keys);
- }
-
- // }}}
- // {{{ remove(key, [layer])
-
- /**
- * Remove the a config key from a specific config layer.
- *
- * @param string config key
- *
- * @param string (optional) config layer
- *
- * @return bool TRUE on success, FALSE on failure
- *
- * @access public
- */
- function remove($key, $layer = 'user')
- {
- if (isset($this->configuration[$layer][$key])) {
- unset($this->configuration[$layer][$key]);
- return true;
- }
- return false;
- }
-
- // }}}
- // {{{ toDefault(key)
-
- /**
- * Unset the user-defined value of a config key, reverting the
- * value to the system-defined one.
- *
- * @param string config key
- *
- * @return bool TRUE on success, FALSE on failure
- *
- * @access public
- */
- function toDefault($key)
- {
- trigger_error("PEAR_Config::toDefault() deprecated, use PEAR_Config::remove() instead", E_USER_NOTICE);
- return $this->remove($key, 'user');
- }
-
- // }}}
- // {{{ definedBy(key)
-
- /**
- * Tells what config layer that gets to define a key.
- *
- * @param string config key
- *
- * @return string the config layer, or an empty string if not found
- *
- * @access public
- */
- function definedBy($key)
- {
- foreach ($this->layers as $layer) {
- if (isset($this->configuration[$layer][$key])) {
- return $layer;
- }
- }
- return '';
- }
-
- // }}}
- // {{{ isDefaulted(key)
-
- /**
- * Tells whether a config value has a system-defined value.
- *
- * @param string config key
- *
- * @return bool
- *
- * @access public
- *
- * @deprecated
- */
- function isDefaulted($key)
- {
- trigger_error("PEAR_Config::isDefaulted() deprecated, use PEAR_Config::definedBy() instead", E_USER_NOTICE);
- return $this->definedBy($key) == 'system';
- }
-
- // }}}
- // {{{ isDefined(key)
-
- /**
- * Tells whether a given key exists as a config value.
- *
- * @param string config key
- *
- * @return bool whether <config key> exists in this object
- *
- * @access public
- */
- function isDefined($key)
- {
- foreach ($this->layers as $layer) {
- if (isset($this->configuration[$layer][$key])) {
- return true;
- }
- }
- return false;
- }
-
- // }}}
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Dependency.php b/pear/PEAR/Dependency.php
deleted file mode 100644
index c6af633f66..0000000000
--- a/pear/PEAR/Dependency.php
+++ /dev/null
@@ -1,246 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 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@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-/**
-* Methods for dependencies check. Based on Stig's dependencies RFC
-* at http://cvs.php.net/cvs.php/pearweb/rfc
-* (requires php >= 4.1)
-*/
-
-require_once "PEAR.php";
-
-class PEAR_Dependency
-{
-
- /**
- * This method maps the xml dependency definition to the
- * PEAR_dependecy one
- *
- * $opts => Array
- * (
- * [type] => pkg
- * [rel] => ge
- * [version] => 3.4
- * [name] => HTML_Common
- * )
- */
- function callCheckMethod($opts)
- {
- $rel = isset($opts['rel']) ? $opts['rel'] : 'has';
- if (isset($opts['version'])) {
- $req = $opts['version'];
- $rel = 'v.' . $rel;
- } else {
- $req = null;
- }
- $name = isset($opts['name']) ? $opts['name'] : null;
- switch ($opts['type']) {
- case 'pkg':
- return $this->checkPackage($name, $req, $rel);
- break;
- case 'ext':
- return $this->checkExtension($name, $req, $rel);
- break;
- case 'php':
- return $this->checkPHP($req, $rel);
- break;
- case 'prog':
- return $this->checkProgram($name);
- break;
- case 'os':
- return $this->checkOS($name);
- break;
- case 'sapi':
- return $this->checkSAPI($name);
- break;
- default:
- return "'{$opts['type']}' dependencie type not supported";
- }
- }
-
- /**
- * Package dependencies check method
- *
- * @param string $name Name of the package to test
- * @param string $version The package version required
- * @param string $relation How to compare versions with eachother
- *
- * @return mixed bool false if no error or the error string
- */
- function checkPackage($name, $req = null, $relation = 'has')
- {
- if (empty($this->registry)) {
- $this->registry = new PEAR_Registry;
- }
- if (!$this->registry->packageExists($name)) {
- return "'$name' PEAR package is not installed";
- }
- if (substr($relation, 0, 2) == 'v.') {
- $pkg_ver = $this->registry->packageInfo($name, 'version');
- $operator = substr($relation, 2);
- if (!version_compare($pkg_ver, $req, $operator)) {
- return "'$name' PEAR package version " .
- $this->signOperator($operator) . " $req is required";
- }
- return false;
- }
- return "Relation '$relation' with requirement '$req' is not supported";
- }
-
- /**
- * Extension dependencies check method
- *
- * @param string $name Name of the extension to test
- * @param string $req_ext_ver Required extension version to compare with
- * @param string $relation How to compare versions with eachother
- *
- * @return mixed bool false if no error or the error string
- */
- function checkExtension($name, $req = null, $relation = 'has')
- {
- // XXX (ssb): could we avoid loading the extension here?
- if (!extension_loaded($name)) {
- $dlext = OS_WINDOWS ? '.dll' : '.so';
- if (!@dl($name . $dlext)) {
- return "'$name' PHP extension is not installed";
- }
- }
- if ($relation == 'has') {
- return false;
- }
- if (substr($relation, 0, 2) == 'v.') {
- $ext_ver = phpversion($name);
- $operator = substr($relation, 2);
- if (!version_compare($ext_ver, $req, $operator)) {
- return "'$name' PHP extension version " .
- $this->signOperator($operator) . " $req is required";
- }
- }
- return false;
- }
-
- /**
- * Operating system dependencies check method
- *
- * @param string $os Name of the operating system
- *
- * @return mixed bool false if no error or the error string
- */
- function checkOS($os)
- {
- // XXX Fixme: Implement a more flexible way, like
- // comma separated values or something similar to PEAR_OS
-
- // only 'has' relation is supported
- if ($os == PHP_OS) {
- return false;
- }
- return "'$os' operating system not supported";
- }
-
- /**
- * PHP version check method
- *
- * @param string $req which version to compare
- * @param string $relation how to compare the version
- *
- * @return mixed bool false if no error or the error string
- */
- function checkPHP($req, $relation = 'v.ge')
- {
- if (substr($relation, 0, 2) == 'v.') {
- $php_ver = phpversion();
- $operator = substr($relation, 2);
- if (!version_compare($php_ver, $req, $operator)) {
- return "PHP version " . $this->signOperator($operator) .
- " $req is required";
- }
- }
- return false;
- }
-
- /**
- * External program check method. Looks for executable files in
- * directories listed in the PATH environment variable.
- *
- * @param string $program which program to look for
- *
- * @return mixed bool false if no error or the error string
- */
- function checkProgram($program)
- {
- // XXX FIXME honor safe mode
- $path_delim = OS_WINDOWS ? ';' : ':';
- $exe_suffix = OS_WINDOWS ? '.exe' : '';
- $path_elements = explode($path_delim, getenv('PATH'));
- foreach ($path_elements as $dir) {
- $file = $dir . DIRECTORY_SEPARATOR . $program . $exe_suffix;
- if (@file_exists($file) && @is_executable($file)) {
- return false;
- }
- }
- return "'$program' program is not present in the PATH";
- }
-
- /**
- * SAPI backend check method. Version comparison is not yet
- * available here.
- *
- * @param string $name name of SAPI backend
- * @param string $req which version to compare
- * @param string $relation how to compare versions (currently
- * hardcoded to 'has')
- * @return mixed bool false if no error or the error string
- */
- function checkSAPI($name, $req = null, $relation = 'has')
- {
- // XXX Fixme: There is no way to know if the user has or
- // not other SAPI backends installed than the installer one
-
- $sapi_backend = php_sapi_name();
- // Version comparisons not supported, sapi backends don't have
- // version information yet.
- if ($sapi_backend == $name) {
- return false;
- }
- return "'$sapi_backend' SAPI backend not supported";
- }
-
- /**
- * Converts text comparing operators to them sign equivalents
- * ex: 'ge' to '>='
- */
- function signOperator($operator)
- {
- switch($operator) {
- case 'lt': return '<';
- case 'le': return '<=';
- case 'gt': return '>';
- case 'ge': return '>=';
- case 'eq': return '==';
- case 'ne': return '!=';
- default:
- return $operator;
- }
- }
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php
deleted file mode 100644
index 260e3e817e..0000000000
--- a/pear/PEAR/Installer.php
+++ /dev/null
@@ -1,397 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 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: Stig Bakken <ssb@fast.no> |
-// | Tomas V.V.Cox <cox@idecnet.com> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once 'PEAR/Common.php';
-require_once 'PEAR/Registry.php';
-require_once 'PEAR/Dependency.php';
-
-/**
- * Administration class used to install PEAR packages and maintain the
- * installed package database.
- *
- * TODO:
- * - Install the "role=doc" files in a central pear doc dir
- * - kill FIXME's
- *
- * @since PHP 4.0.2
- * @author Stig Bakken <ssb@fast.no>
- */
-class PEAR_Installer extends PEAR_Common
-{
- // {{{ properties
-
- /** name of the package directory, for example Foo-1.0 */
- var $pkgdir;
-
- /** directory where PHP code files go */
- var $phpdir;
-
- /** directory where PHP extension files go */
- var $extdir;
-
- /** directory where documentation goes */
- var $docdir;
-
- /** directory where the package wants to put files, relative
- * to one of the three previous dirs
- */
- var $destdir = '';
-
- /** debug level (integer) */
- var $debug = 1;
-
- /** temporary directory */
- var $tmpdir;
-
- /** PEAR_Registry object used by the installer */
- var $registry;
-
- // }}}
-
- // {{{ constructor
-
- function PEAR_Installer($phpdir = PEAR_INSTALL_DIR,
- $extdir = PEAR_EXTENSION_DIR,
- $docdir = null)
- {
- $this->PEAR();
- $this->phpdir = $phpdir;
- $this->extdir = $extdir;
- if ($docdir === null) {
- $docdir = PHP_DATADIR . DIRECTORY_SEPARATOR . 'pear' .
- DIRECTORY_SEPARATOR . 'doc';
- }
- $this->docdir = $docdir;
- }
-
- // }}}
-
- // {{{ _deletePackageFiles()
-
- function _deletePackageFiles($package)
- {
- $info = $this->registry->packageInfo($package);
- if ($info == null) {
- return $this->raiseError("$package not installed");
- }
- foreach ($info['filelist'] as $file => $props) {
- $path = $props['installed_as'];
- // XXX TODO: do a "rmdir -p dirname($path)" to maintain clean the fs
- if (!@unlink($path)) {
- $this->log(2, "unable to delete: $path");
- } else {
- $this->log(2, "+ deleted file: $path");
- }
- }
- }
-
- // }}}
- // {{{ _installFile()
-
- function _installFile($file, $atts, $tmp_path)
- {
- $type = strtolower($atts['role']);
- switch ($type) {
- case 'test':
- // don't install test files for now
- $this->log(2, "+ Test file $file won't be installed yet");
- return true;
- break;
- case 'doc':
- $dest_dir = $this->docdir . DIRECTORY_SEPARATOR .
- $this->pkginfo['package'];
- break;
- case 'php':
- default: {
- $dest_dir = $this->phpdir;
- if (isset($atts['baseinstalldir'])) {
- $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
- }
- if (dirname($file) != '.') {
- $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
- }
- break;
- }
- }
- $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
- if (!@is_dir($dest_dir)) {
- if (!$this->mkDirHier($dest_dir)) {
- $this->log(0, "failed to mkdir $dest_dir");
- return false;
- }
- $this->log(2, "+ created dir $dest_dir");
- }
- $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
- $orig_perms = fileperms($orig_file);
- if (!@copy($orig_file, $dest_file)) {
- $this->log(0, "failed to copy $orig_file to $dest_file");
- return false;
- }
- chmod($dest_file, $orig_perms);
- $this->log(2, "+ copy $orig_file to $dest_file");
-
- // Store the full path where the file was installed for easy unistall
- $this->pkginfo['filelist'][$file]['installed_as'] = $dest_file;
-
- $this->log(1, "installed file $dest_file");
- return true;
- }
-
- // }}}
- // {{{ install()
-
- /**
- * Installs the files within the package file specified.
- *
- * @param $pkgfile path to the package file
- *
- * @return bool true if successful, false if not
- */
-
- function install($pkgfile, $options = array(), $config = null)
- {
- // recognized options:
- // - register_only : update registry but don't install files
- // - upgrade : upgrade existing install
- //
- if (empty($this->registry)) {
- $this->registry = new PEAR_Registry($this->phpdir);
- }
- $oldcwd = getcwd();
- $need_download = false;
- if (preg_match('#^(http|ftp)://#', $pkgfile)) {
- $need_download = true;
- } elseif (!@is_file($pkgfile)) {
- if (preg_match('/^[A-Z][A-Za-z0-9_]+$/', $pkgfile)) {
- // valid package name
- if ($config === null) {
- $pkgfile = "http://pear.php.net/get/$pkgfile";
- } else {
- $pkgfile = "http://" . $config->get('master_server') .
- "/get/$pkgfile";
- }
- $need_download = true;
- } else {
- return $this->raiseError("could not open the package file: $pkgfile");
- }
- }
-
- // Download package -----------------------------------------------
- if ($need_download) {
- $file = basename($pkgfile);
- if (PEAR::isError($downloaddir = $this->mkTempDir())) {
- return $downloaddir;
- }
- $this->log(2, '+ tmp dir created at ' . $downloaddir);
- $downloadfile = $downloaddir . DIRECTORY_SEPARATOR . $file;
- $this->log(1, "downloading $pkgfile ...");
- if (!$fp = @fopen($pkgfile, 'r')) {
- return $this->raiseError("$pkgfile: failed to download ($php_errormsg)");
- }
- // XXX FIXME should check content-disposition header
- // for now we set the "force" option to avoid an error
- // because of a temp. package file called "Package"
- if (!$wp = @fopen($downloadfile, 'w')) {
- return $this->raiseError("$downloadfile: write failed ($php_errormsg)");
- }
- $bytes = 0;
- while ($data = @fread($fp, 16384)) {
- $bytes += strlen($data);
- if (!@fwrite($wp, $data)) {
- return $this->raiseError("$downloadfile: write failed ($php_errormsg)");
- }
- }
- $pkgfile = $downloadfile;
- fclose($fp);
- fclose($wp);
- $this->log(1, '...done: ' . number_format($bytes, 0, '', ',') . ' bytes');
- }
-
- // Decompress pack in tmp dir -------------------------------------
-
- // To allow relative package file calls
- if (!chdir(dirname($pkgfile))) {
- return $this->raiseError('unable to chdir to package directory');
- }
- $pkgfile = getcwd() . DIRECTORY_SEPARATOR . basename($pkgfile);
-
- if (PEAR::isError($tmpdir = $this->mkTempDir())) {
- chdir($oldcwd);
- return $tmpdir;
- }
- $this->log(2, '+ tmp dir created at ' . $tmpdir);
-
- $tar = new Archive_Tar($pkgfile, true);
- if (!@$tar->extract($tmpdir)) {
- chdir($oldcwd);
- return $this->raiseError("unable to unpack $pkgfile");
- }
-/*
- $file = basename($pkgfile);
- // Assume the decompressed dir name
- if (($pos = strrpos($file, '.')) === false) {
- chdir($oldcwd);
- return $this->raiseError("invalid package name");
- }
- $pkgdir = substr($file, 0, $pos);
-*/
-
- // ----- Look for existing package file
- $descfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
-
- // ==> XXX This part should be removed later on
- $flag_old_format = false;
- if (!is_file($descfile)) {
- // ----- Look for old package .tgz archive format
- // In this format the package.xml file was inside the package directory name
- $dp = opendir($tmpdir);
- do {
- $pkgdir = readdir($dp);
- } while ($pkgdir{0} == '.');
-
- $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml';
- $flag_old_format = true;
- $this->log(0, "warning : you are using an archive with an old format");
- }
- // <== XXX This part should be removed later on
-
- if (!is_file($descfile)) {
- chdir($oldcwd);
- return $this->raiseError("no package.xml file after extracting the archive");
- }
-
- // Parse xml file -----------------------------------------------
- $pkginfo = $this->infoFromDescriptionFile($descfile);
- if (PEAR::isError($pkginfo)) {
- chdir($oldcwd);
- return $pkginfo;
- }
-
- $pkgname = $pkginfo['package'];
-
- // Check dependencies -------------------------------------------
- if (isset($pkginfo['release_deps']) && !isset($options['nodeps'])) {
- $error = $this->checkDeps($pkginfo);
- if ($error) {
- $this->log(0, $error);
- return $this->raiseError('Dependencies failed');
- }
- }
-
- if (empty($options['upgrade'])) {
- // checks to do only when installing new packages
- if (empty($options['force']) && $this->registry->packageExists($pkgname)) {
- return $this->raiseError("$pkgname already installed");
- }
- } else {
- // check to do only when upgrading packages
- if (!$this->registry->packageExists($pkgname)) {
- return $this->raiseError("$pkgname not installed");
- }
- $v1 = $this->registry->packageInfo($pkgname, 'version');
- $v2 = $pkginfo['version'];
- $cmp = version_compare($v1, $v2, 'gt');
- if (empty($options['force']) && !version_compare($v2, $v1, 'gt')) {
- return $this->raiseError("upgrade to a newer version ($v2 is not newer than $v1)");
- }
- if (empty($options['register_only'])) {
- // when upgrading, remove old release's files first:
- $this->_deletePackageFiles($package);
- }
- }
-
- // Copy files to dest dir ---------------------------------------
-
- // info from the package it self we want to access from _installFile
- $this->pkginfo = $pkginfo;
- if (empty($options['register_only'])) {
- if (!is_dir($this->phpdir)) {
- chdir($oldcwd);
- return $this->raiseError("no script destination directory\n",
- null, PEAR_ERROR_DIE);
- }
-
- // don't want strange characters
- $pkgname = ereg_replace ('[^a-zA-Z0-9._]', '_', $pkginfo['package']);
- $pkgversion = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $pkginfo['version']);
- $tmp_path = dirname($descfile) . DIRECTORY_SEPARATOR . $pkgname . '-' . $pkgversion;
-
- // ==> XXX This part should be removed later on
- if ($flag_old_format) {
- $tmp_path = dirname($descfile);
- }
- // <== XXX This part should be removed later on
-
- foreach ($pkginfo['filelist'] as $file => $atts) {
- $this->_installFile($file, $atts, $tmp_path);
- }
- }
-
- // Register that the package is installed -----------------------
- if (empty($options['upgrade'])) {
- $ret = $this->registry->addPackage($pkgname, $this->pkginfo);
- } else {
- $ret = $this->registry->updatePackage($pkgname, $this->pkginfo, false);
- }
- chdir($oldcwd);
- return $ret;
- }
-
- // }}}
- // {{{ uninstall()
-
- function uninstall($package)
- {
- if (empty($this->registry)) {
- $this->registry = new PEAR_Registry($this->phpdir);
- }
-
- // Delete the files
- $this->_deletePackageFiles($package);
-
- // Register that the package is no longer installed
- return $this->registry->deletePackage($package);
- }
-
- // }}}
- // {{{ checkDeps()
-
- function checkDeps(&$pkginfo)
- {
- $deps = new PEAR_Dependency;
- $errors = null;
- if (is_array($pkginfo['release_deps'])) {
- foreach($pkginfo['release_deps'] as $dep) {
- if ($error = $deps->callCheckMethod($dep)) {
- $errors .= "\n$error";
- }
- }
- if ($errors) {
- return $errors;
- }
- }
- return false;
- }
-
- // }}}
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php
deleted file mode 100644
index d4fd0c187f..0000000000
--- a/pear/PEAR/Packager.php
+++ /dev/null
@@ -1,165 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 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: Stig Bakken <ssb@fast.no> |
-// | Tomas V.V.Cox <cox@idecnet.com> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once 'PEAR/Common.php';
-
-/**
- * Administration class used to make a PEAR release tarball.
- *
- * TODO:
- * - add an extra param the dir where to place the created package
- * - finish and test Windows support
- *
- * @since PHP 4.0.2
- * @author Stig Bakken <ssb@fast.no>
- */
-class PEAR_Packager extends PEAR_Common
-{
- // {{{ properties
-
- /** assoc with information about the package */
- var $pkginfo = array();
-
- /** name of the package directory, for example Foo-1.0 */
- var $pkgdir;
-
- /** directory where PHP code files go */
- var $phpdir;
-
- /** directory where PHP extension files go */
- var $extdir;
-
- /** directory where documentation goes */
- var $docdir;
-
- /** directory where system state information goes */
- var $statedir;
-
- /** debug mode (integer) */
- var $debug = 0;
-
- /** temporary directory */
- var $tmpdir;
-
- /** whether file list is currently being copied */
- var $recordfilelist;
-
- /** temporary space for copying file list */
- var $filelist;
-
- /** package name and version, for example "HTTP-1.0" */
- var $pkgver;
-
- // }}}
-
- // {{{ constructor
-
- function PEAR_Packager($phpdir = PEAR_INSTALL_DIR,
- $extdir = PEAR_EXTENSION_DIR,
- $docdir = '')
- {
- $this->PEAR();
- $this->phpdir = $phpdir;
- $this->extdir = $extdir;
- $this->docdir = $docdir;
- }
-
- // }}}
- // {{{ destructor
-
- function _PEAR_Packager()
- {
- chdir($this->orig_pwd);
- $this->_PEAR_Common();
- }
-
- // }}}
-
- // {{{ package()
-
- function package($pkgfile = null)
- {
- $this->orig_pwd = getcwd();
- if (empty($pkgfile)) {
- $pkgfile = 'package.xml';
- }
- $pkginfo = $this->infoFromDescriptionFile($pkgfile);
- if (PEAR::isError($pkginfo)) {
- return $pkginfo;
- }
- // XXX This needs to be checked in infoFromDescriptionFile
- // or at least a helper method to do the proper checks
- if (empty($pkginfo['version'])) {
- return $this->raiseError("No version info found in $pkgfile");
- }
- // TMP DIR -------------------------------------------------
- // We allow calls like "pear package /home/user/mypack/package.xml"
- if (!@chdir(dirname($pkgfile))) {
- return $this->raiseError('Could not chdir to '.dirname($pkgfile));
- }
- $pwd = getcwd();
- $pkgfile = basename($pkgfile);
- if (isset($pkginfo['release_state']) && $pkginfo['release_state'] == 'snapshot' && empty($pkginfo['version'])) {
- $pkginfo['version'] = date('Ymd');
- }
- // don't want strange characters
- $pkgname = preg_replace('/[^a-z0-9._]/i', '_', $pkginfo['package']);
- $pkgversion = preg_replace('/[^a-z0-9._-]/i', '_', $pkginfo['version']);
- $pkgver = $pkgname . '-' . $pkgversion;
-
- // ----- Create the package file list
- $filelist = array();
- $i = 0;
-
- // Copy files -----------------------------------------------
- foreach ($pkginfo['filelist'] as $fname => $atts) {
- if (!file_exists($fname)) {
- return $this->raiseError("File $fname does not exist");
- } else {
- $filelist[$i++] = $fname;
- }
- }
- // XXX TODO: Rebuild the package file as the old method did?
-
- // TAR the Package -------------------------------------------
- $dest_package = $this->orig_pwd . DIRECTORY_SEPARATOR . "{$pkgver}.tgz";
- $tar = new Archive_Tar($dest_package, true);
- $tar->setErrorHandling(PEAR_ERROR_PRINT);
- // ----- Creates with the package.xml file
- if (!$tar->create($pkgfile)) {
- return $this->raiseError('an error ocurred during package creation');
- }
- // ----- Add the content of the package
- if (!$tar->addModify($filelist, $pkgver)) {
- return $this->raiseError('an error ocurred during package creation');
- }
-
- $this->log(1, "Package $dest_package done");
- $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pkgversion);
- $cvstag = "RELEASE_$cvsversion";
- $this->log(1, "CVS release tag: $cvstag");
- return $dest_package;
- }
-
- // }}}
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Registry.php b/pear/PEAR/Registry.php
deleted file mode 100644
index 7bb9b9b47d..0000000000
--- a/pear/PEAR/Registry.php
+++ /dev/null
@@ -1,383 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once "System.php";
-require_once "PEAR.php";
-
-define("PEAR_REGISTRY_ERROR_LOCK", -2);
-
-/**
- * Administration class used to maintain the installed package database.
- */
-class PEAR_Registry extends PEAR
-{
- // {{{ properties
-
- /** Directory where registry files are stored.
- * @var string
- */
- var $statedir = '';
-
- /** File where the file map is stored
- * @var string
- */
- var $filemap = '';
-
- /** Name of file used for locking the registry
- * @var string
- */
- var $lockfile = '';
-
- /** File descriptor used during locking
- * @var resource
- */
- var $lock_fp = null;
-
- /** Mode used during locking
- * @var int
- */
- var $lock_mode = 0; // XXX UNUSED
-
- // }}}
-
- // {{{ PEAR_Registry
-
- /**
- * PEAR_Registry constructor.
- *
- * @param string (optional) PEAR install directory (for .php files)
- *
- * @access public
- */
- function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR)
- {
- parent::PEAR();
- $ds = DIRECTORY_SEPARATOR;
- $this->statedir = $pear_install_dir.$ds.".registry";
- $this->filemap = $pear_install_dir.$ds.".filemap";
- $this->lockfile = $pear_install_dir.$ds.".lock";
- if (!file_exists($this->filemap)) {
- $this->_rebuildFileMap();
- }
- }
-
- // }}}
- // {{{ _PEAR_Registry
-
- /**
- * PEAR_Registry destructor. Makes sure no locks are forgotten.
- *
- * @access private
- */
- function _PEAR_Registry()
- {
- parent::_PEAR();
- if (is_resource($this->lock_fp)) {
- $this->_unlock();
- }
- }
-
- // }}}
-
- // {{{ _assertStateDir()
-
- /**
- * Make sure the directory where we keep registry files exists.
- *
- * @return bool TRUE if directory exists, FALSE if it could not be
- * created
- *
- * @access private
- */
- function _assertStateDir()
- {
- if (!@is_dir($this->statedir)) {
- return System::mkdir("-p {$this->statedir}");
- }
- return true;
- }
-
- // }}}
- // {{{ _packageFileName()
-
- /**
- * Get the name of the file where data for a given package is stored.
- *
- * @param string package name
- *
- * @return string registry file name
- *
- * @access public
- */
- function _packageFileName($package)
- {
- return "{$this->statedir}/{$package}.reg";
- }
-
- // }}}
- // {{{ _openPackageFile()
-
- function _openPackageFile($package, $mode)
- {
- $this->_assertStateDir();
- $file = $this->_packageFileName($package);
- $fp = @fopen($file, $mode);
- if (!$fp) {
- return null;
- }
- return $fp;
- }
-
- // }}}
- // {{{ _closePackageFile()
-
- function _closePackageFile($fp)
- {
- fclose($fp);
- }
-
- // }}}
- // {{{ _rebuildFileMap()
-
- function _rebuildFileMap()
- {
- $packages = $this->listPackages();
- $files = array();
- foreach ($packages as $package) {
- $version = $this->packageInfo($package, "version");
- $filelist = $this->packageInfo($package, "filelist");
- if (!is_array($filelist)) {
- continue;
- }
- foreach ($filelist as $name => $attrs) {
- if (isset($attrs['role']) && $attrs['role'] != 'php') {
- continue;
- }
- if (isset($attrs['baseinstalldir'])) {
- $file = $attrs['baseinstalldir'].DIRECTORY_SEPARATOR.$name;
- } else {
- $file = $name;
- }
- $file = preg_replace(',^/+,', '', $file);
- $files[$file] = $package;
- }
- }
- $this->_assertStateDir();
- $fp = @fopen($this->filemap, "w");
- if (!$fp) {
- return false;
- }
- fwrite($fp, serialize($files));
- fclose($fp);
- return true;
- }
-
- // }}}
- // {{{ _lock()
-
- function _lock($mode = LOCK_EX)
- {
- if ($mode != LOCK_UN && is_resource($this->lock_fp)) {
- // XXX does not check type of lock (LOCK_SH/LOCK_EX)
- return true;
- }
- $this->lock_fp = @fopen($this->lockfile, "w");
- if (!is_resource($this->lock_fp)) {
- return null;
- }
- return (int)flock($this->lock_fp, $mode);
- }
-
- // }}}
- // {{{ _unlock()
-
- function _unlock()
- {
- $ret = $this->_lock(LOCK_UN);
- $this->lock_fp = null;
- return $ret;
- }
-
- // }}}
- // {{{ _packageExists()
-
- function _packageExists($package)
- {
- return file_exists($this->_packageFileName($package));
- }
-
- // }}}
- // {{{ _packageInfo()
-
- function _packageInfo($package = null, $key = null)
- {
- if ($package === null) {
- return array_map(array($this, "_packageInfo"),
- $this->_listPackages());
- }
- $fp = $this->_openPackageFile($package, "r");
- if ($fp === null) {
- return null;
- }
- $data = fread($fp, filesize($this->_packageFileName($package)));
- $this->_closePackageFile($fp);
- $data = unserialize($data);
- if ($key === null) {
- return $data;
- }
- if (isset($data[$key])) {
- return $data[$key];
- }
- return null;
- }
-
- // }}}
- // {{{ _listPackages()
-
- function _listPackages()
- {
- $pkglist = array();
- $dp = @opendir($this->statedir);
- if (!$dp) {
- return $pkglist;
- }
- while ($ent = readdir($dp)) {
- if ($ent{0} == "." || substr($ent, -4) != ".reg") {
- continue;
- }
- $pkglist[] = substr($ent, 0, -4);
- }
- return $pkglist;
- }
-
- // }}}
-
- // {{{ packageExists()
-
- function packageExists($package)
- {
- if (!$this->_lock(LOCK_SH)) {
- return $this->raiseError("could not acquire shared lock", PEAR_REGISTRY_ERROR_LOCK);
- }
- $ret = $this->_packageExists($package);
- $this->_unlock();
- return $ret;
- }
-
- // }}}
- // {{{ packageInfo()
-
- function packageInfo($package = null, $key = null)
- {
- if (!$this->_lock(LOCK_SH)) {
- return $this->raiseError("could not acquire shared lock", PEAR_REGISTRY_ERROR_LOCK);
- }
- $ret = $this->_packageInfo($package, $key);
- $this->_unlock();
- return $ret;
- }
-
- // }}}
- // {{{ listPackages()
-
- function listPackages()
- {
- if (!$this->_lock(LOCK_SH)) {
- return $this->raiseError("could not acquire shared lock", PEAR_REGISTRY_ERROR_LOCK);
- }
- $ret = $this->_listPackages();
- $this->_unlock();
- return $ret;
- }
-
- // }}}
- // {{{ addPackage()
-
- function addPackage($package, $info)
- {
- if ($this->packageExists($package)) {
- return false;
- }
- if (!$this->_lock(LOCK_EX)) {
- return $this->raiseError("could not acquire exclusive lock", PEAR_REGISTRY_ERROR_LOCK);
- }
- $fp = $this->_openPackageFile($package, "w");
- if ($fp === null) {
- $this->_unlock();
- return false;
- }
- fwrite($fp, serialize($info));
- $this->_closePackageFile($fp);
- $this->_unlock();
- return true;
- }
-
- // }}}
- // {{{ deletePackage()
-
- function deletePackage($package)
- {
- if (!$this->_lock(LOCK_EX)) {
- return $this->raiseError("could not acquire exclusive lock", PEAR_REGISTRY_ERROR_LOCK);
- }
- $file = $this->_packageFileName($package);
- $ret = @unlink($file);
- $this->_rebuildFileMap();
- $this->_unlock();
- return $ret;
- }
-
- // }}}
- // {{{ updatePackage()
-
- function updatePackage($package, $info, $merge = true)
- {
- $oldinfo = $this->packageInfo($package);
- if (empty($oldinfo)) {
- return false;
- }
- if (!$this->_lock(LOCK_EX)) {
- return $this->raiseError("could not acquire exclusive lock", PEAR_REGISTRY_ERROR_LOCK);
- }
- if (!file_exists($this->filemap)) {
- $this->_rebuildFileMap();
- }
- $fp = $this->_openPackageFile($package, "w");
- if ($fp === null) {
- $this->_unlock();
- return false;
- }
- if ($merge) {
- fwrite($fp, serialize(array_merge($oldinfo, $info)));
- } else {
- fwrite($fp, serialize($info));
- }
- $this->_closePackageFile($fp);
- if (isset($info['filelist'])) {
- $this->_rebuildFileMap();
- }
- $this->_unlock();
- return true;
- }
-
- // }}}
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php
deleted file mode 100644
index 7f397b7221..0000000000
--- a/pear/PEAR/Remote.php
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once 'PEAR.php';
-
-/**
- * This is a class for doing remote operations against the central
- * PEAR database.
- */
-class PEAR_Remote extends PEAR
-{
- // {{{ properties
-
- var $config_object = null;
-
- // }}}
-
- // {{{ PEAR_Remote(config_object)
-
- function PEAR_Remote($config_object)
- {
- $this->PEAR();
- $this->config_object = $config_object;
- }
-
- // }}}
-
- // {{{ call(method, [args...])
-
- function call($method)
- {
- if (!extension_loaded("xmlrpc")) {
- return $this->raiseError("xmlrpc support not loaded");
- }
- $method = str_replace("_", ".", $method);
- $request = xmlrpc_encode_request($method, $params);
- $server_host = $this->config_object->get("master_server");
- if (empty($server_host)) {
- return $this->raiseError("PEAR_Remote::call: no master_server configured");
- }
- $server_port = 80;
- $fp = @fsockopen($server_host, $server_port);
- if (!$fp) {
- return $this->raiseError("PEAR_Remote::call: fsockopen(`$server_host', $server_port) failed");
- }
- $len = strlen($request);
- fwrite($fp, ("POST /xmlrpc.php HTTP/1.0\r\n".
- "Host: $server_host:$server_port\r\n".
- "Content-type: text/xml\r\n".
- "Content-length: $len\r\n".
- "\r\n$request"));
- $response = '';
- while (trim(fgets($fp, 2048)) != ''); // skip headers
- while ($chunk = fread($fp, 10240)) {
- $response .= $chunk;
- }
- fclose($fp);
- $ret = xmlrpc_decode($response);
- if (is_array($ret) && isset($ret['__PEAR_TYPE__'])) {
- if ($ret['__PEAR_TYPE__'] == 'error') {
- if (isset($ret['__PEAR_CLASS__'])) {
- $class = $ret['__PEAR_CLASS__'];
- } else {
- $class = "PEAR_Error";
- }
- if ($ret['code'] === '') $ret['code'] = null;
- if ($ret['message'] === '') $ret['message'] = null;
- if ($ret['userinfo'] === '') $ret['userinfo'] = null;
- if (strtolower($class) == 'db_error') {
- $ret = $this->raiseError(DB::errorMessage($ret['code']),
- $ret['code'], null, null,
- $ret['userinfo']);
- } else {
- $ret = $this->raiseError($ret['message'], $ret['code'],
- null, null, $ret['userinfo']);
- }
- }
- }
- return $ret;
- }
-
- // }}}
-}
-
-?> \ No newline at end of file
diff --git a/pear/PEAR/Uploader.php b/pear/PEAR/Uploader.php
deleted file mode 100644
index 99212f6813..0000000000
--- a/pear/PEAR/Uploader.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-
-require_once "PEAR/Common.php";
-
-/**
- * Administration class used to install PEAR packages and maintain the
- * installed package database.
- *
- * @since PHP 4.0.2
- * @author Stig Bakken <ssb@fast.no>
- */
-class PEAR_Uploader extends PEAR_Common
-{
- // {{{ properties
-
- var $_tempfiles = array();
-
- // }}}
-
- // {{{ constructor
-
- function PEAR_Uploader()
- {
- $this->PEAR_Common();
- }
-
- // }}}
-
- function upload($pkgfile, $infofile = null)
- {
- if ($infofile === null) {
- $info = $this->infoFromTarBall($pkgfile);
- } else {
- $info = $this->infoFromDescriptionFile($infofile);
- }
- if (PEAR::isError($info)) {
- return $info;
- }
-
- }
-}
-
-?>
diff --git a/pear/PEAR/WebInstaller.php b/pear/PEAR/WebInstaller.php
deleted file mode 100644
index c96a759f14..0000000000
--- a/pear/PEAR/WebInstaller.php
+++ /dev/null
@@ -1,631 +0,0 @@
-<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4; */
-// +---------------------------------------------------------------------+
-// | PHP version 4.0 |
-// +---------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +---------------------------------------------------------------------+
-// | This source file is subject to version 2.0 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available 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: Christian Stocker <chregu@phant.ch> |
-// +---------------------------------------------------------------------+
-
-
-/* This class should simplify the task of installing PEAR-packages, if you
- * don't have a cgi-php binary on your system or you don't have access to
- * the system-wide pear directory.
- *
- * To use it, make the following php-script:
- *
- * <?php
- * require("PEAR/WebInstaller.php");
- * $installer = new PEAR_WebInstaller("/path/to/your/install/dir","http://php.chregu.tv/pear/");
- * $installer->start();
- * ?>
- *
- * and put PEAR/WebInstaller.php (this script) anywhere in your include_path.
- *
- * (http://php.chregu.tv/pear/ is just for testing purposes until this
- * system runs on pear.php.net, but feel free to use it till then)
- *
- * Both parameters are optional. If the install dir is ommitted, the
- * installer takes either the system wide pear-directory (mostly
- * /usr/local/lib/php on unix), if it's writeable, or else the directory
- * the script is started. Be advised, that the directory, where the
- * PEAR::Packages will be installed, has to be writeable for the web-server.
- *
- * The second parameter points to the server/directory where all the
- * packages and especially Packages.xml is located. If not given, the
- * standard PEAR-Repository is taken (http://pear.php.net/whatever..)
- *
- * After installation, just add the install-dir to your include_path and
- * the packages should work.
- *
- * If you are System Adminisitrator and want the installed packages to be
- * made available for everyone, just copy the files to the systemwide
- * pear-dir after installation on the commandline. Or also add the
- * install-dir to the systemwide include_path (and maybe don't forget to
- * take the writeable off the directory..)
- *
- * TODO:
- * - More Error Detection
- * - Grouping of Packages
- * - Show installed Packages (from /var/lib/php/packages.lst?)
- * - Add possibility to install a package (.tgz) from the local file
- * system without a global Packages.xml (useful if no cgi-php
- * around and you need this package you downloaded installed :) )
- * - Search Function (maybe needed if we have hundreds of packages)
- * - Only download Packages.xml, if it actually changed.
- *
- * This Code is highly experimental.
- */
-
-require_once "PEAR.php";
-
-class PEAR_WebInstaller extends PEAR
-{
- // {{{ properties
-
- /** stack of elements, gives some sort of XML context */
- var $element_stack;
-
- /** name of currently parsed XML element */
- var $current_element;
-
- /** array of attributes of the currently parsed XML element */
- var $current_attributes = array();
-
- /** assoc with information about a package */
- var $pkginfo = array();
-
- /** assoc with information about all packages */
- var $AllPackages;
-
- /** URL to the server containing all packages in tgz-Format and the Package.xml */
- var $remotedir = "http://php.chregu.tv/pear/";
-
- /* Directory where the to be installed files should be put
- per default PEAR_INSTALL_DIR (/usr/local/lib/php) if it's writeable for the webserver,
- else current directory, or user defined directory (provided as first parameter in constructor)
- The Directory hast to be writeable for the php-module (webserver)
- */
- var $installdir;
-
- /** how many seconds we should cache Packages.xml */
- var $cachetime = 3600;
-
- var $printlogger = True;
- // }}}
-
- // {{{ constructor
-
- function PEAR_Webinstaller($installdir = Null,$remotedir = Null)
- {
- $this->PEAR();
- if ($installdir)
- {
- $this->installdir = $installdir;
- }
- else
- {
- if (is_writeable(PEAR_INSTALL_DIR))
- {
- $this->installdir = PEAR_INSTALL_DIR;
- }
- else
- {
- $this->installdir = getcwd();
- }
- }
-
- if ($remotedir)
- {
- $this->remotedir = $remotedir;
- }
- }
-
- // }}}
- // {{{ start()
-
- function start() {
- global $HTTP_POST_VARS,$HTTP_GET_VARS;
-
- //print header
- $this->header();
-
- $this->loggerStart();
-
- //if some checkboxes for installation were selected, install.
- if ($HTTP_GET_VARS["help"]) {
-
- $this->help($HTTP_GET_VARS["help"]);
- }
-
- elseif ($HTTP_POST_VARS["InstPack"]) {
- $this->installPackages(array_keys($HTTP_POST_VARS["InstPack"]));
- }
-
- //else print all modules
- else {
- $this->printTable();
- }
- $this->footer();
- }
- // }}}
- // {{{ installPackages()
-
- /* installs the Packages and prints if successfull or not */
-
- function installPackages($packages)
- {
- require_once "PEAR/Installer.php";
- $installer =& new PEAR_Installer();
- $installer->phpdir = $this->installdir;
- $this->loggerEnd();
- print "<TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>";
- print "<TR><TD BGCOLOR=\"#000000\">\n";
- print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=100%>\n";
- print " <TR BGCOLOR=\"#e0e0e0\">\n";
- print " <TH>Package</TH>\n";
- print " <TH>Status</TH>\n";
-
- foreach ($packages as $package)
- {
-
-
- if (++$i % 2) {
- $bg1 = "#ffffff";
- $bg2 = "#f0f0f0";
- }
- else {
- $bg1 = "#f0f0f0";
- $bg2 = "#e0e0e0";
- }
- print " <TR>\n";
-
- print "<TD BGCOLOR=\"$bg1\">";
- print $package;
- print "</TD>\n";
-
-
- /*
- print "<TD BGCOLOR=\"$bg2\">";
- print "Installing ...";
- print "</td>";
- print " <TR>\n";
- print "<TD BGCOLOR=\"$bg1\">";
- print "&nbsp;";
- print "</TD>\n";
- */
- print "<TD BGCOLOR=\"$bg2\">";
- if (PEAR::isError($installer->Install($this->remotedir."/".$package.".tgz"))) {
- print "\ninstall failed\n";
- }
- else {
-
- print "install ok\n";
- }
- print "</td></tr>\n";
- }
- print "</td></tr>";
- print "</table>";
- print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n";
- print " <TR BGCOLOR=\"$bg1\">\n";
- print "<th colspan=\"2\">";
- print "<a href=\"$GLOBALS[PHP_SELF]\">Back to the Packages</a>\n";
- print "</th></tr></table>";
- print"</td></tr></table>";
- }
-
- // }}}
- // {{{ printTable()
- /* Prints a table with all modules available on the server-directory */
-
- function printTable()
- {
- global $PHP_SELF;
- $Packages = $this->getPackages();
- if (PEAR::IsError($Packages))
- {
- if ($this->printlogger) {
- $this->logger($Packages->message);
- }
- else
- {
- print $Packages->message;
- }
- return $Packages;
- }
- $this->loggerEnd();
- print "<FORM action=\"$GLOBALS[PHP_SELF]\" method=\"post\">\n";
- print "<TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>";
- print "<TR><TD BGCOLOR=\"#000000\">\n";
- print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n";
- print "<tr bgcolor=\"f0f0f0\">";
- print "<td COLSPAN=\"6\" ><input type=\"submit\" value=\"Install\"></td>";
- print "</tr>";
-
- print " <TR BGCOLOR=\"#e0e0e0\" >\n";
- print " <TH>Inst.</TH>\n";
- print " <TH>Package</TH>\n";
- print " <TH>Summary</TH>\n";
- print " <TH>Version</TH>\n";
- print " <TH>Release date</TH>\n";
- print " <TH>Release notes</TH>\n";
- print " </TR>\n";
- $i = 0;
-
- ksort($Packages);
- foreach ( $Packages as $package) {
-
- if (++$i % 2) {
- $bg1 = "#ffffff";
- $bg2 = "#f0f0f0";
- }
- else {
- $bg1 = "#f0f0f0";
- $bg2 = "#e0e0e0";
- }
-
-
- print "<TR>\n";
-
- print "<TD align=\"middle\" BGCOLOR=\"$bg2\">";
- print "<input type=\"checkbox\" name=\"InstPack[".$package["name"]."-".$package["version"]."]\">\n";
- print "</TD>\n";
-
- print " <TD BGCOLOR=\"$bg1\">";
- print $this->printCell ($package["name"],"http://pear.php.net/pkginfo.php?package=$package[name]");
- print "</TD>\n";
-
- print "<TD BGCOLOR=\"$bg2\">";
- $this->printCell ($package["summary"]);
- print "</TD>\n";
-
- print "<TD BGCOLOR=\"$bg2\">";
- $this->printCell ($package["version"],$this->remotedir."/".$package["name"]."-".$package["version"].".tgz");
- print "</TD>\n";
-
- print "<TD BGCOLOR=\"$bg2\">";
- $this->printCell ($package["release_date"]);
- print "</TD>\n";
-
- print "<TD BGCOLOR=\"$bg2\">";
- $this->printCell (nl2br($package["release_notes"]));
- print "</TD>\n";
- print " </TR>\n";
-
- }
- print "<tr bgcolor=\"$bg1\">";
- print "<td COLSPAN=\"6\" ><input type=\"submit\" value=\"Install\"></td>";
- print "</tr>";
- print "</TABLE> \n";
-
-
- print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n";
- print " <TR BGCOLOR=\"#e0e0e0\">\n";
-
- print "<th align=left width=\"10%\" nowrap>\n";
- print "Install Directory: </th><td>$this->installdir";
- if (!is_writable($this->installdir))
- {
- print " <font color=\"red\">(Directory is NOT writeable!)</font>";
- }
-
- print "</td></tr>\n";
-
- print " <TR BGCOLOR=\"#f0f0f0\">\n";
- print "<th align=left width=\"10%\" nowrap>\n";
- print "PEAR Repository: </th><td>$this->remotedir</td></tr>\n";
-
- print " <TR BGCOLOR=\"#e0e0e0\">\n";
- print "<th align=left width=\"10%\" nowrap>\n";
- print "Caching Time: </th><td>$this->cachetime seconds</td></tr>\n";
-
- print "</table>\n";
- print "</tr></td></table></FORM>\n";
- print "<a href=\"$PHP_SELF?help=1\">Help</A>\n";
- }
-
- // }}}
- // {{{ getPackages()
-
- /** gets the Packages.xml from the server and saves it on the local disc for caching (if possible)
- * If the zlib-extension is compiled in, Packages.xml.gz is used instead.
- */
-
- function getPackages ($TryGz = True)
- {
-
- // if we can write to the installdir, cache the Packages.xml there
-
- $PackageFile = "Packages.xml";
-
- // check if we have the zlib-extension compiled in
- if ($TryGz && function_exists("gzfile")) { $useGz = True; $PackageFile .= ".gz";}
-
- // check if we can write the Package.xml file for caching
-
- if ( (file_exists($this->installdir."/$PackageFile") && is_writeable($this->installdir."/$PackageFile")) || !file_exists($this->installdir."/$PackageFile") && is_writeable($this->installdir) )
- {
- $time = filemtime($this->installdir."/$PackageFile");
-
- if ($time < (time () - $this->cachetime )) {
- $this->logger("$PackageFile too old. Get new one.");
- $fp = @fopen($this->remotedir."/$PackageFile","r");
- if (!$fp) {
- if ($useGz)
- {
- $this->logger("$PackageFile could not be read. Try uncompressed one");
- return $this->getPackages(False);
- }
- else {
- $this->logger("$PackageFile could not be read.");
- return $this->raiseError("$PackageFile could not be read.");
- }
- }
- $fout = fopen($this->installdir."/$PackageFile","w");
- while ($data = fread($fp,8192)) {
- fwrite ($fout, $data);
- }
- fclose($fout);
- fclose($fp);
- $this->logger("Got $PackageFile");
- }
- else {
- $this->logger("Cached $PackageFile seems new enough");
- }
- $Packages = $this->infoFromDescriptionFile($this->installdir."/$PackageFile");
- }
- else
- {
- $this->logger("$PackageFile can not be cached, because Install-Dir or $PackageFile is not writeable. Get it each time from the server");
- $Packages = $this->infoFromDescriptionFile($this->remotedir."/Packages.xml");
- }
- $this->logger("Got Packages");
- return $Packages;
- }
-
- // }}}
- // {{{ printCell()
-
- function printCell($text,$link = Null)
- {
- if ($text)
- {
- if ($link) {
- print "<a href=\"$link\" style=\"color: #000000;\">";
- }
-
- print "$text";
-
- if ($link) {
- print "</a>";
- }
-
- }
- else
- {
- print "&nbsp;";
- }
- }
-
- // }}}
- /* The following 4 functions are taken from PEAR/Common.php written by Stig Bakken
- I had to adjust to use the Packages.xml format.
- */
- // {{{ _element_start()
-
-
- function _element_start($xp, $name, $attribs)
- {
- array_push($this->element_stack, $name);
- $this->current_element = $name;
- $this->current_attributes = $attribs;
- }
-
- // }}}
- // {{{ _element_end()
-
- function _element_end($xp, $name)
- {
- array_pop($this->element_stack);
- if ($name == "PACKAGE")
- {
- $this->AllPackages[$this->pkginfo["name"]] = $this->pkginfo;
- $this->pkginfo = array();
-
- }
-
- $this->current_element = $this->element_stack[sizeof($this->element_stack)-1];
- }
-
- // }}}
- // {{{ _pkginfo_cdata()
-
- function _pkginfo_cdata($xp, $data)
- {
- $next = $this->element_stack[sizeof($this->element_stack)-1];
- switch ($this->current_element) {
- case "NAME":
- $this->pkginfo["name"] .= $data;
- break;
- case "SUMMARY":
- $this->pkginfo["summary"] .= $data;
- break;
- case "USER":
- $this->pkginfo["maintainer_handle"] .= $data;
- break;
- case "EMAIL":
- $this->pkginfo["maintainer_email"] .= $data;
- break;
- case "VERSION":
- $this->pkginfo["version"] .= $data;
- break;
- case "DATE":
- $this->pkginfo["release_date"] .= $data;
- break;
- case "NOTES":
- $this->pkginfo["release_notes"] .= $data;
- break;
- case "DIR":
- if (!$this->installdir) {
- break;
- }
- $dir = trim($data);
- // XXX add to file list
- break;
- case "FILE":
- $role = strtolower($this->current_attributes["ROLE"]);
- $file = trim($data);
- // XXX add to file list
- break;
- }
- }
-
- // }}}
- // {{{ infoFromDescriptionFile()
-
- function infoFromDescriptionFile($descfile)
- {
- $fp = @fopen($descfile,"r");
- if (!$fp) {
- return $this->raiseError("Unable to open $descfile in ".__FILE__.":".__LINE__);
- }
- $xp = @xml_parser_create();
-
- if (!$xp) {
- return $this->raiseError("Unable to create XML parser.");
- }
-
- xml_set_object($xp, $this);
-
- xml_set_element_handler($xp, "_element_start", "_element_end");
- xml_set_character_data_handler($xp, "_pkginfo_cdata");
- xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true);
-
- $this->element_stack = array();
- $this->pkginfo = array();
- $this->current_element = false;
- $this->destdir = '';
-
- // read the whole thing so we only get one cdata callback
- // for each block of cdata
-
- if (preg_match("/\.gz$/",$descfile))
- {
- $data = implode("",gzfile($descfile));
- }
- else
- {
- $data = implode("",file($descfile));
- }
-
- if (!@xml_parse($xp, $data, 1)) {
- $msg = sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xp)),
- xml_get_current_line_number($xp));
- xml_parser_free($xp);
- return $this->raiseError($msg);
- }
-
- xml_parser_free($xp);
-
- foreach ($this->pkginfo as $k => $v) {
- $this->pkginfo[$k] = trim($v);
- }
-
- return $this->AllPackages;
- }
-
- // }}}
- // {{{ header()
-
- function header ()
- {
- print "<html>
- <head>
- <title>PEAR::WebInstaller</title>\n";
- if (file_exists("./style.css"))
- {
- print '<link rel="stylesheet" href="/style.css">';
- }
- print "</head>
- <body bgcolor=\"#FFFFFF\">
- <h3>PEAR::WebInstaller</h3>";
-
- }
-
- // }}}
- // {{{ footer()
-
- function footer () {
- print "</body></html>";
- }
-
- // }}}
-
- function logger ($text) {
-
- if ($this->printlogger) {
- if (++$this->logcol % 2) {
- $bg1 = "#ffffff";
- $bg2 = "#f0f0f0";
- }
- else {
- $bg1 = "#f0f0f0";
- $bg2 = "#e0e0e0";
- }
- print "<TR>\n";
- print "<TD BGCOLOR=\"$bg1\">".date("h:m:i",time())."</td>";
- print "<TD BGCOLOR=\"$bg2\">";
- print "$text\n";
- print "</TD>\n";
- print "</tr>";
- }
- }
- function loggerStart () {
- if ($this->printlogger) {
- print "<TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>";
- print "<TR><TD BGCOLOR=\"#000000\">\n";
- print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n";
- }
- }
-
- function loggerEnd () {
- if ($this->printlogger) {
- print "</table></td></tr></table>";
- }
- }
- function help ($Full = False) {
- global $PHP_SELF;
- $this->loggerEnd();
- print "From the WebInstaller.php introduction: <p>";
-
- $file = file(__FILE__);
- foreach($file as $line)
- {
- if ($Full != 2 && strstr($line,"require_once")){
- break;
- }
- $help .= $line;
- }
-
- highlight_string($help);
- print "<p>";
- if ($Full != 2) {
- print "<a href=\"$PHP_SELF?help=2\">See the full source</a><p>\n";
- }
-
- print "<a href=\"$PHP_SELF\">Back to the packages overview</A>\n";
- }
-
-}
-
-?>