diff options
Diffstat (limited to 'pear/PEAR')
| -rw-r--r-- | pear/PEAR/Autoloader.php | 167 | ||||
| -rw-r--r-- | pear/PEAR/Common.php | 430 | ||||
| -rw-r--r-- | pear/PEAR/Config.php | 222 | ||||
| -rw-r--r-- | pear/PEAR/Dependency.php | 247 | ||||
| -rw-r--r-- | pear/PEAR/Installer.php | 363 | ||||
| -rw-r--r-- | pear/PEAR/Packager.php | 162 | ||||
| -rw-r--r-- | pear/PEAR/Registry.php | 187 | ||||
| -rw-r--r-- | pear/PEAR/Remote.php | 124 | ||||
| -rw-r--r-- | pear/PEAR/Uploader.php | 61 | ||||
| -rw-r--r-- | pear/PEAR/WebInstaller.php | 631 |
10 files changed, 0 insertions, 2594 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/Common.php b/pear/PEAR/Common.php deleted file mode 100644 index b6414e72b7..0000000000 --- a/pear/PEAR/Common.php +++ /dev/null @@ -1,430 +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() - { - $tmpdir = System::mktemp('-d pear'); - if (PEAR::isError($tmpdir)) { - return $tmpdir; - } - $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 9e002f6bc1..0000000000 --- a/pear/PEAR/Config.php +++ /dev/null @@ -1,222 +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> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; - -/** - * This is a class for storing simple configuration values keeping - * track of which are system-defined (defaulted) and which are - * user-defined. 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 - - var $defaults_file = ''; - - var $config_file = ''; - - var $configuration = array(); - - var $defaulted = array(); - - // }}} - - // {{{ PEAR_Config([file], [defaults_file]) - - function PEAR_Config($file = '', $defaults_file = '') - { - $this->PEAR(); - $this->config_file = $file; - $this->defaults_file = $defaults_file; - if ($file && file_exists($file)) { - $this->readConfigFile($file); - } - if ($defaults_file && file_exists($defaults_file)) { - $this->mergeConfigFile($defaults_file, false, true); - } - } - - // }}} - - // {{{ readConfigFile([file], [defaults]) - - function readConfigFile($file = null, $defaults = false) - { - if ($file === null) { - $file = $this->config_file; - } - $fp = @fopen($file, "r"); - if (!$fp) { - return $this->raiseError($php_errormsg); - } - $size = filesize($file); - $contents = fread($fp, $size); - $data = unserialize($contents); - if ($data === false && $size > 1) { - return $this->raiseError("PEAR_Config::readConfigFile: bad data"); - } - $this->configuration = $data; - if ($defaults) { - foreach ($data as $key => $value) { - $this->defaulted[$key] = true; - } - } - } - - // }}} - // {{{ mergeConfigFile(file, [override], [defaults]) - - function mergeConfigFile($file, $override = true, $defaults = false) - { - $fp = @fopen($file, "r"); - if (!$fp) { - return $this->raiseError($php_errormsg); - } - $contents = fread($fp, filesize($file)); - $data = unserialize($contents); - if ($data === false) { - return $this->raiseError("PEAR_Config::mergeConfigFile: bad data"); - } - foreach ($data as $key => $value) { - if (isset($this->configuration[$key]) && !$override) { - continue; - } - if ($defaults) { - $this->defaulted[$key] = true; - } - $this->configuration[$key] = $value; - } - } - - // }}} - // {{{ writeConfigFile([file], [what_keys]) - - function writeConfigFile($file = null, $what_keys = 'userdefined') - { - if ($what_keys == 'both') { - $this->writeConfigFile($file, 'userdefined'); - $this->writeConfigFile($file, 'default'); - return; - } - if ($file === null) { - if ($what_keys == 'default') { - $file = $this->defaults_file; - } else { - $file = $this->config_file; - } - } - if ($what_keys == 'default') { - $keys_to_store = array_intersect(array_keys($this->configuration), - array_keys($this->defaulted)); - } elseif ($what_keys == 'all') { - $keys_to_store = array_keys($this->configuration); - } else { // user-defined keys - $keys_to_store = array_diff(array_keys($this->configuration), - array_keys($this->defaulted)); - } - $data = array(); - foreach ($keys_to_store as $key) { - $data[$key] = $this->configuration[$key]; - } - $fp = @fopen($file, "w"); - if (!$fp) { - return $this->raiseError("PEAR_Config::writeConfigFile fopen('$file','w') failed"); - } - if (!@fwrite($fp, serialize($data))) { - return $this->raiseError("PEAR_Config::writeConfigFile serialize failed"); - } - return true; - } - - // }}} - // {{{ get(key) - - function get($key) - { - return @$this->configuration[$key]; - } - - // }}} - // {{{ set(key, value, [default]) - - function set($key, $value, $default = false) - { - $this->configuration[$key] = $value; - if ($default) { - $this->defaulted[$key] = true; - } elseif (isset($this->defaulted[$key])) { - unset($this->defaulted[$key]); - } - } - - // }}} - // {{{ getKeys() - - function getKeys() - { - return array_keys($this->configuration); - } - - // }}} - // {{{ toDefault(key) - - function toDefault($key) - { - if (file_exists($this->defaults_file)) { - // re-reads the defaults file each time, but hey it works - unset($this->configuration[$key]); - $this->mergeConfigFile($this->defaults_file, false, true); - } - } - - // }}} - // {{{ isDefaulted(key) - - function isDefaulted($key) - { - return isset($this->defaulted[$key]); - } - - // }}} - // {{{ isDefined(key) - - function isDefined($key) - { - return isset($this->configuration[$key]); - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Dependency.php b/pear/PEAR/Dependency.php deleted file mode 100644 index 4949f1d7f1..0000000000 --- a/pear/PEAR/Dependency.php +++ /dev/null @@ -1,247 +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 007ba39def..0000000000 --- a/pear/PEAR/Installer.php +++ /dev/null @@ -1,363 +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; - } - 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)"); - } - 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); - $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml'; - - 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); - } - $tmp_path = dirname($descfile); - 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 f892b79676..0000000000 --- a/pear/PEAR/Packager.php +++ /dev/null @@ -1,162 +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 information found in $pkgfile", - null, PEAR_ERROR_TRIGGER, E_USER_ERROR); - } - // TMP DIR ------------------------------------------------- - // We allow calls like "pear package /home/user/mypack/package.xml" - if (!@chdir(dirname($pkgfile))) { - return $this->raiseError('Couldn\'t chdir to package.xml dir', - null, PEAR_ERROR_TRIGGER, E_USER_ERROR); - } - $pwd = getcwd(); - $pkgfile = basename($pkgfile); - if (isset($pkginfo['release_state']) && $pkginfo['release_state'] == 'snapshot') { - $pkginfo['version'] = date('Ymd'); - } - // don't want strange characters - $pkgname = ereg_replace ('[^a-zA-Z0-9._]', '_', $pkginfo['package']); - $pkgversion = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $pkginfo['version']); - $pkgver = $pkgname . '-' . $pkgversion; - - // ----- Create the package file list - $filelist = array(); - $i = 0; - - // ----- Add the package XML file - $filelist[$i++] = $pkgfile; - - // Copy files ----------------------------------------------- - foreach ($pkginfo['filelist'] as $fname => $atts) { - if (!file_exists($fname)) { - return $this->raiseError("File $fname does not exists"); - } 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); - if (!$tar->createModify($filelist, $pkgver)) { - return $this->raiseError('an error ocurred during package creation'); - } - $this->log(1, "Package $dest_package done"); - 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 51b128d178..0000000000 --- a/pear/PEAR/Registry.php +++ /dev/null @@ -1,187 +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> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "System.php"; - -/** - * Administration class used to maintain the installed package database. - */ -class PEAR_Registry -{ - // {{{ properties - - var $statedir; - - // }}} - - // {{{ PEAR_Registry - - function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR) - { - $this->statedir = $pear_install_dir . "/.registry"; - } - - // }}} - - // {{{ _assertStateDir() - - function _assertStateDir() - { - if (!@is_dir($this->statedir)) { - System::mkdir("-p {$this->statedir}"); - } - } - - // }}} - // {{{ _packageFileName() - - 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); - } - - // }}} - - // {{{ packageExists() - - function packageExists($package) - { - return file_exists($this->_packageFileName($package)); - } - - // }}} - // {{{ addPackage() - - function addPackage($package, $info) - { - if ($this->packageExists($package)) { - return false; - } - $fp = $this->_openPackageFile($package, "w"); - if ($fp === null) { - return false; - } - fwrite($fp, serialize($info)); - $this->_closePackageFile($fp); - return true; - } - - // }}} - // {{{ 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; - } - - // }}} - // {{{ deletePackage() - - function deletePackage($package) - { - $file = $this->_packageFileName($package); - return @unlink($file); - } - - // }}} - // {{{ updatePackage() - - function updatePackage($package, $info, $merge = true) - { - $oldinfo = $this->packageInfo($package); - if (empty($oldinfo)) { - return false; - } - $fp = $this->_openPackageFile($package, "w"); - if ($fp === null) { - return false; - } - if ($merge) { - fwrite($fp, serialize(array_merge($oldinfo, $info))); - } else { - fwrite($fp, serialize($info)); - } - $this->_closePackageFile($fp); - return true; - } - - // }}} - // {{{ 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; - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php deleted file mode 100644 index f2a44f9648..0000000000 --- a/pear/PEAR/Remote.php +++ /dev/null @@ -1,124 +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> | -// | | -// +----------------------------------------------------------------------+ -// -// $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) - { - $args = func_get_args(); - array_shift($args); - $this->__call($method, $args, $retval); - return $retval; - } - - // }}} - - // {{{ __call(method, args) - - function __call($method, $params, &$retval) - { - if (!extension_loaded("xmlrpc")) { - $retval = $this->raiseError("xmlrpc support not loaded"); - return false; - } - $method = str_replace("_", ".", $method); - $request = xmlrpc_encode_request($method, $params); - $server_host = $this->config_object->get("master_server"); - if (empty($server_host)) { - $retval = $this->raiseError("PEAR_Remote::call: no master_server configured"); - return false; - } - $server_port = 80; - $fp = @fsockopen($server_host, $server_port); - if (!$fp) { - $retval = $this->raiseError("PEAR_Remote::call: fsockopen(`$server_host', $server_port) failed"); - return false; - } - $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') { - $retval = $this->raiseError(DB::errorMessage($ret['code']), - $ret['code'], null, null, - $ret['userinfo']); - } else { - $retval = $this->raiseError($ret['message'], $ret['code'], - null, null, $ret['userinfo']); - } - return true; - } - } - $retval = $ret; - return true; - } - - // }}} -} - -if (function_exists("overload")) { - overload("PEAR_Remote"); -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Uploader.php b/pear/PEAR/Uploader.php deleted file mode 100644 index 210de68a02..0000000000 --- a/pear/PEAR/Uploader.php +++ /dev/null @@ -1,61 +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> | -// | | -// +----------------------------------------------------------------------+ -// - -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 " "; - 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 " "; - } - } - - // }}} - /* 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"; - } - -} - -?> |
