diff options
author | SVN Migration <svn@php.net> | 2001-08-12 04:31:15 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2001-08-12 04:31:15 +0000 |
commit | 64da1e7f4e0c11b32a07812abf15b264666a7160 (patch) | |
tree | 94164a4d7fdbe2c473d432fdde13da21f614a14d /pear | |
parent | ff39e51fdf5b17a20b4ac447e66c3048f03c29d3 (diff) | |
download | php-git-BEFORE_EXP_MERGE.tar.gz |
This commit was manufactured by cvs2svn to create tag 'BEFORE_EXP_MERGE'.BEFORE_EXP_MERGE
Diffstat (limited to 'pear')
38 files changed, 0 insertions, 6027 deletions
diff --git a/pear/CMD.php b/pear/CMD.php deleted file mode 100755 index cc4f4bc7e8..0000000000 --- a/pear/CMD.php +++ /dev/null @@ -1,286 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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: Anders Johannsen <anders@johannsen.com> | -// | | -// +----------------------------------------------------------------------+ -// -define('CMD_RCSID', '$Id$'); - -/** - * The Cmd:: class implements an abstraction for various ways - * of executing commands (directly using the backtick operator, - * as a background task after the script has terminated using - * register_shutdown_function() or as a detached process using nohup). - * - * @author Anders Johannsen <anders@johannsen.com> - * @version $Revision$ - **/ - -require_once 'PEAR.php'; - - -class Cmd extends PEAR -{ - var $arrSetting = array(); - var $arrConstant = array(); - var $arrCommand = array(); - - /** - * Class constructor - * - * Defines all necessary constants and sets defaults - * - * @author Anders Johannsen <anders@johannsen.com> - * - * @access public - * - **/ - - function Cmd () - { - // Defining constants - $this->arrConstant = array ("CMD_SEQUENCE", - "CMD_SHUTDOWN", - "CMD_SHELL", - "CMD_OUTPUT", - "CMD_NOHUP", - "CMD_VERBOSE" - ); - - foreach ($this->arrConstant as $key => $value) { - if (!defined($value)) { - define($value, $key); - } - } - - // Setting default values - $this->arrSetting[CMD_SEQUENCE] = true; - $this->arrSetting[CMD_SHUTDOWN] = false; - $this->arrSetting[CMD_OUTPUT] = false; - $this->arrSetting[CMD_NOHUP] = false; - $this->arrSetting[CMD_VERBOSE] = false; - - $arrShell = array ("sh", "bash", "zsh", "tcsh", "csh", "ash", "sash", "esh", "ksh"); - - foreach ($arrShell as $shell) { - if ($this->arrSetting[CMD_SHELL] = $this->which($shell)) { - break; - } - } - - if (empty($this->arrSetting[CMD_SHELL])) { - $this->raiseError("No shell found"); - } - } - - /** - * Sets any option - * - * The options are currently: - * CMD_SHUTDOWN : Execute commands via a shutdown function - * CMD_SHELL : Path to shell - * CMD_OUTPUT : Output stdout from process - * CMD_NOHUP : Use nohup to detach process - * CMD_VERBOSE : Print errors to stdout - * - * @param $option is a constant, which corresponds to the - * option that should be changed - * - * @param $setting is the value of the option currently - * being toggled. - * - * @return bool true if succes, else false - * - * @access public - * - * @author Anders Johannsen <anders@johannsen.com> - * - **/ - - function setOption ($option, $setting) - { - if (empty($this->arrConstant[$option])) { - $this->raiseError("No such option: $option"); - return false; - } - - - switch ($option) { - case CMD_OUTPUT: - case CMD_SHUTDOWN: - case CMD_VERBOSE: - case CMD_SEQUENCE: - $this->arrSetting[$option] = $setting; - return true; - break; - - case CMD_SHELL: - if (is_executable($setting)) { - $this->arrSetting[$option] = $setting; - return true; - } else { - $this->raiseError("No such shell: $setting"); - return false; - } - break; - - - case CMD_NOHUP: - if (empty($setting)) { - $this->arrSetting[$option] = false; - - } else if ($location = $this->which("nohup")) { - $this->arrSetting[$option] = true; - - } else { - $this->raiseError("Nohup was not found on your system"); - return false; - } - break; - - } - } - - /** - * Add command for execution - * - * @param $command accepts both arrays and regular strings - * - * @return bool true if succes, else false - * - * @access public - * - * @author Anders Johannsen <anders@johannsen.com> - * - **/ - - function command($command) - { - if (is_array($command)) { - foreach ($command as $key => $value) { - $this->arrCommand[] = $value; - } - return true; - - } else if (is_string($command)) { - $this->arrCommand[] = $command; - return true; - } - - $this->raiseError("Argument not valid"); - return false; - } - - /** - * Executes the code according to given options - * - * @return bool true if succes, else false - * - * @access public - * - * @author Anders Johannsen <anders@johannsen.com> - * - **/ - - function exec() - { - // Warning about impossible mix of options - if (!empty($this->arrSetting[CMD_OUTPUT])) { - if (!empty($this->arrSetting[CMD_SHUTDOWN]) || !empty($this->arrSetting[CMD_NOHUP])) { - $this->raiseError("Error: Commands executed via shutdown functions or nohup cannot return output"); - return false; - } - } - - // Building command - $strCommand = implode(";", $this->arrCommand); - - $strExec = "echo '$strCommand' | ".$this->arrSetting[CMD_SHELL]; - - if (empty($this->arrSetting[CMD_OUTPUT])) { - $strExec = $strExec . ' > /dev/null'; - } - - if (!empty($this->arrSetting[CMD_NOHUP])) { - $strExec = 'nohup ' . $strExec; - } - - // Executing - if (!empty($this->arrSetting[CMD_SHUTDOWN])) { - $line = "system(\"$strExec\");"; - $function = create_function('', $line); - register_shutdown_function($function); - return true; - } else { - return `$strExec`; - } - } - - /** - * Errorhandler. If option CMD_VERBOSE is true, - * the error is printed to stdout, otherwise it - * is avaliable in lastError - * - * @return bool always returns true - * - * @access private - * - * @author Anders Johannsen <anders@johannsen.com> - **/ - - function raiseError($strError) - { - if (!empty($this->arrSetting[CMD_VERBOSE])) { - echo $strError; - } else { - $this->lastError = $strError; - } - - return true; - } - - /** - * Functionality similiar to unix 'which'. Searches the path - * for the specified program. - * - * @param $cmd name of the executable to search for - * - * @return string returns the full path if found, - * false if not - * - * @access private - * - * @author Anders Johannsen <anders@johannsen.com> - **/ - - function which($cmd) - { - global $HTTP_ENV_VARS; - - $arrPath = explode(":", $HTTP_ENV_VARS['PATH']); - - foreach ($arrPath as $path) { - $location = $path . "/" . $cmd; - - if (is_executable($location)) { - return $location; - } - } - return false; - } -} - -?> diff --git a/pear/CODING_STANDARDS b/pear/CODING_STANDARDS deleted file mode 100644 index b9dd40f100..0000000000 --- a/pear/CODING_STANDARDS +++ /dev/null @@ -1,254 +0,0 @@ -=========================================================================== -|| PEAR Coding Standards || -=========================================================================== - -$Id$ - -------------- -[1] Indenting -============= - -Use an indent of 4 spaces, with no tabs. If you use Emacs to edit PEAR -code, you should set indent-tabs-mode to nil. Here is an example mode -hook that will set up Emacs according to these guidelines (you will -need to ensure that it is called when you are editing php files): - -(defun php-mode-hook () - (setq tab-width 4 - c-basic-offset 4 - c-hanging-comment-ender-p nil - indent-tabs-mode - (not - (and (string-match "/\\(PEAR\\|pear\\)/" (buffer-file-name)) - (string-match "\.php$" (buffer-file-name)))))) - -Here are vim rules for the same thing: - - set expandtab - set shiftwidth=4 - set tabstop=4 - - ----------------------- -[2] Control Structures -====================== - -These include if, for, while, switch, etc. Here is an example if statement, -since it is the most complicated of them: - - if ((condition1) || (condition2)) { - action1; - } elseif ((condition3) && (condition4)) { - action2; - } else { - defaultaction; - } - -Control statements should have one space between the control keyword -and opening parenthesis, to distinguish them from function calls. - -You are strongly encouraged to always use curly braces even in -situations where they are technically optional. Having them increases -readability and decreases the likelihood of logic errors being -introduced when new lines are added. - -For switch statements: - - switch (condition) { - case 1: - action1; - break; - - case 2: - action2; - break; - - default: - defaultaction; - break; - - } - - ------------------- -[3] Function Calls -================== - -Functions should be called with no spaces between the function name, -the opening parenthesis, and the first parameter; spaces between commas -and each parameter, and no space between the last parameter, the -closing parenthesis, and the semicolon. Here's an example: - - $var = foo($bar, $baz, $quux); - -As displayed above, there should be one space on either side of an -equals sign used to assign the return value of a function to a -variable. In the case of a block of related assignments, more space -may be inserted to promote readability: - - $short = foo($bar); - $long_variable = foo($baz); - - ------------------------- -[4] Function Definitions -======================== - -Function declaractions follow the "one true brace" convention: - -function fooFunction($arg1, $arg2 = '') -{ - if (condition) { - statement; - } - return $val; -} - -Arguments with default values go at the end of the argument list. -Always attempt to return a meaningful value from a function if one is -appropriate. Here is a slightly longer example: - -function connect(&$dsn, $persistent = false) -{ - if (is_array($dsn)) { - $dsninfo = &$dsn; - } else { - $dsninfo = DB::parseDSN($dsn); - } - - if (!$dsninfo || !$dsninfo['phptype']) { - return $this->raiseError(); - } - - return true; -} - -Functions should be named using the "studly caps" style (also referred to as -"bumpy case" or "camel caps"). The initial letter of the name is lowercase, -and each letter that starts a new "word" is capitalized. Some examples: - - connect() getData() buildSomeWidget() - -Private class members (meaning class members that an intented to be used -only from within the same class in which they are declared; PHP does not yet -support truly-enforceable private namespaces) are preceeded by a single -underscore. For example: - - _sort() _initTree() $_status - - ------------- -[5] Comments -============ - -Inline documentation for classes should follow the PHPDoc convention, similar -to Javadoc. More information about PHPDoc can be found here: - - http://www.phpdoc.de/ - -Non-documentation comments are strongly encouraged. A general rule of -thumb is that if you look at a section of code and think "Wow, I don't -want to try and describe that", you need to comment it before you -forget how it works. - -C++ style comments (/* */) and standard C comments (// ) are both -fine. Use of perl/shell style comments (# ) is discouraged. - - ------------------- -[6] Including Code -================== - -Anywhere you are unconditionally including a class file, use -require_once. Anywhere you are conditionally including a class file -(for example, factory methods), use include_once. Either of these will -ensure that class files are included only once. They share the same -file list, so you don't need to worry about mixing them - a file -included with require_once will not be included again by include_once. - -Note: include_once and require_once are statements, not functions. You -don't need parentheses around the filename to be included. - - ------------------ -[7] PHP Code Tags -================= - -ALWAYS use <?php ?> to delimit PHP code, not the <? ?> shorthand. -This is required for PEAR compliance and is also the most portable way -to include PHP code on differing operating systems and setups. - - -------------------------- -[8] Header Comment Blocks -========================= - -All source code files in the core PEAR distribution should contain the -following comment block as the header: - -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997, 1998, 1999, 2000, 2001 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 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: Original Author <author@example.com> | -// | Your Name <you@example.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -There's no hard rule to determine when a new code contributer should be -added to the list of authors for a given source file. In general, their -changes should fall into the "substantial" category (meaning somewhere -around 10% to 20% of code changes). Exceptions could be made for rewriting -functions or contributing new logic. - -Simple code reorganization or bug fixes would not justify the addition of a -new individual to the list of authors. - -Files not in the core PEAR repository should have a similar block -stating the copyright, the license, and the authors. All files should -include the modeline comments to encourage consistency. - - ------------- -[9] CVS Tags -============ - -Include the <dollar>Id CVS vendor tag in each file. As each -file is edited, add this tag if it's not yet present (or replace existing -forms such as "Last Modified:", etc.). - -[NOTE: we have a custom $Horde tag in Horde cvs to track our versions -seperately; we could do the same and make a $PEAR tag, that would remain even -if PEAR files were put into another source control system, etc...] - - ------------------ -[10] Example URLs -================= - -Use "example.com" for all example URLs, per RFC 2606. - - ---------------------- -[11] Naming Constants -===================== - -Constants should always be uppercase, with underscores to seperate -words. Prefix constant names with the name of the class/package they -are used in. For example, the constants used by the DB:: package all -begin with "DB_". - -True and false are built in to the php language and behave like -constants, but should be written in lowercase to distinguish them from -user-defined constants. diff --git a/pear/Cache.php b/pear/Cache.php deleted file mode 100644 index 04a662709a..0000000000 --- a/pear/Cache.php +++ /dev/null @@ -1,355 +0,0 @@ -<?php -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997, 1998, 1999, 2000, 2001 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 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: Ulf Wendel <ulf.wendel@phpdoc.de> | -// | Sebastian Bergmann <sb@sebastian-bergmann.de> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'Cache/Error.php'; - -/** -* Cache is a base class for cache implementations. -* -* The pear cache module is a generic data cache which can be used to -* cache script runs. The idea behind the cache is quite simple. If you have -* the same input parameters for whatever tasks/algorithm you use you'll -* usually get the same output. So why not caching templates, functions calls, -* graphic generation etc. Caching certain actions e.g. XSLT tranformations -* saves you lots of time. -* -* The design of the cache reminds of PHPLibs session implementation. A -* (PHPLib: session) controller uses storage container (PHPLib: ct_*.inc) to save -* certain data (PHPLib: session data). In contrast to the session stuff it's up to -* you to generate an ID for the data to cache. If you're using the output cache -* you might use the script name as a seed for cache::generateID(), if your using the -* function cache you'd use an array with all function parameters. -* -* Usage example of the generic data cache: -* -* require_once('Cache.php'); -* -* $cache = new Cache('file', array('cache_dir' => 'cache/') ); -* $id = $cache->generateID('testentry'); -* -* if ($data = $cache->get($id)) { -* print "Cache hit.<br>Data: $data"; -* -* } else { -* $data = 'data of any kind'; -* $cache->save($id, $data); -* print 'Cache miss.<br>'; -* } -* -* WARNING: No File/DB-Table-Row locking is implemented yet, -* it's possible, that you get corrupted data-entries under -* bad circumstances (especially with the file container) -* -* @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Id$ -* @package Cache -* @access public -*/ -class Cache extends PEAR { - - /** - * Enables / disables caching. - * - * TODO: Add explanation what this is good for. - * - * @var boolean - * @access private - */ - var $caching = true; - - /** - * Garbage collection: probability in seconds - * - * If set to a value above 0 a garbage collection will - * flush all cache entries older than the specified number - * of seconds. - * - * @var integer - * @see $gc_probability, $gc_maxlifetime - * @access public - */ - var $gc_time = 1; - - /** - * Garbage collection: probability in percent - * - * TODO: Add an explanation. - * - * @var integer 0 => never - * @see $gc_time, $gc_maxlifetime - * @access public - */ - var $gc_probability = 1; - - /** - * Garbage collection: delete all entries not use for n seconds. - * - * Default is one day, 60 * 60 * 24 = 86400 seconds. - * - * @var integer - * @see $gc_probability, $gc_time - */ - var $gc_maxlifetime = 86400; - - /** - * Storage container object. - * - * @var object Cache_Container - */ - var $container; - - // - // public methods - // - - /** - * - * @param string Name of container class - * @param array Array with container class options - */ - function Cache($container, $container_options = '') - { - $this->PEAR(); - $container = strtolower($container); - $container_class = 'Cache_Container_' . $container; - $container_classfile = 'Cache/Container/' . $container . '.php'; - - include_once $container_classfile; - $this->container = new $container_class($container_options); - } - - //deconstructor - function _Cache() - { - $this->garbageCollection(); - } - - /** - * Returns the current caching state. - * - * @return boolean The current caching state. - * @access public - */ - function getCaching() - { - return ($this->caching); - } - - /** - * Enables or disables caching. - * - * @param boolean The new caching state. - * @access public - */ - function setCaching($state) - { - $this->caching = $state; - } - - /** - * Returns the requested dataset it if exists and is not expired - * - * @param string dataset ID - * @param string cache group - * @return mixed cached data or NULL on failure - * @access public - */ - function get($id, $group = 'default') { - if (!$this->caching) - return ''; - - if ($this->isCached($id, $group) && !$this->isExpired($id, $group)) - return $this->load($id, $group); - - return NULL; - } // end func get - - /** - * Stores the given data in the cache. - * - * @param string dataset ID used as cache identifier - * @param mixed data to cache - * @param integer lifetime of the cached data in seconds - 0 for endless - * @param string cache group - * @return boolean - * @access public - */ - function save($id, $data, $expires = 0, $group = 'default') { - if (!$this->caching) - return true; - - return $this->extSave($id, $data, '',$expires, $group); - } // end func save - - /** - * Stores a dataset without additional userdefined data. - * - * @param string dataset ID - * @param mixed data to store - * @param string additional userdefined data - * @param mixed userdefined expire date - * @param string cache group - * @return boolean - * @throws Cache_Error - * @access public - * @see getUserdata() - */ - function extSave($id, $cachedata, $userdata, $expires = 0, $group = 'default') { - if (!$this->caching) - return true; - - return $this->container->save($id, $cachedata, $expires, $group, $userdata); - } // end func extSave - - /** - * Loads the given ID from the cache. - * - * @param string dataset ID - * @param string cache group - * @return mixed cached data or NULL on failure - * @access public - */ - function load($id, $group = 'default') { - if (!$this->caching) - return ''; - - return $this->container->load($id, $group); - } // end func load - - /** - * Returns the userdata field of a cached data set. - * - * @param string dataset ID - * @param string cache group - * @return string userdata - * @access public - * @see extSave() - */ - function getUserdata($id, $group = 'default') { - if (!$this->caching) - return ''; - - return $this->container->getUserdata($id, $group); - } // end func getUserdata - - /** - * Removes the specified dataset from the cache. - * - * @param string dataset ID - * @param string cache group - * @return boolean - * @access public - */ - function remove($id, $group = 'default') { - if (!$this->caching) - return true; - - return $this->container->remove($id, $group); - } // end func remove - - /** - * Flushes the cache - removes all data from it - * - * @param string cache group, if empty all groups will be flashed - * @return integer number of removed datasets - */ - function flush($group = '') { - if (!$this->caching) - return true; - - return $this->container->flush($group); - } // end func flush - - /** - * Checks if a dataset exists. - * - * Note: this does not say that the cached data is not expired! - * - * @param string dataset ID - * @param string cache group - * @return boolean - * @access public - */ - function isCached($id, $group = 'default') { - if (!$this->caching) - return false; - - return $this->container->isCached($id, $group); - } // end func isCached - - /** - * Checks if a dataset is expired - * - * @param string dataset ID - * @param string cache group - * @param integer maximum age for the cached data in seconds - 0 for endless - * If the cached data is older but the given lifetime it will - * be removed from the cache. You don't have to provide this - * argument if you call isExpired(). Every dataset knows - * it's expire date and will be removed automatically. Use - * this only if you know what you're doing... - * @return boolean - * @access public - */ - function isExpired($id, $group = 'default', $max_age = 0) { - if (!$this->caching) - return true; - - return $this->container->isExpired($id, $group, $max_age); - } // end func isExpired - - /** - * Generates a "unique" ID for the given value - * - * This is a quick but dirty hack to get a "unique" ID for a any kind of variable. - * ID clashes might occur from time to time although they are extreme unlikely! - * - * @param mixed variable to generate a ID for - * @return string "unique" ID - * @access public - */ - function generateID($variable) { - // WARNING: ID clashes are possible although unlikely - return md5(serialize($variable)); - } - - /** - * Calls the garbage collector of the storage object with a certain probability - * - * @param boolean Force a garbage collection run? - * @see $gc_probability, $gc_time - */ - function garbageCollection($force = false) { - static $last_run = 0; - - if (!$this->caching) - return; - - srand((double) microtime() * 1000000); - - // time and probability based - if (($force) || ($last_run && $last_run < time() + $this->gc_time) || (rand(1, 100) < $this->gc_probability)) { - $this->container->garbageCollection($this->gc_maxlifetime); - $last_run = time(); - } - } // end func garbageCollection - -} // end class cache -?> diff --git a/pear/Cache.xml b/pear/Cache.xml deleted file mode 100644 index 193501f5f9..0000000000 --- a/pear/Cache.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE Package SYSTEM "F:\cvs\php4\pear\package.dtd"> -<Package Type="Source"> - <Name>Cache</Name> - <Summary>The PEAR Cache Package is a generic data/content cache that can be used to cache data, output, function calls and dynamic graphic generation. </Summary> - <Maintainer> - <Initials>chregu</Initials> - <Name>Christian Stocker</Name> - <Email>chregu@phant.ch</Email> - </Maintainer> - <Release> - <Version>1.1</Version> - <Date>2001/03/27</Date> - <Notes>stable Code, SHM Implementation missing</Notes> - </Release> - <FileList> - <File Role="php">Cache.php</File> - <Dir>Cache/</Dir> - </FileList> -</Package> diff --git a/pear/Console/Getopt.php b/pear/Console/Getopt.php deleted file mode 100644 index b116b20777..0000000000 --- a/pear/Console/Getopt.php +++ /dev/null @@ -1,202 +0,0 @@ -<?php - -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997, 1998, 1999, 2000, 2001 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 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: Andrei Zmievski <andrei@ispi.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; - -/** - * Command-line options parsing class. - * - * @author Andrei Zmievski <andrei@ispi.net> - * - */ -class Console_Getopt { - /** - * Parses the command-line options. - * - * The first parameter to this function should be the list of command-line - * arguments without the leading reference to the running program. - * - * The second parameter is a string of allowed short options. Each of the - * option letters can be followed by a colon ':' to specify that the option - * requires an argument, or a double colon '::' to specify that the option - * takes an optional argument. - * - * The third argument is an optional array of allowed long options. The - * leading '--' should not be included in the option name. Options that - * require an argument should be followed by '=', and options that take an - * option argument should be followed by '=='. - * - * The return value is an array of two elements: the list of parsed - * options and the list of non-option command-line arguments. Each entry in - * the list of parsed options is a pair of elements - the first one - * specifies the option, and the second one specifies the option argument, - * if there was one. - * - * Long and short options can be mixed. - * - * Most of the semantics of this function are based on GNU getopt_long(). - * - * @param $args array an array of command-line arguments - * @param $short_options string specifies the list of allowed short options - * @param $long_options array specifies the list of allowed long options - * - * @return array two-element array containing the list of parsed options and - * the non-option arguments - * - * @access public - * - */ - function getopt($args, $short_options, $long_options = null) - { - $opts = array(); - $non_opts = array(); - - settype($args, 'array'); - - if ($long_options) - sort($long_options); - - reset($args); - while (list(, $arg) = each($args)) { - - /* The special element '--' means explicit end of options. Treat the - rest of the arguments as non-options and end the loop. */ - if ($arg == '--') { - $non_opts = array_merge($non_opts, array_slice($args, $i + 1)); - break; - } - - if ($arg{0} != '-' || ($arg{1} == '-' && !$long_options)) { - $non_opts[] = $arg; - } else if ($arg{1} == '-') { - $error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args); - if (PEAR::isError($error)) - return $error; - } else { - $error = Console_Getopt::_parseShortOption(substr($arg, 1), $short_options, $opts, $args); - if (PEAR::isError($error)) - return $error; - } - } - - return array($opts, $non_opts); - } - - /** - * @access private - * - */ - function _parseShortOption($arg, $short_options, &$opts, &$args) - { - for ($i = 0; $i < strlen($arg); $i++) { - $opt = $arg{$i}; - $opt_arg = null; - - /* Try to find the short option in the specifier string. */ - if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':') - { - return new Getopt_Error("unrecognized option -- $opt\n"); - } - - if ($spec{1} == ':') { - if ($spec{2} == ':') { - if ($i + 1 < strlen($arg)) { - /* Option takes an optional argument. Use the remainder of - the arg string if there is anything left. */ - $opts[] = array($opt, substr($arg, $i + 1)); - break; - } - } else { - /* Option requires an argument. Use the remainder of the arg - string if there is anything left. */ - if ($i + 1 < strlen($arg)) { - $opts[] = array($opt, substr($arg, $i + 1)); - break; - } else if (list(, $opt_arg) = each($args)) - /* Else use the next argument. */; - else - return new Getopt_Error("option requires an argument -- $opt\n"); - } - } - - $opts[] = array($opt, $opt_arg); - } - } - - /** - * @access private - * - */ - function _parseLongOption($arg, $long_options, &$opts, &$args) - { - list($opt, $opt_arg) = explode('=', $arg); - $opt_len = strlen($opt); - - for ($i = 0; $i < count($long_options); $i++) { - $long_opt = $long_options[$i]; - $opt_start = substr($long_opt, 0, $opt_len); - - /* Option doesn't match. Go on to the next one. */ - if ($opt_start != $opt) - continue; - - $opt_rest = substr($long_opt, $opt_len); - - /* Check that the options uniquely matches one of the allowed - options. */ - if ($opt_rest != '' && $opt{0} != '=' && - $i + 1 < count($long_options) && - $opt == substr($long_options[$i+1], 0, $opt_len)) { - return new Getopt_Error("option --$opt is ambiguous\n"); - } - - if (substr($long_opt, -1) == '=') { - if (substr($long_opt, -2) != '==') { - /* Long option requires an argument. - Take the next argument if one wasn't specified. */; - if (!$opt_arg && !(list(, $opt_arg) = each($args))) { - return new Getopt_Error("option --$opt requires an argument\n"); - } - } - } else if ($opt_arg) { - return new Getopt_Error("option --$opt doesn't allow an argument\n"); - } - - $opts[] = array('--' . $opt, $opt_arg); - return; - } - - return new Getopt_Error("unrecognized option --$opt\n"); - } -} - - -class Getopt_Error extends PEAR_Error { - var $classname = 'Getopt'; - var $error_message_prepend = 'Error in Getopt'; - - function Getopt_Error($message, $code = 0, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE) - { - $this->PEAR_Error($message, $code, $mode, $level); - } -} - -?> diff --git a/pear/DB.php b/pear/DB.php deleted file mode 100644 index 1710f3997f..0000000000 --- a/pear/DB.php +++ /dev/null @@ -1,725 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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$ -// -// Database independent query interface. -// - -require_once "PEAR.php"; - -/* - * The method mapErrorCode in each DB_dbtype implementation maps - * native error codes to one of these. - * - * If you add an error code here, make sure you also add a textual - * version of it in DB::errorMessage(). - */ - -define("DB_OK", 1); -define("DB_ERROR", -1); -define("DB_ERROR_SYNTAX", -2); -define("DB_ERROR_CONSTRAINT", -3); -define("DB_ERROR_NOT_FOUND", -4); -define("DB_ERROR_ALREADY_EXISTS", -5); -define("DB_ERROR_UNSUPPORTED", -6); -define("DB_ERROR_MISMATCH", -7); -define("DB_ERROR_INVALID", -8); -define("DB_ERROR_NOT_CAPABLE", -9); -define("DB_ERROR_TRUNCATED", -10); -define("DB_ERROR_INVALID_NUMBER", -11); -define("DB_ERROR_INVALID_DATE", -12); -define("DB_ERROR_DIVZERO", -13); -define("DB_ERROR_NODBSELECTED", -14); -define("DB_ERROR_CANNOT_CREATE", -15); -define("DB_ERROR_CANNOT_DELETE", -16); -define("DB_ERROR_CANNOT_DROP", -17); -define("DB_ERROR_NOSUCHTABLE", -18); -define("DB_ERROR_NOSUCHFIELD", -19); -define("DB_ERROR_NEED_MORE_DATA", -20); -define("DB_ERROR_NOT_LOCKED", -21); -define("DB_ERROR_VALUE_COUNT_ON_ROW", -22); -define("DB_ERROR_INVALID_DSN", -23); -define("DB_ERROR_CONNECT_FAILED", -24); - -/* - * Warnings are not detected as errors by DB::isError(), and are not - * fatal. You can detect whether an error is in fact a warning with - * DB::isWarning(). - */ - -define('DB_WARNING', -1000); -define('DB_WARNING_READ_ONLY', -1001); - -/* - * These constants are used when storing information about prepared - * statements (using the "prepare" method in DB_dbtype). - * - * The prepare/execute model in DB is mostly borrowed from the ODBC - * extension, in a query the "?" character means a scalar parameter. - * There are two extensions though, a "&" character means an opaque - * parameter. An opaque parameter is simply a file name, the real - * data are in that file (useful for putting uploaded files into your - * database and such). The "!" char means a parameter that must be - * left as it is. - * They modify the quote behavoir: - * DB_PARAM_SCALAR (?) => 'original string quoted' - * DB_PARAM_OPAQUE (&) => 'string from file quoted' - * DB_PARAM_MISC (!) => original string - */ - -define('DB_PARAM_SCALAR', 1); -define('DB_PARAM_OPAQUE', 2); -define('DB_PARAM_MISC', 3); - -/* - * These constants define different ways of returning binary data - * from queries. Again, this model has been borrowed from the ODBC - * extension. - * - * DB_BINMODE_PASSTHRU sends the data directly through to the browser - * when data is fetched from the database. - * DB_BINMODE_RETURN lets you return data as usual. - * DB_BINMODE_CONVERT returns data as well, only it is converted to - * hex format, for example the string "123" would become "313233". - */ - -define('DB_BINMODE_PASSTHRU', 1); -define('DB_BINMODE_RETURN', 2); -define('DB_BINMODE_CONVERT', 3); - -/** - * This is a special constant that tells DB the user hasn't specified - * any particular get mode, so the default should be used. - */ - -define('DB_FETCHMODE_DEFAULT', 0); - -/** - * Column data indexed by numbers, ordered from 0 and up - */ - -define('DB_FETCHMODE_ORDERED', 1); - -/** - * Column data indexed by column names - */ - -define('DB_FETCHMODE_ASSOC', 2); - -/** -* Column data as object properties -*/ - -define('DB_FETCHMODE_OBJECT', 3); - -/** - * For multi-dimensional results: normally the first level of arrays - * is the row number, and the second level indexed by column number or name. - * DB_FETCHMODE_FLIPPED switches this order, so the first level of arrays - * is the column name, and the second level the row number. - */ - -define('DB_FETCHMODE_FLIPPED', 4); - -/* for compatibility */ - -define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED); -define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC); -define('DB_GETMODE_FLIPPED', DB_FETCHMODE_FLIPPED); - -/** - * these are constants for the tableInfo-function - * they are bitwised or'ed. so if there are more constants to be defined - * in the future, adjust DB_TABLEINFO_FULL accordingly - */ - -define('DB_TABLEINFO_ORDER', 1); -define('DB_TABLEINFO_ORDERTABLE', 2); -define('DB_TABLEINFO_FULL', 3); - - -/** - * The main "DB" class is simply a container class with some static - * methods for creating DB objects as well as some utility functions - * common to all parts of DB. - * - * The object model of DB is as follows (indentation means inheritance): - * - * DB The main DB class. This is simply a utility class - * with some "static" methods for creating DB objects as - * well as common utility functions for other DB classes. - * - * DB_common The base for each DB implementation. Provides default - * | implementations (in OO lingo virtual methods) for - * | the actual DB implementations as well as a bunch of - * | query utility functions. - * | - * +-DB_mysql The DB implementation for MySQL. Inherits DB_common. - * When calling DB::factory or DB::connect for MySQL - * connections, the object returned is an instance of this - * class. - * - * @package DB - * @version 2 - * @author Stig Bakken <ssb@fast.no> - * @since PHP 4.0 - */ - -class DB -{ - /** - * Create a new DB connection object for the specified database - * type - * - * @param $type string database type, for example "mysql" - * - * @return object a newly created DB object, or a DB error code on - * error - */ - - function &factory($type) - { - @include_once("DB/${type}.php"); - - $classname = "DB_${type}"; - - if (!class_exists($classname)) { - return PEAR::raiseError(null, DB_ERROR_NOT_FOUND, - null, null, null, 'DB_Error', true); - } - - @$obj =& new $classname; - - return $obj; - } - - /** - * Create a new DB connection object and connect to the specified - * database - * - * @param $dsn mixed "data source name", see the DB::parseDSN - * method for a description of the dsn format. Can also be - * specified as an array of the format returned by DB::parseDSN. - * - * @param $options mixed An associative array of option names and - * their values. For backwards compatibility, this parameter may - * also be a boolean that tells whether the connection should be - * persistent. See DB_common::setOption for more information on - * connection options. - * - * @return object a newly created DB connection object, or a DB - * error object on error - * - * @see DB::parseDSN - * @see DB::isError - * @see DB_common::setOption - */ - function &connect($dsn, $options = false) - { - if (is_array($dsn)) { - $dsninfo = $dsn; - } else { - $dsninfo = DB::parseDSN($dsn); - } - $type = $dsninfo["phptype"]; - - if (is_array($options) && isset($options["debug"]) && - $options["debug"] >= 2) { - // expose php errors with sufficient debug level - include_once "DB/${type}.php"; - } else { - @include_once "DB/${type}.php"; - } - - $classname = "DB_${type}"; - if (!class_exists($classname)) { - return PEAR::raiseError(null, DB_ERROR_NOT_FOUND, - null, null, null, 'DB_Error', true); - } - - @$obj =& new $classname; - - if (is_array($options)) { - foreach ($options as $option => $value) { - $test = $obj->setOption($option, $value); - if (DB::isError($test)) { - return $test; - } - } - } else { - $obj->setOption('persistent', $options); - } - $err = $obj->connect($dsninfo, $obj->getOption('persistent')); - - if (DB::isError($err)) { - $err->addUserInfo($dsn); - return $err; - } - - return $obj; - } - - /** - * Return the DB API version - * - * @return int the DB API version number - */ - function apiVersion() - { - return 2; - } - - /** - * Tell whether a result code from a DB method is an error - * - * @param $value int result code - * - * @return bool whether $value is an error - */ - function isError($value) - { - return (is_object($value) && - (get_class($value) == 'db_error' || - is_subclass_of($value, 'db_error'))); - } - - /** - * Tell whether a query is a data manipulation query (insert, - * update or delete) or a data definition query (create, drop, - * alter, grant, revoke). - * - * @access public - * - * @param string the query - * - * @return bool whether $query is a data manipulation query - */ - function isManip($query) - { - $manips = 'INSERT|UPDATE|DELETE|'.'REPLACE|CREATE|DROP|'. - 'ALTER|GRANT|REVOKE|'.'LOCK|UNLOCK'; - if (preg_match('/^\s*"?('.$manips.')\s+/i', $query)) { - return true; - } - return false; - } - - /** - * Tell whether a result code from a DB method is a warning. - * Warnings differ from errors in that they are generated by DB, - * and are not fatal. - * - * @param $value mixed result value - * - * @return bool whether $value is a warning - */ - function isWarning($value) - { - return (is_object($value) && - (get_class($value) == "db_warning" || - is_subclass_of($value, "db_warning"))); - } - - /** - * Return a textual error message for a DB error code - * - * @param $value int error code - * - * @return string error message, or false if the error code was - * not recognized - */ - function errorMessage($value) - { - static $errorMessages; - if (!isset($errorMessages)) { - $errorMessages = array( - DB_ERROR => 'unknown error', - DB_ERROR_ALREADY_EXISTS => 'already exists', - DB_ERROR_CANNOT_CREATE => 'can not create', - DB_ERROR_CANNOT_DELETE => 'can not delete', - DB_ERROR_CANNOT_DROP => 'can not drop', - DB_ERROR_CONSTRAINT => 'constraint violation', - DB_ERROR_DIVZERO => 'division by zero', - DB_ERROR_INVALID => 'invalid', - DB_ERROR_INVALID_DATE => 'invalid date or time', - DB_ERROR_INVALID_NUMBER => 'invalid number', - DB_ERROR_MISMATCH => 'mismatch', - DB_ERROR_NODBSELECTED => 'no database selected', - DB_ERROR_NOSUCHFIELD => 'no such field', - DB_ERROR_NOSUCHTABLE => 'no such table', - DB_ERROR_NOT_CAPABLE => 'DB backend not capable', - DB_ERROR_NOT_FOUND => 'not found', - DB_ERROR_NOT_LOCKED => 'not locked', - DB_ERROR_SYNTAX => 'syntax error', - DB_ERROR_UNSUPPORTED => 'not supported', - DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row', - DB_ERROR_INVALID_DSN => 'invalid DSN', - DB_ERROR_CONNECT_FAILED => 'connect failed', - DB_OK => 'no error', - DB_WARNING => 'unknown warning', - DB_WARNING_READ_ONLY => 'read only', - DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied' - ); - } - - if (DB::isError($value)) { - $value = $value->getCode(); - } - - return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[DB_ERROR]; - } - - /** - * Parse a data source name - * - * @param $dsn string Data Source Name to be parsed - * - * @return array an associative array with the following keys: - * - * phptype: Database backend used in PHP (mysql, odbc etc.) - * dbsyntax: Database used with regards to SQL syntax etc. - * protocol: Communication protocol to use (tcp, unix etc.) - * hostspec: Host specification (hostname[:port]) - * database: Database to use on the DBMS server - * username: User name for login - * password: Password for login - * - * The format of the supplied DSN is in its fullest form: - * - * phptype(dbsyntax)://username:password@protocol+hostspec/database - * - * Most variations are allowed: - * - * phptype://username:password@protocol+hostspec:110//usr/db_file.db - * phptype://username:password@hostspec/database_name - * phptype://username:password@hostspec - * phptype://username@hostspec - * phptype://hostspec/database - * phptype://hostspec - * phptype(dbsyntax) - * phptype - * - * @author Tomas V.V.Cox <cox@idecnet.com> - */ - function parseDSN($dsn) - { - if (is_array($dsn)) { - return $dsn; - } - - $parsed = array( - 'phptype' => false, - 'dbsyntax' => false, - 'protocol' => false, - 'hostspec' => false, - 'database' => false, - 'username' => false, - 'password' => false - ); - - // Find phptype and dbsyntax - if (($pos = strpos($dsn, '://')) !== false) { - $str = substr($dsn, 0, $pos); - $dsn = substr($dsn, $pos + 3); - } else { - $str = $dsn; - $dsn = NULL; - } - - // Get phptype and dbsyntax - // $str => phptype(dbsyntax) - if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { - $parsed['phptype'] = $arr[1]; - $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; - } else { - $parsed['phptype'] = $str; - $parsed['dbsyntax'] = $str; - } - - if (empty($dsn)) { - return $parsed; - } - - // Get (if found): username and password - // $dsn => username:password@protocol+hostspec/database - if (($at = strpos($dsn,'@')) !== false) { - $str = substr($dsn, 0, $at); - $dsn = substr($dsn, $at + 1); - if (($pos = strpos($str, ':')) !== false) { - $parsed['username'] = urldecode(substr($str, 0, $pos)); - $parsed['password'] = urldecode(substr($str, $pos + 1)); - } else { - $parsed['username'] = urldecode($str); - } - } - - // Find protocol and hostspec - // $dsn => protocol+hostspec/database - if (($pos=strpos($dsn, '/')) !== false) { - $str = substr($dsn, 0, $pos); - $dsn = substr($dsn, $pos + 1); - } else { - $str = $dsn; - $dsn = NULL; - } - - // Get protocol + hostspec - // $str => protocol+hostspec - if (($pos=strpos($str, '+')) !== false) { - $parsed['protocol'] = substr($str, 0, $pos); - $parsed['hostspec'] = urldecode(substr($str, $pos + 1)); - } else { - $parsed['hostspec'] = urldecode($str); - } - - // Get dabase if any - // $dsn => database - if (!empty($dsn)) { - $parsed['database'] = $dsn; - } - - return $parsed; - } - - /** - * Load a PHP database extension if it is not loaded already. - * - * @access public - * - * @param $name the base name of the extension (without the .so or - * .dll suffix) - * - * @return bool true if the extension was already or successfully - * loaded, false if it could not be loaded - */ - function assertExtension($name) - { - if (!extension_loaded($name)) { - $dlext = (substr(PHP_OS, 0, 3) == 'WIN') ? '.dll' : '.so'; - @dl($name . $dlext); - } - if (!extension_loaded($name)) { - trigger_error("The extension '$name' couldn't be loaded. ". - 'Probably you don\'t have support in your PHP '. - 'to this Database backend', E_USER_ERROR); - return false; - } - return true; - } -} - -/** - * DB_Error implements a class for reporting portable database error - * messages. - * - * @package DB - * @author Stig Bakken <ssb@fast.no> - */ -class DB_Error extends PEAR_Error -{ - /** - * DB_Error constructor. - * - * @param $code mixed DB error code, or string with error message. - * @param $mode int what "error mode" to operate in - * @param $level what error level to use for $mode & PEAR_ERROR_TRIGGER - * @param $debuginfo additional debug info, such as the last query - * - * @access public - * - * @see PEAR_Error - */ - - function DB_Error($code = DB_ERROR, $mode = PEAR_ERROR_RETURN, - $level = E_USER_NOTICE, $debuginfo = null) - { - if (is_int($code)) { - $this->PEAR_Error('DB Error: ' . DB::errorMessage($code), $code, $mode, $level, $debuginfo); - } else { - $this->PEAR_Error("DB Error: $code", DB_ERROR, $mode, $level, $debuginfo); - } - } -} - -/** - * DB_Warning implements a class for reporting portable database - * warning messages. - * - * @package DB - * @author Stig Bakken <ssb@fast.no> - */ -class DB_Warning extends PEAR_Error -{ - /** - * DB_Warning constructor. - * - * @param $code mixed DB error code, or string with error message. - * @param $mode int what "error mode" to operate in - * @param $level what error level to use for $mode == PEAR_ERROR_TRIGGER - * @param $debuginfo additional debug info, such as the last query - * - * @access public - * - * @see PEAR_Error - */ - - function DB_Warning($code = DB_WARNING, $mode = PEAR_ERROR_RETURN, - $level = E_USER_NOTICE, $debuginfo = null) - { - if (is_int($code)) { - $this->PEAR_Error('DB Warning: ' . DB::errorMessage($code), $code, $mode, $level, $debuginfo); - } else { - $this->PEAR_Error("DB Warning: $code", 0, $mode, $level, $debuginfo); - } - } -} - -/** - * This class implements a wrapper for a DB result set. - * A new instance of this class will be returned by the DB implementation - * after processing a query that returns data. - * - * @package DB - * @author Stig Bakken <ssb@fast.no> - */ - -class DB_result -{ - var $dbh; - var $result; - - /** - * DB_result constructor. - * @param $dbh DB object reference - * @param $result result resource id - */ - - function DB_result(&$dbh, $result) - { - $this->dbh = &$dbh; - $this->result = $result; - } - - /** - * Fetch and return a row of data (it uses backend->fetchInto for that) - * @param $fetchmode format of fetched row - * @param $rownum the row number to fetch - * - * @return array a row of data, NULL on no more rows or PEAR_Error on error - */ - function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) - { - if ($fetchmode === DB_FETCHMODE_DEFAULT) { - $fetchmode = $this->dbh->fetchmode; - } - if ($fetchmode === DB_FETCHMODE_OBJECT) { - $fetchmode = DB_FETCHMODE_ASSOC; - $return_object = true; - } - $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); - if ($res !== DB_OK) { - return $res; - } - if (isset($return_object)) { - $class = $this->dbh->fetchmode_object_class; - $ret =& new $class($arr); - return $ret; - } - return $arr; - } - - /** - * Fetch a row of data into an existing variable. - * - * @param $arr reference to data containing the row - * @param $fetchmode format of fetched row - * @param $rownum the row number to fetch - * - * @return mixed DB_OK on success, NULL on no more rows or - * a DB_Error object on errors - */ - function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) - { - if ($fetchmode === DB_FETCHMODE_DEFAULT) { - $fetchmode = $this->dbh->fetchmode; - } - if ($fetchmode === DB_FETCHMODE_OBJECT) { - $fetchmode = DB_FETCHMODE_ASSOC; - $return_object = true; - } - $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum); - if (($res === DB_OK) && isset($return_object)) { - $class = $this->dbh->fetchmode_object_class; - $arr = new $class($arr); - } - return $res; - } - - /** - * Get the the number of columns in a result set. - * - * @return int the number of columns, or a DB error - */ - function numCols() - { - return $this->dbh->numCols($this->result); - } - - /** - * Get the number of rows in a result set. - * - * @return int the number of rows, or a DB error - */ - function numRows() - { - return $this->dbh->numRows($this->result); - } - - /** - * Frees the resources allocated for this result set. - * @return int error code - */ - function free() - { - $err = $this->dbh->freeResult($this->result); - if(DB::isError($err)) { - return $err; - } - $this->result = false; - return true; - } - - function tableInfo($mode = null) - { - return $this->dbh->tableInfo($this->result, $mode); - } -} - -class DB_row -{ - function DB_row(&$arr) - { - for (reset($arr); $key = key($arr); next($arr)) { - $this->$key = &$arr[$key]; - } - } -} - -?>
\ No newline at end of file diff --git a/pear/HTTP.php b/pear/HTTP.php deleted file mode 100644 index cffe66ac08..0000000000 --- a/pear/HTTP.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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$ -// -// HTTP utility functions. -// - -if (!empty($GLOBALS['USED_PACKAGES']['HTTP'])) return; -$GLOBALS['USED_PACKAGES']['HTTP'] = true; - -class HTTP { - /** - * Format a date according to RFC-XXXX (can't remember the HTTP - * RFC number off-hand anymore, shame on me). This function - * honors the "y2k_compliance" php.ini directive. - * - * @param $time int UNIX timestamp - * - * @return HTTP date string, or false for an invalid timestamp. - * - * @author Stig Bakken <ssb@fast.no> - */ - function Date($time) { - $y = ini_get("y2k_compliance") ? "Y" : "y"; - return gmdate("D, d M $y H:i:s", $time); - } - - /** - * Negotiate language with the user's browser through the - * Accept-Language HTTP header or the user's host address. - * Language codes are generally in the form "ll" for a language - * spoken in only one country, or "ll_CC" for a language spoken in - * a particular country. For example, U.S. English is "en_US", - * while British English is "en_UK". Portugese as spoken in - * Portugal is "pt_PT", while Brazilian Portugese is "pt_BR". - * Two-letter country codes can be found in the ISO 3166 standard. - * - * Quantities in the Accept-Language: header are supported, for - * example: - * - * Accept-Language: en_UK;q=0.7, en_US;q=0.6, no;q=1.0, dk;q=0.8 - * - * @param $supported an associative array indexed by language - * codes (country codes) supported by the application. Values - * must evaluate to true. - * - * @param $default the default language to use if none is found - * during negotiation, defaults to "en_US" for U.S. English - * - * @author Stig Bakken <ssb@fast.no> - */ - function negotiateLanguage(&$supported, $default = 'en_US') { - global $HTTP_SERVER_VARS; - - /* If the client has sent an Accept-Language: header, see if - * it contains a language we support. - */ - if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) { - $accepted = split(',[[:space:]]*', $HTTP_ACCEPT_LANGUAGE); - for ($i = 0; $i < count($accepted); $i++) { - if (eregi('^([a-z]+);[[:space:]]*q=([0-9\.]+)', $accepted[$i], &$arr)) { - $q = (double)$arr[2]; - $l = $arr[1]; - } else { - $q = 42; - $l = $accepted[$i]; - } - if (!empty($supported[$l]) && ($q > 0.0)) { - if ($q == 42) { - return $l; - } - $candidates[$l] = $q; - } - } - if (isset($candidates)) { - arsort($candidates); - reset($candidates); - return key($candidates); - } - } - - /* Check for a valid language code in the top-level domain of - * the client's host address. - */ - if (ereg("\.[^\.]+$", $HTTP_SERVER_VARS['REMOTE_HOST'], &$arr)) { - $lang = strtolower($arr[1]); - if (!empty($supported[$lang])) { - return $lang; - } - } - - return $default; - } -} -?> diff --git a/pear/ITX.xml b/pear/ITX.xml deleted file mode 100644 index e484e69852..0000000000 --- a/pear/ITX.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE Package SYSTEM "F:\cvs\php4\pear\package.dtd"> -<Package Type="Source"> - <Name>IT[X] Template</Name> - <Summary>Easy to use preg_* based template system.</Summary> - <Maintainer> - <Initials>uw</Initials> - <Name>Ulf Wendel</Name> - <Email>ulf.wendel@phpdoc.de</Email> - </Maintainer> - <Release> - <Version>1.1</Version> - <Date>2001/03/27</Date> - <Notes>some IT[X] methods seem to be broken</Notes> - </Release> - <FileList> - <File>HTML/IT.php</File> - <File>HTML/ITX.php</File> - <File>HTML/IT_Error.php</File> - </FileList> -</Package> diff --git a/pear/Log.php b/pear/Log.php deleted file mode 100644 index f4c029c002..0000000000 --- a/pear/Log.php +++ /dev/null @@ -1,194 +0,0 @@ -<?php -// $Id$ -// $Horde: horde/lib/Log.php,v 1.15 2000/06/29 23:39:45 jon Exp $ - -/** - * The Log:: class implements both an abstraction for various logging - * mechanisms and the Subject end of a Subject-Observer pattern. - * - * @author Chuck Hagenbuch <chuck@horde.org> - * @author Jon Parise <jon@csh.rit.edu> - * @version $Revision$ - * @since Horde 1.3 - */ -class Log { - - // {{{ properties - - /** Boolean indicating whether or not the log connection is - currently open. */ - var $opened = false; - - /** String holding the identifier that will be stored along with - each logged message. */ - var $ident = ''; - - /** Array holding all Log_observer objects that wish to be notified - of any messages that we handle. */ - var $listeners = array(); - - // }}} - - // {{{ factory() - /** - * Attempts to return a concrete Log instance of $log_type. - * - * @param $log_type The type of concrete Log subclass to return. - * Attempt to dynamically include the code for this - * subclass. Currently, valid values are 'syslog', - * 'sql', 'file', and 'mcal'. - * - * @param $log_name (optional) The name of the actually log file, - * table, or other specific store to use. Defaults - * to an empty string, with which the subclass will - * attempt to do something intelligent. - * - * @param $ident (optional) The indentity reported to the log system. - * - * @param $conf (optional) A hash containing any additional - * configuration information that a subclass might need. - * - * @return The newly created concrete Log instance, or an - * false on an error. - */ - function factory ($log_type, $log_name = '', $ident = '', $conf = array()) { - $log_type = strtolower($log_type); - $classfile = 'Log/' . $log_type . '.php'; - if (@include_once $classfile) { - $class = 'Log_' . $log_type; - return new $class($log_name, $ident, $conf); - } else { - return false; - } - } - // }}} - - // {{{ singleton() - /** - * Attempts to return a reference to a concrete Log instance of - * $log_type, only creating a new instance if no log instance with - * the same parameters currently exists. - * - * You should use this if there are multiple places you might - * create a logger, you don't want to create multiple loggers, and - * you don't want to check for the existance of one each time. The - * singleton pattern does all the checking work for you. - * - * <b>You MUST call this method with the $var = &Log::singleton() - * syntax. Without the ampersand (&) in front of the method name, - * you will not get a reference, you will get a copy.</b> - * - * @param $log_type The type of concrete Log subclass to return. - * Attempt to dynamically include the code for - * this subclass. Currently, valid values are - * 'syslog', 'sql', 'file', and 'mcal'. - * - * @param $log_name (optional) The name of the actually log file, - * table, or other specific store to use. Defaults - * to an empty string, with which the subclass will - * attempt to do something intelligent. - * - * @param $ident (optional) The identity reported to the log system. - * - * @param $conf (optional) A hash containing any additional - * configuration information that a subclass might need. - * - * @return The concrete Log reference, or false on an error. - */ - function &singleton ($log_type, $log_name = '', $ident = '', $conf = array()) { - static $instances; - if (!isset($instances)) $instances = array(); - - $signature = md5($log_type . '][' . $log_name . '][' . $ident . '][' . implode('][', $conf)); - if (!isset($instances[$signature])) { - $instances[$signature] = Log::factory($log_type, $log_name, $ident, $conf); - } - return $instances[$signature]; - } - // }}} - - // {{{ priorityToString() - /** - * Returns the string representation of a LOG_* integer constant. - * - * @param $priority The LOG_* integer constant. - * - * @return The string representation of $priority. - */ - function priorityToString ($priority) { - $priorities = array( - LOG_EMERG => 'emergency', - LOG_ALERT => 'alert', - LOG_CRIT => 'critical', - LOG_ERR => 'error', - LOG_WARNING => 'warning', - LOG_NOTICE => 'notice', - LOG_INFO => 'info', - LOG_DEBUG => 'debug' - ); - return $priorities[$priority]; - } - // }}} - - // {{{ attach() - /** - * Adds a Log_observer instance to the list of observers that are - * be notified when a message is logged. - * - * @param $logObserver The Log_observer instance to be added to - * the $listeners array. - */ - function attach (&$logObserver) { - if (!is_object($logObserver)) - return false; - - $logObserver->_listenerID = uniqid(rand()); - - $this->listeners[$logObserver->_listenerID] = &$logObserver; - } - // }}} - - // {{{ detach() - /** - * Removes a Log_observer instance from the list of observers. - * - * @param $logObserver The Log_observer instance to be removed - * from the $listeners array. - */ - function detach ($logObserver) { - if (isset($this->listeners[$logObserver->_listenerID])) - unset($this->listeners[$logObserver->_listenerID]); - } - // }}} - - // {{{ notifyAll() - /** - * Sends any Log_observer objects listening to this Log the message - * that was just logged. - * - * @param $messageOb The data structure holding all relevant log - * information - the message, the priority, what - * log this is, etc. - */ - function notifyAll ($messageOb) { - reset($this->listeners); - foreach ($this->listeners as $listener) { - if ($messageOb['priority'] <= $listener->priority) - $listener->notify($messageOb); - } - } - // }}} - - // {{{ isComposite() - /** - * @return a Boolean: true if this is a composite class, false - * otherwise. The composite subclass overrides this to return - * true. - */ - function isComposite () { - return false; - } - // }}} -} - -?> diff --git a/pear/Mail.php b/pear/Mail.php deleted file mode 100644 index d72f25b3d4..0000000000 --- a/pear/Mail.php +++ /dev/null @@ -1,186 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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: Chuck Hagenbuch <chuck@horde.org> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; - -/** - * PEAR's Mail:: interface. Defines the interface for implementing - * mailers under the PEAR hierarchy, and provides supporting functions - * useful in multiple mailer backends. - * - * @access public - * @version $Revision$ - * @package Mail - */ -class Mail extends PEAR -{ - /** - * Provides an interface for generating Mail:: objects of various - * types - * - * @param string $driver The kind of Mail:: object to instantiate. - * @param array $params The parameters to pass to the Mail:: object. - * @return object Mail a instance of the driver class or if fails a PEAR Error - * @access public - */ - function factory($driver, $params = array()) - { - $driver = strtolower($driver); - @include_once 'Mail/' . $driver . '.php'; - $class = 'Mail_' . $driver; - if (class_exists($class)) { - return new $class($params); - } else { - return $this->raiseError('Unable to find class for driver ' . $driver); - } - } - - /** - * Implements Mail::send() function using php's built-in mail() - * command. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - * @deprecated use Mail_mail::send instead - */ - function send($recipients, $headers, $body) - { - // if we're passed an array of recipients, implode it. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // get the Subject out of the headers array so that we can - // pass it as a seperate argument to mail(). - $subject = ''; - if (isset($headers['Subject'])) { - $subject = $headers['Subject']; - unset($headers['Subject']); - } - - // flatten the headers out. - list(,$text_headers) = Mail::prepareHeaders($headers); - - return mail($recipients, $subject, $body, $text_headers); - - } - - /** - * Take an array of mail headers and return a string containing - * text usable in sending a message. - * - * @param array $headers The array of headers to prepare, in an associative - * array, where the array key is the header name (ie, - * 'Subject'), and the array value is the header - * value (ie, 'test'). The header produced from those - * values would be 'Subject: test'. - * - * @return mixed Returns false if it encounters a bad address, - * otherwise returns an array containing two - * elements: Any From: address found in the headers, - * and the plain text version of the headers. - * @access private - */ - function prepareHeaders($headers) - { - // Look out for the From: value to use along the way. - $text_headers = ''; // text representation of headers - $from = null; - - foreach ($headers as $key => $val) { - if ($key == 'From') { - include_once 'Mail/RFC822.php'; - - $from_arr = Mail_RFC822::parseAddressList($val, 'localhost', false); - $from = $from_arr[0]->mailbox . '@' . $from_arr[0]->host; - if (strstr($from, ' ')) { - // Reject outright envelope From addresses with spaces. - return false; - } - $text_headers .= $key . ': ' . $val . "\n"; - } else if ($key == 'Received') { - // put Received: headers at the top, since Receieved: - // after Subject: in the header order is somtimes used - // as a spam trap. - $text_headers = $key . ': ' . $val . "\n" . $text_headers; - } else { - $text_headers .= $key . ': ' . $val . "\n"; - } - } - - return array($from, $text_headers); - } - - /** - * Take a set of recipients and parse them, returning an array of - * bare addresses (forward paths) that can be passed to sendmail - * or an smtp server with the rcpt to: command. - * - * @param mixed Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. - * - * @return array An array of forward paths (bare addresses). - * @access private - */ - function parseRecipients($recipients) - { - include_once 'Mail/RFC822.php'; - - // if we're passed an array, assume addresses are valid and - // implode them before parsing. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // Parse recipients, leaving out all personal info. This is - // for smtp recipients, etc. All relevant personal information - // should already be in the headers. - $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false); - $recipients = array(); - if (is_array($addresses)) { - foreach ($addresses as $ob) { - $recipients[] = $ob->mailbox . '@' . $ob->host; - } - } - - return $recipients; - } - -} -?>
\ No newline at end of file diff --git a/pear/Makefile.in b/pear/Makefile.in deleted file mode 100644 index b8391f5727..0000000000 --- a/pear/Makefile.in +++ /dev/null @@ -1,192 +0,0 @@ - -install_targets = \ - install-data-local \ - install-headers \ - install-build \ - install-programs - -include $(top_srcdir)/build/rules.mk - -peardir=$(PEAR_INSTALLDIR) - -PEAR_SUBDIRS = \ - Benchmark \ - Cache \ - Cache/Container \ - Console \ - Crypt \ - Date \ - DB \ - File \ - HTML \ - HTTP \ - Image \ - Log \ - Mail \ - Math \ - Net \ - Numbers \ - Payment \ - PEAR \ - Schedule \ - XML \ - XML/RPC - -PEAR_FILES = \ - Benchmark/Iterate.php \ - Benchmark/Timer.php \ - Cache.php \ - Cache/Container.php \ - Cache/Function.php \ - Cache/Graphics.php \ - Cache/Output.php \ - Cache/Error.php \ - Cache/OutputCompression.php \ - Cache/Container/db.php \ - Cache/Container/dbx.php \ - Cache/Container/file.php \ - Cache/Container/phplib.php \ - Cache/Container/shm.php \ - Console/Getopt.php \ - Crypt/CBC.php \ - Crypt/HCEMD5.php \ - Date/Calc.php \ - Date/Human.php \ - DB.php \ - DB/common.php \ - DB/ibase.php \ - DB/ifx.php \ - DB/msql.php \ - DB/mssql.php \ - DB/mysql.php \ - DB/oci8.php \ - DB/odbc.php \ - DB/pgsql.php \ - DB/storage.php \ - DB/sybase.php \ - File/Find.php \ - File/Passwd.php \ - File/SearchReplace.php \ - HTML/Common.php \ - HTML/Form.php \ - HTML/IT.php \ - HTML/ITX.php \ - HTML/IT_Error.php \ - HTML/Page.php \ - HTML/Processor.php \ - HTML/Select.php \ - HTML/Table.php \ - HTTP.php \ - HTTP/Compress.php \ - Image/Remote.php \ - Log.php \ - Log/composite.php \ - Log/file.php \ - Log/mcal.php \ - Log/observer.php \ - Log/sql.php \ - Log/syslog.php \ - Mail.php \ - Mail/RFC822.php \ - Mail/sendmail.php \ - Mail/smtp.php \ - Math/Fraction.php \ - Math/Util.php \ - Net/Curl.php \ - Net/Dig.php \ - Net/SMTP.php \ - Net/Socket.php \ - Numbers/Roman.php \ - PEAR.php \ - PEAR/Common.php \ - PEAR/Installer.php \ - PEAR/Packager.php \ - PEAR/Uploader.php \ - Payment/Verisign.php \ - Schedule/At.php \ - XML/Parser.php \ - XML/RPC.php \ - XML/RPC/Server.php - -install-data-local: - @if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \ - for i in $(PEAR_SUBDIRS); do \ - (set -x;$(mkinstalldirs) $(INSTALL_ROOT)$(peardir)/$$i); \ - done; \ - for i in $(PEAR_FILES); do \ - dir=`echo $$i|sed 's%[^/][^/]*$$%%'`; \ - (set -x;$(INSTALL_DATA) $(srcdir)/$$i $(INSTALL_ROOT)$(peardir)/$$dir); \ - done; \ - else \ - cat $(srcdir)/install-pear.txt; \ - exit 5; \ - fi - -phpincludedir = $(includedir)/php -phpbuilddir = $(prefix)/lib/php/build - -BUILD_FILES = \ - pear/pear.m4 \ - build/fastgen.sh \ - build/library.mk \ - build/ltlib.mk \ - build/mkdep.awk \ - build/program.mk \ - build/rules.mk \ - build/rules_common.mk \ - build/rules_pear.mk \ - build/dynlib.mk \ - build/shtool \ - dynlib.m4 \ - acinclude.m4 - -bin_SCRIPTS = phpize php-config pear pearize - -install-build: - $(mkinstalldirs) $(INSTALL_ROOT)$(phpbuilddir) $(INSTALL_ROOT)$(bindir) && \ - (cd $(top_srcdir) && cp $(BUILD_FILES) $(INSTALL_ROOT)$(phpbuilddir)) - -install-programs: - for prog in $(bin_SCRIPTS); do \ - $(INSTALL) -m 755 scripts/$$prog $(INSTALL_ROOT)$(bindir)/$$prog; \ - done; \ - for prog in phpextdist; do \ - $(INSTALL) -m 755 $(srcdir)/scripts/$$prog $(INSTALL_ROOT)$(bindir)/$$prog; \ - done - -HEADER_DIRS = \ - / \ - Zend \ - TSRM \ - ext/standard \ - ext/xml \ - ext/xml/expat/xmlparse \ - ext/xml/expat/xmltok \ - main \ - regex - -install-headers: - -@for i in $(HEADER_DIRS); do \ - paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \ - done; \ - $(mkinstalldirs) $$paths && \ - echo "creating header file hierarchy" && \ - for i in $(HEADER_DIRS); do \ - (cd $(top_srcdir)/$$i && cp -p *.h $(INSTALL_ROOT)$(phpincludedir)/$$i; \ - cd $(top_builddir)/$$i && cp -p *.h $(INSTALL_ROOT)$(phpincludedir)/$$i) 2>/dev/null || true; \ - done - -Makefile: Makefile.in $(top_builddir)/config.status - (cd ..;CONFIG_FILES=pear/Makefile CONFIG_HEADERS= $(top_builddir)/config.status) - -scripts/pear: scripts/pear.in $(top_builddir)/config.status - (cd ..;CONFIG_FILES=pear/scripts/pear CONFIG_HEADERS= $(top_builddir)/config.status) - -scripts/phpize: scripts/phpize.in $(top_builddir)/config.status - (cd ..;CONFIG_FILES=pear/scripts/phpize CONFIG_HEADERS= $(top_builddir)/config.status) - -scripts/pearize: scripts/pearize.in $(top_builddir)/config.status - (cd ..;CONFIG_FILES=pear/scripts/pearize CONFIG_HEADERS= $(top_builddir)/config.status) - -scripts/php-config: scripts/php-config.in $(top_builddir)/config.status - (cd ..;CONFIG_FILES=pear/scripts/php-config CONFIG_HEADERS= $(top_builddir)/config.status) diff --git a/pear/PEAR.php b/pear/PEAR.php deleted file mode 100644 index 2feafd8f98..0000000000 --- a/pear/PEAR.php +++ /dev/null @@ -1,682 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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 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: Sterling Hughes <sterling@php.net> | -// | Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - -define('PEAR_ERROR_RETURN', 1); -define('PEAR_ERROR_PRINT', 2); -define('PEAR_ERROR_TRIGGER', 4); -define('PEAR_ERROR_DIE', 8); -define('PEAR_ERROR_CALLBACK', 16); - -if (substr(PHP_OS, 0, 3) == 'WIN') { - define('OS_WINDOWS', true); - define('OS_UNIX', false); - define('PEAR_OS', 'Windows'); -} else { - define('OS_WINDOWS', false); - define('OS_UNIX', true); - define('PEAR_OS', 'Unix'); // blatant assumption -} - -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_default_error_callback'] = ''; -$GLOBALS['_PEAR_destructor_object_list'] = array(); - -// -// Tests needed: - PEAR inheritance -// - destructors -// - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: <code>$this->PEAR();</code>. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use <code>error_log()</code>, <code>syslog()</code> or - * something like that instead. - * - * @since PHP 4.0.2 - * @author Stig Bakken <ssb@fast.no> - */ -class PEAR -{ - // {{{ properties - - var $_debug = false; - var $_default_error_mode = null; - var $_default_error_options = null; - var $_default_error_handler = ''; - var $_error_class = 'PEAR_Error'; - - // }}} - - // {{{ constructor - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - */ - function PEAR($error_class = null) - { - $classname = get_class($this); - if ($this->_debug) { - print "PEAR constructor called, class=$classname\n"; - } - if ($error_class !== null) { - $this->_error_class = $error_class; - } - while ($classname) { - $destructor = "_$classname"; - if (method_exists($this, $destructor)) { - global $_PEAR_destructor_object_list; - $_PEAR_destructor_object_list[] = &$this; - break; - } else { - $classname = get_parent_class($classname); - } - } - } - - // }}} - // {{{ destructor - - /** - * Destructor (the emulated type of...). Does nothing right now, - * but is included for forward compatibility, so subclass - * destructors should always call it. - * - * See the note in the class desciption about output from - * destructors. - * - * @access public - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", - get_class($this)); - } - } - - // }}} - // {{{ isError() - - /** - * Tell whether a value is a PEAR error. - * - * @param $data the value to test - * @access public - * @return bool true if $data is an error - */ - function isError($data) { - return (bool)(is_object($data) && - (get_class($data) == "pear_error" || - is_subclass_of($data, "pear_error"))); - } - - // }}} - // {{{ setErrorHandling() - - /** - * Sets how errors generated by this DB object should be handled. - * Can be invoked both in objects and statically. If called - * statically, setErrorHandling sets the default behaviour for all - * PEAR objects. If called in an object, setErrorHandling sets - * the default behaviour for that object. - * - * @param $mode int - * one of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or - * PEAR_ERROR_CALLBACK. - * - * @param $options mixed - * Ignored unless $mode is PEAR_ERROR_TRIGGER or - * PEAR_ERROR_CALLBACK. When $mode is PEAR_ERROR_TRIGGER, - * this parameter is expected to be an integer and one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR. When - * $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * - * @since PHP 4.0.5 - */ - - function setErrorHandling($mode = null, $options = null) - { - if (isset($this)) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - $setcallback = &$this->_default_error_callback; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - $setcallback = &$GLOBALS['_PEAR_default_error_callback']; - } - - switch ($mode) { - case PEAR_ERROR_RETURN: - case PEAR_ERROR_PRINT: - case PEAR_ERROR_TRIGGER: - case PEAR_ERROR_DIE: - case null: - $setmode = $mode; - $setoptions = $options; - break; - - case PEAR_ERROR_CALLBACK: - $setmode = $mode; - if ((is_string($options) && function_exists($options)) || - (is_array($options) && method_exists(@$options[0], @$options[1]))) - { - $setcallback = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - // }}} - // {{{ raiseError() - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param $message a text error message or a PEAR error object - * @param $code a numeric error code (it is up to your class - * to define these if you want to use codes) - * @param $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or - * PEAR_ERROR_CALLBACK. - * @param $options If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * @param $userinfo If you need to pass along for example debug - * information, this parameter is meant for that. - * @param $error_class The returned error object will be instantiated - * from this class, if specified. - * @param $skipmsg If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * - * @return object a PEAR error object - * - * @see PEAR::setErrorHandling - * - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message = $message->getMessage(); - } - - if ($mode === null) { - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - } else { - $mode = $GLOBALS['_PEAR_default_error_mode']; - } - } - - if ($mode == PEAR_ERROR_TRIGGER && $options === null) { - if (isset($this) && isset($this->_default_error_options)) { - $options = $this->_default_error_options; - } else { - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($mode == PEAR_ERROR_CALLBACK) { - if (!is_string($options) && - !(is_array($options) && sizeof($options) == 2 && - is_object($options[0]) && is_string($options[1]))) { - if (isset($this) && isset($this->_default_error_callback)) { - $options = $this->_default_error_callback; - } else { - $options = $GLOBALS['_PEAR_default_error_callback']; - } - } - } else { - if ($options === null) { - if (isset($this) && isset($this->_default_error_options)) { - $options = $this->_default_error_options; - } else { - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - } - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - if ($skipmsg) { - return new $ec($code, $mode, $options, $userinfo); - } else { - return new $ec($message, $code, $mode, $options, $userinfo); - } - } - - // }}} - // {{{ pushErrorHandling() - - /** - * Push a new error handler on top of the error handler options stack. With this - * you can easely override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param $mode mixed (same as setErrorHandling) - * @param $options mixed (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (!is_array($stack)) { - if (isset($this)) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - // XXX Used anywhere? - //$def_callback = &$this->_default_error_callback; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - // XXX Used anywhere? - //$def_callback = &$GLOBALS['_PEAR_default_error_callback']; - } - if (!isset($def_mode)) { - $def_mode = PEAR_ERROR_RETURN; - } - $stack = array(); - $stack[] = array($def_mode, $def_options); - } - - if (isset($this)) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - $stack[] = array($mode, $options); - return true; - } - - // }}} - // {{{ popErrorHandling() - - /** - * Pop the last error handler used - * - * @return bool Always true - * - * @see PEAR::pushErrorHandling - */ - function popErrorHandling() - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - array_pop($stack); - list($mode, $options) = $stack[sizeof($stack) - 1]; - if (isset($this)) { - $this->setErrorHandling($mode, $options); - } else { - PEAR::setErrorHandling($mode, $options); - } - return true; - } - - // }}} -} - -// {{{ _PEAR_call_destructors() - -function _PEAR_call_destructors() -{ - global $_PEAR_destructor_object_list; - if (is_array($_PEAR_destructor_object_list) && - sizeof($_PEAR_destructor_object_list)) - { - reset($_PEAR_destructor_object_list); - while (list($k, $objref) = each($_PEAR_destructor_object_list)) { - $classname = get_class($objref); - while ($classname) { - $destructor = "_$classname"; - if (method_exists($objref, $destructor)) { - $objref->$destructor(); - break; - } else { - $classname = get_parent_class($classname); - } - } - } - // Empty the object list to ensure that destructors are - // not called more than once. - $_PEAR_destructor_object_list = array(); - } -} - -// }}} - -class PEAR_Error -{ - // {{{ properties - - var $error_message_prefix = ''; - var $error_prepend = ''; - var $error_append = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $debuginfo = ''; - - // Wait until we have a stack-groping function in PHP. - //var $file = ''; - //var $line = 0; - - - // }}} - // {{{ constructor - - /** - * PEAR_Error constructor - * - * @param $message error message - * - * @param $code (optional) error code - * - * @param $mode (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER or - * PEAR_ERROR_CALLBACK - * - * @param $level (optional) error level, _OR_ in the case of - * PEAR_ERROR_CALLBACK, the callback function or object/method - * tuple. - * - * @access public - * - */ - function PEAR_Error($message = "unknown error", $code = null, - $mode = null, $options = null, $userinfo = null) - { - if ($mode === null) { - $mode = PEAR_ERROR_RETURN; - } - $this->message = $message; - $this->code = $code; - $this->mode = $mode; - $this->userinfo = $userinfo; - if ($mode & PEAR_ERROR_CALLBACK) { - $this->level = E_USER_NOTICE; - $this->callback = $options; - } else { - if ($options === null) { - $options = E_USER_NOTICE; - } - $this->level = $options; - $this->callback = null; - } - if ($this->mode & PEAR_ERROR_PRINT) { - print $this->getMessage(); - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - die($msg); - } - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_string($this->callback) && strlen($this->callback)) { - call_user_func($this->callback, $this); - } elseif (is_array($this->callback) && - sizeof($this->callback) == 2 && - is_object($this->callback[0]) && - is_string($this->callback[1]) && - strlen($this->callback[1])) { - @call_user_method($this->callback[1], $this->callback[0], - $this); - } - } - } - - // }}} - // {{{ getMode() - - /** - * Get the error mode from an error object. - * - * @return int error mode - * @access public - */ - function getMode() { - return $this->mode; - } - - // }}} - // {{{ getCallback() - - /** - * Get the callback function/method from an error object. - * - * @return mixed callback function or object/method array - * @access public - */ - function getCallback() { - return $this->callback; - } - - // }}} - // {{{ getMessage() - - - /** - * Get the error message from an error object. - * - * @return string full error message - * @access public - */ - function getMessage () - { - return ($this->error_prepend . $this->error_message_prefix . - $this->message . $this->error_append); - } - - - // }}} - // {{{ getCode() - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - // }}} - // {{{ getType() - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType () - { - return get_class($this); - } - - // }}} - // {{{ getUserInfo() - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo () - { - return $this->userinfo; - } - - // }}} - // {{{ getDebugInfo() - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo () - { - return $this->getUserInfo(); - } - - // }}} - // {{{ addUserInfo() - - function addUserInfo($info) - { - if (empty($this->userinfo)) { - $this->userinfo = $info; - } else { - $this->userinfo .= " ** $info"; - } - } - - // }}} - // {{{ toString() - - /** - * Make a string representation of this object. - * - * @return string a string with an object summary - * @access public - */ - function toString() { - $modes = array(); - $levels = array(E_USER_NOTICE => "notice", - E_USER_WARNING => "warning", - E_USER_ERROR => "error"); - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_array($this->callback)) { - $callback = get_class($this->callback[0]) . "::" . - $this->callback[1]; - } else { - $callback = $this->callback; - } - return sprintf('[%s: message="%s" code=%d mode=callback '. - 'callback=%s prefix="%s" prepend="%s" append="%s" '. - 'info="%s"]', - get_class($this), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->error_prepend, $this->error_append, - $this->debuginfo); - } - if ($this->mode & PEAR_ERROR_CALLBACK) { - $modes[] = "callback"; - } - if ($this->mode & PEAR_ERROR_PRINT) { - $modes[] = "print"; - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - $modes[] = "trigger"; - } - if ($this->mode & PEAR_ERROR_DIE) { - $modes[] = "die"; - } - if ($this->mode & PEAR_ERROR_RETURN) { - $modes[] = "return"; - } - return sprintf('[%s: message="%s" code=%d mode=%s level=%s prefix="%s" '. - 'prepend="%s" append="%s" info="%s"]', - get_class($this), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->error_prepend, $this->error_append, - $this->userinfo); - } - - // }}} -} - -register_shutdown_function("_PEAR_call_destructors"); - -/* - * Local Variables: - * mode: c++ - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php deleted file mode 100644 index 15ddf8fe80..0000000000 --- a/pear/PEAR/Common.php +++ /dev/null @@ -1,299 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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'; - -/** -* TODO: -* - check in inforFromDescFile that the minimal data needed is present -* (pack name, version, files, others?) -* - perhaps use parser folding to be less restrictive with the format - of the package.xml file -*/ -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(); - - // }}} - - // {{{ constructor - - function PEAR_Common() - { - $this->PEAR(); - } - - // }}} - // {{{ destructor - - function _PEAR_Common() - { - $this->_PEAR(); - while (is_array($this->_tempfiles) && - $file = array_shift($this->_tempfiles)) - { - if (@is_dir($file)) { - system("rm -rf $file"); // XXX FIXME Windows - } elseif (file_exists($file)) { - unlink($file); - } - } - } - - // }}} - // {{{ addTempFile() - - function addTempFile($file) - { - $this->_tempfiles[] = $file; - } - - // }}} - // {{{ mkDirHier() - - function mkDirHier($dir) - { - $dirstack = array(); - while (!@is_dir($dir) && $dir != DIRECTORY_SEPARATOR) { - array_unshift($dirstack, $dir); - $dir = dirname($dir); - } - while ($newdir = array_shift($dirstack)) { - if (mkdir($newdir, 0777)) { - $this->log(2, "+ created dir $newdir"); - } else { - return false; - } - } - return true; - } - - // }}} - // {{{ log() - - function log($level, $msg) - { - if ($this->debug >= $level) { - print "$msg\n"; - } - } - - // }}} - - // {{{ _element_start() - - function _element_start($xp, $name, $attribs) - { - array_push($this->element_stack, $name); - $this->current_element = $name; - $this->current_attributes = $attribs; - 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; - } - } - - // }}} - // {{{ _element_end() - - function _element_end($xp, $name) - { - switch ($name) { - case 'Dir': - array_pop($this->dir_names); - unset($this->dir_install); - unset($this->dir_role); - break; - case 'File': - $path = ''; - 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': - $path = ''; - 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; - } - array_pop($this->element_stack); - $this->current_element = $this->element_stack[sizeof($this->element_stack)-1]; - } - - // }}} - // {{{ _pkginfo_cdata() - - function _pkginfo_cdata($xp, $data) - { - $prev = $this->element_stack[sizeof($this->element_stack)-2]; - switch ($this->current_element) { - case 'Name': - switch ($prev) { - case 'Package': - $this->pkginfo['package'] .= $data; - break; - case 'Maintainer': - $this->pkginfo['maintainer_name'] .= $data; - break; - } - break; - case 'Summary': - $this->pkginfo['summary'] .= $data; - break; - case 'Initials': - $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->phpdir) { - break; - } - $dir = trim($data); - // XXX add to file list - break; - case 'File': - $role = strtolower($this->current_attributes['Role']); - $this->current_file = trim($data); - break; - case 'LibName': - $this->lib_name = trim($data); - break; - case 'Sources': - $this->lib_sources[] = trim($data); - break; - } - } - - // }}} - // {{{ 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->filelist = array(); - - // 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) { - $this->pkginfo[$k] = trim($v); - } - $this->pkginfo['filelist'] = &$this->filelist; - return $this->pkginfo; - } - - // }}} -} -?>
\ No newline at end of file diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php deleted file mode 100644 index a4c595691a..0000000000 --- a/pear/PEAR/Installer.php +++ /dev/null @@ -1,242 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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 install PEAR packages and maintain the - * installed package database. - * - * TODO: - * - maintain file perms (look at umask or fileperms+chmod), ideas are welcome - * - * @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; - - // }}} - - // {{{ constructor - - function PEAR_Installer($phpdir = PEAR_INSTALL_DIR, - $extdir = PEAR_EXTENSION_DIR, - $docdir = '') - { - $this->PEAR(); - $this->phpdir = $phpdir; - $this->extdir = $extdir; - $this->docdir = $docdir; - $this->statedir = "/var/lib/php"; // XXX FIXME Windows - } - - // }}} - // {{{ destructor - - function _PEAR_Installer() - { - chdir($this->pwd); - if ($this->tmpdir && is_dir($this->tmpdir)) { - system("rm -rf $this->tmpdir"); // XXX FIXME Windows - } - $this->tmpdir = null; - $this->_PEAR_Common(); - } - - // }}} - // {{{ 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) - { - // XXX FIXME Add here code to manage packages database - //$this->loadPackageList("$this->statedir/packages.lst"); - $this->pwd = getcwd(); - $need_download = false; - if (preg_match('#^(http|ftp)://#', $pkgfile)) { - $need_download = true; - } elseif (!@is_file($pkgfile)) { - return $this->raiseError("Could not open the package file: $pkgfile"); - } - // Download package ----------------------------------------------- - if ($need_download) { - $file = basename($pkgfile); - // XXX FIXME use ??? on Windows, use $TMPDIR on unix (use tmpnames?) - $downloaddir = '/tmp/pearinstall'; - if (!$this->mkDirHier($downloaddir)) { - return $this->raiseError("Failed to create tmp dir: $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)"); - } - $this->addTempFile($downloadfile); - $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 pakage directory'); - } - $pkgfile = getcwd() . DIRECTORY_SEPARATOR . basename($pkgfile); - - // XXX FIXME Windows - $this->tmpdir = tempnam('/tmp', 'pear'); - unlink($this->tmpdir); - if (!mkdir($this->tmpdir, 0755)) { - return $this->raiseError("Unable to create temporary directory $this->tmpdir."); - } else { - $this->log(2, '+ tmp dir created at ' . $this->tmpdir); - } - $this->addTempFile($this->tmpdir); - if (!chdir($this->tmpdir)) { - return $this->raiseError("Unable to chdir to $this->tmpdir."); - } - // XXX FIXME Windows - $fp = popen("gzip -dc $pkgfile | tar -xvf -", 'r'); - $this->log(2, "+ launched command: gzip -dc $pkgfile | tar -xvf -"); - if (!is_resource($fp)) { - return $this->raiseError("Unable to examine $pkgfile (gzip or tar failed)"); - } - while ($line = fgets($fp, 4096)) { - $line = rtrim($line); - if (preg_match('!^[^/]+/package.xml$!', $line)) { - if (isset($descfile)) { - return $this->raiseError("Invalid package: multiple package.xml files at depth one!"); - } - $descfile = $line; - } - } - pclose($fp); - if (!isset($descfile) || !is_file($descfile)) { - return $this->raiseError("No package.xml file after extracting the archive."); - } - - // Parse xml file ----------------------------------------------- - $pkginfo = $this->infoFromDescriptionFile($descfile); - if (PEAR::isError($pkginfo)) { - return $pkginfo; - } - - // Copy files to dest dir --------------------------------------- - if (!is_dir($this->phpdir)) { - return $this->raiseError("No script destination directory found\n", - null, PEAR_ERROR_DIE); - } - $tmp_path = dirname($descfile); - foreach ($pkginfo['filelist'] as $fname => $atts) { - $dest_dir = $this->phpdir . DIRECTORY_SEPARATOR; - if (isset($atts['BaseInstallDir'])) { - $dest_dir .= $atts['BaseInstallDir'] . DIRECTORY_SEPARATOR; - } - if (dirname($fname) != '.') { - $dest_dir .= dirname($fname) . DIRECTORY_SEPARATOR; - } - $fname = $tmp_path . DIRECTORY_SEPARATOR . $fname; - $this->_installFile($fname, $dest_dir, $atts); - } - return true; - } - - function _installFile($file, $dest_dir, $atts) - { - $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': - case 'php': - default: - $dest_file = $dest_dir . basename($file); - break; - } - 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"); - } - if (!@copy($file, $dest_file)) { - $this->log(0, "failed to copy $file to $dest_file"); - return false; - } - $this->log(2, "+ copy $file to $dest_file"); - // FIXME Update Package database here - //$this->updatePackageListFrom("$d/$file"); - $this->log(1, "installed file $dest_file"); - return true; - } - // }}} -} -?>
\ No newline at end of file diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php deleted file mode 100644 index b790ac956f..0000000000 --- a/pear/PEAR/Packager.php +++ /dev/null @@ -1,359 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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 - * - preserve file permissions (solve umask in copy problem) - * - * @since PHP 4.0.2 - * @author Stig Bakken <ssb@fast.no> - */ -class PEAR_Packager extends PEAR_Common -{ - // {{{ properties - - /** XML_Parser object */ - var $parser; - - /** 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 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() { - $this->_PEAR(); - while (is_array($this->_tempfiles) && - $file = array_shift($this->_tempfiles)) - { - if (is_dir($file)) { - system("rm -rf $file"); // XXX FIXME Windows - } else { - unlink($file); - } - } - } - - // }}} - - // {{{ package() - - function package($pkgfile = 'package.xml') - { - $pkginfo = $this->infoFromDescriptionFile($pkgfile); - if (PEAR::isError($pkginfo)) { - return $pkginfo; - } - // TMP DIR ------------------------------------------------- - $orig_pwd = getcwd(); - // 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); - $pkgver = $pkginfo['package'] . '-' . $pkginfo['version']; - // don't want strange characters - $pkgver = ereg_replace ('[^a-zA-Z0-9._-]', '_', $pkgver); - $this->tmpdir = $pwd . DIRECTORY_SEPARATOR . $pkgver; - if (file_exists($this->tmpdir)) { - return $this->raiseError('Tmpdir: ' . $this->tmpdir .' already exists', - null, PEAR_ERROR_TRIGGER, E_USER_ERROR); - } - if (!mkdir($this->tmpdir, 0755)) { - return $this->raiseError("Unable to create temporary directory $this->tmpdir.", - null, PEAR_ERROR_TRIGGER, E_USER_ERROR); - } else { - $this->log(2, "+ tmp dir created at: " . $this->tmpdir); - } - $this->_tempfiles[] = $this->tmpdir; - - // Copy files ----------------------------------------------- - foreach ($pkginfo['filelist'] as $fname => $atts) { - $file = $this->tmpdir . DIRECTORY_SEPARATOR . $fname; - $dir = dirname($file); - if (!@is_dir($dir)) { - if (!$this->mkDirHier($dir)) { - return $this->raiseError("could not mkdir $dir"); - } - } - if (!@copy($fname, $file)) { - $this->log(0, "could not copy $fname to $file"); - } else { - $this->log(2, "+ copying from $fname to $file"); - } - } - // XXX TODO: Rebuild the package file as the old method did? - - // This allows build packages from different pear pack def files - if (!@copy($pkgfile, $this->tmpdir . DIRECTORY_SEPARATOR . 'package.xml')) { - return $this->raiseError("could not copy $pkgfile to " . $this->tmpdir); - } - $this->log(2, "+ copying package $pkgfile to " . $this->tmpdir); - - // TAR the Package ------------------------------------------- - chdir(dirname($this->tmpdir)); - $dest_package = $orig_pwd . DIRECTORY_SEPARATOR . "${pkgver}.tgz"; - // XXX FIXME Windows and non-GNU tar - $cmd = "tar -cvzf $dest_package $pkgver"; - $this->log(2, "+ launched cmd: $cmd"); - // XXX TODO: add an extra param where to leave the package? - $this->log(1, `$cmd`); - $this->log(1, "Package $dest_package done"); - chdir($orig_pwd); - return $dest_package; - } - - /* XXXX REMOVEME: this is the old code - function _package($pkgfile = "package.xml") - { - $pwd = getcwd(); - $fp = @fopen($pkgfile, "r"); - if (!is_resource($fp)) { - return $this->raiseError($php_errormsg); - } - - $xp = xml_parser_create(); - if (!$xp) { - return $this->raiseError("Unable to create XML parser."); - } - xml_set_object($xp, $this); - xml_set_element_handler($xp, "startHandler", "endHandler"); - xml_set_character_data_handler($xp, "charHandler"); - xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); - xml_parser_set_option($xp, XML_OPTION_TARGET_ENCODING, "UTF-8"); - - $this->element_stack = array(); - $this->pkginfo = array(); - $this->current_element = false; - - $data = fread($fp, filesize($pkgfile)); - fclose($fp); - if (!xml_parse($xp, $data, true)) { - $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); - - $pkginfofile = $this->tmpdir . DIRECTORY_SEPARATOR . "package.xml"; - $fp = fopen($pkginfofile, "w"); - if (!is_resource($fp)) { - return $this->raiseError("Could not create $pkginfofile: $php_errormsg"); - } - - $this->filelist = preg_replace('/^[\r\n]+\s+/', ' ', $this->filelist); - $this->filelist = preg_replace('/\n\s+/', "\n ", $this->filelist); - $this->filelist = preg_replace('/\n\s+$/', "", $this->filelist); - - fputs($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n". - "<!DOCTYPE Package PUBLIC \"-//PHP Group//DTD PEAR Package 1.0//EN//XML\" \"http://php.net/pear/package.dtd\">\n". - "<Package Type=\"Source\">\n". - " <Name>".$this->pkginfo["Package,Name"]."</Name>\n". - " <Summary>".$this->pkginfo["Package,Summary"]."</Summary>\n". - " <Maintainer>\n". - " <Initials>".$this->pkginfo["Maintainer,Initials"]."</Initials>\n". - " <Name>".$this->pkginfo["Maintainer,Name"]."</Name>\n". - " <Email>".$this->pkginfo["Maintainer,Email"]."</Email>\n". - " </Maintainer>\n". - " <Release>\n". - " <Version>".$this->pkginfo["Release,Version"]."</Version>\n". - " <Date>".$this->pkginfo["Release,Date"]."</Date>\n". - " <Notes>".$this->pkginfo["Release,Notes"]."</Notes>\n". - " </Release>\n". - " <FileList>\n". - "$this->filelist\n". - " </FileList>\n". - "</Package>\n"); - fclose($fp); - chdir(dirname($this->tmpdir)); - // XXX FIXME Windows and non-GNU tar - $pkgver = $this->pkgver; - $cmd = "tar -cvzf $pwd/${pkgver}.tgz $pkgver"; - $this->log(1, `$cmd`); - $this->log(1, "Package $pwd/${pkgver}.tgz done"); - } - - // }}} - - // {{{ startHandler() - - function startHandler($xp, $name, $attribs) - { - array_push($this->element_stack, $name); - $this->current_element = $name; - $this->current_attributes = $attribs; - $this->tmpdata = ''; - if ($this->recordfilelist) { - $this->filelist .= "<$name"; - foreach ($attribs as $k => $v) { - $this->filelist .= " $k=\"$v\""; - } - $this->filelist .= ">"; - } - switch ($name) { - case "Package": - if ($attribs["Type"]) { - // warning - } - break; - case "FileList": - // XXX FIXME Windows - $this->recordfilelist = true; - $pwd = getcwd(); - $this->pkgver = $this->pkginfo["Package,Name"] . "-" . - $this->pkginfo["Release,Version"]; - // don't want extrange characters - $this->pkgver = ereg_replace ("[^a-zA-Z0-9._-]", '_', $this->pkgver); - $this->tmpdir = $pwd . DIRECTORY_SEPARATOR . $this->pkgver; - if (file_exists($this->tmpdir)) { - xml_parser_free($xp); - $this->raiseError("$this->tmpdir already exists", - null, PEAR_ERROR_TRIGGER, - E_USER_ERROR); - } - if (!mkdir($this->tmpdir, 0755)) { - xml_parser_free($xp); - $this->raiseError("Unable to create temporary directory $this->tmpdir.", - null, PEAR_ERROR_TRIGGER, - E_USER_ERROR); - } - $this->_tempfiles[] = $this->tmpdir; - break; - } - } - - // }}} - // {{{ endHandler() - - function endHandler($xp, $name) - { - array_pop($this->element_stack); - $this->current_element = $this->element_stack[sizeof($this->element_stack)-1]; - switch ($name) { - case "FileList": - $this->recordfilelist = false; - break; - } - if ($this->recordfilelist) { - $this->filelist .= "</$name>"; - } - } - - // }}} - // {{{ charHandler() - - function charHandler($xp, $data) - { - if ($this->recordfilelist) { - $this->filelist .= $data; - } - switch ($this->current_element) { - case "Dir": - break; - case "File": - $file = "$this->tmpdir/$data"; - $dir = dirname($file); - if (!is_dir($dir)) { - if (!$this->mkDirHier($dir)) { - $this->log(0, "could not mkdir $dir"); - break; - } - } - if (!@copy($data, $file)) { - $this->log(0, "could not copy $data to $file"); - } - // fall through - default: - $data = trim($data); - if ($data) { - $id = implode(",", array_slice($this->element_stack, -2)); - $this->pkginfo[$id] = $data; - } - break; - } - } - */ - // }}} -} - -?> diff --git a/pear/PEAR/Packlist.php b/pear/PEAR/Packlist.php deleted file mode 100644 index f898968f1b..0000000000 --- a/pear/PEAR/Packlist.php +++ /dev/null @@ -1,254 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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/Common.php"; - -/** - * Administration class used to maintain the installed package database. - * - * THIS CLASS IS EXPERIMENTAL - */ -class PEAR_Packlist -{ - /** directory where system state information goes */ - var $statedir; - - /** list of installed packages */ - var $pkglist = array(); - - /** temporary directory */ - var $tmpdir; - - /** file pointer for package list file if open */ - var $pkglist_fp; - - // {{{ constructor - - function PEAR_Packlist($phpdir = PEAR_INSTALL_DIR, - $extdir = PEAR_EXTENSION_DIR, - $docdir = '') - { - $this->PEAR(); - $this->phpdir = $phpdir; - $this->extdir = $extdir; - $this->docdir = $docdir; - $this->statedir = "/var/lib/php"; // XXX FIXME Windows - } - - // }}} - // {{{ destructor - - function _PEAR_Packlist() - { - if ($this->tmpdir && is_dir($this->tmpdir)) { - system("rm -rf $this->tmpdir"); // XXX FIXME Windows - } - if (isset($this->pkglist_fp) && is_resource($this->pkglist_fp)) { - flock($this->pkglist_fp, LOCK_UN); - fclose($this->pkglist_fp); - } - $this->tmpdir = null; - $this->pkglist_fp = null; - $this->_PEAR_Common(); - } - - // }}} - - // {{{ lockPackageList() - - function lockPackageList() - { - $fp = $this->pkglist_fp; - if (!is_resource($fp)) { - $this->pkglist_fp = $fp = fopen($this->pkglist_file, "r"); - } - return flock($fp, LOCK_EX); - } - - // }}} - // {{{ unlockPackageList() - - function unlockPackageList() - { - $fp = $this->pkglist_fp; - if (!is_resource($fp)) { - $this->pkglist_fp = $fp = fopen($this->pkglist_file, "r"); - $doclose = true; - } - $ret = flock($fp, LOCK_EX); - if ($doclose) { - fclose($fp); - } - return $ret; - } - - // }}} - // {{{ loadPackageList() - - function loadPackageList($file) - { - $this->pkglist_file = $file; - $this->pkglist = array(); - if (!file_exists($file)) { - if (!@touch($file)) { - return $this->raiseError("touch($file): $php_errormsg"); - } - } - $fp = $this->pkglist_fp = @fopen($file, "r"); - if (!is_resource($fp)) { - return $this->raiseError("fopen($file): $php_errormsg"); - } - $this->lockPackageList(); - $versionline = trim(fgets($fp, 2048)); - if ($versionline == ";1") { - while ($line = fgets($fp, 2048)) { - list($name, $version, $file) = explode(";", trim($line)); - $this->pkglist[$name]["version"] = $version; - $this->pkglist[$name]["files"][] = $file; - } - } - $this->unlockPackageList(); - } - - // }}} - // {{{ savePackageList() - - function savePackageList() - { - $fp = $this->pkglist_fp; - $wfp = @fopen($this->pkglist_file, "w"); - if (!is_resource($wfp)) { - return $this->raiseError("could not write $this->pkglist_file"); - } - if (is_resource($fp)) { - fclose($fp); - } - $this->pkglist_fp = $fp = $wfp; - fwrite($fp, ";1\n"); - foreach ($this->pkglist as $name => $entry) { - $ver = $entry["version"]; - foreach ($entry["files"] as $file) { - fwrite($fp, "$name;$ver;$file\n"); - } - } - fclose($fp); - $this->pkglist_fp = $fp = null; - } - - // }}} - // {{{ updatePackageListFrom() - - function updatePackageListFrom($file) - { - /* - $new = $this->classesDeclaredBy($file); - reset($new); - while (list($i, $name) = each($new)) { - $this->pkglist['class'][$name] = $file; - } - */ - } - - // }}} - // {{{ classesDeclaredBy() - - /** - * Find out which new classes are defined by a file. - * - * @param $file file name passed to "include" - * - * @return array classes that were defined - */ - function classesDeclaredBy($file) - { - $before = get_declared_classes(); - ob_start(); - include($file); - ob_end_clean(); - $after = get_declared_classes(); - // using array_slice to renumber array - $diff = array_slice(array_diff($after, $before), 0); - return $diff; - } - - // }}} - - // {{{ declaredWhenIncluding() - - /** - * Find out which new classes are defined by a file. - * - * @param $file file name passed to "include" - * - * @return array classes that were defined - */ - function &declaredWhenIncluding($file) - { - $classes_before = get_declared_classes(); - $funcs_before = get_defined_functions(); -// $vars_before = $GLOBALS; - ob_start(); - include($file); - ob_end_clean(); - $classes_after = get_declared_classes(); - $funcs_after = get_defined_functions(); -// $vars_after = $GLOBALS; - //using array_slice to renumber array - return array( - "classes" => array_slice(array_diff($classes_after, $classes_before), 0), - "functions" => array_slice(array_diff($funcs_after, $funcs_before), 0), -// "globals" => array_slice(array_diff($vars_after, $vars_before), 0) - ); - } - - // }}} - - // {{{ lockDir() - - /** - * Uses advisory locking (flock) to temporarily claim $dir as its - * own. - * - * @param $dir the directory to lock - * - * @return bool true if successful, false if not - */ - function lockDir($dir) - { - $lockfile = "$dir/.lock"; - if (!file_exists($lockfile)) { - if (!touch($lockfile)) { - // could not create lockfile! - return false; - } - } - $fp = fopen($lockfile, "r"); - if (!flock($fp, LOCK_EX)) { - // could not create lock! - return false; - } - return true; - } - - // }}} - -} -?>
\ No newline at end of file diff --git a/pear/PEAR/Uploader.php b/pear/PEAR/Uploader.php deleted file mode 100644 index 593a92d01b..0000000000 --- a/pear/PEAR/Uploader.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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 5fb7c46aec..0000000000 --- a/pear/PEAR/WebInstaller.php +++ /dev/null @@ -1,627 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4; */ -// +---------------------------------------------------------------------+ -// | PHP version 4.0 | -// +---------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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=\"#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 ($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 ( 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 to 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 "Initials": - $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, false); - - $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 = implode("",file(__FILE__)); - $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"; - } - -} - -?> diff --git a/pear/README b/pear/README deleted file mode 100644 index bed22c7106..0000000000 --- a/pear/README +++ /dev/null @@ -1,34 +0,0 @@ - PEAR - PHP Extension and Application Repository - =============================================== - Dedicated to Malin Bakken, born 1999-11-21 - -WHAT IS PEAR? - -PEAR is a code repository for PHP extensions and PHP library code -similar to TeX's CTAN and Perl's CPAN. - -The intention behind PEAR is to provide a means for library code -authors to organize their code in a defined way shared by other -developers, and to give the PHP community a single source for such -code. - - -ADMINISTRATION - -This section will describe the rules for how files are structured and -how functions and classes should be named. - - -TOOLS - -This section will describe the tools provided to PEAR users. - - -CODING RULES AND GUIDELINES - -* All PHP code must use <?php ?>. This is the only really portable tag. - -* Before adding a new top-level directory ("DB" is one), discuss your - intentions on php-pear@lists.php.net. - -* Please see the CODING_STANDARDS file for full rules and guidelines. diff --git a/pear/TODO b/pear/TODO deleted file mode 100644 index 64dde1b275..0000000000 --- a/pear/TODO +++ /dev/null @@ -1,20 +0,0 @@ -TODO file for PEAR. Last modified $Date$ by $Author$ - -Legend: - --: noone actively working on this right now -W: work in progress by NN - -Infrastructure stuff: - -- finish database design -W ssb make XML DTD for package description files -- build web site for uploading/downloading packages and XML - description files -W ssb build tools for installing packages from the net - -Bundled PEAR packages: - -W ssb make regression tests for DB -- make DB_Error store queries -W uw implement Javadoc -> phpdoc/DocBook conversion diff --git a/pear/catalog b/pear/catalog deleted file mode 100644 index 6e0c69d40b..0000000000 --- a/pear/catalog +++ /dev/null @@ -1 +0,0 @@ -PUBLIC "-//PHP Group//DTD PEAR Package 1.0//EN//XML" "package.dtd" diff --git a/pear/install-pear.txt b/pear/install-pear.txt deleted file mode 100644 index 3cb9338a40..0000000000 --- a/pear/install-pear.txt +++ /dev/null @@ -1,11 +0,0 @@ -+----------------------------------------------------------------------+ -| The installation process is incomplete. The following resources were | -| not installed: | -| | -| Self-contained Extension Support | -| PEAR: PHP Extension and Add-on Repository | -| | -| To install these components, become the superuser and execute: | -| | -| # make install-su | -+----------------------------------------------------------------------+ diff --git a/pear/package.dtd b/pear/package.dtd deleted file mode 100644 index e45c436dea..0000000000 --- a/pear/package.dtd +++ /dev/null @@ -1,125 +0,0 @@ -<!-- - $Id: package.dtd,v 1.6 2001-05-28 11:14:47 ssb Exp $ - - This is the PEAR package description, version 1.1b1. - It should be used with the informal public identifier: - - "-//PHP Group//DTD PEAR Package 1.1b1//EN//XML" - - Copyright (c) 1997-2001 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 S. Bakken <ssb@fast.no> - - --> -<!--============== attributes present in all elements ======================--> -<!ENTITY % global.atts "id ID #IMPLIED"> -<!--============== attributes common to several elements ===================--> -<!ENTITY % role.atts "Role (php|ext|test|doc) 'php'"> -<!ENTITY % extension.atts "Debug (on|off) 'off' - ThreadSafe (on|off) 'off'"> -<!ENTITY % format.atts "Format CDATA #IMPLIED"> -<!--=============== ELEMENT: Package =======================================--> -<!ELEMENT Package (Name, Summary, Maintainer, Release, FileList)> -<!ATTLIST Package - %global.atts; - Type (Source | Binary | Empty) "Empty" -> -<!--=============== ELEMENT: Name ==========================================--> -<!ELEMENT Name (#PCDATA)> -<!ATTLIST Name - %global.atts; -> -<!--=============== ELEMENT: Summary =======================================--> -<!ELEMENT Summary (#PCDATA)> -<!ATTLIST Summary - %global.atts; -> -<!--=============== ELEMENT: Maintainer ====================================--> -<!ELEMENT Maintainer (Initials, Name, Email)> -<!ATTLIST Maintainer - %global.atts; -> -<!--=============== ELEMENT: Initials ======================================--> -<!ELEMENT Initials (#PCDATA)> -<!ATTLIST Initials - %global.atts; -> -<!--=============== ELEMENT: Email =========================================--> -<!ELEMENT Email (#PCDATA)> -<!ATTLIST Email - %global.atts; -> -<!--=============== ELEMENT: Release =======================================--> -<!ELEMENT Release (Version, Date, Notes?)> -<!ATTLIST Release - %global.atts; -> -<!--=============== ELEMENT: Version =======================================--> -<!ELEMENT Version (#PCDATA)> -<!ATTLIST Version - %global.atts; -> -<!--=============== ELEMENT: Date =========================================--> -<!ELEMENT Date (#PCDATA)> -<!ATTLIST Date - %global.atts; -> -<!--=============== ELEMENT: Notes =========================================--> -<!ELEMENT Notes (#PCDATA)> -<!ATTLIST Notes - %global.atts; -> -<!--=============== ELEMENT: FileList ======================================--> -<!ELEMENT FileList (Dir | File | LibFile)*> -<!ATTLIST FileList - %global.atts; -> -<!--=============== ELEMENT: Dir ===========================================--> -<!ELEMENT Dir (#PCDATA)> -<!ATTLIST Dir - %global.atts; -> -<!--=============== ELEMENT: File ==========================================--> -<!ELEMENT File (#PCDATA)> -<!ATTLIST File - %global.atts; - %role.atts; - %extension.atts; - %format.atts; -> -<!--=============== ELEMENT: LibFile =======================================--> -<!ELEMENT LibFile (LibName,Sources,Includes?,LibAdd?)> -<!ATTLIST LibFile - %global.atts; - %role.atts; -> -<!--=============== ELEMENT: LibFile =======================================--> -<!ELEMENT LibFile (LibName,Sources,Includes?,LibAdd?)> -<!ATTLIST LibFile - %global.atts; - %role.atts; -> -<!--=============== ELEMENT: LibName =======================================--> -<!ELEMENT LibName (#PCDATA)> -<!ATTLIST LibName - %global.atts; -> -<!--=============== ELEMENT: Sources =======================================--> -<!ELEMENT Sources (#PCDATA)> -<!ATTLIST Sources - %global.atts; -> -<!--=============== ELEMENT: LibAdd ========================================--> -<!ELEMENT LibAdd (#PCDATA)> -<!ATTLIST LibAdd - %global.atts; -> diff --git a/pear/pear.m4 b/pear/pear.m4 deleted file mode 100644 index 92ec102bb6..0000000000 --- a/pear/pear.m4 +++ /dev/null @@ -1,87 +0,0 @@ - -AC_INIT(Makefile.in) - -AC_DEFUN(PHP_WITH_PHP_CONFIG,[ - AC_ARG_WITH(php-config, -[ --with-php-config=PATH],[ - PHP_CONFIG=$withval -],[ - PHP_CONFIG=php-config -]) - - prefix=`$PHP_CONFIG --prefix 2>/dev/null` - INCLUDES=`$PHP_CONFIG --includes 2>/dev/null` - EXTENSION_DIR=`$PHP_CONFIG --extension-dir` - - if test -z "$prefix"; then - AC_MSG_ERROR(Cannot find php-config. Please use --with-php-config=PATH) - fi - AC_MSG_CHECKING(for PHP prefix) - AC_MSG_RESULT($prefix) - AC_MSG_CHECKING(for PHP includes) - AC_MSG_RESULT($INCLUDES) - AC_MSG_CHECKING(for PHP extension directory) - AC_MSG_RESULT($EXTENSION_DIR) -]) - -abs_srcdir=`(cd $srcdir && pwd)` - -php_always_shared=yes - -AC_PROG_CC -AC_PROG_CC_C_O - -PHP_WITH_PHP_CONFIG - -AC_PREFIX_DEFAULT() - -sinclude(config.m4) - -enable_static=no -enable_shared=yes - -AC_PROG_LIBTOOL - -SHARED_LIBTOOL='$(LIBTOOL)' -PHP_COMPILE='$(LIBTOOL) --mode=compile $(COMPILE) -c $<' -phplibdir="`pwd`/modules" -CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H" - -test "$prefix" = "NONE" && prefix="/usr/local" -test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)' - -PHP_SUBST(prefix) -PHP_SUBST(exec_prefix) -PHP_SUBST(libdir) -PHP_SUBST(prefix) -PHP_SUBST(phplibdir) - -PHP_SUBST(PHP_COMPILE) -PHP_SUBST(CC) -PHP_SUBST(CFLAGS) -PHP_SUBST(CPP) -PHP_SUBST(CPPFLAGS) -PHP_SUBST(CXX) -PHP_SUBST(DEFS) -PHP_SUBST(EXTENSION_DIR) -PHP_SUBST(EXTRA_LDFLAGS) -PHP_SUBST(EXTRA_LIBS) -PHP_SUBST(INCLUDES) -PHP_SUBST(LEX) -PHP_SUBST(LEX_OUTPUT_ROOT) -PHP_SUBST(LFLAGS) -PHP_SUBST(SHARED_LIBTOOL) -PHP_SUBST(LIBTOOL) -PHP_SUBST(SHELL) - -PHP_FAST_OUTPUT(Makefile) - -PHP_GEN_CONFIG_VARS -PHP_GEN_MAKEFILES($PHP_FAST_OUTPUT_FILES) - -test -d modules || mkdir modules -touch .deps - -AC_CONFIG_HEADER(config.h) - -AC_OUTPUT() diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in deleted file mode 100644 index 08adc72573..0000000000 --- a/pear/scripts/pear.in +++ /dev/null @@ -1,116 +0,0 @@ -#!@prefix@/bin/php -Cq -<?php // -*- C++ -*- -// -// +----------------------------------------------------------------------+ -// | PHP version 4.0 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2001 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> | -// +----------------------------------------------------------------------+ -// -require_once 'PEAR.php'; -require_once 'Console/Getopt.php'; - -error_reporting(E_ALL ^ E_NOTICE); - -$options = Console_Getopt::getopt($argv, "h?v:e:p:d:"); -if (PEAR::isError($options)) { - usage($options); -} - -$opts = $options[0]; -foreach ($opts as $opt) { - $param = $opt[1]; - switch ($opt[0]) { - case 'v': - $verbose = $param; - break; - case 'e': - if ($param{0} != DIRECTORY_SEPARATOR) { - usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); - } - $ext_dir = $param; - break; - case 'p': - if ($param{0} != DIRECTORY_SEPARATOR) { - usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); - } - $script_dir = $param; - break; - case 'd': - if ($param{0} != DIRECTORY_SEPARATOR) { - usage (new PEAR_Error("no absolute path (ej. /usr/lib/php)\n")); - } - $doc_dir = $param; - break; - } -} - -$verbose = (isset($verbose)) ? $verbose : 1; -$script_dir = (isset($script_dir)) ? $script_dir : PEAR_INSTALL_DIR; -$ext_dir = (isset($ext_dir)) ? $ext_dir : PEAR_EXTENSION_DIR; -$doc_dir = (isset($doc_dir)) ? $doc_dir : ''; - -PEAR::setErrorHandling(PEAR_ERROR_PRINT); -$command = $options[1][1]; -switch ($command) { - case 'install': - include_once 'PEAR/Installer.php'; - $package = $options[1][2]; - $installer =& new PEAR_Installer($script_dir, $ext_dir, $doc_dir); - $installer->debug = $verbose; - if (PEAR::isError($installer->Install($package))) { - print "\ninstall failed\n"; - } else { - print "install ok\n"; - } - break; - case 'package': - include_once 'PEAR/Packager.php'; - $pkginfofile = $options[1][2]; - $packager =& new PEAR_Packager($script_dir, $ext_dir, $doc_dir); - $packager->debug = $verbose; - if (PEAR::isError($packager->Package($pkginfofile))) { - print "\npackage failed\n"; - } else { - print "package ok\n"; - } - break; - default: - usage(); - break; -} - -function usage($obj = null) -{ - $stderr = fopen('php://stderr', 'w'); - if ($obj !== null) { - fputs($stderr, $obj->getMessage()); - } - fputs($stderr, - "Usage: pear [-v n] [-h] [-p <dir>] [-e <dir>] [-d <dir>] command <parameters>\n". - "Options:\n". - " -v set verbosity level to <n> (0-2, default 1)\n". - " -p <dir> set script install dir (absolute path)\n". - " -e <dir> set extension install dir (absolute path)\n". - " -d <dir> set documentation dest dir (absolute path)\n". - " -h, -? display help/usage (this message)\n". - "Commands:\n". - " install <package file>\n". - " package [package info file]\n". - "\n"); - fclose($stderr); - exit; -} - -?> diff --git a/pear/scripts/pearize.in b/pear/scripts/pearize.in deleted file mode 100644 index 332f3333aa..0000000000 --- a/pear/scripts/pearize.in +++ /dev/null @@ -1,172 +0,0 @@ -#!@prefix@/bin/php -Cq -<?php // -*- PHP -*- - -main($argc, $argv, $HTTP_ENV_VARS); - -// {{{ main() - -function main(&$argc, &$argv, &$env) -{ - $file = check_options($argc, $argv, $env); - parse_package_file($file); - make_makefile_in($env); -} - -// }}} -// {{{ check_options() - -function check_options(&$argc, &$argv, &$env) -{ - $file = $argv[1]; - if (empty($file)) { - $file = "package.xml"; - } - return $file; -} - -// }}} -// {{{ make_makefile_in() - -function make_makefile_in(&$env) -{ - global $libdata; - if (sizeof($libdata) == 0) { - exit; - } elseif (sizeof($libdata) > 1) { - die("No support yet for multiple libraries in one package.\n"); - } - - $wp = @fopen("Makefile.in", "w"); - if (is_resource($wp)) { - print "Creating Makefile.in..."; - flush(); - } else { - die("Could not create Makefile.in in current directory.\n"); - } - - foreach ($libdata as $lib => $info) { - extract($info); - $_who = $env["USER"]; - $_when = gmdate('Y-m-d h:i'); - fwrite($wp, "\ -# This file was generated by `pearize' by $_who at $_when GMT -INCLUDES = $includes -LTLIBRARY_NAME = lib{$lib}.la -LTLIBRARY_SOURCES = $sources -LTLIBRARY_SHARED_NAME = {$lib}.la -LTLIBRARY_SHARED_LIBADD = $libadd - -include \$(top_srcdir)/build/dynlib.mk -"); - } - fclose($wp); - print "done.\n"; -} - -// }}} -// {{{ parse_package_file() - -function parse_package_file($file) -{ - global $in_file, $curlib, $curelem, $libdata, $cdata; - - $in_file = false; - $curlib = ''; - $curelem = ''; - $libdata = array(); - $cdata = array(); - - $xp = xml_parser_create(); - xml_set_element_handler($xp, "start_handler", "end_handler"); - xml_set_character_data_handler($xp, "cdata_handler"); - xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); - - $fp = @fopen($file, "r"); - if (!is_resource($fp)) { - die("Could not open file `$file'.\n"); - } - while (!feof($fp)) { - xml_parse($xp, fread($fp, 2048), feof($fp)); - } - xml_parser_free($xp); -} - -// }}} -// {{{ start_handler() - -function start_handler($xp, $elem, $attrs) -{ - global $cdata, $in_file, $curelem; - switch ($elem) { - case "File": { - switch ($attrs['Role']) { - case "ext": { - $in_file = true; - $cdata = array(); - break; - } - case "php": default: { - break; - } - } - break; - } - case "Includes": - case "LibName": - case "LibAdd": - case "Sources": { - $curelem = $elem; - break; - } - } -} - -// }}} -// {{{ end_handler() - -function end_handler($xp, $elem) -{ - global $in_file, $curlib, $curelem, $libdata, $cdata; - switch ($elem) { - case "File": { - if ($in_file === true) { - $libname = trim($cdata['LibName']); - $libdata[$libname] = array( - "sources" => trim($cdata['Sources']), - "includes" => trim($cdata['Includes']), - "libadd" => trim($cdata['LibAdd']), - ); - $in_file = false; - } - break; - } - } -} - -// }}} -// {{{ cdata_handler() - -function cdata_handler($xp, $data) -{ - global $curelem, $cdata; - switch ($curelem) { - case "Includes": - case "LibAdd": - case "LibName": - case "Sources": { - $cdata[$curelem] .= $data; - break; - } - } -} - -// }}} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - */ -?> diff --git a/pear/scripts/php-config.in b/pear/scripts/php-config.in deleted file mode 100644 index 62acb5ac68..0000000000 --- a/pear/scripts/php-config.in +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh - -prefix="@prefix@" -includedir="@includedir@/php" -includes="-I$includedir -I$includedir/main -I$includedir/Zend" -if test '@TSRM_DIR@' != ''; then - includes="$includes -I$includedir/TSRM" -fi -extension_dir='@EXTENSION_DIR@' - -case "$1" in ---prefix) - echo $prefix;; ---includes) - echo $includes;; ---extension-dir) - echo $extension_dir;; -*) - echo "Usage: $0 [--prefix|--includes|--extension-dir]" - exit 1;; -esac - -exit 0 diff --git a/pear/scripts/phpextdist b/pear/scripts/phpextdist deleted file mode 100755 index 97df70020d..0000000000 --- a/pear/scripts/phpextdist +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh -if test $# -lt 2; then - echo "usage: phpextdist <extension> <version>"; - exit 1 -fi - -phpize=`php-config --prefix`/bin/phpize -distname="$1-$2" - -if test ! -f Makefile.in || test ! -f config.m4; then - echo "Did not find required files in current directory" - exit 1 -fi - -rm -rf modules *.lo *.o *.la config.status config.cache \ -config.log libtool php_config.h config_vars.mk Makefile - -myname=`basename \`pwd\`` -cd .. -cp -rp $myname $distname -cd $distname -$phpize -cd .. -tar cf $distname.tar $distname -rm -rf $distname $distname.tar.* -gzip --best $distname.tar -mv $distname.tar.gz $myname diff --git a/pear/scripts/phpize.in b/pear/scripts/phpize.in deleted file mode 100644 index 33b5ad2cfb..0000000000 --- a/pear/scripts/phpize.in +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/sh - -prefix='@prefix@' -phpdir="$prefix/lib/php/build" -builddir="`pwd`" -FILES_BUILD="dynlib.mk fastgen.sh library.mk ltlib.mk mkdep.awk program.mk rules.mk rules_common.mk rules_pear.mk shtool" -FILES="acinclude.m4 dynlib.m4" - -if test ! -r config.m4; then - echo "Cannot find config.m4. " - echo "Make sure that you run $0 in the top level source directory of the module" - exit 1 -fi - -test -d build || mkdir build - -(cd $phpdir && cp $FILES_BUILD $builddir/build) -(cd $phpdir && cp $FILES $builddir) - -mv build/rules_pear.mk build/rules.mk - -sed \ --e "s#@prefix@#$prefix#" \ -< $phpdir/pear.m4 > configure.in - -touch install-sh mkinstalldirs missing - -aclocal -autoconf -autoheader -libtoolize -f -c diff --git a/pear/tests/PEAR.r b/pear/tests/PEAR.r deleted file mode 100644 index e8210eee35..0000000000 --- a/pear/tests/PEAR.r +++ /dev/null @@ -1,3 +0,0 @@ -test class __TestPEAR1 -PEAR constructor called, class=__testpear1 -string(11) "__testpear1" diff --git a/pear/tests/PEAR.t b/pear/tests/PEAR.t deleted file mode 100644 index 6c8346adc7..0000000000 --- a/pear/tests/PEAR.t +++ /dev/null @@ -1,16 +0,0 @@ -<?php // -*- C++ -*- - -require_once "PEAR.php"; - -class __TestPEAR1 extends PEAR { - function __TestPEAR1() { - $this->_debug = true; - $this->PEAR(); - } -} - -print "test class __TestPEAR1\n"; -$o = new __TestPEAR1; -var_dump(get_class($o)); - -?> diff --git a/pear/tests/PEAR_Error.r b/pear/tests/PEAR_Error.r deleted file mode 100644 index fce8a664a7..0000000000 --- a/pear/tests/PEAR_Error.r +++ /dev/null @@ -1,20 +0,0 @@ -new PEAR_Error object(pear_error)(8) { - ["classname"]=> - string(10) "pear_error" - ["error_message_prefix"]=> - string(0) "" - ["error_prepend"]=> - string(0) "" - ["error_append"]=> - string(0) "" - ["mode"]=> - int(0) - ["level"]=> - int(1024) - ["message"]=> - string(13) "unknown error" - ["code"]=> - int(0) -} -isError 1 bool(true) -isError 2 bool(false) diff --git a/pear/tests/PEAR_Error.t b/pear/tests/PEAR_Error.t deleted file mode 100644 index 4fae7b4cda..0000000000 --- a/pear/tests/PEAR_Error.t +++ /dev/null @@ -1,18 +0,0 @@ -<?php // -*- C++ -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::isError static method -// testing PEAR_Error - -require_once "PEAR.php"; - -print "new PEAR_Error "; -var_dump($err = new PEAR_Error); -print "isError 1 "; -var_dump(PEAR::isError($err)); -print "isError 2 "; -$str = "not an error"; -var_dump(PEAR::isError($str)); - -?> diff --git a/pear/tests/pear1.phpt b/pear/tests/pear1.phpt deleted file mode 100644 index 07b737f5bc..0000000000 --- a/pear/tests/pear1.phpt +++ /dev/null @@ -1,58 +0,0 @@ ---TEST-- -PEAR constructor/destructor test ---SKIPIF-- ---FILE-- -<?php - -require_once "PEAR.php"; - -class TestPEAR extends PEAR { - function TestPEAR($name) { - $this->_debug = true; - $this->name = $name; - $this->PEAR(); - } - function _TestPEAR() { - print "This is the TestPEAR($this->name) destructor\n"; - $this->_PEAR(); - } -} - -class Test2 extends PEAR { - function _Test2() { - print "This is the Test2 destructor\n"; - $this->_PEAR(); - } -} - -class Test3 extends Test2 { -} - -print "testing plain destructors\n"; -$o = new TestPEAR("test1"); -$p = new TestPEAR("test2"); -print "..\n"; -print "testing inherited destructors\n"; -$q = new Test3; - -print "..\n"; -print "script exiting...\n"; -print "..\n"; - -?> ---GET-- ---POST-- ---EXPECT-- -testing plain destructors -PEAR constructor called, class=testpear -PEAR constructor called, class=testpear -.. -testing inherited destructors -.. -script exiting... -.. -This is the TestPEAR(test1) destructor -PEAR destructor called, class=testpear -This is the TestPEAR(test2) destructor -PEAR destructor called, class=testpear -This is the Test2 destructor diff --git a/pear/tests/pear_error.phpt b/pear/tests/pear_error.phpt deleted file mode 100644 index e42085403b..0000000000 --- a/pear/tests/pear_error.phpt +++ /dev/null @@ -1,128 +0,0 @@ ---TEST-- -PEAR_Error test ---SKIPIF-- ---FILE-- -<?php // -*- C++ -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::isError static method -// testing PEAR_Error - -require_once "PEAR.php"; - -error_reporting(4095); - -class Foo_Error extends PEAR_Error { - function Foo_Error($message = "unknown error", $code = null, - $mode = null, $options = null, $userinfo = null) - { - $this->PEAR_Error($message, $code, $mode, $options, $userinfo); - $this->error_message_prefix = 'Foo_Error prefix'; - } -} - -class Test1 extends PEAR { - function Test1() { - $this->PEAR("Foo_Error"); - } - function runtest() { - return $this->raiseError("test error"); - } -} - -function errorhandler(&$obj) { - print "errorhandler function called, obj=".$obj->toString()."\n"; -} - -class errorclass { - function errorhandler(&$obj) { - print "errorhandler method called, obj=".$obj->toString()."\n"; - } -} - -print "specify error class: "; -$obj = new Test1; -$err = $obj->runtest(); -print $err->toString() . "\n"; - -$eo = new errorclass; - -print "default PEAR_Error: "; -$err = new PEAR_Error; -print $err->toString() . "\n"; -print "Testing it: "; -var_dump(PEAR::isError($err)); -print "This is not an error: "; -$str = "not an error"; -var_dump(PEAR::isError($str)); - -print "Now trying a bunch of variations...\n"; - -print "different message: "; -$err = new PEAR_Error("test error"); -print $err->toString() . "\n"; - -print "different message,code: "; -$err = new PEAR_Error("test error", -42); -print $err->toString() . "\n"; - -print "mode=print: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_PRINT); -print $err->toString() . "\n"; - -print "mode=callback(function): "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_CALLBACK, "errorhandler"); - -print "mode=callback(method): "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_CALLBACK, - array(&$eo, "errorhandler")); - -print "mode=print&trigger: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_PRINT|PEAR_ERROR_TRIGGER); -print $err->toString() . "\n"; - -print "mode=trigger: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER); -print $err->toString() . "\n"; - -print "mode=trigger,level=notice: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER, E_USER_NOTICE); -print $err->toString() . "\n"; - -print "mode=trigger,level=warning: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER, E_USER_WARNING); -print $err->toString() . "\n"; - -print "mode=trigger,level=error: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER, E_USER_ERROR); -print $err->toString() . "\n"; - -?> ---GET-- ---POST-- ---EXPECT-- -specify error class: [foo_error: message="test error" code=0 mode=return level=notice prefix="Foo_Error prefix" prepend="" append="" info=""] -default PEAR_Error: [pear_error: message="unknown error" code=0 mode=return level=notice prefix="" prepend="" append="" info=""] -Testing it: bool(true) -This is not an error: bool(false) -Now trying a bunch of variations... -different message: [pear_error: message="test error" code=0 mode=return level=notice prefix="" prepend="" append="" info=""] -different message,code: [pear_error: message="test error" code=-42 mode=return level=notice prefix="" prepend="" append="" info=""] -mode=print: test error[pear_error: message="test error" code=-42 mode=print level=notice prefix="" prepend="" append="" info=""] -mode=callback(function): errorhandler function called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorhandler prefix="" prepend="" append="" info=""] -mode=callback(method): errorhandler method called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorclass::errorhandler prefix="" prepend="" append="" info=""] -mode=print&trigger: test error<br> -<b>Notice</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> -[pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" prepend="" append="" info=""] -mode=trigger: <br> -<b>Notice</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> -[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""] -mode=trigger,level=notice: <br> -<b>Notice</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> -[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""] -mode=trigger,level=warning: <br> -<b>Warning</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> -[pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" prepend="" append="" info=""] -mode=trigger,level=error: <br> -<b>Fatal error</b>: test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br> diff --git a/pear/tests/pear_error2.phpt b/pear/tests/pear_error2.phpt deleted file mode 100644 index 8d2531380e..0000000000 --- a/pear/tests/pear_error2.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -PEAR_Error in die mode ---SKIPIF-- ---FILE-- -<?php // -*- C++ -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::isError static method -// testing PEAR_Error - -require_once "PEAR.php"; - -error_reporting(4095); - -print "mode=die: "; -$err = new PEAR_Error("test error!!\n", -42, PEAR_ERROR_DIE); -print $err->toString() . "\n"; - -?> ---GET-- ---POST-- ---EXPECT-- -mode=die: test error!! diff --git a/pear/tests/pear_error3.phpt b/pear/tests/pear_error3.phpt deleted file mode 100644 index 4703a222b6..0000000000 --- a/pear/tests/pear_error3.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -PEAR default error handling ---FILE-- -<?php // -*- C++ -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::setErrorHandling -// - PEAR::raiseError method - -require_once "PEAR.php"; - -error_reporting(4095); - -function errorhandler($eobj) -{ - if (PEAR::isError($eobj)) { - print "errorhandler called with an error object.\n"; - print "error message: ".$eobj->getMessage()."\n"; - } else { - print "errorhandler called, but without an error object.\n"; - } -} - -$obj = new PEAR; -$obj->setErrorHandling(PEAR_ERROR_PRINT); -$obj->raiseError("error 1\n"); -$obj->setErrorHandling(null); -$obj->raiseError("error 2\n"); -PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "errorhandler"); -$obj->raiseError("error 3\n"); -$obj->setErrorHandling(PEAR_ERROR_PRINT); -$obj->raiseError("error 4\n"); - -?> ---EXPECT-- -error 1 -errorhandler called with an error object. -error message: error 3 -error 4 diff --git a/pear/tests/php.ini b/pear/tests/php.ini deleted file mode 100644 index c75c9b4f11..0000000000 --- a/pear/tests/php.ini +++ /dev/null @@ -1,2 +0,0 @@ -; php.ini for PEAR tests -include_path=.. |