diff options
author | SVN Migration <svn@php.net> | 2002-05-19 13:54:38 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2002-05-19 13:54:38 +0000 |
commit | 62e263f01ef567ae3926739f37d13cac17fe7739 (patch) | |
tree | 353ff240a432d453632dcad134524cbb9e0ea610 /pear | |
parent | e3490f1429d8f03c16d8cef7cd835c3fb2d5b43e (diff) | |
download | php-git-php-4.3.0dev-ZendEngine2.tar.gz |
This commit was manufactured by cvs2svn to create tagphp-4.3.0dev-ZendEngine2
'php_4_3_0_dev_ZendEngine2'.
Diffstat (limited to 'pear')
65 files changed, 0 insertions, 13057 deletions
diff --git a/pear/Archive/Tar.php b/pear/Archive/Tar.php deleted file mode 100644 index 3400a87764..0000000000 --- a/pear/Archive/Tar.php +++ /dev/null @@ -1,1149 +0,0 @@ -<?php -/* vim: set ts=4 sw=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Vincent Blavet <vincent@blavet.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; - -/** -* Creates a (compressed) Tar archive -* -* @author Vincent Blavet <vincent@blavet.net> -* @version $Revision$ -* @package Archive -*/ -class Archive_Tar extends PEAR -{ - /** - * @var string Name of the Tar - */ - var $_tarname=''; - - /** - * @var boolean if true, the Tar file will be gzipped - */ - var $_compress=false; - - /** - * @var file descriptor - */ - var $_file=0; - - /** - * @var string Local Tar name of a remote Tar (http:// or ftp://) - */ - var $_temp_tarname=''; - - // {{{ constructor - /** - * Archive_Tar Class constructor. This flavour of the constructor only - * declare a new Archive_Tar object, identifying it by the name of the - * tar file. - * If the compress argument is set the tar will be read or created as a - * gzip compressed TAR file. - * - * @param string $p_tarname The name of the tar archive to create - * @param boolean $p_compress if true, the archive will be gezip(ped) - * @access public - */ - function Archive_Tar($p_tarname, $p_compress = false) - { - $this->PEAR(); - $this->_tarname = $p_tarname; - if ($p_compress) { // assert zlib extension support - $extname = 'zlib'; - if (!extension_loaded($extname)) { - $dlext = (OS_WINDOWS) ? '.dll' : '.so'; - @dl($extname . $dlext); - } - if (!extension_loaded($extname)) { - die("The extension '$extname' couldn't be found.\n". - "Please make sure your version of PHP was built". - "with '$extname' support.\n"); - return false; - } - } - $this->_compress = $p_compress; - } - // }}} - - // {{{ destructor - function _Archive_Tar() - { - $this->_close(); - // ----- Look for a local copy to delete - if ($this->_temp_tarname != '') - @unlink($this->_temp_tarname); - $this->_PEAR(); - } - // }}} - - // {{{ create() - /** - * This method creates the archive file and add the files / directories - * that are listed in $p_filelist. - * If a file with the same name exist and is writable, it is replaced - * by the new tar. - * The method return false and a PEAR error text. - * The $p_filelist parameter can be an array of string, each string - * representing a filename or a directory name with their path if - * needed. It can also be a single string with names separated by a - * single blank. - * For each directory added in the archive, the files and - * sub-directories are also added. - * See also createModify() method for more details. - * - * @param array $p_filelist An array of filenames and directory names, or a single - * string with names separated by a single blank space. - * @return true on success, false on error. - * @see createModify() - * @access public - */ - function create($p_filelist) - { - return $this->createModify($p_filelist, '', ''); - } - // }}} - - // {{{ add() - /** - * This method add the files / directories that are listed in $p_filelist in - * the archive. If the archive does not exist it is created. - * The method return false and a PEAR error text. - * The files and directories listed are only added at the end of the archive, - * even if a file with the same name is already archived. - * See also createModify() method for more details. - * - * @param array $p_filelist An array of filenames and directory names, or a single - * string with names separated by a single blank space. - * @return true on success, false on error. - * @see createModify() - * @access public - */ - function add($p_filelist) - { - return $this->addModify($p_filelist, '', ''); - } - // }}} - - // {{{ extract() - function extract($p_path='') - { - return $this->extractModify($p_path, ''); - } - // }}} - - // {{{ listContent() - function listContent() - { - $v_list_detail = array(); - - if ($this->_openRead()) { - if (!$this->_extractList('', $v_list_detail, "list", '', '')) { - unset($v_list_detail); - return(0); - } - $this->_close(); - } - - return $v_list_detail; - } - // }}} - - // {{{ createModify() - /** - * This method creates the archive file and add the files / directories - * that are listed in $p_filelist. - * If the file already exists and is writable, it is replaced by the - * new tar. It is a create and not an add. If the file exists and is - * read-only or is a directory it is not replaced. The method return - * false and a PEAR error text. - * The $p_filelist parameter can be an array of string, each string - * representing a filename or a directory name with their path if - * needed. It can also be a single string with names separated by a - * single blank. - * The path indicated in $p_remove_dir will be removed from the - * memorized path of each file / directory listed when this path - * exists. By default nothing is removed (empty path '') - * The path indicated in $p_add_dir will be added at the beginning of - * the memorized path of each file / directory listed. However it can - * be set to empty ''. The adding of a path is done after the removing - * of path. - * The path add/remove ability enables the user to prepare an archive - * for extraction in a different path than the origin files are. - * See also addModify() method for file adding properties. - * - * @param array $p_filelist An array of filenames and directory names, or a single - * string with names separated by a single blank space. - * @param string $p_add_dir A string which contains a path to be added to the - * memorized path of each element in the list. - * @param string $p_remove_dir A string which contains a path to be removed from - * the memorized path of each element in the list, when - * relevant. - * @return boolean true on success, false on error. - * @access public - * @see addModify() - */ - function createModify($p_filelist, $p_add_dir, $p_remove_dir='') - { - $v_result = true; - - if (!$this->_openWrite()) - return false; - - if ($p_filelist != '') { - if (is_array($p_filelist)) - $v_list = $p_filelist; - elseif (is_string($p_filelist)) - $v_list = explode(" ", $p_filelist); - else { - $this->_cleanFile(); - $this->_error('Invalid file list'); - return false; - } - - $v_result = $this->_addList($v_list, $p_add_dir, $p_remove_dir); - } - - if ($v_result) { - $this->_writeFooter(); - $this->_close(); - } else - $this->_cleanFile(); - - return $v_result; - } - // }}} - - // {{{ addModify() - /** - * This method add the files / directories listed in $p_filelist at the - * end of the existing archive. If the archive does not yet exists it - * is created. - * The $p_filelist parameter can be an array of string, each string - * representing a filename or a directory name with their path if - * needed. It can also be a single string with names separated by a - * single blank. - * The path indicated in $p_remove_dir will be removed from the - * memorized path of each file / directory listed when this path - * exists. By default nothing is removed (empty path '') - * The path indicated in $p_add_dir will be added at the beginning of - * the memorized path of each file / directory listed. However it can - * be set to empty ''. The adding of a path is done after the removing - * of path. - * The path add/remove ability enables the user to prepare an archive - * for extraction in a different path than the origin files are. - * If a file/dir is already in the archive it will only be added at the - * end of the archive. There is no update of the existing archived - * file/dir. However while extracting the archive, the last file will - * replace the first one. This results in a none optimization of the - * archive size. - * If a file/dir does not exist the file/dir is ignored. However an - * error text is send to PEAR error. - * If a file/dir is not readable the file/dir is ignored. However an - * error text is send to PEAR error. - * If the resulting filename/dirname (after the add/remove option or - * not) string is greater than 99 char, the file/dir is - * ignored. However an error text is send to PEAR error. - * - * @param array $p_filelist An array of filenames and directory names, or a single - * string with names separated by a single blank space. - * @param string $p_add_dir A string which contains a path to be added to the - * memorized path of each element in the list. - * @param string $p_remove_dir A string which contains a path to be removed from - * the memorized path of each element in the list, when - * relevant. - * @return true on success, false on error. - * @access public - */ - function addModify($p_filelist, $p_add_dir, $p_remove_dir='') - { - $v_result = true; - - if (!@is_file($this->_tarname)) - $v_result = $this->createModify($p_filelist, $p_add_dir, $p_remove_dir); - else { - if (is_array($p_filelist)) - $v_list = $p_filelist; - elseif (is_string($p_filelist)) - $v_list = explode(" ", $p_filelist); - else { - $this->_error('Invalid file list'); - return false; - } - - $v_result = $this->_append($v_list, $p_add_dir, $p_remove_dir); - } - - return $v_result; - } - // }}} - - // {{{ extractModify() - /** - * This method extract all the content of the archive in the directory - * indicated by $p_path. When relevant the memorized path of the - * files/dir can be modified by removing the $p_remove_path path at the - * beginning of the file/dir path. - * While extracting a file, if the directory path does not exists it is - * created. - * While extracting a file, if the file already exists it is replaced - * without looking for last modification date. - * While extracting a file, if the file already exists and is write - * protected, the extraction is aborted. - * While extracting a file, if a directory with the same name already - * exists, the extraction is aborted. - * While extracting a directory, if a file with the same name already - * exists, the extraction is aborted. - * While extracting a file/directory if the destination directory exist - * and is write protected, or does not exist but can not be created, - * the extraction is aborted. - * If after extraction an extracted file does not show the correct - * stored file size, the extraction is aborted. - * When the extraction is aborted, a PEAR error text is set and false - * is returned. However the result can be a partial extraction that may - * need to be manually cleaned. - * - * @param string $p_path The path of the directory where the files/dir need to by - * extracted. - * @param string $p_remove_path Part of the memorized path that can be removed if - * present at the beginning of the file/dir path. - * @return boolean true on success, false on error. - * @access public - * @see extractList() - */ - function extractModify($p_path, $p_remove_path) - { - $v_result = true; - $v_list_detail = array(); - - if ($v_result = $this->_openRead()) { - $v_result = $this->_extractList($p_path, $v_list_detail, "complete", 0, $p_remove_path); - $this->_close(); - } - - return $v_result; - } - // }}} - - // {{{ extractList() - /** - * This method extract from the archive only the files indicated in the - * $p_filelist. These files are extracted in the current directory or - * in the directory indicated by the optional $p_path parameter. - * If indicated the $p_remove_path can be used in the same way as it is - * used in extractModify() method. - * @param array $p_filelist An array of filenames and directory names, or a single - * string with names separated by a single blank space. - * @param string $p_path The path of the directory where the files/dir need to by - * extracted. - * @param string $p_remove_path Part of the memorized path that can be removed if - * present at the beginning of the file/dir path. - * @return true on success, false on error. - * @access public - * @see extractModify() - */ - function extractList($p_filelist, $p_path='', $p_remove_path='') - { - $v_result = true; - $v_list_detail = array(); - - if (is_array($p_filelist)) - $v_list = $p_filelist; - elseif (is_string($p_filelist)) - $v_list = explode(" ", $p_filelist); - else { - $this->_error('Invalid string list'); - return false; - } - - if ($v_result = $this->_openRead()) { - $v_result = $this->_extractList($p_path, $v_list_detail, "complete", $v_list, $p_remove_path); - $this->_close(); - } - - return $v_result; - } - // }}} - - // {{{ _error() - function _error($p_message) - { - // ----- To be completed - $this->raiseError($p_message); - } - // }}} - - // {{{ _warning() - function _warning($p_message) - { - // ----- To be completed - $this->raiseError($p_message); - } - // }}} - - // {{{ _openWrite() - function _openWrite() - { - if ($this->_compress) - $this->_file = @gzopen($this->_tarname, "w"); - else - $this->_file = @fopen($this->_tarname, "w"); - - if ($this->_file == 0) { - $this->_error('Unable to open in write mode \''.$this->_tarname.'\''); - return false; - } - - return true; - } - // }}} - - // {{{ _openRead() - function _openRead() - { - if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') { - - // ----- Look if a local copy need to be done - if ($this->_temp_tarname == '') { - $this->_temp_tarname = uniqid('tar').'.tmp'; - if (!$v_file_from = @fopen($this->_tarname, 'rb')) { - $this->_error('Unable to open in read mode \''.$this->_tarname.'\''); - $this->_temp_tarname = ''; - return false; - } - if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) { - $this->_error('Unable to open in write mode \''.$this->_temp_tarname.'\''); - $this->_temp_tarname = ''; - return false; - } - while ($v_data = @fread($v_file_from, 1024)) - @fwrite($v_file_to, $v_data); - @fclose($v_file_from); - @fclose($v_file_to); - } - - // ----- File to open if the local copy - $v_filename = $this->_temp_tarname; - - } else - // ----- File to open if the normal Tar file - $v_filename = $this->_tarname; - - if ($this->_compress) - $this->_file = @gzopen($v_filename, "rb"); - else - $this->_file = @fopen($v_filename, "rb"); - - if ($this->_file == 0) { - $this->_error('Unable to open in read mode \''.$v_filename.'\''); - return false; - } - - return true; - } - // }}} - - // {{{ _openReadWrite() - function _openReadWrite() - { - if ($this->_compress) - $this->_file = @gzopen($this->_tarname, "r+b"); - else - $this->_file = @fopen($this->_tarname, "r+b"); - - if ($this->_file == 0) { - $this->_error('Unable to open in read/write mode \''.$this->_tarname.'\''); - return false; - } - - return true; - } - // }}} - - // {{{ _close() - function _close() - { - if (isset($this->_file)) { - if ($this->_compress) - @gzclose($this->_file); - else - @fclose($this->_file); - - $this->_file = 0; - } - - // ----- Look if a local copy need to be erase - // Note that it might be interesting to keep the url for a time : ToDo - if ($this->_temp_tarname != '') { - @unlink($this->_temp_tarname); - $this->_temp_tarname = ''; - } - - return true; - } - // }}} - - // {{{ _cleanFile() - function _cleanFile() - { - $this->_close(); - - // ----- Look for a local copy - if ($this->_temp_tarname != '') { - // ----- Remove the local copy but not the remote tarname - @unlink($this->_temp_tarname); - $this->_temp_tarname = ''; - } else { - // ----- Remove the local tarname file - @unlink($this->_tarname); - } - $this->_tarname = ''; - - return true; - } - // }}} - - // {{{ _writeFooter() - function _writeFooter() - { - if ($this->_file) { - // ----- Write the last 0 filled block for end of archive - $v_binary_data = pack("a512", ''); - if ($this->_compress) - @gzputs($this->_file, $v_binary_data); - else - @fputs($this->_file, $v_binary_data); - } - return true; - } - // }}} - - // {{{ _addList() - function _addList($p_list, $p_add_dir, $p_remove_dir) - { - $v_result=true; - $v_header = array(); - - // ----- Remove potential windows directory separator - $p_add_dir = $this->_translateWinPath($p_add_dir); - $p_remove_dir = $this->_translateWinPath($p_remove_dir, false); - - if (!$this->_file) { - $this->_error('Invalid file descriptor'); - return false; - } - - if (sizeof($p_list) == 0) - return true; - - for ($j=0; ($j<count($p_list)) && ($v_result); $j++) { - $v_filename = $p_list[$j]; - - // ----- Skip the current tar name - if ($v_filename == $this->_tarname) - continue; - - if ($v_filename == '') - continue; - - if (!file_exists($v_filename)) { - $this->_warning("File '$v_filename' does not exist"); - continue; - } - - // ----- Add the file or directory header - if (!$this->_addFile($v_filename, $v_header, $p_add_dir, $p_remove_dir)) - return false; - - if (@is_dir($v_filename)) { - if (!($p_hdir = opendir($v_filename))) { - $this->_warning("Directory '$v_filename' can not be read"); - continue; - } - $p_hitem = readdir($p_hdir); // '.' directory - $p_hitem = readdir($p_hdir); // '..' directory - while ($p_hitem = readdir($p_hdir)) { - if ($v_filename != ".") - $p_temp_list[0] = $v_filename.'/'.$p_hitem; - else - $p_temp_list[0] = $p_hitem; - - $v_result = $this->_addList($p_temp_list, $p_add_dir, $p_remove_dir); - } - - unset($p_temp_list); - unset($p_hdir); - unset($p_hitem); - } - } - - return $v_result; - } - // }}} - - // {{{ _addFile() - function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir) - { - if (!$this->_file) { - $this->_error('Invalid file descriptor'); - return false; - } - - if ($p_filename == '') { - $this->_error('Invalid file name'); - return false; - } - - // ----- Calculate the stored filename - $p_filename = $this->_translateWinPath($p_filename, false);; - $v_stored_filename = $p_filename; - if (strcmp($p_filename, $p_remove_dir) == 0) { - return true; - } - if ($p_remove_dir != '') { - if (substr($p_remove_dir, -1) != '/') - $p_remove_dir .= '/'; - - if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) - $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); - } - $v_stored_filename = $this->_translateWinPath($v_stored_filename); - if ($p_add_dir != '') { - if (substr($p_add_dir, -1) == '/') - $v_stored_filename = $p_add_dir.$v_stored_filename; - else - $v_stored_filename = $p_add_dir.'/'.$v_stored_filename; - } - - $v_stored_filename = $this->_pathReduction($v_stored_filename); - - if (strlen($v_stored_filename) > 99) { - $this->_warning("Stored file name is too long (max. 99) : '$v_stored_filename'"); - fclose($v_file); - return true; - } - - if (is_file($p_filename)) { - if (($v_file = @fopen($p_filename, "rb")) == 0) { - $this->_warning("Unable to open file '$p_filename' in binary read mode"); - return true; - } - - if (!$this->_writeHeader($p_filename, $v_stored_filename)) - return false; - - while (($v_buffer = fread($v_file, 512)) != '') { - $v_binary_data = pack("a512", "$v_buffer"); - if ($this->_compress) - @gzputs($this->_file, $v_binary_data); - else - @fputs($this->_file, $v_binary_data); - } - - fclose($v_file); - - } else { - // ----- Only header for dir - if (!$this->_writeHeader($p_filename, $v_stored_filename)) - return false; - } - - return true; - } - // }}} - - // {{{ _writeHeader() - function _writeHeader($p_filename, $p_stored_filename) - { - if ($p_stored_filename == '') - $p_stored_filename = $p_filename; - $v_reduce_filename = $this->_pathReduction($p_stored_filename); - - $v_info = stat($p_filename); - $v_uid = sprintf("%6s ", DecOct($v_info[4])); - $v_gid = sprintf("%6s ", DecOct($v_info[5])); - $v_perms = sprintf("%6s ", DecOct(fileperms($p_filename))); - - $v_mtime = sprintf("%11s", DecOct(filemtime($p_filename))); - - if (@is_dir($p_filename)) { - $v_typeflag = "5"; - $v_size = sprintf("%11s ", DecOct(0)); - } else { - $v_typeflag = ''; - clearstatcache(); - $v_size = sprintf("%11s ", DecOct(filesize($p_filename))); - } - - $v_linkname = ''; - - $v_magic = ''; - - $v_version = ''; - - $v_uname = ''; - - $v_gname = ''; - - $v_devmajor = ''; - - $v_devminor = ''; - - $v_prefix = ''; - - $v_binary_data_first = pack("a100a8a8a8a12A12", $v_reduce_filename, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime); - $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", $v_typeflag, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, ''); - - // ----- Calculate the checksum - $v_checksum = 0; - // ..... First part of the header - for ($i=0; $i<148; $i++) - $v_checksum += ord(substr($v_binary_data_first,$i,1)); - // ..... Ignore the checksum value and replace it by ' ' (space) - for ($i=148; $i<156; $i++) - $v_checksum += ord(' '); - // ..... Last part of the header - for ($i=156, $j=0; $i<512; $i++, $j++) - $v_checksum += ord(substr($v_binary_data_last,$j,1)); - - // ----- Write the first 148 bytes of the header in the archive - if ($this->_compress) - @gzputs($this->_file, $v_binary_data_first, 148); - else - @fputs($this->_file, $v_binary_data_first, 148); - - // ----- Write the calculated checksum - $v_checksum = sprintf("%6s ", DecOct($v_checksum)); - $v_binary_data = pack("a8", $v_checksum); - if ($this->_compress) - @gzputs($this->_file, $v_binary_data, 8); - else - @fputs($this->_file, $v_binary_data, 8); - - // ----- Write the last 356 bytes of the header in the archive - if ($this->_compress) - @gzputs($this->_file, $v_binary_data_last, 356); - else - @fputs($this->_file, $v_binary_data_last, 356); - - return true; - } - // }}} - - // {{{ _readHeader() - function _readHeader($v_binary_data, &$v_header) - { - if (strlen($v_binary_data)==0) { - $v_header['filename'] = ''; - return true; - } - - if (strlen($v_binary_data) != 512) { - $v_header['filename'] = ''; - $this->_error('Invalid block size : '.strlen($v_binary_data)); - return false; - } - - // ----- Calculate the checksum - $v_checksum = 0; - // ..... First part of the header - for ($i=0; $i<148; $i++) - $v_checksum+=ord(substr($v_binary_data,$i,1)); - // ..... Ignore the checksum value and replace it by ' ' (space) - for ($i=148; $i<156; $i++) - $v_checksum += ord(' '); - // ..... Last part of the header - for ($i=156; $i<512; $i++) - $v_checksum+=ord(substr($v_binary_data,$i,1)); - - $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $v_binary_data); - - // ----- Extract the checksum - $v_header['checksum'] = OctDec(trim($v_data['checksum'])); - if ($v_header['checksum'] != $v_checksum) { - $v_header['filename'] = ''; - - // ----- Look for last block (empty block) - if (($v_checksum == 256) && ($v_header['checksum'] == 0)) - return true; - - $this->_error('Invalid checksum : '.$v_checksum.' calculated, '.$v_header['checksum'].' expected'); - return false; - } - - // ----- Extract the properties - $v_header['filename'] = trim($v_data['filename']); - $v_header['mode'] = OctDec(trim($v_data['mode'])); - $v_header['uid'] = OctDec(trim($v_data['uid'])); - $v_header['gid'] = OctDec(trim($v_data['gid'])); - $v_header['size'] = OctDec(trim($v_data['size'])); - $v_header['mtime'] = OctDec(trim($v_data['mtime'])); - if (($v_header['typeflag'] = $v_data['typeflag']) == "5") { - $v_header['size'] = 0; - } - /* ----- All these fields are removed form the header because they do not carry interesting info - $v_header[link] = trim($v_data[link]); - $v_header[magic] = trim($v_data[magic]); - $v_header[version] = trim($v_data[version]); - $v_header[uname] = trim($v_data[uname]); - $v_header[gname] = trim($v_data[gname]); - $v_header[devmajor] = trim($v_data[devmajor]); - $v_header[devminor] = trim($v_data[devminor]); - */ - - return true; - } - // }}} - - // {{{ _extractList() - function _extractList($p_path, &$p_list_detail, $p_mode, $p_file_list, $p_remove_path) - { - $v_result=true; - $v_nb = 0; - $v_extract_all = true; - $v_listing = false; - - $p_path = $this->_translateWinPath($p_path, false); - if ($p_path == '' || (substr($p_path, 0, 1) != '/' && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) { - $p_path = "./".$p_path; - } - $p_remove_path = $this->_translateWinPath($p_remove_path); - - // ----- Look for path to remove format (should end by /) - if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) - $p_remove_path .= '/'; - $p_remove_path_size = strlen($p_remove_path); - - switch ($p_mode) { - case "complete" : - $v_extract_all = TRUE; - $v_listing = FALSE; - break; - case "partial" : - $v_extract_all = FALSE; - $v_listing = FALSE; - break; - case "list" : - $v_extract_all = FALSE; - $v_listing = TRUE; - break; - default : - $this->_error('Invalid extract mode ('.$p_mode.')'); - return false; - } - - clearstatcache(); - - While (!($v_end_of_file = ($this->_compress?@gzeof($this->_file):@feof($this->_file)))) - { - $v_extract_file = FALSE; - $v_extraction_stopped = 0; - - if ($this->_compress) - $v_binary_data = @gzread($this->_file, 512); - else - $v_binary_data = @fread($this->_file, 512); - - if (!$this->_readHeader($v_binary_data, $v_header)) - return false; - - if ($v_header['filename'] == '') - continue; - - if ((!$v_extract_all) && (is_array($p_file_list))) { - // ----- By default no unzip if the file is not found - $v_extract_file = false; - - for ($i=0; $i<sizeof($p_file_list); $i++) { - // ----- Look if it is a directory - if (substr($p_file_list[$i], -1) == '/') { - // ----- Look if the directory is in the filename path - if ((strlen($v_header['filename']) > strlen($p_file_list[$i])) && (substr($v_header['filename'], 0, strlen($p_file_list[$i])) == $p_file_list[$i])) { - $v_extract_file = TRUE; - break; - } - } - - // ----- It is a file, so compare the file names - elseif ($p_file_list[$i] == $v_header['filename']) { - $v_extract_file = TRUE; - break; - } - } - } else { - $v_extract_file = TRUE; - } - - // ----- Look if this file need to be extracted - if (($v_extract_file) && (!$v_listing)) - { - if (($p_remove_path != '') - && (substr($v_header['filename'], 0, $p_remove_path_size) == $p_remove_path)) - $v_header['filename'] = substr($v_header['filename'], $p_remove_path_size); - if (($p_path != './') && ($p_path != '/')) { - while (substr($p_path, -1) == '/') - $p_path = substr($p_path, 0, strlen($p_path)-1); - - if (substr($v_header['filename'], 0, 1) == '/') - $v_header['filename'] = $p_path.$v_header['filename']; - else - $v_header['filename'] = $p_path.'/'.$v_header['filename']; - } - if (file_exists($v_header['filename'])) { - if ((@is_dir($v_header['filename'])) && ($v_header['typeflag'] == '')) { - $this->_error('File '.$v_header['filename'].' already exists as a directory'); - return false; - } - if ((is_file($v_header['filename'])) && ($v_header['typeflag'] == "5")) { - $this->_error('Directory '.$v_header['filename'].' already exists as a file'); - return false; - } - if (!is_writeable($v_header['filename'])) { - $this->_error('File '.$v_header['filename'].' already exists and is write protected'); - return false; - } - if (filemtime($v_header['filename']) > $v_header['mtime']) { - // To be completed : An error or silent no replace ? - } - } - - // ----- Check the directory availability and create it if necessary - elseif (($v_result = $this->_dirCheck(($v_header['typeflag'] == "5"?$v_header['filename']:dirname($v_header['filename'])))) != 1) { - $this->_error('Unable to create path for '.$v_header['filename']); - return false; - } - - if ($v_extract_file) { - if ($v_header['typeflag'] == "5") { - if (!@file_exists($v_header['filename'])) { - if (!@mkdir($v_header['filename'], 0777)) { - $this->_error('Unable to create directory {'.$v_header['filename'].'}'); - return false; - } - } - } else { - if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) { - $this->_error('Error while opening {'.$v_header['filename'].'} in write binary mode'); - return false; - } else { - $n = floor($v_header['size']/512); - for ($i=0; $i<$n; $i++) { - if ($this->_compress) - $v_content = @gzread($this->_file, 512); - else - $v_content = @fread($this->_file, 512); - fwrite($v_dest_file, $v_content, 512); - } - if (($v_header['size'] % 512) != 0) { - if ($this->_compress) - $v_content = @gzread($this->_file, 512); - else - $v_content = @fread($this->_file, 512); - fwrite($v_dest_file, $v_content, ($v_header['size'] % 512)); - } - - @fclose($v_dest_file); - - // ----- Change the file mode, mtime - @touch($v_header['filename'], $v_header['mtime']); - // To be completed - //chmod($v_header[filename], DecOct($v_header[mode])); - } - - // ----- Check the file size - clearstatcache(); - if (filesize($v_header['filename']) != $v_header['size']) { - $this->_error('Extracted file '.$v_header['filename'].' does not have the correct file size \''.filesize($v_filename).'\' ('.$v_header['size'].' expected). Archive may be corrupted.'); - return false; - } - } - } else { - // ----- Jump to next file - if ($this->_compress) - @gzseek($this->_file, @gztell($this->_file)+(ceil(($v_header['size']/512))*512)); - else - @fseek($this->_file, @ftell($this->_file)+(ceil(($v_header['size']/512))*512)); - } - } else { - // ----- Jump to next file - if ($this->_compress) - @gzseek($this->_file, @gztell($this->_file)+(ceil(($v_header['size']/512))*512)); - else - @fseek($this->_file, @ftell($this->_file)+(ceil(($v_header['size']/512))*512)); - } - - if ($this->_compress) - $v_end_of_file = @gzeof($this->_file); - else - $v_end_of_file = @feof($this->_file); - - if ($v_listing || $v_extract_file || $v_extraction_stopped) { - // ----- Log extracted files - if (($v_file_dir = dirname($v_header['filename'])) == $v_header['filename']) - $v_file_dir = ''; - if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) - $v_file_dir = '/'; - - $p_list_detail[$v_nb++] = $v_header; - } - } - - return true; - } - // }}} - - // {{{ _append() - function _append($p_filelist, $p_add_dir='', $p_remove_dir='') - { - if ($this->_compress) { - $this->_close(); - - if (!@rename($this->_tarname, $this->_tarname.".tmp")) { - $this->_error('Error while renaming \''.$this->_tarname.'\' to temporary file \''.$this->_tarname.'.tmp\''); - return false; - } - - if (($v_temp_tar = @gzopen($this->_tarname.".tmp", "rb")) == 0) { - $this->_error('Unable to open file \''.$this->_tarname.'.tmp\' in binary read mode'); - @rename($this->_tarname.".tmp", $this->_tarname); - return false; - } - - if (!$this->_openWrite()) { - @rename($this->_tarname.".tmp", $this->_tarname); - return false; - } - - $v_buffer = @gzread($v_temp_tar, 512); - - // ----- Read the following blocks but not the last one - if (!@gzeof($v_temp_tar)) { - do{ - $v_binary_data = pack("a512", "$v_buffer"); - @gzputs($this->_file, $v_binary_data); - $v_buffer = @gzread($v_temp_tar, 512); - - } while (!@gzeof($v_temp_tar)); - } - - if ($this->_addList($p_filelist, $p_add_dir, $p_remove_dir)) - $this->_writeFooter(); - - $this->_close(); - @gzclose($v_temp_tar); - - if (!@unlink($this->_tarname.".tmp")) { - $this->_error('Error while deleting temporary file \''.$this->_tarname.'.tmp\''); - } - - return true; - } - - // ----- For not compressed tar, just add files before the last 512 bytes block - if (!$this->_openReadWrite()) - return false; - - clearstatcache(); - $v_size = filesize($this->_tarname); - fseek($this->_file, $v_size-512); - - if ($this->_addList($p_filelist, $p_add_dir, $p_remove_dir)) - $this->_writeFooter(); - - $this->_close(); - - return true; - } - // }}} - - // {{{ _dirCheck() - function _dirCheck($p_dir) - { - if ((@is_dir($p_dir)) || ($p_dir == '')) - return true; - - $p_parent_dir = dirname($p_dir); - - if (($p_parent_dir != $p_dir) && - ($p_parent_dir != '') && - (!$this->_dirCheck($p_parent_dir))) - return false; - - if (!@mkdir($p_dir, 0777)) { - $this->_error("Unable to create directory '$p_dir'"); - return false; - } - - return true; - } - // }}} - - // {{{ _pathReduction() - function _pathReduction($p_dir) - { - $v_result = ''; - - // ----- Look for not empty path - if ($p_dir != '') { - // ----- Explode path by directory names - $v_list = explode('/', $p_dir); - - // ----- Study directories from last to first - for ($i=sizeof($v_list)-1; $i>=0; $i--) { - // ----- Look for current path - if ($v_list[$i] == ".") { - // ----- Ignore this directory - // Should be the first $i=0, but no check is done - } - else if ($v_list[$i] == "..") { - // ----- Ignore it and ignore the $i-1 - $i--; - } - else if (($v_list[$i] == '') && ($i!=(sizeof($v_list)-1)) && ($i!=0)) { - // ----- Ignore only the double '//' in path, - // but not the first and last / - } else { - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?'/'.$v_result:''); - } - } - } - $v_result = strtr($v_result, '\\', '/'); - return $v_result; - } - // }}} - - // {{{ _translateWinPath() - function _translateWinPath($p_path, $p_remove_disk_letter=true) - { - if (OS_WINDOWS) { - // ----- Look for potential disk letter - if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { - $p_path = substr($p_path, $v_position+1); - } - // ----- Change potential windows directory separator - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { - $p_path = strtr($p_path, '\\', '/'); - } - } - return $p_path; - } - // }}} - -} -?>
\ No newline at end of file diff --git a/pear/CMD.php b/pear/CMD.php deleted file mode 100755 index e33544463e..0000000000 --- a/pear/CMD.php +++ /dev/null @@ -1,285 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: 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 b42a70fbb8..0000000000 --- a/pear/CODING_STANDARDS +++ /dev/null @@ -1,8 +0,0 @@ -=========================================================================== -|| PEAR Coding Standards || -=========================================================================== - -$Id$ - -This document is no longer maintained, see -http://pear.php.net/manual/ instead. diff --git a/pear/Console/Getopt.php b/pear/Console/Getopt.php deleted file mode 100644 index c82aabba34..0000000000 --- a/pear/Console/Getopt.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Andrei Zmievski <andrei@php.net> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; - -/** - * Command-line options parsing class. - * - * @author Andrei Zmievski <andrei@php.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 array $args an array of command-line arguments - * @param string $short_options specifies the list of allowed short options - * @param array $long_options 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) - { - // in case you pass directly readPHPArgv() as the first arg - if (PEAR::isError($args)) { - return $args; - } - $opts = array(); - $non_opts = array(); - - settype($args, 'array'); - - if ($long_options) - sort($long_options); - - reset($args); - while (list($i, $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} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) { - $non_opts = array_merge($non_opts, array_slice($args, $i)); - break; - } elseif (strlen($arg) > 1 && $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 PEAR::raiseError("Console_Getopt: unrecognized option -- $opt"); - } - - if (strlen($spec) > 1 && $spec{1} == ':') { - if (strlen($spec) > 2 && $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 PEAR::raiseError("Console_Getopt: option requires an argument -- $opt"); - } - } - - $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 PEAR::raiseError("Console_Getopt: option --$opt is ambiguous"); - } - - 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 PEAR::raiseError("Console_Getopt: option --$opt requires an argument"); - } - } - } else if ($opt_arg) { - return PEAR::raiseError("Console_Getopt: option --$opt doesn't allow an argument"); - } - - $opts[] = array('--' . $opt, $opt_arg); - return; - } - - return PEAR::raiseError("Console_Getopt: unrecognized option --$opt"); - } - - /** - * Safely read the $argv PHP array across different PHP configurations. - * Will take care on register_globals and register_argc_argv ini directives - * - * @access public - * @return mixed the $argv PHP array or PEAR error if not registered - */ - function readPHPArgv() - { - global $argv; - if (!is_array($argv)) { - if (!@is_array($_SERVER['argv'])) { - if (!is_array($HTTP_SERVER_VARS['argv'])) { - return PEAR::raiseError("Console_Getopt: Could not read cmd args (register_argc_argv=Off?)"); - } - return $HTTP_SERVER_VARS['argv']; - } - return $_SERVER['argv']; - } - return $argv; - } - -} - -?> diff --git a/pear/Console/tests/001-getopt.phpt b/pear/Console/tests/001-getopt.phpt deleted file mode 100644 index 440a8834c9..0000000000 --- a/pear/Console/tests/001-getopt.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -Console_Getopt ---FILE-- -<?php - -error_reporting(E_ALL); -chdir(dirname(__FILE__)); -include "../Getopt.php"; -PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s\n\n"); - -function test($argstr, $optstr) { - $argv = split('[[:space:]]+', $argstr); - if (PEAR::isError($options = Console_Getopt::getopt($argv, $optstr))) { - return; - } - $opts = $options[0]; - $non_opts = $options[1]; - $i = 0; - print "options: "; - foreach ($opts as $o => $d) { - if ($i++ > 0) { - print ", "; - } - print $d[0] . '=' . $d[1]; - } - print "\n"; - print "params: " . implode(", ", $non_opts) . "\n"; - print "\n"; -} - -test("-abc", "abc"); -test("-abc foo", "abc"); -test("-abc foo", "abc:"); -test("-abc foo bar gazonk", "abc"); -test("-abc foo bar gazonk", "abc:"); -test("-a -b -c", "abc"); -test("-a -b -c", "abc:"); -test("-abc", "ab:c"); -test("-abc foo -bar gazonk", "abc"); -?> ---EXPECT-- -options: a=, b=, c= -params: - -options: a=, b=, c= -params: foo - -options: a=, b=, c=foo -params: - -options: a=, b=, c= -params: foo, bar, gazonk - -options: a=, b=, c=foo -params: bar, gazonk - -options: a=, b=, c= -params: - -Console_Getopt: option requires an argument -- c - -options: a=, b=c -params: - -options: a=, b=, c= -params: foo, -bar, gazonk diff --git a/pear/HTTP.php b/pear/HTTP.php deleted file mode 100644 index 9f28094848..0000000000 --- a/pear/HTTP.php +++ /dev/null @@ -1,172 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -// HTTP utility functions. -// - -if (!empty($GLOBALS['USED_PACKAGES']['HTTP'])) return; -$GLOBALS['USED_PACKAGES']['HTTP'] = true; - -class HTTP { - /** - * Format a RFC compliant HTTP header. 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> - * @author Sterling Hughes <sterling@php.net> - */ - function Date($time) { - /* If we're y2k compliant, use the newer, reccomended RFC 822 - format */ - if (ini_get("y2k_compliance") == true) { - return gmdate("D, d M Y H:i:s \G\M\T", $time); - } - /* Use RFC-850 which supports two character year numbers */ - else { - return gmdate("F, d-D-y H:i:s \G\M\T", $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_SERVER_VARS['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 (isset($HTTP_SERVER_VARS['REMOTE_HOST']) && - ereg("\.[^\.]+$", $HTTP_SERVER_VARS['REMOTE_HOST'], $arr)) { - $lang = strtolower($arr[1]); - if (!empty($supported[$lang])) { - return $lang; - } - } - - return $default; - } - - /** - * Sends a "HEAD" HTTP command to a server and returns the headers - * as an associative array. Example output could be: - * Array - * ( - * [response_code] => 200 // The HTTP response code - * [response] => HTTP/1.1 200 OK // The full HTTP response string - * [Date] => Fri, 11 Jan 2002 01:41:44 GMT - * [Server] => Apache/1.3.20 (Unix) PHP/4.1.1 - * [X-Powered-By] => PHP/4.1.1 - * [Connection] => close - * [Content-Type] => text/html - * ) - * - * @param string $url A valid url, for ex: http://pear.php.net/credits.php - * @return mixed Assoc array or PEAR error on no conection - * - * @author Tomas V.V.Cox <cox@idecnet.com> - */ - function head($url) - { - $purl = parse_url($url); - $port = (isset($purl['port'])) ? $purl['port'] : 80; - $fp = fsockopen($purl['host'], $port, $errno, $errstr, 10); - if (!$fp) { - return PEAR::raiseError("HTTP::head Error $errstr ($erno)"); - } - $path = (!empty($purl['path'])) ? $purl['path'] : '/'; - - fputs($fp, "HEAD $path HTTP/1.0\r\n"); - fputs($fp, "Host: " . $purl['host'] . "\r\n\r\n"); - - $response = rtrim(fgets($fp, 4096)); - if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|", $response, $status)) { - $headers['response_code'] = $status[1]; - } - $headers['response'] = $response; - - while ($line = fgets($fp, 4096)) { - if (!trim($line)) { - break; - } - if (($pos = strpos($line, ':')) !== false) { - $header = substr($line, 0, $pos); - $value = trim(substr($line, $pos + 1)); - $headers[$header] = $value; - } - } - fclose($fp); - return $headers; - } -} -?>
\ No newline at end of file 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/Mail.php b/pear/Mail.php deleted file mode 100644 index 75259454c5..0000000000 --- a/pear/Mail.php +++ /dev/null @@ -1,186 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: 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 PEAR::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.frag b/pear/Makefile.frag deleted file mode 100644 index f49b7d7650..0000000000 --- a/pear/Makefile.frag +++ /dev/null @@ -1,206 +0,0 @@ -# -*- makefile -*- - -pear_install_targets = \ - install-pear \ - install-headers \ - install-build \ - install-programs - -peardir=$(PEAR_INSTALLDIR) - -#PEAR_SUBDIRS = \ -# Archive \ -# Console \ -# PEAR \ -# PEAR/Command \ -# PEAR/Frontend \ -# XML - -# These are moving to /pear (in cvs): -# Crypt \ -# File \ -# Date \ -# DB \ -# HTML \ -# HTTP \ -# Image \ -# Mail \ -# Net \ -# Schedule \ - -#PEAR_FILES = \ -# Archive/Tar.php \ -# Console/Getopt.php \ -# PEAR.php \ -# PEAR/Autoloader.php \ -# PEAR/Command.php \ -# PEAR/Command/Auth.php \ -# PEAR/Command/Common.php \ -# PEAR/Command/Config.php \ -# PEAR/Command/Install.php \ -# PEAR/Command/Package.php \ -# PEAR/Command/Registry.php \ -# PEAR/Command/Remote.php \ -# PEAR/Frontend/CLI.php \ -# PEAR/Frontend/Gtk.php \ -# PEAR/Common.php \ -# PEAR/Config.php \ -# PEAR/Dependency.php \ -# PEAR/Installer.php \ -# PEAR/Packager.php \ -# PEAR/Registry.php \ -# PEAR/Remote.php \ -# System.php \ -# XML/Parser.php - -# These are moving to /pear (in cvs): -# Crypt/CBC.php \ -# Crypt/HCEMD5.php \ -# DB.php \ -# DB/common.php \ -# DB/fbsql.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 \ -# Date/Calc.php \ -# Date/Human.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 \ -# Mail.php \ -# Mail/RFC822.php \ -# Mail/sendmail.php \ -# Mail/smtp.php \ -# Net/Curl.php \ -# Net/Dig.php \ -# Net/SMTP.php \ -# Net/Socket.php \ -# Schedule/At.php \ - -PEARCMD=$(top_builddir)/sapi/cli/php -d include_path=$(top_srcdir)/pear pear/scripts/pear.in - -install-pear-installer: $(top_builddir)/sapi/cli/php - @for descfile in $(srcdir)/package-*.xml; do \ - tmp="$${descfile%.xml}"; \ - pkgname="$${tmp#*-}"; \ - pkgver=`grep '<version>' $$descfile|head -1|cut -d\> -f2|cut -d\< -f1`; \ - if $(PEARCMD) shell-test $$pkgname; then \ - if ! $(PEARCMD) shell-test $$pkgname $$pkgver; then \ - $(PEARCMD) -q upgrade $$descfile | sed -e "s/^/$$pkgname $$pkgver: /"; \ - fi; \ - else \ - $(PEARCMD) -q install $$descfile | sed -e "s/^/$$pkgname $$pkgver: /"; \ - fi; \ - done - -install-pear-packages: # requires cli installed - @/bin/ls -1 $(srcdir)/packages | while read package; do \ - case $$package in \ - *.tgz) pkg=$${package%.tgz};; \ - *.tar) pkg=$${package%.tar};; \ - *) continue;; \ - esac; \ - pkgname="$${pkg%-*}"; pkgver="$${pkg#*-}"; \ - if $(INSTALL_ROOT)$(bindir)/pear -d php_dir=$(INSTALL_ROOT)$(PEAR_INSTALLDIR) shell-test $$pkgname $$pkgver; then \ - echo "$$pkgname $$pkgver: already installed"; \ - else \ - $(INSTALL_ROOT)$(bindir)/pear -q -d php_dir=$(INSTALL_ROOT)$(PEAR_INSTALLDIR) -d bin_dir=$(INSTALL_ROOT)$(bindir) -d doc_dir=$(INSTALL_ROOT)$(datadir)/doc/pear -d ext_dir=$(INSTALL_ROOT)$(EXTENSION_DIR) install $(srcdir)/packages/$$package 2>&1 | sed -e "s/^/$$pkgname $$pkgver: /"; \ - fi; \ - done - -install-pear: - @if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \ - $(MAKE) install-pear-installer; \ - $(MAKE) install-pear-packages; \ - else \ - cat $(srcdir)/install-pear.txt; \ - exit 5; \ - fi - -phpincludedir = $(includedir)/php -phpbuilddir = $(prefix)/lib/php/build - -BUILD_FILES = \ - pear/pear.m4 \ - build/mkdep.awk \ - build/shtool \ - Makefile.global \ - scan_makefile_in.awk \ - acinclude.m4 - -bin_SCRIPTS = phpize php-config pear pearize phptar - -install-build: - @echo "Installing build environment" - @$(mkinstalldirs) $(INSTALL_ROOT)$(phpbuilddir) $(INSTALL_ROOT)$(bindir) && \ - (cd $(top_srcdir) && cp $(BUILD_FILES) $(INSTALL_ROOT)$(phpbuilddir)) - -install-programs: - @for prog in $(bin_SCRIPTS); do \ - echo "Installing program: $$prog"; \ - $(INSTALL) -m 755 $(builddir)/scripts/$$prog $(INSTALL_ROOT)$(bindir)/$$prog; \ - done; \ - for file in $(INSTALL_ROOT)$(bindir)/pearcmd-*.php; do \ - rm -f $$file; \ - done; \ - for prog in phpextdist; do \ - echo "Installing program: $$prog"; \ - $(INSTALL) -m 755 $(srcdir)/scripts/$$prog $(INSTALL_ROOT)$(bindir)/$$prog; \ - done - -HEADER_DIRS = \ - / \ - Zend \ - TSRM \ - ext/standard \ - ext/session \ - ext/xml \ - ext/xml/expat \ - main \ - ext/mbstring \ - ext/pgsql \ - regex - -install-headers: - -@for i in $(HEADER_DIRS); do \ - paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \ - done; \ - $(mkinstalldirs) $$paths && \ - echo "Installing header files" && \ - 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 - -$(builddir)/scripts/pear: $(srcdir)/scripts/pear.in $(top_builddir)/config.status - (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status) - -$(builddir)/scripts/phpize: $(srcdir)/scripts/phpize.in $(top_builddir)/config.status - (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status) - -$(builddir)/scripts/phptar: $(srcdir)/scripts/phptar.in $(top_builddir)/config.status - (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status) - -$(builddir)/scripts/pearize: $(srcdir)/scripts/pearize.in $(top_builddir)/config.status - (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status) - -$(builddir)/scripts/php-config: $(srcdir)/scripts/php-config.in $(top_builddir)/config.status - (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status) diff --git a/pear/OS/Guess.php b/pear/OS/Guess.php deleted file mode 100644 index 78a7a96281..0000000000 --- a/pear/OS/Guess.php +++ /dev/null @@ -1,198 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stig Bakken <ssb@fast.no> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -// {{{ uname examples - -// php_uname() without args returns the same as 'uname -a', or a PHP-custom -// string for Windows. -// PHP versions prior to 4.3 return the uname of the host where PHP was built, -// as of 4.3 it returns the uname of the host running the PHP code. -// -// PC RedHat Linux 7.1: -// Linux host.example.com 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown -// -// PC Debian Potato: -// Linux host 2.4.17 #2 SMP Tue Feb 12 15:10:04 CET 2002 i686 unknown -// -// PC FreeBSD 3.3: -// FreeBSD host.example.com 3.3-STABLE FreeBSD 3.3-STABLE #0: Mon Feb 21 00:42:31 CET 2000 root@example.com:/usr/src/sys/compile/CONFIG i386 -// -// PC FreeBSD 4.3: -// FreeBSD host.example.com 4.3-RELEASE FreeBSD 4.3-RELEASE #1: Mon Jun 25 11:19:43 EDT 2001 root@example.com:/usr/src/sys/compile/CONFIG i386 -// -// PC FreeBSD 4.5: -// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb 6 23:59:23 CET 2002 root@example.com:/usr/src/sys/compile/CONFIG i386 -// -// PC FreeBSD 4.5 w/uname from GNU shellutils: -// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb i386 unknown -// -// HP 9000/712 HP-UX 10: -// HP-UX iq B.10.10 A 9000/712 2008429113 two-user license -// -// HP 9000/712 HP-UX 10 w/uname from GNU shellutils: -// HP-UX host B.10.10 A 9000/712 unknown -// -// IBM RS6000/550 AIX 4.3: -// AIX host 3 4 000003531C00 -// -// AIX 4.3 w/uname from GNU shellutils: -// AIX host 3 4 000003531C00 unknown -// -// SGI Onyx IRIX 6.5 w/uname from GNU shellutils: -// IRIX64 host 6.5 01091820 IP19 mips -// -// SGI Onyx IRIX 6.5: -// IRIX64 host 6.5 01091820 IP19 -// -// SparcStation 20 Solaris 8 w/uname from GNU shellutils: -// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc -// -// SparcStation 20 Solaris 8: -// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc SUNW,SPARCstation-20 -// - -// }}} - -class OS_Guess -{ - var $sysname; - var $nodename; - var $cpu; - var $release; - var $extra; - - function OS_Guess($uname = null) - { - static $sysmap = array( - 'HP-UX' => 'hpux', - 'IRIX64' => 'irix', - // Darwin? - ); - static $cpumap = array( - 'i586' => 'i386', - 'i686' => 'i386', - ); - if ($uname === null) { - $uname = php_uname(); - } - $parts = preg_split('/\s+/', trim($uname)); - $n = count($parts); - - $this->release = $this->machine = $this->cpu = ''; - - $this->sysname = $parts[0]; - $nodename = $parts[1]; - $this->cpu = $parts[$n-1]; - if ($this->cpu == 'unknown') { - $this->cpu = $parts[$n-2]; - } - - switch ($this->sysname) { - case 'AIX': - $this->release = "$parts[3].$parts[2]"; - break; - case 'Windows': - $this->release = $parts[3]; - break; - default: - $this->release = preg_replace('/-.*/', '', $parts[2]); - break; - } - - - if (isset($sysmap[$this->sysname])) { - $this->sysname = $sysmap[$this->sysname]; - } else { - $this->sysname = strtolower($this->sysname); - } - if (isset($cpumap[$this->cpu])) { - $this->cpu = $cpumap[$this->cpu]; - } - } - - function getSignature() - { - return "{$this->sysname}-{$this->release}-{$this->cpu}"; - } - - function getSysname() - { - return $this->sysname; - } - - function getNodename() - { - return $this->nodename; - } - - function getCpu() - { - return $this->cpu; - } - - function getRelease() - { - return $this->release; - } - - function getExtra() - { - return $this->extra; - } - - function matchSignature($match) - { - $fragments = explode('-', $match); - $n = count($fragments); - $matches = 0; - if ($n > 0) { - $matches += $this->_matchFragment($fragments[0], $this->sysname); - } - if ($n > 1) { - $matches += $this->_matchFragment($fragments[1], $this->release); - } - if ($n > 2) { - $matches += $this->_matchFragment($fragments[2], $this->cpu); - } - if ($n > 3) { - $matches += $this->_matchFragment($fragments[3], $this->extra); - } - return ($matches == $n); - } - - function _matchFragment($fragment, $value) - { - if (strcspn($fragment, '*?') < strlen($fragment)) { - $preg = '/^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '$/i'; - return preg_match($preg, $value); - } - return ($fragment == '*' || !strcasecmp($fragment, $value)); - } - -} - -/* - * Local Variables: - * indent-tabs-mode: nil - * c-basic-offset: 4 - * End: - */ -?>
\ No newline at end of file diff --git a/pear/PEAR.php b/pear/PEAR.php deleted file mode 100644 index 46f0cec20c..0000000000 --- a/pear/PEAR.php +++ /dev/null @@ -1,804 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available 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> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// -// $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_destructor_object_list'] = array(); -$GLOBALS['_PEAR_shutdown_funcs'] = array(); -$GLOBALS['_PEAR_error_handler_stack'] = array(); - -/** - * Base class for other PEAR classes. Provides rudimentary - * emulation of destructors. - * - * If you want a destructor in your class, inherit PEAR and make a - * destructor method called _yourclassname (same name as the - * constructor, but with a "_" prefix). Also, in your constructor you - * have to call the PEAR constructor: $this->PEAR();. - * The destructor method will be called without parameters. Note that - * at in some SAPI implementations (such as Apache), any output during - * the request shutdown (in which destructors are called) seems to be - * discarded. If you need to get any debug information from your - * destructor, use error_log(), syslog() or something similar. - * - * IMPORTANT! To use the emulated destructors you need to create the - * objects by reference, ej: $obj =& new PEAR_child; - * - * @since PHP 4.0.2 - * @author Stig Bakken <ssb@fast.no> - * @see http://pear.php.net/manual/ - */ -class PEAR -{ - // {{{ properties - - /** - * Whether to enable internal debug messages. - * - * @var bool - * @access private - */ - var $_debug = false; - - /** - * Default error mode for this object. - * - * @var int - * @access private - */ - var $_default_error_mode = null; - - /** - * Default error options used for this object when error mode - * is PEAR_ERROR_TRIGGER. - * - * @var int - * @access private - */ - var $_default_error_options = null; - - /** - * Default error handler (callback) for this object, if error mode is - * PEAR_ERROR_CALLBACK. - * - * @var string - * @access private - */ - var $_default_error_handler = ''; - - /** - * Which class to use for error objects. - * - * @var string - * @access private - */ - var $_error_class = 'PEAR_Error'; - - /** - * An array of expected errors. - * - * @var array - * @access private - */ - var $_expected_errors = array(); - - // }}} - - // {{{ constructor - - /** - * Constructor. Registers this object in - * $_PEAR_destructor_object_list for destructor emulation if a - * destructor object exists. - * - * @param string (optional) which class to use for error objects, - * defaults to PEAR_Error. - * @access public - * @return void - */ - 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 - * @return void - */ - function _PEAR() { - if ($this->_debug) { - printf("PEAR destructor called, class=%s\n", get_class($this)); - } - } - - // }}} - // {{{ getStaticProperty() - - /** - * If you have a class that's mostly/entirely static, and you need static - * properties, you can use this method to simulate them. Eg. in your method(s) - * do this: $myVar = &PEAR::getStaticProperty('myVar'); - * You MUST use a reference, or they will not persist! - * - * @access public - * @param string The calling classname, to prevent clashes - * @param string The variable to retrieve. - * @return mixed A reference to the variable. If not set it will be - * auto initialised to NULL. - */ - function &getStaticProperty($class, $var) - { - static $properties; - return $properties[$class][$var]; - } - - // }}} - // {{{ registerShutdownFunc() - - /** - * Use this function to register a shutdown method for static - * classes. - * - * @access public - * @param mixed The function name (or array of class/method) to call - * @param mixed The arguments to pass to the function - * @return void - */ - function registerShutdownFunc($func, $args = array()) - { - $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); - } - - // }}} - // {{{ isError() - - /** - * Tell whether a value is a PEAR error. - * - * @param mixed the value to test - * @access public - * @return bool true if parameter 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 int - * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or - * PEAR_ERROR_CALLBACK. - * - * @param mixed - * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one - * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * - * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected - * to be the callback function or method. A callback - * function is a string with the name of the function, a - * callback method is an array of two elements: the element - * at index 0 is the object, and the element at index 1 is - * the name of the method to call in the object. - * - * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is - * a printf format string used when printing the error - * message. - * - * @access public - * @return void - * @see PEAR_ERROR_RETURN - * @see PEAR_ERROR_PRINT - * @see PEAR_ERROR_TRIGGER - * @see PEAR_ERROR_DIE - * @see PEAR_ERROR_CALLBACK - * - * @since PHP 4.0.5 - */ - - function setErrorHandling($mode = null, $options = null) - { - if (isset($this)) { - $setmode = &$this->_default_error_mode; - $setoptions = &$this->_default_error_options; - } else { - $setmode = &$GLOBALS['_PEAR_default_error_mode']; - $setoptions = &$GLOBALS['_PEAR_default_error_options']; - } - - switch ($mode) { - case PEAR_ERROR_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]))) - { - $setoptions = $options; - } else { - trigger_error("invalid error callback", E_USER_WARNING); - } - break; - - default: - trigger_error("invalid error mode", E_USER_WARNING); - break; - } - } - - // }}} - // {{{ expectError() - - /** - * This method is used to tell which errors you expect to get. - * Expected errors are always returned with error mode - * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, - * and this method pushes a new element onto it. The list of - * expected errors are in effect until they are popped off the - * stack with the popExpect() method. - * - * Note that this method can not be called statically - * - * @param mixed a single error code or an array of error codes to expect - * - * @return int the new depth of the "expected errors" stack - * @access public - */ - function expectError($code = '*') - { - if (is_array($code)) { - array_push($this->_expected_errors, $code); - } else { - array_push($this->_expected_errors, array($code)); - } - return sizeof($this->_expected_errors); - } - - // }}} - // {{{ popExpect() - - /** - * This method pops one element off the expected error codes - * stack. - * - * @return array the list of error codes that were popped - */ - function popExpect() - { - return array_pop($this->_expected_errors); - } - - // }}} - // {{{ raiseError() - - /** - * This method is a wrapper that returns an instance of the - * configured error class with this object's default error - * handling applied. If the $mode and $options parameters are not - * specified, the object's defaults are used. - * - * @param mixed a text error message or a PEAR error object - * - * @param int a numeric error code (it is up to your class - * to define these if you want to use codes) - * - * @param int One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, - * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or - * PEAR_ERROR_CALLBACK. - * - * @param mixed If $mode is PEAR_ERROR_TRIGGER, this parameter - * specifies the PHP-internal error level (one of - * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). - * If $mode is PEAR_ERROR_CALLBACK, this - * parameter specifies the callback function or - * method. In other error modes this parameter - * is ignored. - * - * @param string If you need to pass along for example debug - * information, this parameter is meant for that. - * - * @param string The returned error object will be instantiated - * from this class, if specified. - * - * @param bool If true, raiseError will only pass error codes, - * the error message parameter will be dropped. - * - * @access public - * @return object a PEAR error object - * @see PEAR::setErrorHandling - * @since PHP 4.0.5 - */ - function &raiseError($message = null, - $code = null, - $mode = null, - $options = null, - $userinfo = null, - $error_class = null, - $skipmsg = false) - { - // The error is yet a PEAR error object - if (is_object($message)) { - $code = $message->getCode(); - $userinfo = $message->getUserInfo(); - $error_class = $message->getType(); - $message = $message->getMessage(); - } - - if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { - if ($exp[0] == "*" || - (is_int(reset($exp)) && in_array($code, $exp)) || - (is_string(reset($exp)) && in_array($message, $exp))) { - $mode = PEAR_ERROR_RETURN; - } - } - // No mode given, try global ones - if ($mode === null) { - // Class error handler - if (isset($this) && isset($this->_default_error_mode)) { - $mode = $this->_default_error_mode; - $options = $this->_default_error_options; - // Global error handler - } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { - $mode = $GLOBALS['_PEAR_default_error_mode']; - $options = $GLOBALS['_PEAR_default_error_options']; - } - } - - if ($error_class !== null) { - $ec = $error_class; - } elseif (isset($this) && isset($this->_error_class)) { - $ec = $this->_error_class; - } else { - $ec = 'PEAR_Error'; - } - if ($skipmsg) { - 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 easily override the actual error handler for some code and restore - * it later with popErrorHandling. - * - * @param mixed (same as setErrorHandling) - * @param mixed (same as setErrorHandling) - * - * @return bool Always true - * - * @see PEAR::setErrorHandling - */ - function pushErrorHandling($mode, $options = null) - { - $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this)) { - $def_mode = &$this->_default_error_mode; - $def_options = &$this->_default_error_options; - } else { - $def_mode = &$GLOBALS['_PEAR_default_error_mode']; - $def_options = &$GLOBALS['_PEAR_default_error_options']; - } - $stack[] = array($def_mode, $def_options); - - if (isset($this)) { - $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(); - } - - // Now call the shutdown functions - if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { - foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { - call_user_func_array($value[0], $value[1]); - } - } -} - -// }}} - -class PEAR_Error -{ - // {{{ properties - - var $error_message_prefix = ''; - var $mode = PEAR_ERROR_RETURN; - var $level = E_USER_NOTICE; - var $code = -1; - var $message = ''; - var $userinfo = ''; - - // Wait until we have a stack-groping function in PHP. - //var $file = ''; - //var $line = 0; - - - // }}} - // {{{ constructor - - /** - * PEAR_Error constructor - * - * @param string message - * - * @param int (optional) error code - * - * @param int (optional) error mode, one of: PEAR_ERROR_RETURN, - * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER or - * PEAR_ERROR_CALLBACK - * - * @param mixed (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) { - if (is_null($options) || is_int($options)) { - $format = "%s"; - } else { - $format = $options; - } - printf($format, $this->getMessage()); - } - if ($this->mode & PEAR_ERROR_TRIGGER) { - trigger_error($this->getMessage(), $this->level); - } - if ($this->mode & PEAR_ERROR_DIE) { - $msg = $this->getMessage(); - if (is_null($options) || is_int($options)) { - $format = "%s"; - if (substr($msg, -1) != "\n") { - $msg .= "\n"; - } - } else { - $format = $options; - } - die(sprintf($format, $msg)); - } - if ($this->mode & PEAR_ERROR_CALLBACK) { - if (is_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_message_prefix . $this->message); - } - - - // }}} - // {{{ getCode() - - /** - * Get error code from an error object - * - * @return int error code - * @access public - */ - function getCode() - { - return $this->code; - } - - // }}} - // {{{ getType() - - /** - * Get the name of this error/exception. - * - * @return string error/exception name (type) - * @access public - */ - function getType() - { - return get_class($this); - } - - // }}} - // {{{ getUserInfo() - - /** - * Get additional user-supplied information. - * - * @return string user-supplied information - * @access public - */ - function getUserInfo() - { - return $this->userinfo; - } - - // }}} - // {{{ getDebugInfo() - - /** - * Get additional debug information supplied by the application. - * - * @return string debug information - * @access public - */ - function getDebugInfo() - { - return $this->getUserInfo(); - } - - // }}} - // {{{ 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" info="%s"]', - get_class($this), $this->message, $this->code, - $callback, $this->error_message_prefix, - $this->userinfo); - } - 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" info="%s"]', - get_class($this), $this->message, $this->code, - implode("|", $modes), $levels[$this->level], - $this->error_message_prefix, - $this->userinfo); - } - - // }}} -} - -register_shutdown_function("_PEAR_call_destructors"); - -/* - * Local Variables: - * mode: php - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ -?> diff --git a/pear/PEAR/Autoloader.php b/pear/PEAR/Autoloader.php deleted file mode 100644 index f9a9d4edb6..0000000000 --- a/pear/PEAR/Autoloader.php +++ /dev/null @@ -1,186 +0,0 @@ -<?php -// /* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -if (!extension_loaded("overload")) { - // die hard without ext/overload - die("Rebuild PHP with the `overload' extension to use PEAR_Autoloader"); -} - -require_once "PEAR.php"; - -/** - * This class is for objects where you want to separate the code for - * some methods into separate classes. This is useful if you have a - * class with not-frequently-used methods that contain lots of code - * that you would like to avoid always parsing. - * - * The PEAR_Autoloader class provides autoloading and aggregation. - * The autoloading lets you set up in which classes the separated - * methods are found. Aggregation is the technique used to import new - * methods, an instance of each class providing separated methods is - * stored and called every time the aggregated method is called. - * - * @author Stig Sæther Bakken <ssb@fast.no> - */ -class PEAR_Autoloader extends PEAR -{ - /** - * Map of methods and classes where they are defined - * - * @var array - * - * @access private - */ - var $_autoload_map = array(); - - /** - * Map of methods and aggregate objects - * - * @var array - * - * @access private - */ - var $_method_map = array(); - - /** - * Add one or more autoload entries. - * - * @param string $method which method to autoload - * - * @param string $classname (optional) which class to find the method in. - * If the $method parameter is an array, this - * parameter may be omitted (and will be ignored - * if not), and the $method parameter will be - * treated as an associative array with method - * names as keys and class names as values. - * - * @return void - * - * @access public - */ - function addAutoload($method, $classname = null) - { - if (is_array($method)) { - $this->_autoload_map = array_merge($this->_autoload_map, $method); - } else { - $this->_autoload_map[$method] = $classname; - } - } - - /** - * Remove an autoload entry. - * - * @param string $method which method to remove the autoload entry for - * - * @return bool TRUE if an entry was removed, FALSE if not - * - * @access public - */ - function removeAutoload($method) - { - $ok = isset($this->_autoload_map[$method]); - unset($this->_autoload_map[$method]); - return $ok; - } - - /** - * Add an aggregate object to this object. If the specified class - * is not defined, loading it will be attempted following PEAR's - * file naming scheme. All the methods in the class will be - * aggregated, except private ones (name starting with an - * underscore) and constructors. - * - * @param string $classname what class to instantiate for the object. - * - * @return void - * - * @access public - */ - function addAggregateObject($classname) - { - $classname = strtolower($classname); - if (!class_exists($classname)) { - $include_file = preg_replace('/[^a-z0-9]/i', '_', $classname); - include_once $include_file; - } - $obj =& new $classname; - $methods = get_class_methods($classname); - foreach ($methods as $method) { - // don't import priviate methods and constructors - if ($method{0} != '_' && $method != $classname) { - $this->_method_map[$method] = $obj; - } - } - } - - /** - * Remove an aggregate object. - * - * @param string $classname the class of the object to remove - * - * @return bool TRUE if an object was removed, FALSE if not - * - * @access public - */ - function removeAggregateObject($classname) - { - $ok = false; - $classname = strtolower($classname); - reset($this->_method_map); - while (list($method, $obj) = each($this->_method_map)) { - if (get_class($obj) == $classname) { - unset($this->_method_map[$method]); - $ok = true; - } - } - return $ok; - } - - /** - * Overloaded object call handler, called each time an - * undefined/aggregated method is invoked. This method repeats - * the call in the right aggregate object and passes on the return - * value. - * - * @param string $method which method that was called - * - * @param string $args An array of the parameters passed in the - * original call - * - * @return mixed The return value from the aggregated method, or a PEAR - * error if the called method was unknown. - */ - function __call($method, $args, &$retval) - { - if (empty($this->_method_map[$method]) && isset($this->_autoload_map[$method])) { - $this->addAggregateObject($this->_autoload_map[$method]); - } - if (isset($this->_method_map[$method])) { - $retval = call_user_func_array(array($this->_method_map[$method], $method), $args); - return true; - } - return false; - } -} - -overload("PEAR_Autoloader"); - -?> diff --git a/pear/PEAR/Command.php b/pear/PEAR/Command.php deleted file mode 100644 index 6127a97099..0000000000 --- a/pear/PEAR/Command.php +++ /dev/null @@ -1,290 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - - -require_once "PEAR.php"; - -/** - * List of commands and what classes they are implemented in. - * @var array command => implementing class - */ -$GLOBALS['_PEAR_Command_commandlist'] = array(); - -/** - * Array of command objects - * @var array class => object - */ -$GLOBALS['_PEAR_Command_objects'] = array(); - -/** - * Which user interface class is being used. - * @var string class name - */ -$GLOBALS['_PEAR_Command_uiclass'] = 'PEAR_Frontend_CLI'; - -/** - * Instance of $_PEAR_Command_uiclass. - * @var object - */ -$GLOBALS['_PEAR_Command_uiobject'] = null; - -/** - * PEAR command class, a simple factory class for administrative - * commands. - * - * How to implement command classes: - * - * - The class must be called PEAR_Command_Nnn, installed in the - * "PEAR/Common" subdir, with a method called getCommands() that - * returns an array of the commands implemented by the class (see - * PEAR/Command/Install.php for an example). - * - * - The class must implement a run() function that is called with three - * params: - * - * (string) command name - * (array) assoc array with options, freely defined by each - * command, for example: - * array('force' => true) - * (array) list of the other parameters - * - * The run() function returns a PEAR_CommandResponse object. Use - * these methods to get information: - * - * int getStatus() Returns PEAR_COMMAND_(SUCCESS|FAILURE|PARTIAL) - * *_PARTIAL means that you need to issue at least - * one more command to complete the operation - * (used for example for validation steps). - * - * string getMessage() Returns a message for the user. Remember, - * no HTML or other interface-specific markup. - * - * If something unexpected happens, run() returns a PEAR error. - * - * - DON'T OUTPUT ANYTHING! Return text for output instead. - * - * - DON'T USE HTML! The text you return will be used from both Gtk, - * web and command-line interfaces, so for now, keep everything to - * plain text. There may be a common (XML) markup format later. - * - * - DON'T USE EXIT OR DIE! Always use pear errors. From static - * classes do PEAR::raiseError(), from other classes do - * $this->raiseError(). - */ -class PEAR_Command -{ - /** - * Get the right object for executing a command. - * - * @param string $command The name of the command - * @param object $config Instance of PEAR_Config object - * - * @return object the command object or a PEAR error - * - * @access public - */ - function factory($command, &$config) - { - if (empty($GLOBALS['_PEAR_Command_commandlist'])) { - PEAR_Command::registerCommands(); - } - $class = @$GLOBALS['_PEAR_Command_commandlist'][$command]; - if (empty($class)) { - return PEAR::raiseError("unknown command `$command'"); - } - $ui = PEAR_Command::getFrontendObject(); - $obj = &new $class($ui, $config); - return $obj; - } - - /** - * Get instance of frontend object. - * - * @return object - */ - function &getFrontendObject() - { - if (empty($GLOBALS['_PEAR_Command_uiobject'])) { - $GLOBALS['_PEAR_Command_uiobject'] = &new $GLOBALS['_PEAR_Command_uiclass']; - } - return $GLOBALS['_PEAR_Command_uiobject']; - } - - /** - * Load current frontend class. - * - * @param string $uiclass Name of class implementing the frontend - * - * @return object the frontend object, or a PEAR error - */ - function &setFrontendClass($uiclass) - { - $file = str_replace('_', '/', $uiclass) . '.php'; - @include_once $file; - if (class_exists(strtolower($uiclass))) { - $obj = &new $uiclass; - // quick test to see if this class implements a few of the most - // important frontend methods - if (method_exists($obj, 'displayLine') && method_exists($obj, 'userConfirm')) { - $GLOBALS['_PEAR_Command_uiobject'] = &$obj; - $GLOBALS['_PEAR_Command_uiclass'] = $uiclass; - return $obj; - } else { - return PEAR::raiseError("not a frontend class: $uiclass"); - } - } - return PEAR::raiseError("no such class: $uiclass"); - } - - /** - * Set current frontend. - * - * @param string $uitype Name of the frontend type (for example "CLI") - * - * @return object the frontend object, or a PEAR error - */ - function setFrontendType($uitype) - { - $uiclass = 'PEAR_Frontend_' . $uitype; - return PEAR_Command::setFrontendClass($uiclass); - } - - /** - * Scan through the Command directory looking for classes - * and see what commands they implement. - * - * @param bool (optional) if FALSE (default), the new list of - * commands should replace the current one. If TRUE, - * new entries will be merged with old. - * - * @param string (optional) where (what directory) to look for - * classes, defaults to the Command subdirectory of - * the directory from where this file (__FILE__) is - * included. - * - * @return bool TRUE on success, a PEAR error on failure - * - * @access public - */ - function registerCommands($merge = false, $dir = null) - { - if ($dir === null) { - $dir = dirname(__FILE__) . '/Command'; - } - $dp = @opendir($dir); - if (empty($dp)) { - return PEAR::raiseError("registerCommands: opendir($dir) failed"); - } - if (!$merge) { - $GLOBALS['_PEAR_Command_commandlist'] = array(); - } - while ($entry = readdir($dp)) { - if ($entry{0} == '.' || substr($entry, -4) != '.php' || $entry == 'Common.php') { - continue; - } - $class = "PEAR_Command_".substr($entry, 0, -4); - $file = "$dir/$entry"; - include_once $file; - // List of commands - if (empty($GLOBALS['_PEAR_Command_objects'][$class])) { - $GLOBALS['_PEAR_Command_objects'][$class] = &new $class($ui, $config); - } - $implements = $GLOBALS['_PEAR_Command_objects'][$class]->getCommands(); - foreach ($implements as $command => $desc) { - $GLOBALS['_PEAR_Command_commandlist'][$command] = $class; - $GLOBALS['_PEAR_Command_commanddesc'][$command] = $desc; - } - } - return true; - } - - /** - * Get the list of currently supported commands, and what - * classes implement them. - * - * @return array command => implementing class - * - * @access public - */ - function getCommands() - { - if (empty($GLOBALS['_PEAR_Command_commandlist'])) { - PEAR_Command::registerCommands(); - } - return $GLOBALS['_PEAR_Command_commandlist']; - } - - /** - * Compiles arguments for getopt. - * - * @param string $command command to get optstring for - * @param string $short_args (reference) short getopt format - * @param array $long_args (reference) long getopt format - * - * @return void - * - * @access public - */ - function getGetoptArgs($command, &$short_args, &$long_args) - { - if (empty($GLOBALS['_PEAR_Command_commandlist'])) { - PEAR_Command::registerCommands(); - } - $class = @$GLOBALS['_PEAR_Command_commandlist'][$command]; - if (empty($class)) { - return null; - } - $obj = &$GLOBALS['_PEAR_Command_objects'][$class]; - return $obj->getGetoptArgs($command, $short_args, $long_args); - } - - /** - * Get description for a command. - * - * @param string $command Name of the command - * - * @return string command description - * - * @access public - */ - function getDescription($command) - { - return @$GLOBALS['_PEAR_Command_commanddesc'][$command]; - } - - /** - * Get help for command. - * - * @param string $command Name of the command to return help for - * - * @access public - */ - function getHelp($command) - { - $cmds = PEAR_Command::getCommands(); - if (isset($cmds[$command])) { - $class = $cmds[$command]; - return $GLOBALS['_PEAR_Command_objects'][$class]->getHelp($command); - } - return false; - } -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Auth.php b/pear/PEAR/Command/Auth.php deleted file mode 100644 index 5f99b2756e..0000000000 --- a/pear/PEAR/Command/Auth.php +++ /dev/null @@ -1,131 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR/Command/Common.php"; -require_once "PEAR/Remote.php"; -require_once "PEAR/Config.php"; - -/** - * PEAR commands for managing configuration data. - * - */ -class PEAR_Command_Auth extends PEAR_Command_Common -{ - var $commands = array( - 'login' => array( - 'summary' => 'Connects and authenticates to remote server', - 'function' => 'doLogin', - 'options' => array(), - 'doc' => 'To use functions in the installer that require any kind -of privilege, you need to log in first. The username and password you enter -here will be stored in your per-user PEAR configuration (~/.pearrc on -Unix-like systems). After logging in, your username and password will be -passed along in every subsequent operation on the remote server. -', - ), - 'logout' => array( - 'summary' => 'Logs out from the remote server', - 'function' => 'doLogout', - 'options' => array(), - 'doc' => 'Logs out from the remote server. -This command does not actually connect to the remote -server, it only deletes the stored username and password from your -user configuration. -', - ) - - ); - - /** - * PEAR_Command_Auth constructor. - * - * @access public - */ - function PEAR_Command_Auth(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - /** - * Execute the 'login' command. - * - * @param string $command command name - * - * @param array $options option_name => value - * - * @param array $params list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function doLogin($command, $options, $params) - { - $server = $this->config->get('master_server'); - $remote = new PEAR_Remote($this->config); - $username = $this->config->get('username'); - if (empty($username)) { - $username = @$_ENV['USER']; - } - $this->ui->displayLine("Logging in to $server."); - $username = trim($this->ui->userDialog('Username', 'text', $username)); - - $this->config->set('username', $username); - $password = trim($this->ui->userDialog('Password', 'password')); - $this->config->set('password', $password); - $remote->expectError(401); - $ok = $remote->call('logintest'); - $remote->popExpect(); - if ($ok === true) { - $this->ui->displayLine("Logged in."); - $this->config->store(); - } else { - $this->ui->displayLine("Login failed!"); - } - - } - - /** - * Execute the 'logout' command. - * - * @param string $command command name - * - * @param array $options option_name => value - * - * @param array $params list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function doLogout($command, $options, $params) - { - $server = $this->config->get('master_server'); - $this->ui->displayLine("Logging out from $server."); - $this->config->remove('username'); - $this->config->remove('password'); - $this->config->store(); - } - -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Common.php b/pear/PEAR/Command/Common.php deleted file mode 100644 index dc308c6896..0000000000 --- a/pear/PEAR/Command/Common.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Sæther Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR.php"; - -class PEAR_Command_Common extends PEAR -{ - // {{{ properties - - /** - * PEAR_Config object used to pass user system and configuration - * on when executing commands - * - * @var object - */ - var $config; - - /** - * User Interface object, for all interaction with the user. - * @var object - */ - var $ui; - - // }}} - // {{{ constructor - - /** - * PEAR_Command_Common constructor. - * - * @access public - */ - function PEAR_Command_Common(&$ui, &$config) - { - parent::PEAR(); - $this->config = &$config; - $this->ui = &$ui; - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - $ret = array(); - foreach (array_keys($this->commands) as $command) { - $ret[$command] = $this->commands[$command]['summary']; - } - return $ret; - } - - // }}} - // {{{ getOptions() - - function getOptions($command) - { - return @$this->commands[$command]['options']; - } - - // }}} - // {{{ getGetoptArgs() - - function getGetoptArgs($command, &$short_args, &$long_args) - { - $short_args = ""; - $long_args = array(); - if (empty($this->commands[$command])) { - return; - } - reset($this->commands[$command]); - while (list($option, $info) = each($this->commands[$command]['options'])) { - $larg = $sarg = ''; - if (isset($info['arg'])) { - if ($info['arg']{0} == '(') { - $larg = '=='; - $sarg = '::'; - $arg = substr($info['arg'], 1, -1); - } else { - $larg = '='; - $sarg = ':'; - $arg = $info['arg']; - } - } - if (isset($info['shortopt'])) { - $short_args .= $info['shortopt'] . $sarg; - } - $long_args[] = $option . $larg; - } - } - - // }}} - // {{{ getHelp() - - function getHelp($command) - { - $help = preg_replace('/{config\s+([^\}]+)}/e', "\$config->get('\1')", @$this->commands[$command]['doc']); - return $help; - } - - // }}} - // {{{ run() - - function run($command, $options, $params) - { - $func = @$this->commands[$command]['function']; - if (empty($func)) { - return $this->raiseError("unknown command `$command'"); - } - return $this->$func($command, $options, $params); - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Config.php b/pear/PEAR/Command/Config.php deleted file mode 100644 index 2775a306e9..0000000000 --- a/pear/PEAR/Command/Config.php +++ /dev/null @@ -1,169 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR/Command/Common.php"; -require_once "PEAR/Config.php"; - -/** - * PEAR commands for managing configuration data. - * - */ -class PEAR_Command_Config extends PEAR_Command_Common -{ - var $commands = array( - 'config-show' => array( - 'summary' => 'Show All Settings', - 'options' => array(), - 'doc' => 'Displays all configuration values. An optional argument -may be used to tell which configuration layer to display. Valid -configuration layers are "user", "system" and "default". -', - ), - 'config-get' => array( - 'summary' => 'Show One Setting', - 'options' => array(), - 'doc' => 'Displays the value of one configuration parameter. The -first argument is the name of the parameter, an optional second argument -may be used to tell which configuration layer to look in. Valid configuration -layers are "user", "system" and "default". If no layer is specified, a value -will be picked from the first layer that defines the parameter, in the order -just specified. -', - ), - 'config-set' => array( - 'summary' => 'Change Setting', - 'options' => array(), - 'doc' => 'Sets the value of one configuration parameter. The first -argument is the name of the parameter, the second argument is the new value. -Some parameters are be subject to validation, and the command will fail with -an error message if the new value does not make sense. An optional third -argument may be used to specify which layer to set the configuration parameter -in. The default layer is "user". -', - ), - ); - - /** - * PEAR_Command_Config constructor. - * - * @access public - */ - function PEAR_Command_Config(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - function run($command, $options, $params) - { - $cf = &$this->config; - $failmsg = ''; - switch ($command) { - case 'config-show': { - // $params[0] -> the layer - if ($error = $this->_checkLayer(@$params[0])) { - $failmsg .= $error; - break; - } - $keys = $cf->getKeys(); - sort($keys); - $this->ui->startTable(array('caption' => 'Configuration:')); - foreach ($keys as $key) { - $type = $cf->getType($key); - $value = $cf->get($key, @$params[0]); - if ($type == 'password' && $value) { - $value = '********'; - } - if (empty($value)) { - $value = '<not set>'; - } - $this->ui->tableRow(array($key, $value)); - } - $this->ui->endTable(); - break; - } - case 'config-get': { - // $params[0] -> the parameter - // $params[1] -> the layer - if ($error = $this->_checkLayer(@$params[1])) { - $failmsg .= $error; - break; - } - if (sizeof($params) < 1 || sizeof($params) > 2) { - $failmsg .= "config-get expects 1 or 2 parameters. Try \"help config-get\" for help"; - } elseif (sizeof($params) == 1) { - $this->ui->displayLine("$params[0] = " . $cf->get($params[0])); - } else { - $this->ui->displayLine("($params[1])$params[0] = " . - $cf->get($params[0], $params[1])); - } - break; - } - case 'config-set': { - // $param[0] -> a parameter to set - // $param[1] -> the value for the parameter - // $param[2] -> the layer - if (sizeof($params) < 2 || sizeof($params) > 3) { - $failmsg .= "config-set expects 2 or 3 parameters. Try \"help config-set\" for help"; - break; - } - if ($error = $this->_checkLayer(@$params[2])) { - $failmsg .= $error; - break; - } - if (!call_user_func_array(array(&$cf, 'set'), $params)) - { - $failmsg = "config-set (" . implode(", ", $params) . ") failed"; - } else { - $cf->store(); - } - break; - } - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - /** - * Checks if a layer is defined or not - * - * @param string $layer The layer to search for - * @return mixed False on no error or the error message - */ - function _checkLayer($layer = null) - { - if (!empty($layer)) { - $layers = $this->config->getLayers(); - if (!in_array($layer, $layers)) { - return " only the layers: \"" . implode('" or "', $layers) . "\" are supported"; - } - } - return false; - } - -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Install.php b/pear/PEAR/Command/Install.php deleted file mode 100644 index d136e740a5..0000000000 --- a/pear/PEAR/Command/Install.php +++ /dev/null @@ -1,210 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Sæther Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "PEAR/Command/Common.php"; -require_once "PEAR/Installer.php"; -require_once "Console/Getopt.php"; - -/** - * PEAR commands for installation or deinstallation/upgrading of - * packages. - * - */ -class PEAR_Command_Install extends PEAR_Command_Common -{ - // {{{ command definitions - - var $commands = array( - 'install' => array( - 'summary' => 'Install Package', - 'function' => 'doInstall', - 'options' => array( - 'force' => array( - 'shortopt' => 'f', - 'doc' => 'will overwrite newer installed packages', - ), - 'nodeps' => array( - 'shortopt' => 'n', - 'doc' => 'ignore dependencies, install anyway', - ), - 'register-only' => array( - 'shortopt' => 'r', - 'doc' => 'do not install files, only register the package as installed', - ), - 'soft' => array( - 'shortopt' => 's', - 'doc' => 'soft install, fail silently, or upgrade if already installed', - ), - 'nocompress' => array( - 'shortopt' => 'Z', - 'doc' => 'request uncompressed files when downloading', - ), - ), - 'doc' => 'Installs one or more PEAR packages. You can specify a package to -install in four ways: - -"Package-1.0.tgz" : installs from a local file - -"http://example.com/Package-1.0.tgz" : installs from -anywhere on the net. - -"package.xml" : installs the package described in -package.xml. Useful for testing, or for wrapping a PEAR package in -another package manager such as RPM. - -"Package" : queries your configured server -({config master_server}) and downloads the newest package with -the preferred quality/state ({config preferred_state}). - -More than one package may be specified at once. It is ok to mix these -four ways of specifying packages. -'), - 'upgrade' => array( - 'summary' => 'Upgrade Package', - 'function' => 'doInstall', - 'options' => array( - 'force' => array( - 'shortopt' => 'f', - 'doc' => 'overwrite newer installed packages', - ), - 'nodeps' => array( - 'shortopt' => 'n', - 'doc' => 'ignore dependencies, upgrade anyway', - ), - 'register-only' => array( - 'shortopt' => 'r', - 'doc' => 'do not install files, only register the package as upgraded', - ), - 'nocompress' => array( - 'shortopt' => 'Z', - 'request uncompressed files when downloading', - ), - ), - 'doc' => 'Upgrades one or more PEAR packages. See documentation for the -"install" command for ways to specify a package. - -When upgrading, your package will be updated if the provided new -package has a higher version number (use the -f option if you need to -upgrade anyway). - -More than one package may be specified at once. -'), - 'uninstall' => array( - 'summary' => 'Un-install Package', - 'function' => 'doUninstall', - 'options' => array( - 'nodeps' => array( - 'shortopt' => 'n', - 'doc' => 'ignore dependencies, uninstall anyway', - ), - 'register-only' => array( - 'shortopt' => 'r', - 'doc' => 'do not remove files, only register the packages as not installed', - ), - ), - 'doc' => 'Upgrades one or more PEAR packages. See documentation for the -"install" command for ways to specify a package. - -When upgrading, your package will be updated if the provided new -package has a higher version number (use the -f option if you need to -upgrade anyway). - -More than one package may be specified at once. -'), - - ); - - // }}} - // {{{ constructor - - /** - * PEAR_Command_Install constructor. - * - * @access public - */ - function PEAR_Command_Install(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - $ret = array(); - foreach (array_keys($this->commands) as $command) { - $ret[$command] = $this->commands[$command]['summary']; - } - return $ret; - } - - // }}} - // {{{ run() - - function run($command, $options, $params) - { - $this->installer = &new PEAR_Installer($ui); -// return parent::run($command, $options, $params); - $failmsg = ''; - switch ($command) { - case 'upgrade': - $options['upgrade'] = true; - // fall through - case 'install': - foreach ($params as $pkg) { - $bn = basename($pkg); - $info = $this->installer->install($pkg, $options, $this->config); - if (is_array($info)) { - $label = "$info[package] $info[version]"; - $this->ui->displayLine("$command ok: $label"); - } else { - $failmsg = "$command failed"; - } - } - break; - case 'uninstall': - foreach ($params as $pkg) { - if ($this->installer->uninstall($pkg, $options)) { - $this->ui->displayLine("uninstall ok"); - } else { - $failmsg = "uninstall failed"; - } - } - break; - default: - return false; - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Package.php b/pear/PEAR/Command/Package.php deleted file mode 100644 index d1cba6a6f7..0000000000 --- a/pear/PEAR/Command/Package.php +++ /dev/null @@ -1,469 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Command/Common.php'; -require_once 'PEAR/Packager.php'; -require_once 'PEAR/Common.php'; - -class PEAR_Command_Package extends PEAR_Command_Common -{ - var $commands = array( - 'package' => array( - 'summary' => 'Build Package', - 'function' => 'doPackage', - 'options' => array( - 'nocompress' => array( - 'shortopt' => 'Z', - 'doc' => 'Do not gzip the package file' - ), - '???' => array( - 'shortopt' => 'n', - 'doc' => 'Return only the created package file name. Useful for -shell script operations. -', - ), - ), - 'doc' => 'Creates a PEAR package from its description file (usually -called package.xml). -' - ), - 'package-info' => array( - 'summary' => 'Display information about a package file', - 'function' => 'doPackageInfo', - 'options' => array(), - 'doc' => 'Extracts information from a package file and displays it. -', - ), - 'package-list' => array( - 'summary' => 'List Files in Package', - 'function' => 'doPackageList', - 'options' => array(), - 'doc' => '', - ), - 'package-validate' => array( - 'summary' => 'Validate Package Consistency', - 'function' => 'doPackageValidate', - 'options' => array(), - 'doc' => '', - ), - 'cvstag' => array( - 'summary' => 'Set CVS Release Tag', - 'function' => 'doCvsTag', - 'options' => array(), - 'doc' => '', - ), - 'run-tests' => array( - 'summary' => 'Run Regression Tests', - 'function' => 'doRunTests', - 'options' => array(), - 'doc' => '', - ), - ); - - /** - * PEAR_Command_Package constructor. - * - * @access public - */ - function PEAR_Command_Package(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - function _displayValidationResults($err, $warn, $strict = false) - { - foreach ($err as $e) { - $this->ui->displayLine("Error: $e"); - } - foreach ($warn as $w) { - $this->ui->displayLine("Warning: $w"); - } - $this->ui->displayLine(sprintf('Validation: %d error(s), %d warning(s)', - sizeof($err), sizeof($warn))); - if ($strict && sizeof($err) > 0) { - $this->ui->displayLine("Fix these errors and try again."); - return false; - } - return true; - } - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - return array('package' => 'Build Package', - 'package-info' => 'Show Package Info', - 'package-list' => 'List Files in Package', - 'package-validate' => 'Validate Package', - 'cvstag' => 'Set CVS Release Tag', - 'run-tests' => 'Run Regression Tests'); - } - - // {{{ getOptions() - - function getOptions() - { - return array('Z', 'n', 'F' /*, 'd', 'q', 'Q'*/); - } - - // }}} - // {{{ getHelp() - - function getHelp($command) - { - switch ($command) { - case 'package': - return array('[-n] [<package.xml>]', - 'Creates a PEAR package from its description file (usually '. - "named as package.xml)\n". - " -n Return only the created package file name. Useful for\n". - " shell script operations.\n". - " -Z Do not compress the tar package"); - case 'package-list': - return array('<pear package>', - 'List the contents (the files) of a PEAR package'); - case 'package-info': - return array('<pear package>', - 'Shows information about a PEAR package'); - case 'package-validate': - return array('<package.(tgz|tar|xml)>', - 'Verifies a package or description file'); - case 'cvstag': - return array('<package.xml>', - 'Runs "cvs tag" on files contained in a release'); - } - } - - // }}} - // {{{ run() - - /** - * Execute the command. - * - * @param string command name - * - * @param array option_name => value - * - * @param array list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function run($command, $options, $params) - { - $failmsg = ''; - switch ($command) { - case 'package': - case 'package-list': - case 'package-info': - case 'package-validate': - break; - // {{{ cvstag - - case 'cvstag': { - } - - // }}} - // {{{ run-tests - - case 'run-tests': { - break; - } - - // }}} - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} - - - function doPackage($command, $options, $params) - { - $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml'; - ob_start(); - $packager =& new PEAR_Packager($this->config->get('php_dir'), - $this->config->get('ext_dir'), - $this->config->get('doc_dir')); - $packager->debug = $this->config->get('verbose'); - $err = $warn = array(); - $packager->validatePackageInfo($pkginfofile, $err, $warn); - if (!$this->_displayValidationResults($err, $warn, true)) { - return; - } - $compress = empty($options['Z']) ? true : false; - $result = $packager->Package($pkginfofile, $compress); - $output = ob_get_contents(); - ob_end_clean(); - if (PEAR::isError($result)) { - return $this->raiseError($result); - } - // Don't want output, only the package file name just created - if (isset($options['n'])) { - $this->ui->displayLine($result); - return; - } - $lines = explode("\n", $output); - foreach ($lines as $line) { - $this->ui->displayLine($line); - } - if (PEAR::isError($result)) { - $this->ui->displayLine("Package failed: ".$result->getMessage()); - } - return true; - } - - - function doPackageList($command, $options, $params) - { - // $params[0] -> the PEAR package to list its files - if (sizeof($params) != 1) { - return $this->raiseError("bad parameters, try \"help $command\""); - } - $obj = new PEAR_Common(); - - if (PEAR::isError($info = $obj->infoFromTgzFile($params[0]))) { - return $info; - } - $list =$info['filelist']; - $caption = 'Contents of ' . basename($params[0]); - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); - $this->ui->tableRow(array('Package Files', 'Install Destination'), - array('bold' => true)); - foreach ($list as $file => $att) { - if (isset($att['baseinstalldir'])) { - $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . - $file; - } else { - $dest = $file; - } - switch ($att['role']) { - case 'test': - $dest = '-- will not be installed --'; break; - case 'doc': - $dest = $this->config->get('doc_dir') . DIRECTORY_SEPARATOR . - $dest; - break; - case 'php': - default: - $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . - $dest; - } - $dest = preg_replace('!/+!', '/', $dest); - $file = preg_replace('!/+!', '/', $file); - $opts = array(0 => array('wrap' => 23), - 1 => array('wrap' => 45) - ); - $this->ui->tableRow(array($file, $dest), null, $opts); - } - $this->ui->endTable(); - return true; - } - - function doPackageInfo($command, $options, $params) - { - // $params[0] -> the PEAR package to list its information - if (sizeof($params) != 1) { - return $this->raiseError("bad parameter(s), try \"help $command\""); - } - - $obj = new PEAR_Common(); - if (PEAR::isError($info = $obj->infoFromTgzFile($params[0]))) { - return $info; - } - unset($info['filelist']); - unset($info['changelog']); - $keys = array_keys($info); - $longtext = array('description', 'summary'); - foreach ($keys as $key) { - if (is_array($info[$key])) { - switch ($key) { - case 'maintainers': { - $i = 0; - $mstr = ''; - foreach ($info[$key] as $m) { - if ($i++ > 0) { - $mstr .= "\n"; - } - $mstr .= $m['name'] . " <"; - if (isset($m['email'])) { - $mstr .= $m['email']; - } else { - $mstr .= $m['handle'] . '@php.net'; - } - $mstr .= "> ($m[role])"; - } - $info[$key] = $mstr; - break; - } - case 'release_deps': { - static $rel_trans = array( - 'lt' => '<', - 'le' => '<=', - 'eq' => '=', - 'ne' => '!=', - 'gt' => '>', - 'ge' => '>=', - ); - $i = 0; - $dstr = ''; - foreach ($info[$key] as $d) { - if ($i++ > 0) { - $dstr .= ", "; - } - if (isset($rel_trans[$d['rel']])) { - $d['rel'] = $rel_trans[$d['rel']]; - } - $dstr .= "$d[type] $d[rel]"; - if (isset($d['version'])) { - $dstr .= " $d[version]"; - } - } - $info[$key] = $dstr; - break; - } - default: { - $info[$key] = implode(", ", $info[$key]); - break; - } - } - } - $info[$key] = trim($info[$key]); - if (in_array($key, $longtext)) { - $info[$key] = preg_replace('/ +/', ' ', $info[$key]); - } - } - $caption = 'About ' . basename($params[0]); - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); - foreach ($info as $key => $value) { - $key = ucwords(str_replace('_', ' ', $key)); - $this->ui->tableRow(array($key, $value), null, array(1 => array('wrap' => 55))); - } - $this->ui->endTable(); - return true; - } - - function doPackageValidate($command, $options, $params) - { - if (sizeof($params) < 1) { - $params[0] = "package.xml"; - } - $obj = new PEAR_Common; - $info = null; - if (file_exists($params[0])) { - $fp = fopen($params[0], "r"); - $test = fread($fp, 5); - fclose($fp); - if ($test == "<?xml") { - $info = $obj->infoFromDescriptionFile($params[0]); - } - } - if (empty($info)) { - $info = $obj->infoFromTgzFile($params[0]); - } - if (PEAR::isError($info)) { - return $this->raiseError($info); - } - $obj->validatePackageInfo($info, $err, $warn); - $this->_displayValidationResults($err, $warn); - return true; - } - - function doCvsTag($command, $options, $params) - { - if (sizeof($params) < 1) { - $help = $this->getHelp($command); - return $this->raiseError("$command: missing parameter: $help[0]"); - } - $obj = new PEAR_Common; - $info = $obj->infoFromDescriptionFile($params[0]); - if (PEAR::isError($info)) { - return $this->raiseError($info); - } - $err = $warn = array(); - $obj->validatePackageInfo($info, $err, $warn); - if (!$this->_displayValidationResults($err, $warn, true)) { - break; - } - $version = $info['version']; - $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version); - $cvstag = "RELEASE_$cvsversion"; - $files = array_keys($info['filelist']); - $command = "cvs"; - if (isset($options['q'])) { - $command .= ' -q'; - } - if (isset($options['Q'])) { - $command .= ' -Q'; - } - $command .= ' tag'; - if (isset($options['F'])) { - $command .= ' -F'; - } - if (isset($options['d'])) { - $command .= ' -d'; - } - $command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]); - foreach ($files as $file) { - $command .= ' ' . escapeshellarg($file); - } - $this->ui->displayLine("+ $command"); - if (empty($options['n'])) { - $fp = popen($command, "r"); - while ($line = fgets($fp, 1024)) { - $this->ui->displayLine(rtrim($line)); - } - pclose($fp); - } - return true; - } - - function doRunTests($command, $options, $params) - { - $cwd = getcwd(); - $php = PHP_BINDIR . '/php' . (OS_WINDOWS ? '.exe' : ''); - putenv("TEST_PHP_EXECUTABLE=$php"); - $ip = ini_get("include_path"); - $ps = OS_WINDOWS ? ';' : ':'; - $run_tests = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . 'run-tests.php'; - if (!file_exists($run_tests)) { - $run_tests = PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . 'run-tests.php'; - } - $plist = implode(" ", $params); - $cmd = "$php -d include_path=$cwd$ps$ip $run_tests $plist"; - system($cmd); - return true; - } -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Registry.php b/pear/PEAR/Command/Registry.php deleted file mode 100644 index be5bf182a8..0000000000 --- a/pear/PEAR/Command/Registry.php +++ /dev/null @@ -1,161 +0,0 @@ -<?php -// /* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Command/Common.php'; -require_once 'PEAR/Registry.php'; -require_once 'PEAR/Config.php'; - -class PEAR_Command_Registry extends PEAR_Command_Common -{ - // {{{ constructor - - /** - * PEAR_Command_Registry constructor. - * - * @access public - */ - function PEAR_Command_Registry(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - return array('list-installed' => 'List Installed Packages', - 'shell-test' => 'Shell Script Test'); - } - - function getHelp($command) - { - switch ($command) { - case 'list-installed': - return array(null, 'List the installed PEAR packages in the system'); - case 'shell-test': - return array('<package name> [<relation>] [<version>]', - "Tests if a package is installed in the system. Will exit(1) if it is not.\n". - " <relation> The version comparison operator. One of:\n". - " <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne\n". - " <version> The version to compare with"); - } - } - - // }}} - // {{{ run() - - /** - * Execute the command. - * - * @param string command name - * - * @param array option_name => value - * - * @param array list of additional parameters - * - * @return bool TRUE on success, FALSE if the command was unknown, - * or a PEAR error on failure - * - * @access public - */ - function run($command, $options, $params) - { - $failmsg = ''; - $cf = &PEAR_Config::singleton(); - switch ($command) { - // {{{ list-installed - - case 'list-installed': { - $reg = new PEAR_Registry($cf->get('php_dir')); - $installed = $reg->packageInfo(); - $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Installed packages:', - 'border' => true)); - foreach ($installed as $package) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version', 'State'), - array('bold' => true)); - } - $this->ui->tableRow(array($package['package'], - $package['version'], - @$package['release_state'])); - } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed yet)')); - } - $this->ui->endTable(); - break; - } - - // }}} - case 'shell-test': { - // silence error messages for the rest of the execution - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $reg = &new PEAR_Registry($this->config->get('php_dir')); - // "pear shell-test Foo" - if (sizeof($params) == 1) { - if (!$reg->packageExists($params[0])) { - exit(1); - } - // "pear shell-test Foo 1.0" - } elseif (sizeof($params) == 2) { - $v = $reg->packageInfo($params[0], 'version'); - if (!$v || !version_compare($v, $params[1], "ge")) { - exit(1); - } - // "pear shell-test Foo ge 1.0" - } elseif (sizeof($params) == 3) { - $v = $reg->packageInfo($params[0], 'version'); - if (!$v || !version_compare($v, $params[2], $params[1])) { - exit(1); - } - } else { - PEAR::popErrorHandling(); - PEAR::raiseError("$command: expects 1 to 3 parameters"); - exit(1); - } - break; - } - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} - - -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php deleted file mode 100644 index def57a4be1..0000000000 --- a/pear/PEAR/Command/Remote.php +++ /dev/null @@ -1,212 +0,0 @@ -<?php -// /* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// | | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Command/Common.php'; -require_once 'PEAR/Common.php'; -require_once 'PEAR/Remote.php'; - -class PEAR_Command_Remote extends PEAR_Command_Common -{ - // {{{ constructor - - /** - * PEAR_Command_Remote constructor. - * - * @access public - */ - function PEAR_Command_Remote(&$ui, &$config) - { - parent::PEAR_Command_Common($ui, $config); - } - - // }}} - - // {{{ getCommands() - - /** - * Return a list of all the commands defined by this class. - * @return array list of commands - * @access public - */ - function getCommands() - { - return array('remote-package-info' => 'Information About Remote Package', - 'list-upgrades' => 'List Available Upgrades', - 'list-remote-packages' => 'List Remote Packages', - 'download' => 'Download Package'); - } - - // }}} - // {{{ run() - - /** - * Execute the command. - * - * @param string command name - * - * @param array option_name => value - * - * @param array list of additional parameters - * - * @return bool TRUE on success, FALSE for unknown commands, or - * a PEAR error on failure - * - * @access public - */ - function run($command, $options, $params) - { - $failmsg = ''; - $remote = &new PEAR_Remote($this->config); - switch ($command) { - // {{{ remote-package-info - - case 'remote-package-info': { - break; - } - - // }}} - // {{{ list-remote-packages - - case 'list-remote-packages': { - $r = new PEAR_Remote($this->config); - $available = $r->call('package.listAll', true); - if (PEAR::isError($available)) { - return $this->raiseError($available); - } - $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Available packages:', - 'border' => true)); - foreach ($available as $name => $info) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version'), - array('bold' => true)); - } - $this->ui->tableRow(array($name, $info['stable'])); - } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed yet)')); - } - $this->ui->endTable(); - break; - } - - // }}} - // {{{ download - - case 'download': { - //$params[0] -> The package to download - if (count($params) != 1) { - return PEAR::raiseError("download expects one argument: the package to download"); - } - $server = $this->config->get('master_server'); - if (!ereg('^http://', $params[0])) { - $pkgfile = "http://$server/get/$params[0]"; - } else { - $pkgfile = $params[0]; - } - $this->bytes_downloaded = 0; - $saved = PEAR_Common::downloadHttp($pkgfile, $this->ui, '.', - array(&$this, 'downloadCallback')); - if (PEAR::isError($saved)) { - return $this->raiseError($saved); - } - $fname = basename($saved); - $this->ui->displayLine("File $fname downloaded ($this->bytes_downloaded bytes)"); - break; - } - - // }}} - // {{{ list-upgrades - - case 'list-upgrades': { - include_once "PEAR/Registry.php"; - if (empty($params[0])) { - $state = $this->config->get('preferred_state'); - } else { - $state = $params[0]; - } - $caption = 'Available Upgrades'; - if (empty($state) || $state == 'any') { - $latest = $remote->call("package.listLatestReleases"); - } else { - $latest = $remote->call("package.listLatestReleases", $state); - $caption .= ' (' . $state . ')'; - } - $caption .= ':'; - if (PEAR::isError($latest)) { - return $latest; - } - $reg = new PEAR_Registry($this->config->get('php_dir')); - $inst = array_flip($reg->listPackages()); - $this->ui->startTable(array('caption' => $caption, - 'border' => 1)); - $this->ui->tableRow(array('Package', 'Version', 'Size'), - array('bold' => true)); - foreach ($latest as $package => $info) { - if (!isset($inst[$package])) { - // skip packages we don't have installed - continue; - } - extract($info); - $inst_version = $reg->packageInfo($package, 'version'); - if (version_compare($version, $inst_version, "le")) { - // installed version is up-to-date - continue; - } - if ($filesize >= 20480) { - $filesize += 1024 - ($filesize % 1024); - $fs = sprintf("%dkB", $filesize / 1024); - } elseif ($filesize > 0) { - $filesize += 103 - ($filesize % 103); - $fs = sprintf("%.1fkB", $filesize / 1024.0); - } else { - $fs = " -"; // XXX center instead - } - $this->ui->tableRow(array($package, $version, $fs)); - } - $this->ui->endTable(); - break; - } - - // }}} - default: { - return false; - } - } - if ($failmsg) { - return $this->raiseError($failmsg); - } - return true; - } - - // }}} - - function downloadCallback($msg, $params = null) - { - if ($msg == 'done') { - $this->bytes_downloaded = $params; - } - } -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php deleted file mode 100644 index 6720646178..0000000000 --- a/pear/PEAR/Common.php +++ /dev/null @@ -1,1458 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; -require_once 'Archive/Tar.php'; -require_once 'System.php'; -require_once 'PEAR/Config.php'; - -// {{{ globals - -/** - * List of temporary files and directories registered by - * PEAR_Common::addTempFile(). - * @var array - */ -$GLOBALS['_PEAR_Common_tempfiles'] = array(); - -/** - * Valid maintainer roles - * @var array - */ -$GLOBALS['_PEAR_Common_maintainer_roles'] = array('lead','developer','contributor','helper'); - -/** - * Valid release states - * @var array - */ -$GLOBALS['_PEAR_Common_release_states'] = array('alpha','beta','stable','snapshot','devel'); - -/** - * Valid dependency types - * @var array - */ -$GLOBALS['_PEAR_Common_dependency_types'] = array('pkg','ext','php','prog','ldlib','rtlib','os','websrv','sapi'); - -/** - * Valid dependency relations - * @var array - */ -$GLOBALS['_PEAR_Common_dependency_relations'] = array('has','eq','lt','le','gt','ge'); - -/** - * Valid file roles - * @var array - */ -$GLOBALS['_PEAR_Common_file_roles'] = array('php','ext','test','doc','data','extsrc','script'); - -/** - * Valid replacement types - * @var array - */ -$GLOBALS['_PEAR_Common_replacement_types'] = array('php-const', 'pear-config'); - -/** - * Valid "provide" types - * @var array - */ -$GLOBALS['_PEAR_Common_provide_types'] = array('ext', 'prog', 'class', 'function', 'feature', 'api'); - -/** - * Valid "provide" types - * @var array - */ -$GLOBALS['_PEAR_Common_script_phases'] = array('pre-install', 'post-install', 'pre-uninstall', 'post-uninstall', 'pre-build', 'post-build', 'pre-configure', 'post-configure', 'pre-setup', 'post-setup'); - -// }}} - -/** - * Class providing common functionality for PEAR adminsitration classes. - */ -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(); - - /** assoc with information about a package */ - var $pkginfo = array(); - - /** - * User Interface object (PEAR_Frontend_* class). If null, - * the log() method uses print. - * @var object - */ - var $ui = null; - - /** - * Configuration object (PEAR_Config). - * @var object - */ - var $config = null; - - var $current_path = null; - - // }}} - - // {{{ constructor - - /** - * PEAR_Common constructor - * - * @access public - */ - function PEAR_Common() - { - $this->PEAR(); - $this->config = &PEAR_Config::singleton(); - } - - // }}} - // {{{ destructor - - /** - * PEAR_Common destructor - * - * @access private - */ - function _PEAR_Common() - { - // doesn't work due to bug #14744 - //$tempfiles = $this->_tempfiles; - $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles']; - while ($file = array_shift($tempfiles)) { - if (@is_dir($file)) { - System::rm("-rf $file"); - } elseif (file_exists($file)) { - unlink($file); - } - } - } - - // }}} - // {{{ addTempFile() - - /** - * Register a temporary file or directory. When the destructor is - * executed, all registered temporary files and directories are - * removed. - * - * @param string $file name of file or directory - * - * @return void - * - * @access public - */ - function addTempFile($file) - { - $GLOBALS['_PEAR_Common_tempfiles'][] = $file; - } - - // }}} - // {{{ mkDirHier() - - /** - * Wrapper to System::mkDir(), creates a directory as well as - * any necessary parent directories. - * - * @param string $dir directory name - * - * @return bool TRUE on success, or a PEAR error - * - * @access public - */ - function mkDirHier($dir) - { - $this->log(2, "+ create dir $dir"); - return System::mkDir("-p $dir"); - } - - // }}} - // {{{ log() - - /** - * Logging method. - * - * @param int $level log level (0 is quiet, higher is noisier) - * @param string $msg message to write to the log - * - * @return void - * - * @access public - */ - function log($level, $msg) - { - if ($this->debug >= $level) { - if (is_object($this->ui)) { - $this->ui->displayLine($msg); - } else { - print "$msg\n"; - } - } - } - - // }}} - // {{{ mkTempDir() - - /** - * Create and register a temporary directory. - * - * @param string $tmpdir (optional) Directory to use as tmpdir. - * Will use system defaults (for example - * /tmp or c:\windows\temp) if not specified - * - * @return string name of created directory - * - * @access public - */ - function mkTempDir($tmpdir = '') - { - if ($tmpdir) { - $topt = "-t $tmpdir "; - } else { - $topt = ''; - } - if (!$tmpdir = System::mktemp($topt . '-d pear')) { - return false; - } - $this->addTempFile($tmpdir); - return $tmpdir; - } - - // }}} - // {{{ setFrontendObject() - - function setFrontendObject(&$ui) - { - $this->ui = &$ui; - } - - // }}} - - // {{{ _element_start() - - /** - * XML parser callback for starting elements. Used while package - * format version is not yet known. - * - * @param resource $xp XML parser resource - * @param string $name name of starting element - * @param array $attribs element attributes, name => value - * - * @return void - * - * @access private - */ - function _element_start($xp, $name, $attribs) - { - array_push($this->element_stack, $name); - $this->current_element = $name; - $spos = sizeof($this->element_stack) - 2; - $this->prev_element = ($spos >= 0) ? $this->element_stack[$spos] : ''; - $this->current_attributes = $attribs; - switch ($name) { - case 'package': { - if (isset($attribs['version'])) { - $vs = preg_replace('/[^0-9a-z]/', '_', $attribs['version']); - } else { - $vs = '1_0'; - } - $elem_start = '_element_start_'. $vs; - $elem_end = '_element_end_'. $vs; - $cdata = '_pkginfo_cdata_'. $vs; - xml_set_element_handler($xp, $elem_start, $elem_end); - xml_set_character_data_handler($xp, $cdata); - break; - } - } - } - - // }}} - // {{{ _element_end() - - /** - * XML parser callback for ending elements. Used while package - * format version is not yet known. - * - * @param resource $xp XML parser resource - * @param string $name name of ending element - * - * @return void - * - * @access private - */ - function _element_end($xp, $name) - { - } - - // }}} - - // Support for package DTD v1.0: - // {{{ _element_start_1_0() - - /** - * XML parser callback for ending elements. Used for version 1.0 - * packages. - * - * @param resource $xp XML parser resource - * @param string $name name of ending element - * - * @return void - * - * @access private - */ - function _element_start_1_0($xp, $name, $attribs) - { - array_push($this->element_stack, $name); - $this->current_element = $name; - $spos = sizeof($this->element_stack) - 2; - $this->prev_element = ($spos >= 0) ? $this->element_stack[$spos] : ''; - $this->current_attributes = $attribs; - $this->cdata = ''; - switch ($name) { - case 'dir': - if ($this->in_changelog) { - break; - } - if ($attribs['name'] != '/') { - $this->dir_names[] = $attribs['name']; - } - if (isset($attribs['baseinstalldir'])) { - $this->dir_install = $attribs['baseinstalldir']; - } - if (isset($attribs['role'])) { - $this->dir_role = $attribs['role']; - } - break; - case 'file': - if ($this->in_changelog) { - break; - } - if (isset($attribs['name'])) { - $path = ''; - if (count($this->dir_names)) { - foreach ($this->dir_names as $dir) { - $path .= $dir . DIRECTORY_SEPARATOR; - } - } - $path .= $attribs['name']; - unset($attribs['name']); - $this->current_path = $path; - $this->filelist[$path] = $attribs; - // 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 'replace': - if (!$this->in_changelog) { - $this->filelist[$this->current_path]['replacements'][] = $attribs; - } - break; - - case 'libfile': - if (!$this->in_changelog) { - $this->lib_atts = $attribs; - $this->lib_atts['role'] = 'extsrc'; - } - break; - case 'maintainers': - $this->pkginfo['maintainers'] = array(); - $this->m_i = 0; // maintainers array index - break; - case 'maintainer': - // compatibility check - if (!isset($this->pkginfo['maintainers'])) { - $this->pkginfo['maintainers'] = array(); - $this->m_i = 0; - } - $this->pkginfo['maintainers'][$this->m_i] = array(); - $this->current_maintainer =& $this->pkginfo['maintainers'][$this->m_i]; - break; - case 'changelog': - $this->pkginfo['changelog'] = array(); - $this->c_i = 0; // changelog array index - $this->in_changelog = true; - break; - case 'release': - if ($this->in_changelog) { - $this->pkginfo['changelog'][$this->c_i] = array(); - $this->current_release = &$this->pkginfo['changelog'][$this->c_i]; - } else { - $this->current_release = &$this->pkginfo; - } - break; - case 'deps': - if (!$this->in_changelog) { - $this->pkginfo['release_deps'] = array(); - } - break; - case 'dep': - // dependencies array index - if (!$this->in_changelog) { - $this->d_i = (isset($this->d_i)) ? $this->d_i + 1 : 0; - $this->pkginfo['release_deps'][$this->d_i] = $attribs; - } - break; - } - } - - // }}} - // {{{ _element_end_1_0() - - /** - * XML parser callback for ending elements. Used for version 1.0 - * packages. - * - * @param resource $xp XML parser resource - * @param string $name name of ending element - * - * @return void - * - * @access private - */ - function _element_end_1_0($xp, $name) - { - $data = trim($this->cdata); - switch ($name) { - case 'name': - switch ($this->prev_element) { - case 'package': - $this->pkginfo['package'] = ereg_replace('[^a-zA-Z0-9._]', '_', $data); - break; - case 'maintainer': - $this->current_maintainer['name'] = $data; - break; - } - break; - case 'summary': - $this->pkginfo['summary'] = $data; - break; - case 'description': - $this->pkginfo['description'] = $data; - break; - case 'user': - $this->current_maintainer['handle'] = $data; - break; - case 'email': - $this->current_maintainer['email'] = $data; - break; - case 'role': - $this->current_maintainer['role'] = $data; - break; - case 'version': - $data = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $data); - if ($this->in_changelog) { - $this->current_release['version'] = $data; - } else { - $this->pkginfo['version'] = $data; - } - break; - case 'date': - if ($this->in_changelog) { - $this->current_release['release_date'] = $data; - } else { - $this->pkginfo['release_date'] = $data; - } - break; - case 'notes': - if ($this->in_changelog) { - $this->current_release['release_notes'] = $data; - } else { - $this->pkginfo['release_notes'] = $data; - } - break; - case 'state': - if ($this->in_changelog) { - $this->current_release['release_state'] = $data; - } else { - $this->pkginfo['release_state'] = $data; - } - break; - case 'license': - $this->pkginfo['release_license'] = $data; - break; - case 'sources': - $this->lib_sources[] = $data; - break; - case 'dep': - if ($data = trim($data)) { - $this->pkginfo['release_deps'][$this->d_i]['name'] = $data; - } - break; - case 'dir': - if ($this->in_changelog) { - break; - } - array_pop($this->dir_names); - break; - case 'file': - if ($this->in_changelog) { - break; - } - if ($data) { - $path = ''; - if (count($this->dir_names)) { - foreach ($this->dir_names as $dir) { - $path .= $dir . DIRECTORY_SEPARATOR; - } - } - $path .= $data; - $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': - if ($this->in_changelog) { - break; - } - $path = ''; - if (!empty($this->dir_names)) { - foreach ($this->dir_names as $dir) { - $path .= $dir . DIRECTORY_SEPARATOR; - } - } - $path .= $this->lib_name; - $this->filelist[$path] = $this->lib_atts; - // Set the baseinstalldir only if the file don't have this attrib - if (!isset($this->filelist[$path]['baseinstalldir']) && - isset($this->dir_install)) - { - $this->filelist[$path]['baseinstalldir'] = $this->dir_install; - } - if (isset($this->lib_sources)) { - $this->filelist[$path]['sources'] = implode(' ', $this->lib_sources); - } - unset($this->lib_atts); - unset($this->lib_sources); - unset($this->lib_name); - break; - case 'libname': - if ($this->in_changelog) { - break; - } - $this->lib_name = $data; - break; - case 'maintainer': - if (empty($this->pkginfo['maintainers'][$this->m_i]['role'])) { - $this->pkginfo['maintainers'][$this->m_i]['role'] = 'lead'; - } - $this->m_i++; - break; - case 'release': - if ($this->in_changelog) { - $this->c_i++; - } - break; - case 'changelog': - $this->in_changelog = false; - break; - case 'summary': - $this->pkginfo['summary'] = $data; - break; - } - array_pop($this->element_stack); - $spos = sizeof($this->element_stack) - 1; - $this->current_element = ($spos > 0) ? $this->element_stack[$spos] : ''; - } - - // }}} - // {{{ _pkginfo_cdata_1_0() - - /** - * XML parser callback for character data. Used for version 1.0 - * packages. - * - * @param resource $xp XML parser resource - * @param string $name character data - * - * @return void - * - * @access private - */ - function _pkginfo_cdata_1_0($xp, $data) - { - if (isset($this->cdata)) { - $this->cdata .= $data; - } - } - - // }}} - - // {{{ infoFromTgzFile() - - /** - * Returns information about a package file. Expects the name of - * a gzipped tar file as input. - * - * @param string $file name of .tgz file - * - * @return array array with package information - * - * @access public - * - */ - function infoFromTgzFile($file) - { - if (!@is_file($file)) { - return $this->raiseError('tgz :: could not open file'); - } - if (substr($file, -4) == '.tar') { - $compress = false; - } else { - $compress = true; - } - $tar = new Archive_Tar($file, $compress); - $content = $tar->listContent(); - if (!is_array($content)) { - return $this->raiseError('tgz :: could not get contents of package'); - } - $xml = null; - foreach ($content as $file) { - $name = $file['filename']; - if ($name == 'package.xml') { - $xml = $name; - } elseif (ereg('^.*/package.xml$', $name, $match)) { - $xml = $match[0]; - } - } - $tmpdir = System::mkTemp('-d pear'); - $this->addTempFile($tmpdir); - if (!$xml || !$tar->extractList($xml, $tmpdir)) { - return $this->raiseError('tgz :: could not extract the package.xml file'); - } - return $this->infoFromDescriptionFile("$tmpdir/$xml"); - } - - // }}} - // {{{ infoFromDescriptionFile() - - /** - * Returns information about a package file. Expects the name of - * a package xml file as input. - * - * @param string $descfile name of package xml file - * - * @return array array with package information - * - * @access public - * - */ - function infoFromDescriptionFile($descfile) - { - if (!@is_file($descfile) || !is_readable($descfile) || - (!$fp = @fopen($descfile, 'r'))) { - return $this->raiseError("Unable to open $descfile"); - } - - // read the whole thing so we only get one cdata callback - // for each block of cdata - $data = fread($fp, filesize($descfile)); - return $this->infoFromString($data); - } - - // }}} - // {{{ infoFromString() - - /** - * Returns information about a package file. Expects the contents - * of a package xml file as input. - * - * @param string $data name of package xml file - * - * @return array array with package information - * - * @access public - * - */ - function infoFromString($data) - { - $xp = @xml_parser_create(); - if (!$xp) { - return $this->raiseError('Unable to create XML parser'); - } - xml_set_object($xp, $this); - xml_set_element_handler($xp, '_element_start', '_element_end'); - xml_set_character_data_handler($xp, '_pkginfo_cdata'); - xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false); - - $this->element_stack = array(); - $this->pkginfo = array(); - $this->current_element = false; - $this->destdir = ''; - $this->pkginfo['filelist'] = array(); - $this->filelist =& $this->pkginfo['filelist']; - $this->dir_names = array(); - $this->in_changelog = false; - - if (!xml_parse($xp, $data, 1)) { - $code = xml_get_error_code($xp); - $msg = sprintf("XML error: %s at line %d", - xml_error_string($code), - xml_get_current_line_number($xp)); - xml_parser_free($xp); - return $this->raiseError($msg, $code); - } - - xml_parser_free($xp); - - foreach ($this->pkginfo as $k => $v) { - if (!is_array($v)) { - $this->pkginfo[$k] = trim($v); - } - } - return $this->pkginfo; - } - // }}} - // {{{ xmlFromInfo() - - /** - * Return an XML document based on the package info (as returned - * by the PEAR_Common::infoFrom* methods). - * - * @param array $pkginfo package info - * - * @return string XML data - * - * @access public - */ - function xmlFromInfo($pkginfo) - { - static $maint_map = array( - "handle" => "user", - "name" => "name", - "email" => "email", - "role" => "role", - ); - $ret = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; - //$ret .= "<!DOCTYPE package SYSTEM \"http://pear.php.net/package10.dtd\">\n"; - $ret .= "<package version=\"1.0\"> - <name>$pkginfo[package]</name> - <summary>".htmlspecialchars($pkginfo['summary'])."</summary> - <description>".htmlspecialchars($pkginfo['description'])."</description> - <maintainers> -"; - foreach ($pkginfo['maintainers'] as $maint) { - $ret .= " <maintainer>\n"; - foreach ($maint_map as $idx => $elm) { - $ret .= " <$elm>"; - $ret .= htmlspecialchars($maint[$idx]); - $ret .= "</$elm>\n"; - } - $ret .= " </maintainer>\n"; - } - $ret .= " </maintainers>\n"; - $ret .= $this->_makeReleaseXml($pkginfo); - if (@sizeof($pkginfo['changelog']) > 0) { - $ret .= " <changelog>\n"; - foreach ($pkginfo['changelog'] as $oldrelease) { - $ret .= $this->_makeReleaseXml($oldrelease, true); - } - $ret .= " </changelog>\n"; - } - $ret .= "</package>\n"; - return $ret; - } - - // }}} - // {{{ _makeReleaseXml() - - /** - * Generate part of an XML description with release information. - * - * @param array $pkginfo array with release information - * @param bool $changelog whether the result will be in a changelog element - * - * @return string XML data - * - * @access private - */ - function _makeReleaseXml($pkginfo, $changelog = false) - { - // XXX QUOTE ENTITIES IN PCDATA, OR EMBED IN CDATA BLOCKS!! - $indent = $changelog ? " " : ""; - $ret = "$indent <release>\n"; - if (!empty($pkginfo['version'])) { - $ret .= "$indent <version>$pkginfo[version]</version>\n"; - } - if (!empty($pkginfo['release_date'])) { - $ret .= "$indent <date>$pkginfo[release_date]</date>\n"; - } - if (!empty($pkginfo['release_license'])) { - $ret .= "$indent <license>$pkginfo[release_license]</license>\n"; - } - if (!empty($pkginfo['release_state'])) { - $ret .= "$indent <state>$pkginfo[release_state]</state>\n"; - } - if (!empty($pkginfo['release_notes'])) { - $ret .= "$indent <notes>".htmlspecialchars($pkginfo['release_notes'])."</notes>\n"; - } - if (isset($pkginfo['release_deps']) && sizeof($pkginfo['release_deps']) > 0) { - $ret .= "$indent <deps>\n"; - foreach ($pkginfo['release_deps'] as $dep) { - $ret .= "$indent <dep type=\"$dep[type]\" rel=\"$dep[rel]\""; - if (isset($dep['version'])) { - $ret .= " version=\"$dep[version]\""; - } - if (isset($dep['name'])) { - $ret .= ">$dep[name]</dep>\n"; - } else { - $ret .= "/>\n"; - } - } - $ret .= "$indent </deps>\n"; - } - if (isset($pkginfo['filelist'])) { - $ret .= "$indent <filelist>\n"; - foreach ($pkginfo['filelist'] as $file => $fa) { - if (@$fa['role'] == 'extsrc') { - $ret .= "$indent <libfile>\n"; - $ret .= "$indent <libname>$file</libname>\n"; - $ret .= "$indent <sources>$fa[sources]</sources>\n"; - $ret .= "$indent </libfile>\n"; - } else { - @$ret .= "$indent <file role=\"$fa[role]\""; - if (isset($fa['baseinstalldir'])) { - $ret .= ' baseinstalldir="' . - htmlspecialchars($fa['baseinstalldir']) . '"'; - } - if (isset($fa['md5sum'])) { - $ret .= " md5sum=\"$fa[md5sum]\""; - } - if (!empty($fa['install-as'])) { - $ret .= ' install-as="' . - htmlspecialchars($fa['install-as']) . '"'; - } - $ret .= ' name="' . htmlspecialchars($file) . '"'; - if (empty($fa['replacements'])) { - $ret .= "/>\n"; - } else { - $ret .= ">\n"; - foreach ($fa['replacements'] as $r) { - $ret .= "$indent <replace"; - foreach ($r as $k => $v) { - $ret .= " $k=\"" . htmlspecialchars($v) .'"'; - } - $ret .= "/>\n"; - } - @$ret .= "$indent </file>\n"; - } - } - } - $ret .= "$indent </filelist>\n"; - } - $ret .= "$indent </release>\n"; - return $ret; - } - - // }}} - // {{{ _infoFromAny() - - function _infoFromAny($info) - { - if (is_string($info) && file_exists($info)) { - $tmp = substr($info, -4); - if ($tmp == '.xml') { - $info = $this->infoFromDescriptionFile($info); - } elseif ($tmp == '.tar' || $tmp == '.tgz') { - $info = $this->infoFromTgzFile($info); - } else { - $fp = fopen($params[0], "r"); - $test = fread($fp, 5); - fclose($fp); - if ($test == "<?xml") { - $info = $obj->infoFromDescriptionFile($info); - } else { - $info = $obj->infoFromTgzFile($info); - } - } - if (PEAR::isError($info)) { - return $this->raiseError($info); - } - } - return $info; - } - - // }}} - // {{{ validatePackageInfo() - - function validatePackageInfo($info, &$errors, &$warnings) - { - global $_PEAR_Common_maintainer_roles, - $_PEAR_Common_release_states, - $_PEAR_Common_dependency_types, - $_PEAR_Common_dependency_relations, - $_PEAR_Common_file_roles, - $_PEAR_Common_replacement_types; - if (PEAR::isError($info = $this->_infoFromAny($info))) { - return $this->raiseError($info); - } - if (!is_array($info)) { - return false; - } - $errors = array(); - $warnings = array(); - if (empty($info['package'])) { - $errors[] = 'missing package name'; - } - if (empty($info['summary'])) { - $errors[] = 'missing summary'; - } elseif (strpos(trim($info['summary']), "\n") !== false) { - $warnings[] = 'summary should be on a single line'; - } - if (empty($info['description'])) { - $errors[] = 'missing description'; - } - if (empty($info['release_license'])) { - $errors[] = 'missing license'; - } - if (empty($info['version'])) { - $errors[] = 'missing version'; - } - if (empty($info['release_state'])) { - $errors[] = 'missing release state'; - } elseif (!in_array($info['release_state'], $_PEAR_Common_release_states)) { - $errors[] = "invalid release state `$info[release_state]', should be one of: ".implode(' ', $_PEAR_Common_release_states); - } - if (empty($info['release_date'])) { - $errors[] = 'missing release date'; - } elseif (!preg_match('/^\d{4}-\d\d-\d\d$/', $info['release_date'])) { - $errors[] = "invalid release date `$info[release_date]', format is YYYY-MM-DD"; - } - if (empty($info['release_notes'])) { - $errors[] = "missing release notes"; - } - if (empty($info['maintainers'])) { - $errors[] = 'no maintainer(s)'; - } else { - $i = 1; - foreach ($info['maintainers'] as $m) { - if (empty($m['handle'])) { - $errors[] = "maintainer $i: missing handle"; - } - if (empty($m['role'])) { - $errors[] = "maintainer $i: missing role"; - } elseif (!in_array($m['role'], $_PEAR_Common_maintainer_roles)) { - $errors[] = "maintainer $i: invalid role `$m[role]', should be one of: ".implode(' ', $_PEAR_Common_maintainer_roles); - } - if (empty($m['name'])) { - $errors[] = "maintainer $i: missing name"; - } - if (empty($m['email'])) { - $errors[] = "maintainer $i: missing email"; - } - $i++; - } - } - if (!empty($info['deps'])) { - $i = 1; - foreach ($info['deps'] as $d) { - if (empty($d['type'])) { - $errors[] = "depenency $i: missing type"; - } elseif (!in_array($d['type'], $_PEAR_Common_dependency_types)) { - $errors[] = "dependency $i: invalid type, should be one of: ".implode(' ', $_PEAR_Common_depenency_types); - } - if (empty($d['rel'])) { - $errors[] = "dependency $i: missing relation"; - } elseif (!in_array($d['rel'], $_PEAR_Common_dependency_relations)) { - $errors[] = "dependency $i: invalid relation, should be one of: ".implode(' ', $_PEAR_Common_dependency_relations); - } - if ($d['rel'] != 'has' && empty($d['version'])) { - $warnings[] = "dependency $i: missing version"; - } elseif ($d['rel'] == 'has' && !empty($d['version'])) { - $warnings[] = "dependency $i: version ignored for `has' dependencies"; - } - if ($d['type'] == 'php' && !empty($d['name'])) { - $warnings[] = "dependency $i: name ignored for php type dependencies"; - } elseif ($d['type'] != 'php' && empty($d['name'])) { - $errors[] = "dependency $i: missing name"; - } - $i++; - } - } - if (empty($info['filelist'])) { - $errors[] = 'no files'; - } else { - foreach ($info['filelist'] as $file => $fa) { - if (empty($fa['role'])) { - $errors[] = "file $file: missing role"; - } elseif (!in_array($fa['role'], $_PEAR_Common_file_roles)) { - $errors[] = "file $file: invalid role, should be one of: ".implode(' ', $_PEAR_Common_file_roles); - } elseif ($fa['role'] == 'extsrc' && empty($fa['sources'])) { - $errors[] = "file $file: no source files"; - } - // (ssb) Any checks we can do for baseinstalldir? - // (cox) Perhaps checks that either the target dir and baseInstall - // doesn't cointain "../../" - } - } - return true; - } - - // }}} - // {{{ analyzeSourceCode() - - function analyzeSourceCode($file) - { - if (!function_exists("token_get_all")) { - return false; - } - if (!$fp = @fopen($file, "r")) { - return false; - } - $contents = fread($fp, filesize($file)); - $tokens = token_get_all($contents); - for ($i = 0; $i < sizeof($tokens); $i++) { - list($token, $data) = $tokens[$i]; - if (is_string($token)) { - var_dump($token); - } else { - print token_name($token) . ' '; - var_dump(rtrim($data)); - } - } - $look_for = 0; - $paren_level = 0; - $bracket_level = 0; - $brace_level = 0; - $lastphpdoc = ''; - $current_class = ''; - $current_class_level = -1; - $current_function = ''; - $current_function_level = -1; - $declared_classes = array(); - $declared_functions = array(); - $declared_methods = array(); - $used_classes = array(); - $used_functions = array(); - for ($i = 0; $i < sizeof($tokens); $i++) { - list($token, $data) = $tokens[$i]; - switch ($token) { - case '{': - $brace_level++; - continue 2; - case '}': - $brace_level--; - if ($current_class_level == $brace_level) { - $current_class = ''; - $current_class_level = -1; - } - if ($current_function_level == $brace_level) { - $current_function = ''; - $current_function_level = -1; - } - continue 2; - case '[': $bracket_level++; continue 2; - case ']': $bracket_level--; continue 2; - case '(': $paren_level++; continue 2; - case ')': $paren_level--; continue 2; - case T_CLASS: - case T_FUNCTION: - case T_NEW: - $look_for = $token; - continue 2; - case T_STRING: - if ($look_for == T_CLASS) { - $current_class = $data; - $current_class_level = $brace_level; - $declared_classes[] = $current_class; - } elseif ($look_for == T_FUNCTION) { - if ($current_class) { - $current_function = "$current_class::$data"; - $declared_methods[$current_class][] = $data; - } else { - $current_function = $data; - } - $current_function_level = $brace_level; - $declared_functions[] = $current_function; - } elseif ($look_for == T_NEW) { - $used_classes[$data] = true; - } - $look_for = 0; - continue 2; - case T_COMMENT: - if (preg_match('!^/\*\*\s!', $data)) { - $lastphpdoc = $data; - //$j = $i; - //while ($tokens[$j][0] == T_WHITESPACE) $j++; - // the declaration that the phpdoc applies to - // is at $tokens[$j] now - } - continue 2; - case T_DOUBLE_COLON: - $used_classes[$tokens[$i - 1][1]] = true; - continue 2; - } - } - return array( - "declared_classes" => $declared_classes, - "declared_methods" => $declared_methods, - "declared_functions" => $declared_functions, - "used_classes" => array_keys($used_classes), - ); - } - - // }}} - // {{{ detectDependencies() - - function detectDependencies($any, $status_callback = null) - { - if (!function_exists("token_get_all")) { - return false; - } - if (PEAR::isError($info = $this->_infoFromAny($any))) { - return $this->raiseError($info); - } - if (!is_array($info)) { - return false; - } - $deps = array(); - $used_c = $decl_c = array(); - foreach ($info['filelist'] as $file => $fa) { - $tmp = $this->analyzeSourceCode($file); - $used_c = @array_merge($used_c, $tmp['used_classes']); - $decl_c = @array_merge($decl_c, $tmp['declared_classes']); - } - $used_c = array_unique($used_c); - $decl_c = array_unique($decl_c); - $undecl_c = array_diff($used_c, $decl_c); - return array('used_classes' => $used_c, - 'declared_classes' => $decl_c, - 'undeclared_classes' => $undecl_c); - } - - // }}} - // {{{ getUserRoles() - - /** - * Get the valid roles for a PEAR package maintainer - * - * @return array - * @static - */ - function getUserRoles() - { - return $GLOBALS['_PEAR_Common_maintainer_roles']; - } - - // }}} - // {{{ getReleaseStates() - - /** - * Get the valid package release states of packages - * - * @return array - * @static - */ - function getReleaseStates() - { - return $GLOBALS['_PEAR_Common_release_states']; - } - - // }}} - // {{{ getDependencyTypes() - - /** - * Get the implemented dependency types (php, ext, pkg etc.) - * - * @return array - * @static - */ - function getDependencyTypes() - { - return $GLOBALS['_PEAR_Common_dependency_types']; - } - - // }}} - // {{{ getDependencyRelations() - - /** - * Get the implemented dependency relations (has, lt, ge etc.) - * - * @return array - * @static - */ - function getDependencyRelations() - { - return $GLOBALS['_PEAR_Common_dependency_relations']; - } - - // }}} - // {{{ getFileRoles() - - /** - * Get the implemented file roles - * - * @return array - * @static - */ - function getFileRoles() - { - return $GLOBALS['_PEAR_Common_file_roles']; - } - - // }}} - // {{{ getReplacementTypes() - - /** - * Get the implemented file replacement types in - * - * @return array - * @static - */ - function getReplacementTypes() - { - return $GLOBALS['_PEAR_Common_replacement_types']; - } - - // }}} - // {{{ getReplacementTypes() - - /** - * Get the implemented file replacement types in - * - * @return array - * @static - */ - function getProvideTypes() - { - return $GLOBALS['_PEAR_Common_provide_types']; - } - - // }}} - // {{{ getReplacementTypes() - - /** - * Get the implemented file replacement types in - * - * @return array - * @static - */ - function getScriptPhases() - { - return $GLOBALS['_PEAR_Common_script_phases']; - } - - // }}} - // {{{ validPackageName() - - /** - * Test whether a string contains a valid package name. - * - * @param string $name the package name to test - * - * @return bool - * - * @access public - */ - function validPackageName($name) - { - return (bool)preg_match('/^[A-Z][A-Za-z0-9_]+$/', $name); - } - - - // }}} - - // {{{ downloadHttp() - - /** - * Download a file through HTTP. Considers suggested file name in - * Content-disposition: header and can run a callback function for - * different events. The callback will be called with two - * parameters: the callback type, and parameters. The implemented - * callback types are: - * - * 'setup' called at the very beginning, parameter is a UI object - * that should be used for all output - * 'message' the parameter is a string with an informational message - * 'saveas' may be used to save with a different file name, the - * parameter is the filename that is about to be used. - * If a 'saveas' callback returns a non-empty string, - * that file name will be used as the filename instead. - * Note that $save_dir will not be affected by this, only - * the basename of the file. - * 'start' download is starting, parameter is number of bytes - * that are expected, or -1 if unknown - * 'bytesread' parameter is the number of bytes read so far - * 'done' download is complete, parameter is the total number - * of bytes read - * 'connfailed' if the TCP connection fails, this callback is called - * with array(host,port,errno,errmsg) - * 'writefailed' if writing to disk fails, this callback is called - * with array(destfile,errmsg) - * - * If an HTTP proxy has been configured (http_proxy PEAR_Config - * setting), the proxy will be used. - * - * @param string $url the URL to download - * @param object $ui PEAR_Frontend_* instance - * @param object $config PEAR_Config instance - * @param string $save_dir (optional) directory to save file in - * @param mixed $callback (optional) function/method to call for status - * updates - * - * @return string Returns the full path of the downloaded file or a PEAR - * error on failure. If the error is caused by - * socket-related errors, the error object will - * have the fsockopen error code available through - * getCode(). - * - * @access public - */ - function downloadHttp($url, &$ui, $save_dir = '.', $callback = null) - { - if ($callback) { - call_user_func($callback, 'setup', array(&$ui)); - } - if (preg_match('!^http://([^/:?#]*)(:(\d+))?(/.*)!', $url, $matches)) { - list(,$host,,$port,$path) = $matches; - } - if (isset($this)) { - $config = &$this->config; - } else { - $config = &PEAR_Config::singleton(); - } - $proxy_host = $proxy_port = null; - if ($proxy = $config->get('http_proxy')) { - list($proxy_host, $proxy_port) = explode(':', $proxy); - if (empty($proxy_port)) { - $proxy_port = 8080; - } - if ($callback) { - call_user_func($callback, 'message', "Using HTTP proxy $host:$port"); - } - } - if (empty($port)) { - $port = 80; - } - if ($proxy_host) { - $fp = @fsockopen($proxy_host, $proxy_port, $errno, $errstr); - if (!$fp) { - if ($callback) { - call_user_func($callback, 'connfailed', array($proxy_host, $proxy_port, - $errno, $errstr)); - } - return PEAR::raiseError("Connection to `$proxy_host:$proxy_port' failed: $errstr", $errno); - } - $request = "GET $url HTTP/1.0\r\n"; - } else { - $fp = @fsockopen($host, $port, $errno, $errstr); - if (!$fp) { - if ($callback) { - call_user_func($callback, 'connfailed', array($host, $port, - $errno, $errstr)); - } - return PEAR::raiseError("Connection to `$host:$port' failed: $errstr", $errno); - } - $request = "GET $path HTTP/1.0\r\n"; - } - $request .= "Host: $host:$port\r\n". - "User-Agent: ".PHP_VERSION."\r\n". - "\r\n"; - fwrite($fp, $request); - $headers = array(); - while (trim($line = fgets($fp, 1024))) { - if (preg_match('/^([^:]+):\s+(.*)\s*$/', $line, $matches)) { - $headers[strtolower($matches[1])] = trim($matches[2]); - } elseif (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) { - if ($matches[1] != 200) { - return PEAR::raiseError("File http://$host:$port$path not valid (received: $line)"); - } - } - } - if (isset($headers['content-disposition']) && - preg_match('/\sfilename=\"([^;]*\S)\"\s*(;|$)/', $headers['content-disposition'], $matches)) { - $save_as = basename($matches[1]); - } else { - $save_as = basename($url); - } - if ($callback) { - $tmp = call_user_func($callback, 'saveas', $save_as); - if ($tmp) { - $save_as = $tmp; - } - } - $dest_file = $save_dir . DIRECTORY_SEPARATOR . $save_as; - if (!$wp = @fopen($dest_file, 'wb')) { - fclose($fp); - if ($callback) { - call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg)); - } - return PEAR::raiseError("could not open $dest_file for writing"); - } - if (isset($headers['content-length'])) { - $length = $headers['content-length']; - } else { - $length = -1; - } - $bytes = 0; - if ($callback) { - call_user_func($callback, 'start', $length); - } - while ($data = @fread($fp, 1024)) { - $bytes += strlen($data); - if ($callback) { - call_user_func($callback, 'bytesread', $bytes); - } - if (!@fwrite($wp, $data)) { - fclose($fp); - if ($callback) { - call_user_func($callback, 'writefailed', array($dest_file, $php_errormsg)); - } - return PEAR::raiseError("$dest_file: write failed ($php_errormsg)"); - } - } - fclose($fp); - fclose($wp); - if ($callback) { - call_user_func($callback, 'done', $bytes); - } - // callback: done! - return $dest_file; - } - - // }}} -} - -?> diff --git a/pear/PEAR/Config.php b/pear/PEAR/Config.php deleted file mode 100644 index 8e3ed6dbd5..0000000000 --- a/pear/PEAR/Config.php +++ /dev/null @@ -1,801 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; - -/** - * Last created PEAR_Config instance. - * @var object - */ -$GLOBALS['_PEAR_Config_instance'] = null; - -define('PEAR_CONFIG_DEFAULT_DOCDIR', - PHP_DATADIR.DIRECTORY_SEPARATOR.'doc'.DIRECTORY_SEPARATOR.'pear'); -define('PEAR_DEFAULT_UMASK', umask()); - -// in case a --without-pear PHP installation is used -if (!defined('PEAR_INSTALL_DIR')) { - define('PEAR_INSTALL_DIR', PHP_LIBDIR); -} -if (!defined('PEAR_EXTENSION_DIR')) { - define('PEAR_EXTENSION_DIR', PHP_EXTENSION_DIR); -} - -/** - * This is a class for storing configuration data, keeping track of - * which are system-defined, user-defined or defaulted. - */ -class PEAR_Config extends PEAR -{ - // {{{ properties - - /** - * Array of config files used. - * - * @var array layer => config file - */ - var $files = array( - 'system' => '', - 'user' => '', - ); - - var $layers = array(); - - /** - * Configuration data, two-dimensional array where the first - * dimension is the config layer ('user', 'system' and 'default'), - * and the second dimension is keyname => value. - * - * The order in the first dimension is important! Earlier - * layers will shadow later ones when a config value is - * requested (if a 'user' value exists, it will be returned first, - * then 'system' and finally 'default'). - * - * @var array layer => array(keyname => value, ...) - */ - var $configuration = array( - 'user' => array(), - 'system' => array(), - 'default' => array(), - ); - - /** - * Information about the configuration data. Stores the type, - * default value and a documentation string for each configuration - * value. - * - * @var array layer => array(infotype => value, ...) - */ - var $configuration_info = array( - 'master_server' => array( - 'type' => 'string', - 'default' => 'pear.php.net', - 'doc' => 'name of the main PEAR server', - ), - 'php_dir' => array( - 'type' => 'directory', - 'default' => PEAR_INSTALL_DIR, - 'doc' => 'directory where .php files are installed', - ), - 'ext_dir' => array( - 'type' => 'directory', - 'default' => PEAR_EXTENSION_DIR, - 'doc' => 'directory where loadable extensions are installed', - ), - 'doc_dir' => array( - 'type' => 'directory', - 'default' => PEAR_CONFIG_DEFAULT_DOCDIR, - 'doc' => 'directory where documentation is installed', - ), - 'bin_dir' => array( - 'type' => 'directory', - 'default' => PHP_BINDIR, - 'doc' => 'directory where executables are installed', - ), - 'username' => array( - 'type' => 'string', - 'default' => '', - 'doc' => '(maintainers) your PEAR account name', - ), - 'password' => array( - 'type' => 'password', - 'default' => '', - 'doc' => '(maintainers) your PEAR account password', - ), - 'verbose' => array( - 'type' => 'integer', - 'default' => 1, - 'doc' => 'verbosity level', - ), - 'preferred_state' => array( - 'type' => 'set', - 'default' => 'stable', - 'doc' => 'the installer will prefer releases with this state -when installing packages without a version or state specified', - 'valid_set' => array( - 'stable', 'beta', 'alpha', 'devel', 'snapshot', 'any'), - ), - 'http_proxy' => array( - 'type' => 'string', - 'default' => '', - 'doc' => 'HTTP proxy (host:port) to use when downloading packages', - ), - 'umask' => array( - 'type' => 'int', - 'default' => PEAR_DEFAULT_UMASK, - 'doc' => 'umask used when creating files (Unix-like systems only)', - ), -/* - 'testset1' => array( - 'type' => 'set', - 'default' => 'foo', - 'doc' => 'test set', - 'valid_set' => array('foo', 'bar'), - ), -*/ - ); - - // }}} - - // {{{ PEAR_Config([file], [defaults_file]) - - /** - * Constructor. - * - * @param string (optional) file to read user-defined options from - * @param string (optional) file to read system-wide defaults from - * - * @access public - * - * @see PEAR_Config::singleton - */ - function PEAR_Config($user_file = '', $system_file = '') - { - $this->PEAR(); - $sl = DIRECTORY_SEPARATOR; - if (empty($user_file)) { - if (OS_WINDOWS) { - $user_file = PHP_SYSCONFDIR . $sl . 'pear.ini'; - } else { - $user_file = getenv('HOME') . $sl . '.pearrc'; - } - } - if (empty($system_file)) { - if (OS_WINDOWS) { - $system_file = PHP_SYSCONFDIR . $sl . 'pearsys.ini'; - } else { - $system_file = PHP_SYSCONFDIR . $sl . 'pear.conf'; - } - } - $this->layers = array_keys($this->configuration); - $this->files['user'] = $user_file; - $this->files['system'] = $system_file; - if ($user_file && file_exists($user_file)) { - $this->readConfigFile($user_file); - } - if ($system_file && file_exists($system_file)) { - $this->mergeConfigFile($system_file, false, 'system'); - } - foreach ($this->configuration_info as $key => $info) { - $this->configuration['default'][$key] = $info['default']; - } - //$GLOBALS['_PEAR_Config_instance'] = &$this; - } - - // }}} - // {{{ singleton([file], [defaults_file]) - - /** - * Static singleton method. If you want to keep only one instance - * of this class in use, this method will give you a reference to - * the last created PEAR_Config object if one exists, or create a - * new object. - * - * @param string (optional) file to read user-defined options from - * @param string (optional) file to read system-wide defaults from - * - * @return object an existing or new PEAR_Config instance - * - * @access public - * - * @see PEAR_Config::PEAR_Config - */ - function &singleton($user_file = '', $system_file = '') - { - if (is_object($GLOBALS['_PEAR_Config_instance'])) { - return $GLOBALS['_PEAR_Config_instance']; - } - $GLOBALS['_PEAR_Config_instance'] = - &new PEAR_Config($user_file, $system_file); - return $GLOBALS['_PEAR_Config_instance']; - } - - // }}} - // {{{ readConfigFile([file], [layer]) - - /** - * Reads configuration data from a file. All existing values in - * the config layer are discarded and replaced with data from the - * file. - * - * @param string (optional) file to read from, if NULL or not - * specified, the last-used file for the same layer (second param) - * is used - * - * @param string (optional) config layer to insert data into - * ('user' or 'system') - * - * @return bool TRUE on success or a PEAR error on failure - * - * @access public - */ - function readConfigFile($file = null, $layer = 'user') - { - if (empty($this->files[$layer])) { - return $this->raiseError("unknown config file type `$layer'"); - } - if ($file === null) { - $file = $this->files[$layer]; - } - $data = $this->_readConfigDataFrom($file); - if (PEAR::isError($data)) { - return $data; - } - $this->_decodeInput($data); - $this->configuration[$layer] = $data; - return true; - } - - // }}} - // {{{ mergeConfigFile(file, [override], [layer]) - - /** - * Merges data into a config layer from a file. Does the same - * thing as readConfigFile, except it does not replace all - * existing values in the config layer. - * - * @param string file to read from - * - * @param bool (optional) whether to overwrite existing data - * (default TRUE) - * - * @param string config layer to insert data into ('user' or - * 'system') - * - * @return bool TRUE on success or a PEAR error on failure - * - * @access public. - */ - function mergeConfigFile($file, $override = true, $layer = 'user') - { - if (empty($this->files[$layer])) { - return $this->raiseError("unknown config file type `$layer'"); - } - if ($file === null) { - $file = $this->files[$layer]; - } - $data = $this->_readConfigDataFrom($file); - if (PEAR::isError($data)) { - return $data; - } - $this->_decodeInput($data); - if ($override) { - $this->configuration[$layer] = array_merge($this->configuration[$layer], $data); - } else { - $this->configuration[$layer] = array_merge($data, $this->configuration[$layer]); - } - return true; - } - - // }}} - // {{{ writeConfigFile([file], [layer]) - - /** - * Writes data into a config layer from a file. - * - * @param string file to read from - * - * @param bool (optional) whether to overwrite existing data - * (default TRUE) - * - * @param string config layer to insert data into ('user' or - * 'system') - * - * @return bool TRUE on success or a PEAR error on failure - * - * @access public. - */ - function writeConfigFile($file = null, $layer = 'user') - { - if ($layer == 'both' || $layer == 'all') { - foreach ($this->files as $type => $file) { - $err = $this->writeConfigFile($file, $type); - if (PEAR::isError($err)) { - return $err; - } - } - return true; - } - if (empty($this->files[$layer])) { - return $this->raiseError("unknown config file type `$layer'"); - } - if ($file === null) { - $file = $this->files[$layer]; - } - $data = $this->configuration[$layer]; - $this->_encodeOutput($data); - if (!@System::mkDir("-p " . dirname($file))) { - return $this->raiseError("could not create directory: " . dirname($file)); - } - if (@is_file($file) && !@is_writeable($file)) { - return $this->raiseError("no write access to $file!"); - } - $fp = @fopen($file, "w"); - if (!$fp) { - return $this->raiseError("PEAR_Config::writeConfigFile fopen('$file','w') failed"); - } - $contents = "#PEAR_Config 0.9\n" . serialize($data); - if (!@fwrite($fp, $contents)) { - return $this->raiseError("PEAR_Config::writeConfigFile: fwrite failed"); - } - return true; - } - - // }}} - // {{{ _readConfigDataFrom(file) - - /** - * Reads configuration data from a file and returns the parsed data - * in an array. - * - * @param string file to read from - * - * @return array configuration data or a PEAR error on failure - * - * @access private - */ - function _readConfigDataFrom($file) - { - $fp = @fopen($file, "r"); - if (!$fp) { - return $this->raiseError("PEAR_Config::readConfigFile fopen('$file','r') failed"); - } - $size = filesize($file); - $contents = fread($fp, $size); - $version = '0.1'; - if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, $matches)) { - $version = $matches[1]; - $contents = substr($contents, strlen($matches[0])); - } - if (version_compare($version, '1', '<')) { - $data = unserialize($contents); - if (!is_array($data)) { - if (strlen(trim($contents)) > 0) { - $error = "PEAR_Config: bad data in $file"; -// if (isset($this)) { - return $this->raiseError($error); -// } else { -// return PEAR::raiseError($error); - } else { - $data = array(); - } - } - // add parsing of newer formats here... - } else { - return $this->raiseError("$file: unknown version `$version'"); - } - return $data; - } - - // }}} - // {{{ _encodeOutput(&data) - - /** - * Encodes/scrambles configuration data before writing to files. - * Currently, 'password' values will be base64-encoded as to avoid - * that people spot cleartext passwords by accident. - * - * @param array (reference) array to encode values in - * - * @return bool TRUE on success - * - * @access private - */ - function _encodeOutput(&$data) - { - foreach ($data as $key => $value) { - if (!isset($this->configuration_info[$key])) { - continue; - } - $type = $this->configuration_info[$key]['type']; - switch ($type) { - // we base64-encode passwords so they are at least - // not shown in plain by accident - case 'password': { - $data[$key] = base64_encode($data[$key]); - break; - } - } - } - return true; - } - - // }}} - // {{{ _decodeInput(&data) - - /** - * Decodes/unscrambles configuration data after reading from files. - * - * @param array (reference) array to encode values in - * - * @return bool TRUE on success - * - * @access private - * - * @see PEAR_Config::_encodeOutput - */ - function _decodeInput(&$data) - { - if (!is_array($data)) { - return true; - } - foreach ($data as $key => $value) { - if (!isset($this->configuration_info[$key])) { - continue; - } - $type = $this->configuration_info[$key]['type']; - switch ($type) { - case 'password': { - $data[$key] = base64_decode($data[$key]); - break; - } - } - } - return true; - } - - // }}} - // {{{ get(key, [layer]) - - /** - * Returns a configuration value, prioritizing layers as per the - * layers property. - * - * @param string config key - * - * @return mixed the config value, or NULL if not found - * - * @access public - */ - function get($key, $layer = null) - { - if ($layer === null) { - foreach ($this->layers as $layer) { - if (isset($this->configuration[$layer][$key])) { - return $this->configuration[$layer][$key]; - } - } - } elseif (isset($this->configuration[$layer][$key])) { - return $this->configuration[$layer][$key]; - } - return null; - } - - // }}} - // {{{ set(key, value, [layer]) - - /** - * Set a config value in a specific layer (defaults to 'user'). - * Enforces the types defined in the configuration_info array. An - * integer config variable will be cast to int, and a set config - * variable will be validated against its legal values. - * - * @param string config key - * - * @param string config value - * - * @param string (optional) config layer - * - * @return bool TRUE on success, FALSE on failure - * - * @access public - */ - function set($key, $value, $layer = 'user') - { - if (empty($this->configuration_info[$key])) { - return false; - } - extract($this->configuration_info[$key]); - switch ($type) { - case 'integer': { - $value = (int)$value; - break; - } - case 'set': { - // If a valid_set is specified, require the value to - // be in the set. If there is no valid_set, accept - // any value. - if ($valid_set) { - reset($valid_set); - if ((key($valid_set) === 0 && !in_array($value, $valid_set)) || - empty($valid_set[$value])) - { - return false; - } - } - break; - } - } - $this->configuration[$layer][$key] = $value; - return true; - } - - // }}} - // {{{ getType(key) - - /** - * Get the type of a config value. - * - * @param string config key - * - * @return string type, one of "string", "integer", "file", - * "directory", "set" or "password". - * - * @access public - * - */ - function getType($key) - { - if (isset($this->configuration_info[$key])) { - return $this->configuration_info[$key]['type']; - } - return false; - } - - // }}} - // {{{ getDocs(key) - - /** - * Get the documentation for a config value. - * - * @param string config key - * - * @return string documentation string - * - * @access public - * - */ - function getDocs($key) - { - if (isset($this->configuration_info[$key])) { - return $this->configuration_info[$key]['doc']; - } - return false; - } - - // }}} - // {{{ getSetValues(key) - - /** - * Get the list of allowed set values for a config value. Returns - * NULL for config values that are not sets. - * - * @param string config key - * - * @return array enumerated array of set values, or NULL if the - * config key is unknown or not a set - * - * @access public - * - */ - function getSetValues($key) - { - if (isset($this->configuration_info[$key]) && - isset($this->configuration_info[$key]['type']) && - $this->configuration_info[$key]['type'] == 'set') - { - $valid_set = $this->configuration_info[$key]['valid_set']; - reset($valid_set); - if (key($valid_set) === 0) { - return $valid_set; - } - return array_keys($valid_set); - } - return false; - } - - // }}} - // {{{ getKeys() - - /** - * Get all the current config keys. - * - * @return array simple array of config keys - * - * @access public - */ - function getKeys() - { - $keys = array(); - foreach ($this->layers as $layer) { - $keys = array_merge($keys, $this->configuration[$layer]); - } - return array_keys($keys); - } - - // }}} - // {{{ remove(key, [layer]) - - /** - * Remove the a config key from a specific config layer. - * - * @param string config key - * - * @param string (optional) config layer - * - * @return bool TRUE on success, FALSE on failure - * - * @access public - */ - function remove($key, $layer = 'user') - { - if (isset($this->configuration[$layer][$key])) { - unset($this->configuration[$layer][$key]); - return true; - } - return false; - } - - // }}} - // {{{ store([layer]) - - /** - * Stores configuration data in a layer. - * - * @param string config layer to store - * - * @return bool TRUE on success, or PEAR error on failure - * - * @access public - */ - function store($layer = 'user') - { - return $this->writeConfigFile(null, $layer); - } - - // }}} - // {{{ toDefault(key) - - /** - * Unset the user-defined value of a config key, reverting the - * value to the system-defined one. - * - * @param string config key - * - * @return bool TRUE on success, FALSE on failure - * - * @access public - */ - function toDefault($key) - { - trigger_error("PEAR_Config::toDefault() deprecated, use PEAR_Config::remove() instead", E_USER_NOTICE); - return $this->remove($key, 'user'); - } - - // }}} - // {{{ definedBy(key) - - /** - * Tells what config layer that gets to define a key. - * - * @param string config key - * - * @return string the config layer, or an empty string if not found - * - * @access public - */ - function definedBy($key) - { - foreach ($this->layers as $layer) { - if (isset($this->configuration[$layer][$key])) { - return $layer; - } - } - return ''; - } - - // }}} - // {{{ isDefaulted(key) - - /** - * Tells whether a config value has a system-defined value. - * - * @param string config key - * - * @return bool - * - * @access public - * - * @deprecated - */ - function isDefaulted($key) - { - trigger_error("PEAR_Config::isDefaulted() deprecated, use PEAR_Config::definedBy() instead", E_USER_NOTICE); - return $this->definedBy($key) == 'system'; - } - - // }}} - // {{{ isDefined(key) - - /** - * Tells whether a given key exists as a config value. - * - * @param string config key - * - * @return bool whether <config key> exists in this object - * - * @access public - */ - function isDefined($key) - { - foreach ($this->layers as $layer) { - if (isset($this->configuration[$layer][$key])) { - return true; - } - } - return false; - } - - // }}} - // {{{ isDefinedLayer(key) - - /** - * Tells whether a given config layer exists. - * - * @param string config layer - * - * @return bool whether <config layer> exists in this object - * - * @access public - */ - function isDefinedLayer($layer) - { - return isset($this->configuration[$layer]); - } - - // }}} - // {{{ getLayers() - - /** - * Returns the layers defined (except the 'default' one) - * - * @return array of the defined layers - */ - function getLayers() - { - $cf = $this->configuration; - unset($cf['default']); - return array_keys($cf); - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Dependency.php b/pear/PEAR/Dependency.php deleted file mode 100644 index 3b6f6a7684..0000000000 --- a/pear/PEAR/Dependency.php +++ /dev/null @@ -1,257 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Tomas V.V.Cox <cox@idecnet.com> | -// | Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -/** -* Methods for dependencies check. Based on Stig's dependencies RFC -* at http://cvs.php.net/cvs.php/pearweb/rfc -* (requires php >= 4.1) -*/ - -require_once "PEAR.php"; - -class PEAR_Dependency -{ - function PEAR_Dependency(&$registry) - { - $this->registry = &$registry; - } - /** - * This method maps the xml dependency definition to the - * PEAR_dependecy one - * - * $opts => Array - * ( - * [type] => pkg - * [rel] => ge - * [version] => 3.4 - * [name] => HTML_Common - * ) - */ - function callCheckMethod($opts) - { - $rel = isset($opts['rel']) ? $opts['rel'] : 'has'; - if (isset($opts['version'])) { - $req = $opts['version']; - $rel = 'v.' . $rel; - } else { - $req = null; - } - $name = isset($opts['name']) ? $opts['name'] : null; - switch ($opts['type']) { - case 'pkg': - return $this->checkPackage($name, $req, $rel); - break; - case 'ext': - return $this->checkExtension($name, $req, $rel); - break; - case 'php': - return $this->checkPHP($req, $rel); - break; - case 'prog': - return $this->checkProgram($name); - break; - case 'os': - return $this->checkOS($name); - break; - case 'sapi': - return $this->checkSAPI($name); - break; - default: - return "'{$opts['type']}' dependency type not supported"; - } - } - - /** - * Package dependencies check method - * - * @param string $name Name of the package to test - * @param string $version The package version required - * @param string $relation How to compare versions with eachother - * - * @return mixed bool false if no error or the error string - */ - function checkPackage($name, $req = null, $relation = 'has') - { - switch ($relation) { - case 'has': - if (!$this->registry->packageExists($name)) { - return "requires package `$name'"; - } - return false; - case 'not': - if (!$this->registry->packageExists($name)) { - return "conflicts with package `$name'"; - } - return false; - case 'lt': - case 'le': - case 'eq': - case 'ne': - case 'ge': - case 'gt': - $version = $this->registry->packageInfo($name, 'version'); - if (!version_compare($version, $req, $relation)) { - return "requires package `$name' " . - $this->signOperator($relation) . " $req"; - } - } - return "Relation '$relation' with requirement '$req' is not supported (name=$name)"; - } - - /** - * Extension dependencies check method - * - * @param string $name Name of the extension to test - * @param string $req_ext_ver Required extension version to compare with - * @param string $relation How to compare versions with eachother - * - * @return mixed bool false if no error or the error string - */ - function checkExtension($name, $req = null, $relation = 'has') - { - // XXX (ssb): could we avoid loading the extension here? - if (!extension_loaded($name)) { - $dlext = OS_WINDOWS ? '.dll' : '.so'; - if (!@dl($name . $dlext)) { - return "'$name' PHP extension is not installed"; - } - } - if ($relation == 'has') { - return false; - } - if (substr($relation, 0, 2) == 'v.') { - $ext_ver = phpversion($name); - $operator = substr($relation, 2); - if (!version_compare($ext_ver, $req, $operator)) { - return "'$name' PHP extension version " . - $this->signOperator($operator) . " $req is required"; - } - } - return false; - } - - /** - * Operating system dependencies check method - * - * @param string $os Name of the operating system - * - * @return mixed bool false if no error or the error string - */ - function checkOS($os) - { - // XXX Fixme: Implement a more flexible way, like - // comma separated values or something similar to PEAR_OS - - // only 'has' relation is supported - if ($os == PHP_OS) { - return false; - } - return "'$os' operating system not supported"; - } - - /** - * PHP version check method - * - * @param string $req which version to compare - * @param string $relation how to compare the version - * - * @return mixed bool false if no error or the error string - */ - function checkPHP($req, $relation = 'v.ge') - { - if (substr($relation, 0, 2) == 'v.') { - $php_ver = phpversion(); - $operator = substr($relation, 2); - if (!version_compare($php_ver, $req, $operator)) { - return "PHP version " . $this->signOperator($operator) . - " $req is required"; - } - } - return false; - } - - /** - * External program check method. Looks for executable files in - * directories listed in the PATH environment variable. - * - * @param string $program which program to look for - * - * @return mixed bool false if no error or the error string - */ - function checkProgram($program) - { - // XXX FIXME honor safe mode - $path_delim = OS_WINDOWS ? ';' : ':'; - $exe_suffix = OS_WINDOWS ? '.exe' : ''; - $path_elements = explode($path_delim, getenv('PATH')); - foreach ($path_elements as $dir) { - $file = $dir . DIRECTORY_SEPARATOR . $program . $exe_suffix; - if (@file_exists($file) && @is_executable($file)) { - return false; - } - } - return "'$program' program is not present in the PATH"; - } - - /** - * SAPI backend check method. Version comparison is not yet - * available here. - * - * @param string $name name of SAPI backend - * @param string $req which version to compare - * @param string $relation how to compare versions (currently - * hardcoded to 'has') - * @return mixed bool false if no error or the error string - */ - function checkSAPI($name, $req = null, $relation = 'has') - { - // XXX Fixme: There is no way to know if the user has or - // not other SAPI backends installed than the installer one - - $sapi_backend = php_sapi_name(); - // Version comparisons not supported, sapi backends don't have - // version information yet. - if ($sapi_backend == $name) { - return false; - } - return "'$sapi_backend' SAPI backend not supported"; - } - - /** - * Converts text comparing operators to them sign equivalents - * ex: 'ge' to '>=' - */ - function signOperator($operator) - { - switch($operator) { - case 'lt': return '<'; - case 'le': return '<='; - case 'gt': return '>'; - case 'ge': return '>='; - case 'eq': return '=='; - case 'ne': return '!='; - default: - return $operator; - } - } -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Frontend/CLI.php b/pear/PEAR/Frontend/CLI.php deleted file mode 100644 index f8e928a463..0000000000 --- a/pear/PEAR/Frontend/CLI.php +++ /dev/null @@ -1,322 +0,0 @@ -<?php -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Stig Sæther Bakken <ssb@fast.no> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -require_once "PEAR.php"; - -class PEAR_Frontend_CLI extends PEAR -{ - // {{{ properties - - /** - * What type of user interface this frontend is for. - * @var string - * @access public - */ - var $type = 'CLI'; - var $lp = ''; // line prefix - - var $omode = 'plain'; - var $params = array(); - var $term = array( - 'bold' => '', - 'normal' => '', - ); - - // }}} - - // {{{ constructor - - function PEAR_Frontend_CLI() - { - parent::PEAR(); - $term = getenv('TERM'); //(cox) $_ENV is empty for me in 4.1.1 - if ($term) { - // XXX can use ncurses extension here, if available - if (preg_match('/^(xterm|vt220|linux)/', $term)) { - $this->term['bold'] = sprintf("%c%c%c%c", 27, 91, 49, 109); - $this->term['normal']=sprintf("%c%c%c", 27, 91, 109); - } elseif (preg_match('/^vt100/', $term)) { - $this->term['bold'] = sprintf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); - $this->term['normal']=sprintf("%c%c%c%c%c", 27, 91, 109, 0, 0); - } - } elseif (OS_WINDOWS) { - // XXX add ANSI codes here - } - } - - // }}} - - // {{{ displayLine(text) - - function displayLine($text) - { - print "$this->lp$text\n"; - } - - function display($text) - { - print $text; - } - - // }}} - // {{{ displayError(eobj) - - function displayError($eobj) - { - return $this->displayLine($eobj->getMessage()); - } - - // }}} - // {{{ displayFatalError(eobj) - - function displayFatalError($eobj) - { - $this->displayError($eobj); - exit(1); - } - - // }}} - // {{{ displayHeading(title) - - function displayHeading($title) - { - print $this->lp.$this->bold($title)."\n"; - print $this->lp.str_repeat("=", strlen($title))."\n"; - } - - // }}} - // {{{ userDialog(prompt, [type], [default]) - - function userDialog($prompt, $type = 'text', $default = '') - { - if ($type == 'password') { - system('stty -echo'); - } - print "$this->lp$prompt "; - if ($default) { - print "[$default] "; - } - print ": "; - $fp = fopen("php://stdin", "r"); - $line = fgets($fp, 2048); - fclose($fp); - if ($type == 'password') { - system('stty echo'); - print "\n"; - } - if ($default && trim($line) == "") { - return $default; - } - return $line; - } - - // }}} - // {{{ userConfirm(prompt, [default]) - - function userConfirm($prompt, $default = 'yes') - { - static $positives = array('y', 'yes', 'on', '1'); - static $negatives = array('n', 'no', 'off', '0'); - print "$this->lp$prompt [$default] : "; - $fp = fopen("php://stdin", "r"); - $line = fgets($fp, 2048); - fclose($fp); - $answer = strtolower(trim($line)); - if (empty($answer)) { - $answer = $default; - } - if (in_array($answer, $positives)) { - return true; - } - if (in_array($answer, $negatives)) { - return false; - } - if (in_array($default, $positives)) { - return true; - } - return false; - } - - // }}} - // {{{ startTable([params]) - - function startTable($params = array()) - { - $this->omode = 'table'; - $params['table_data'] = array(); - $params['widest'] = array(); // indexed by column - $params['highest'] = array(); // indexed by row - $params['ncols'] = 0; - $this->params = $params; - } - - // }}} - // {{{ tableRow(columns, [rowparams], [colparams]) - - function tableRow($columns, $rowparams = array(), $colparams = array()) - { - $highest = 1; - for ($i = 0; $i < sizeof($columns); $i++) { - $col = &$columns[$i]; - if (isset($colparams[$i]) && !empty($colparams[$i]['wrap'])) { - $col = wordwrap($col, $colparams[$i]['wrap'], "\n", 1); - } - if (strpos($col, "\n") !== false) { - $multiline = explode("\n", $col); - $w = 0; - foreach ($multiline as $n => $line) { - if (strlen($line) > $w) { - $w = strlen($line); - } - } - $lines = sizeof($lines); - } else { - $w = strlen($col); - } - if ($w > @$this->params['widest'][$i]) { - $this->params['widest'][$i] = $w; - } - $tmp = count_chars($columns[$i], 1); - // handle unix, mac and windows formats - $lines = (isset($tmp[10]) ? $tmp[10] : @$tmp[13]) + 1; - if ($lines > $highest) { - $highest = $lines; - } - } - if (sizeof($columns) > $this->params['ncols']) { - $this->params['ncols'] = sizeof($columns); - } - $new_row = array( - 'data' => $columns, - 'height' => $highest, - 'rowparams' => $rowparams, - 'colparams' => $colparams, - ); - $this->params['table_data'][] = $new_row; - } - - // }}} - // {{{ endTable() - - function endTable() - { - $this->omode = ''; - extract($this->params); - if (!empty($caption)) { - $this->displayHeading($caption); - } - if (count($table_data) == 0) { - return; - } - if (!isset($width)) { - $width = $widest; - } else { - for ($i = 0; $i < $ncols; $i++) { - if (!isset($width[$i])) { - $width[$i] = $widest[$i]; - } - } - } - if (empty($border)) { - $cellstart = ''; - $cellend = ' '; - $rowend = ''; - $padrowend = false; - $borderline = ''; - } else { - $cellstart = '| '; - $cellend = ' '; - $rowend = '|'; - $padrowend = true; - $borderline = '+'; - foreach ($width as $w) { - $borderline .= str_repeat('-', $w + strlen($cellstart) + strlen($cellend) - 1); - $borderline .= '+'; - } - } - if ($borderline) { - $this->displayLine($borderline); - } - for ($i = 0; $i < sizeof($table_data); $i++) { - extract($table_data[$i]); - $rowlines = array(); - if ($height > 1) { - for ($c = 0; $c < sizeof($data); $c++) { - $rowlines[$c] = preg_split('/(\r?\n|\r)/', $data[$c]); - if (sizeof($rowlines[$c]) < $height) { - $rowlines[$c] = array_pad($rowlines[$c], $height, ''); - } - } - } else { - for ($c = 0; $c < sizeof($data); $c++) { - $rowlines[$c] = array($data[$c]); - } - } - for ($r = 0; $r < $height; $r++) { - $rowtext = ''; - for ($c = 0; $c < sizeof($data); $c++) { - if (isset($colparams[$c])) { - $attribs = array_merge($rowparams, $colparams); - } else { - $attribs = $rowparams; - } - $w = isset($width[$c]) ? $width[$c] : 0; - //$cell = $data[$c]; - $cell = $rowlines[$c][$r]; - $l = strlen($cell); - if ($l > $w) { - $cell = substr($cell, 0, $w); - } - if (isset($attribs['bold'])) { - $cell = $this->bold($cell); - } - if ($l < $w) { - // not using str_pad here because we may - // add bold escape characters to $cell - $cell .= str_repeat(' ', $w - $l); - } - - $rowtext .= $cellstart . $cell . $cellend; - } - $rowtext .= $rowend; - $this->displayLine($rowtext); - } - } - if ($borderline) { - $this->displayLine($borderline); - } - } - - // }}} - // {{{ bold($text) - - function bold($text) - { - if (empty($this->term['bold'])) { - return strtoupper($text); - } - return $this->term['bold'] . $text . $this->term['normal']; - } - - // }}} -} - -?> diff --git a/pear/PEAR/Frontend/Gtk.php b/pear/PEAR/Frontend/Gtk.php deleted file mode 100644 index f715fb41bb..0000000000 --- a/pear/PEAR/Frontend/Gtk.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Stig Sæther Bakken <ssb@fast.no> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -require_once "PEAR.php"; - -class PEAR_Frontend_Gtk extends PEAR -{ - // {{{ properties - - /** - * What type of user interface this frontend is for. - * @var string - * @access public - */ - var $type = 'Gtk'; - - var $omode = 'plain'; - var $params = array(); - var $window = null; - - // }}} - - // {{{ constructor - - function PEAR_Frontend_Gtk() - { - parent::PEAR(); - if (!extension_loaded('php_gtk')) { - dl('php_gtk.' . (OS_WINDOWS ? 'dll' : 'so')); - } - $this->window = &new GtkWindow(); - $this->window->set_title('PEAR Installer'); - $this->window->set_usize((gdk::screen_width()/3), (gdk::screen_height()/3)); - $this->window->show_all(); - } - - // }}} - - // {{{ displayLine(text) - - function displayLine($text) - { - } - - function display($text) - { - } - - // }}} - // {{{ displayError(eobj) - - function displayError($eobj) - { - } - - // }}} - // {{{ displayFatalError(eobj) - - function displayFatalError($eobj) - { - } - - // }}} - // {{{ displayHeading(title) - - function displayHeading($title) - { - } - - // }}} - // {{{ userDialog(prompt, [type], [default]) - - function userDialog($prompt, $type = 'text', $default = '') - { - } - - // }}} - // {{{ userConfirm(prompt, [default]) - - function userConfirm($prompt, $default = 'yes') - { - } - - // }}} - // {{{ startTable([params]) - - function startTable($params = array()) - { - } - - // }}} - // {{{ tableRow(columns, [rowparams], [colparams]) - - function tableRow($columns, $rowparams = array(), $colparams = array()) - { - } - - // }}} - // {{{ endTable() - - function endTable() - { - } - - // }}} - // {{{ bold($text) - - function bold($text) - { - } - - // }}} -} - -?> diff --git a/pear/PEAR/Installer.php b/pear/PEAR/Installer.php deleted file mode 100644 index 4341ea1864..0000000000 --- a/pear/PEAR/Installer.php +++ /dev/null @@ -1,524 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Common.php'; -require_once 'PEAR/Registry.php'; -require_once 'PEAR/Dependency.php'; - -/** - * Administration class used to install PEAR packages and maintain the - * installed package database. - * - * @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 string - */ - var $pkgdir; - - /** directory where PHP code files go - * @var string - */ - var $phpdir; - - /** directory where PHP extension files go - * @var string - */ - var $extdir; - - /** directory where documentation goes - * @var string - */ - var $docdir; - - /** directory where the package wants to put files, relative - * to one of the previous dirs - * @var string - */ - var $destdir = ''; - - /** debug level - * @var int - */ - var $debug = 1; - - /** temporary directory - * @var string - */ - var $tmpdir; - - /** PEAR_Registry object used by the installer - * @var object - */ - var $registry; - - // }}} - - // {{{ constructor - - /** - * PEAR_Installer constructor. - * - * @param object $ui user interface object (instance of PEAR_Frontend_*) - * - * @access public - */ - function PEAR_Installer(&$ui) - { - $this->PEAR_Common(); - $this->setFrontendObject($ui); - $this->debug = $this->config->get('verbose'); - $this->registry = &new PEAR_Registry($this->config->get('php_dir')); - } - - // }}} - - // {{{ _deletePackageFiles() - - /** - * Delete a package's installed files, remove empty directories. - * - * @param string $package package name - * - * @return bool TRUE on success, or a PEAR error on failure - * - * @access private - */ - function _deletePackageFiles($package) - { - if (!strlen($package)) { - return $this->raiseError("No package to uninstall given"); - } - $filelist = $this->registry->packageInfo($package, 'filelist'); - if ($filelist == null) { - return $this->raiseError("$package not installed"); - } - foreach ($filelist as $file => $props) { - if (empty($props['installed_as'])) { - continue; - } - $path = $props['installed_as']; - if (!@unlink($path)) { - $this->log(1, "unable to delete: $path"); - } else { - $this->log(1, "deleted file $path"); - // Delete package directory if it's empty - if (@rmdir(dirname($path))) { - $this->log(2, "+ rmdir $path"); - } - } - } - return true; - } - - // }}} - // {{{ _installFile() - - function _installFile($file, $atts, $tmp_path) - { - static $os; - if (isset($atts['platform'])) { - if (empty($os)) { - include_once "OS/Guess.php"; - $os = new OS_Guess(); - } - // return if this file is meant for another platform - if (!$os->matchSignature($atts['platform'])) { - $this->log(1, "skipped $file (meant for $atts[platform], we are ".$os->getSignature().")"); - return; - } - } - - switch ($atts['role']) { - case 'test': case 'data': case 'ext': - // don't install test files for now - $this->log(2, "$file: $atts[role] file not installed yet"); - return true; - case 'doc': - $dest_dir = $this->config->get('doc_dir') . - DIRECTORY_SEPARATOR . $this->pkginfo['package']; - break; - case 'extsrc': - // don't install test files for now - $this->log(2, "$file: no support for building extensions yet"); - return true; - case 'php': - $dest_dir = $this->config->get('php_dir'); - break; - case 'script': { - $dest_dir = $this->config->get('bin_dir'); - break; - } - default: - break; - } - if (!isset($atts['baseinstalldir']) || - $atts['baseinstalldir'] == '/' || - $atts['baseinstalldir'] == DIRECTORY_SEPARATOR) { - $atts['baseinstalldir'] = ''; - } - if (!empty($atts['baseinstalldir']) && $atts['role'] != 'doc') { - $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir']; - } - if (dirname($file) != '.' && empty($atts['install-as'])) { - $dest_dir .= DIRECTORY_SEPARATOR . dirname($file); - } - if (empty($atts['install-as'])) { - $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file); - } else { - $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as']; - } - $dest_file = preg_replace('!//+!', '/', $dest_file); - if (!@is_dir($dest_dir)) { - if (!$this->mkDirHier($dest_dir)) { - $this->log(0, "failed to mkdir $dest_dir"); - return false; - } - $this->log(2, "+ mkdir $dest_dir"); - } - $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file; - if (empty($atts['replacements'])) { - if (!@copy($orig_file, $dest_file)) { - $this->log(0, "failed to copy $orig_file to $dest_file"); - return false; - } - $this->log(2, "+ cp $orig_file $dest_file"); - } else { - $fp = fopen($orig_file, "r"); - $contents = fread($fp, filesize($orig_file)); - fclose($fp); - $subst_from = $subst_to = array(); - foreach ($atts['replacements'] as $a) { - $to = ''; - if ($a['type'] == 'php-const') { - if (preg_match('/^[a-z0-9_]+$/i', $a['to'])) { - eval("\$to = $a[to];"); - } else { - $this->log(0, "invalid php-const replacement: $a[to]"); - continue; - } - } elseif ($a['type'] == 'pear-config') { - $to = $this->config->get($a['to']); - } - if ($to) { - $subst_from = $a['from']; - $subst_to = $to; - } - } - $this->log(1, "doing ".sizeof($subst_from)." substitution(s) for $dest_file"); - if (sizeof($subst_from)) { - $contents = str_replace($subst_from, $subst_to, $contents); - } - $wp = @fopen($dest_file, "w"); - if (!is_resource($wp)) { - $this->log(0, "failed to create $dest_file"); - return false; - } - fwrite($wp, $contents); - fclose($wp); - } - if (!OS_WINDOWS) { - if ($atts['role'] == 'script') { - $mode = 0777 & ~$this->config->get('umask'); - $this->log(2, "+ chmod +x $dest_file"); - } else { - $mode = 0666 & ~$this->config->get('umask'); - } - if (!@chmod($dest_file, $mode)) { - $this->log(0, "failed to change mode of $dest_file"); - } - } - - // Store the full path where the file was installed for easy unistall - $this->pkginfo['filelist'][$file]['installed_as'] = $dest_file; - - $this->log(1, "installed file $dest_file"); - return true; - } - - // }}} - // {{{ getPackageDownloadUrl() - - function getPackageDownloadUrl($package) - { - if ($this === null || $this->config === null) { - $package = "http://pear.php.net/get/$package"; - } else { - $package = "http://" . $this->config->get('master_server') . - "/get/$package"; - } - if (!extension_loaded("zlib")) { - $package .= '?uncompress=yes'; - } - return $package; - } - - // }}} - // {{{ install() - - /** - * Installs the files within the package file specified. - * - * @param $pkgfile path to the package file - * - * @return array package info if successful, null if not - */ - - function install($pkgfile, $options = array()) - { - // recognized options: - // - register-only : update registry but don't install files - // - upgrade : upgrade existing install - // - soft : fail silently - // - $need_download = false; - // ==> XXX should be removed later on - $flag_old_format = false; - if (preg_match('#^(http|ftp)://#', $pkgfile)) { - $need_download = true; - } elseif (!@is_file($pkgfile)) { - if ($this->validPackageName($pkgfile)) { - if ($this->registry->packageExists($pkgfile) && empty($options['upgrade'])) { - return $this->raiseError("$pkgfile already installed"); - } - $pkgfile = $this->getPackageDownloadUrl($pkgfile); - $need_download = true; - } else { - if (strlen($pkgfile)) { - return $this->raiseError("Could not open the package file: $pkgfile"); - } else { - return $this->raiseError("No package file given"); - } - } - } - - // Download package ----------------------------------------------- - if ($need_download) { - $downloaddir = $this->config->get('download_dir'); - if (empty($downloaddir)) { - if (PEAR::isError($downloaddir = $this->mkTempDir())) { - return $downloaddir; - } - $this->log(2, '+ tmp dir created at ' . $downloaddir); - } - $callback = $this->ui ? array(&$this, '_downloadCallback') : null; - $file = $this->downloadHttp($pkgfile, $this->ui, $downloaddir, $callback); - if (PEAR::isError($file)) { - return $this->raiseError($file); - } - $pkgfile = $file; - } - - if (substr($pkgfile, -4) == '.xml') { - $descfile = $pkgfile; - } else { - // Decompress pack in tmp dir ------------------------------------- - - // To allow relative package file names - $oldcwd = getcwd(); - if (@chdir(dirname($pkgfile))) { - $pkgfile = getcwd() . DIRECTORY_SEPARATOR . basename($pkgfile); - chdir($oldcwd); - } - - if (PEAR::isError($tmpdir = $this->mkTempDir())) { - return $tmpdir; - } - $this->log(2, '+ tmp dir created at ' . $tmpdir); - - $tar = new Archive_Tar($pkgfile, true); - if (!@$tar->extract($tmpdir)) { - return $this->raiseError("unable to unpack $pkgfile"); - } - - // ----- Look for existing package file - $descfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml'; - - if (!is_file($descfile)) { - // ----- Look for old package archive format - // In this format the package.xml file was inside the - // Package-n.n directory - $dp = opendir($tmpdir); - do { - $pkgdir = readdir($dp); - } while ($pkgdir{0} == '.'); - - $descfile = $tmpdir . DIRECTORY_SEPARATOR . $pkgdir . DIRECTORY_SEPARATOR . 'package.xml'; - $flag_old_format = true; - $this->log(0, "warning : you are using an archive with an old format"); - } - // <== XXX This part should be removed later on - } - - if (!is_file($descfile)) { - return $this->raiseError("no package.xml file after extracting the archive"); - } - - // Parse xml file ----------------------------------------------- - $pkginfo = $this->infoFromDescriptionFile($descfile); - if (PEAR::isError($pkginfo)) { - return $pkginfo; - } - - $pkgname = $pkginfo['package']; - - // Check dependencies ------------------------------------------- - if (isset($pkginfo['release_deps']) && !isset($options['nodeps'])) { - $error = $this->checkDeps($pkginfo); - if ($error) { - if (empty($options['soft'])) { - $this->log(0, $error); - } - return $this->raiseError("$pkgname: dependencies failed"); - } - } - - if (empty($options['upgrade'])) { - // checks to do only when installing new packages - if (empty($options['force']) && $this->registry->packageExists($pkgname)) { - return $this->raiseError("$pkgname already installed"); - } - } else { - // check to do only when upgrading packages - if (!$this->registry->packageExists($pkgname)) { - return $this->raiseError("$pkgname not installed"); - } - $v1 = $this->registry->packageInfo($pkgname, 'version'); - $v2 = $pkginfo['version']; - $cmp = version_compare($v1, $v2, 'gt'); - if (empty($options['force']) && !version_compare($v2, $v1, 'gt')) { - return $this->raiseError("upgrade to a newer version ($v2 is not newer than $v1)"); - } - if (empty($options['register-only'])) { - // when upgrading, remove old release's files first: - if (PEAR::isError($err = $this->_deletePackageFiles($pkgname))) { - return $this->raiseError($err); - } - } - } - - // Copy files to dest dir --------------------------------------- - - // info from the package it self we want to access from _installFile - $this->pkginfo = $pkginfo; - if (empty($options['register-only'])) { - if (!is_dir($this->config->get('php_dir'))) { - return $this->raiseError("no script destination directory\n", - null, PEAR_ERROR_DIE); - } - - // don't want strange characters - $pkgname = ereg_replace ('[^a-zA-Z0-9._]', '_', $pkginfo['package']); - $pkgversion = ereg_replace ('[^a-zA-Z0-9._\-]', '_', $pkginfo['version']); - $tmp_path = dirname($descfile); - if (substr($pkgfile, -4) != '.xml') { - $tmp_path .= DIRECTORY_SEPARATOR . $pkgname . '-' . $pkgversion; - } - - // ==> XXX This part should be removed later on - if ($flag_old_format) { - $tmp_path = dirname($descfile); - } - // <== XXX This part should be removed later on - - foreach ($pkginfo['filelist'] as $file => $atts) { - $this->_installFile($file, $atts, $tmp_path); - } - } - - // Register that the package is installed ----------------------- - if (empty($options['upgrade'])) { - // if 'force' is used, replace the info in registry - if (!empty($options['force']) && $this->registry->packageExists($pkgname)) { - $this->registry->deletePackage($pkgname); - } - $ret = $this->registry->addPackage($pkgname, $this->pkginfo); - } else { - $ret = $this->registry->updatePackage($pkgname, $this->pkginfo, false); - } - if (!$ret) { - return null; - } - return $pkginfo; - } - - // }}} - // {{{ uninstall() - - function uninstall($package) - { - if (empty($this->registry)) { - $this->registry = new PEAR_Registry($this->config->get('php_dir')); - } - - // Delete the files - if (PEAR::isError($err = $this->_deletePackageFiles($package))) { - return $this->raiseError($err); - } - - // Register that the package is no longer installed - return $this->registry->deletePackage($package); - } - - // }}} - // {{{ checkDeps() - - function checkDeps(&$pkginfo) - { - $deps = &new PEAR_Dependency($this->registry); - $errors = null; - if (is_array($pkginfo['release_deps'])) { - foreach($pkginfo['release_deps'] as $dep) { - if ($error = $deps->callCheckMethod($dep)) { - $errors .= "\n$error"; - } - } - if ($errors) { - return $errors; - } - } - return false; - } - - // }}} - // {{{ _downloadCallback() - - function _downloadCallback($msg, $params = null) - { - switch ($msg) { - case 'saveas': - $this->log(1, "downloading $params ..."); - break; - case 'done': - $this->log(1, '...done: ' . number_format($params, 0, '', ',') . ' bytes'); - break; - } - } - - // }}} -} - -?> diff --git a/pear/PEAR/Packager.php b/pear/PEAR/Packager.php deleted file mode 100644 index c58ce8fab6..0000000000 --- a/pear/PEAR/Packager.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR/Common.php'; - -/** - * Administration class used to make a PEAR release tarball. - * - * TODO: - * - add an extra param the dir where to place the created package - * - * @since PHP 4.0.2 - * @author Stig Bakken <ssb@fast.no> - */ -class PEAR_Packager extends PEAR_Common -{ - // {{{ constructor - - function PEAR_Packager() - { - $this->PEAR_Common(); - } - - // }}} - // {{{ destructor - - function _PEAR_Packager() - { - $this->_PEAR_Common(); - } - - // }}} - - // {{{ package() - - function package($pkgfile = null, $compress = true) - { - if (empty($pkgfile)) { - $pkgfile = 'package.xml'; - } - $pkginfo = $this->infoFromDescriptionFile($pkgfile); - if (PEAR::isError($pkginfo)) { - return $this->raiseError($pkginfo); - } - if (empty($pkginfo['version'])) { - return $this->raiseError("No version info found in $pkgfile"); - } - // TMP DIR ------------------------------------------------- - // We allow calls like "pear package /home/user/mypack/package.xml" - $oldcwd = getcwd(); - if (!@chdir(dirname($pkgfile))) { - return $this->raiseError('Could not chdir to '.dirname($pkgfile)); - } - $pkgfile = basename($pkgfile); - if (@$pkginfo['release_state'] == 'snapshot' && empty($pkginfo['version'])) { - $pkginfo['version'] = date('Ymd'); - } - // don't want strange characters - $pkgname = preg_replace('/[^a-z0-9._]/i', '_', $pkginfo['package']); - $pkgversion = preg_replace('/[^a-z0-9._-]/i', '_', $pkginfo['version']); - $pkgver = $pkgname . '-' . $pkgversion; - - // ----- Create the package file list - $filelist = array(); - $i = 0; - - // Copy files ----------------------------------------------- - foreach ($pkginfo['filelist'] as $fname => $atts) { - if (!file_exists($fname)) { - chdir($oldcwd); - return $this->raiseError("File $fname does not exist"); - } else { - $filelist[$i++] = $fname; - if (empty($pkginfo['filelist'][$fname]['md5sum'])) { - $md5sum = md5_file($fname); - $pkginfo['filelist'][$fname]['md5sum'] = $md5sum; - } - $this->log(2, "Adding file $fname"); - } - } - $new_xml = $this->xmlFromInfo($pkginfo); - if (PEAR::isError($new_xml)) { - chdir($oldcwd); - return $this->raiseError($new_xml); - } - $tmpdir = $this->mkTempDir(getcwd()); - $newpkgfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml'; - $np = @fopen($newpkgfile, "w"); - if (!$np) { - chdir($oldcwd); - return $this->raiseError("PEAR_Packager: unable to rewrite $pkgfile"); - } - fwrite($np, $new_xml); - fclose($np); - - // TAR the Package ------------------------------------------- - $ext = $compress ? '.tgz' : '.tar'; - $dest_package = $oldcwd . DIRECTORY_SEPARATOR . $pkgver . $ext; - $tar =& new Archive_Tar($dest_package, $compress); - $tar->setErrorHandling(PEAR_ERROR_RETURN); // XXX Don't print errors - // ----- Creates with the package.xml file - $ok = $tar->createModify($newpkgfile, '', $tmpdir); - if (PEAR::isError($ok)) { - chdir($oldcwd); - return $this->raiseError($ok); - } elseif (!$ok) { - chdir($oldcwd); - return $this->raiseError('PEAR_Packager: tarball creation failed'); - } - // ----- Add the content of the package - if (!$tar->addModify($filelist, $pkgver)) { - chdir($oldcwd); - return $this->raiseError('PEAR_Packager: tarball creation failed'); - } - $this->log(1, "Package $dest_package done"); - if (file_exists("CVS/Root")) { - $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pkgversion); - $cvstag = "RELEASE_$cvsversion"; - $this->log(1, "Tag the released code with `pear cvstag $pkgfile'"); - $this->log(1, "(or set the CVS tag $cvstag by hand)"); - } - chdir($oldcwd); - return $dest_package; - } - - // }}} -} - -if (!function_exists('md5_file')) { - function md5_file($file) { - if (!$fd = @fopen($file, 'r')) { - return false; - } - $md5 = md5(fread($fd, filesize($file))); - fclose($fd); - return $md5; - } -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Registry.php b/pear/PEAR/Registry.php deleted file mode 100644 index 30f31ce6f9..0000000000 --- a/pear/PEAR/Registry.php +++ /dev/null @@ -1,422 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once "System.php"; -require_once "PEAR.php"; - -define("PEAR_REGISTRY_ERROR_LOCK", -2); - -/** - * Administration class used to maintain the installed package database. - */ -class PEAR_Registry extends PEAR -{ - // {{{ properties - - /** Directory where registry files are stored. - * @var string - */ - var $statedir = ''; - - /** File where the file map is stored - * @var string - */ - var $filemap = ''; - - /** Name of file used for locking the registry - * @var string - */ - var $lockfile = ''; - - /** File descriptor used during locking - * @var resource - */ - var $lock_fp = null; - - /** Mode used during locking - * @var int - */ - var $lock_mode = 0; // XXX UNUSED - - // }}} - - // {{{ constructor - - /** - * PEAR_Registry constructor. - * - * @param string (optional) PEAR install directory (for .php files) - * - * @access public - */ - function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR) - { - parent::PEAR(); - $ds = DIRECTORY_SEPARATOR; - $this->statedir = $pear_install_dir.$ds.'.registry'; - $this->filemap = $pear_install_dir.$ds.'.filemap'; - $this->lockfile = $pear_install_dir.$ds.'.lock'; - if (!file_exists($this->filemap)) { - $this->_rebuildFileMap(); - } - } - - // }}} - // {{{ destructor - - /** - * PEAR_Registry destructor. Makes sure no locks are forgotten. - * - * @access private - */ - function _PEAR_Registry() - { - parent::_PEAR(); - if (is_resource($this->lock_fp)) { - $this->_unlock(); - } - } - - // }}} - - // {{{ _assertStateDir() - - /** - * Make sure the directory where we keep registry files exists. - * - * @return bool TRUE if directory exists, FALSE if it could not be - * created - * - * @access private - */ - function _assertStateDir() - { - if (!@is_dir($this->statedir)) { - if (!System::mkdir("-p {$this->statedir}")) { - return $this->raiseError("could not create directory '{$this->statedir}'"); - } - } - return true; - } - - // }}} - // {{{ _packageFileName() - - /** - * Get the name of the file where data for a given package is stored. - * - * @param string package name - * - * @return string registry file name - * - * @access public - */ - function _packageFileName($package) - { - return "{$this->statedir}/{$package}.reg"; - } - - // }}} - // {{{ _openPackageFile() - - function _openPackageFile($package, $mode) - { - $this->_assertStateDir(); - $file = $this->_packageFileName($package); - $fp = @fopen($file, $mode); - if (!$fp) { - return null; - } - return $fp; - } - - // }}} - // {{{ _closePackageFile() - - function _closePackageFile($fp) - { - fclose($fp); - } - - // }}} - // {{{ _rebuildFileMap() - - function _rebuildFileMap() - { - $packages = $this->listPackages(); - $files = array(); - foreach ($packages as $package) { - $version = $this->packageInfo($package, 'version'); - $filelist = $this->packageInfo($package, 'filelist'); - if (!is_array($filelist)) { - continue; - } - foreach ($filelist as $name => $attrs) { - if (isset($attrs['role']) && $attrs['role'] != 'php') { - continue; - } - if (isset($attrs['baseinstalldir'])) { - $file = $attrs['baseinstalldir'].DIRECTORY_SEPARATOR.$name; - } else { - $file = $name; - } - $file = preg_replace(',^/+,', '', $file); - $files[$file] = $package; - } - } - $this->_assertStateDir(); - $fp = @fopen($this->filemap, 'w'); - if (!$fp) { - return false; - } - fwrite($fp, serialize($files)); - fclose($fp); - return true; - } - - // }}} - // {{{ _lock() - - /** - * Lock the registry. - * - * @param integer lock mode, one of LOCK_EX, LOCK_SH or LOCK_UN. - * See flock manual for more information. - * - * @return bool TRUE on success, FALSE if locking failed, or a - * PEAR error if some other error occurs (such as the - * lock file not being writable). - * - * @access private - */ - function _lock($mode = LOCK_EX) - { - if(!strstr(php_uname(), 'Windows 95/98')) { - if ($mode != LOCK_UN && is_resource($this->lock_fp)) { - // XXX does not check type of lock (LOCK_SH/LOCK_EX) - return true; - } - if (PEAR::isError($err = $this->_assertStateDir())) { - return $err; - } - $open_mode = 'w'; - // XXX People reported problems with LOCK_SH and 'w' - if ($mode === LOCK_SH) { - if (@!is_file($this->lockfile)) { - touch($this->lockfile); - } - $open_mode = 'r'; - } - $this->lock_fp = @fopen($this->lockfile, $open_mode); - if (!is_resource($this->lock_fp)) { - return $this->raiseError("could not create lock file: $php_errormsg"); - } - if (!(int)flock($this->lock_fp, $mode)) { - switch ($mode) { - case LOCK_SH: $str = 'shared'; break; - case LOCK_EX: $str = 'exclusive'; break; - case LOCK_UN: $str = 'unlock'; break; - default: $str = 'unknown'; break; - } - return $this->raiseError("could not acquire $str lock ($this->lockfile)", - PEAR_REGISTRY_ERROR_LOCK); - } - } - return true; - } - - // }}} - // {{{ _unlock() - - function _unlock() - { - $ret = $this->_lock(LOCK_UN); - $this->lock_fp = null; - return $ret; - } - - // }}} - // {{{ _packageExists() - - function _packageExists($package) - { - return file_exists($this->_packageFileName($package)); - } - - // }}} - // {{{ _packageInfo() - - function _packageInfo($package = null, $key = null) - { - if ($package === null) { - return array_map(array($this, '_packageInfo'), - $this->_listPackages()); - } - $fp = $this->_openPackageFile($package, 'r'); - if ($fp === null) { - return null; - } - $data = fread($fp, filesize($this->_packageFileName($package))); - $this->_closePackageFile($fp); - $data = unserialize($data); - if ($key === null) { - return $data; - } - if (isset($data[$key])) { - return $data[$key]; - } - return null; - } - - // }}} - // {{{ _listPackages() - - function _listPackages() - { - $pkglist = array(); - $dp = @opendir($this->statedir); - if (!$dp) { - return $pkglist; - } - while ($ent = readdir($dp)) { - if ($ent{0} == '.' || substr($ent, -4) != '.reg') { - continue; - } - $pkglist[] = substr($ent, 0, -4); - } - return $pkglist; - } - - // }}} - - // {{{ packageExists() - - function packageExists($package) - { - if (PEAR::isError($e = $this->_lock(LOCK_SH))) { - return $e; - } - $ret = $this->_packageExists($package); - $this->_unlock(); - return $ret; - } - - // }}} - // {{{ packageInfo() - - function packageInfo($package = null, $key = null) - { - if (PEAR::isError($e = $this->_lock(LOCK_SH))) { - return $e; - } - $ret = $this->_packageInfo($package, $key); - $this->_unlock(); - return $ret; - } - - // }}} - // {{{ listPackages() - - function listPackages() - { - if (PEAR::isError($e = $this->_lock(LOCK_SH))) { - return $e; - } - $ret = $this->_listPackages(); - $this->_unlock(); - return $ret; - } - - // }}} - // {{{ addPackage() - - function addPackage($package, $info) - { - if ($this->packageExists($package)) { - return false; - } - if (PEAR::isError($e = $this->_lock(LOCK_EX))) { - return $e; - } - $fp = $this->_openPackageFile($package, 'w'); - if ($fp === null) { - $this->_unlock(); - return false; - } - $info['_lastmodified'] = time(); - fwrite($fp, serialize($info)); - $this->_closePackageFile($fp); - $this->_unlock(); - return true; - } - - // }}} - // {{{ deletePackage() - - function deletePackage($package) - { - if (PEAR::isError($e = $this->_lock(LOCK_EX))) { - return $e; - } - $file = $this->_packageFileName($package); - $ret = @unlink($file); - $this->_rebuildFileMap(); - $this->_unlock(); - return $ret; - } - - // }}} - // {{{ updatePackage() - - function updatePackage($package, $info, $merge = true) - { - $oldinfo = $this->packageInfo($package); - if (empty($oldinfo)) { - return false; - } - if (PEAR::isError($e = $this->_lock(LOCK_EX))) { - return $e; - } - if (!file_exists($this->filemap)) { - $this->_rebuildFileMap(); - } - $fp = $this->_openPackageFile($package, 'w'); - if ($fp === null) { - $this->_unlock(); - return false; - } - $info['_lastmodified'] = time(); - if ($merge) { - fwrite($fp, serialize(array_merge($oldinfo, $info))); - } else { - fwrite($fp, serialize($info)); - } - $this->_closePackageFile($fp); - if (isset($info['filelist'])) { - $this->_rebuildFileMap(); - } - $this->_unlock(); - return true; - } - - // }}} -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php deleted file mode 100644 index b7279b76a5..0000000000 --- a/pear/PEAR/Remote.php +++ /dev/null @@ -1,258 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Stig Bakken <ssb@fast.no> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; -require_once 'PEAR/Config.php'; - -/** - * This is a class for doing remote operations against the central - * PEAR database. - */ -class PEAR_Remote extends PEAR -{ - // {{{ properties - - var $config = null; - - // }}} - - // {{{ PEAR_Remote(config_object) - - function PEAR_Remote(&$config) - { - $this->PEAR(); - $this->config = &$config; - } - - // }}} - - // {{{ call(method, [args...]) - - function call($method) - { - if (extension_loaded("xmlrpc")) { - $args = func_get_args(); - return call_user_func_array(array(&$this, 'call_epi'), $args); - } - if (!@include_once("XML/RPC.php")) { - return $this->raiseError("For this remote PEAR operation you need to install the XML_RPC package"); - } - $args = func_get_args(); - array_shift($args); - $server_host = $this->config->get('master_server'); - $username = $this->config->get('username'); - $password = $this->config->get('password'); - $f = new XML_RPC_Message($method, $this->_encode($args)); - $c = new XML_RPC_Client('/xmlrpc.php', $server_host, 80); - if ($username && $password) { - $c->setCredentials($username, $password); - } - $c->setDebug(1); - $r = $c->send($f); - if (!$r) { - return $this->raiseError("XML_RPC send failed"); - } - $v = $r->value(); - if ($e = $r->faultCode()) { - return $this->raiseError($r->faultString(), $e); - } - return XML_RPC_decode($v); - } - - // }}} - - // {{{ call_epi(method, [args...]) - - function call_epi($method) - { - do { - if (extension_loaded("xmlrpc")) { - break; - } - if (OS_WINDOWS) { - $ext = 'dll'; - } elseif (PHP_OS == 'HP-UX') { - $ext = 'sl'; - } elseif (PHP_OS == 'AIX') { - $ext = 'a'; - } else { - $ext = 'so'; - } - $ext = OS_WINDOWS ? 'dll' : 'so'; - @dl("xmlrpc-epi.$ext"); - if (extension_loaded("xmlrpc")) { - break; - } - @dl("xmlrpc.$ext"); - if (extension_loaded("xmlrpc")) { - break; - } - return $this->raiseError("xmlrpc extension not loaded"); - } while (false); - $params = func_get_args(); - array_shift($params); - $method = str_replace("_", ".", $method); - $request = xmlrpc_encode_request($method, $params); - $server_host = $this->config->get("master_server"); - if (empty($server_host)) { - return $this->raiseError("PEAR_Remote::call: no master_server configured"); - } - $server_port = 80; - $fp = @fsockopen($server_host, $server_port); - if (!$fp) { - return $this->raiseError("PEAR_Remote::call: fsockopen(`$server_host', $server_port) failed"); - } - $len = strlen($request); - $req_headers = "Host: $server_host:$server_port\r\n" . - "Content-type: text/xml\r\n" . - "Content-length: $len\r\n"; - $username = $this->config->get('username'); - $password = $this->config->get('password'); - if ($username && $password) { - $req_headers .= "Cookie: PEAR_USER=$username; PEAR_PW=$password\r\n"; - $tmp = base64_encode("$username:$password"); - $req_headers .= "Authorization: Basic $tmp\r\n"; - } - fwrite($fp, ("POST /xmlrpc.php HTTP/1.0\r\n$req_headers\r\n$request")); - $response = ''; - $line1 = fgets($fp, 2048); - if (!preg_match('!^HTTP/[0-9\.]+ (\d+) (.*)!', $line1, $matches)) { - return $this->raiseError("PEAR_Remote: invalid HTTP response from XML-RPC server"); - } - switch ($matches[1]) { - case "200": - break; - case "401": - if ($username && $password) { - return $this->raiseError("PEAR_Remote: authorization failed", 401); - } else { - return $this->raiseError("PEAR_Remote: authorization required, please log in first", 401); - } - default: - return $this->raiseError("PEAR_Remote: unexpected HTTP response", (int)$matches[1], null, null, "$matches[1] $matches[2]"); - } - while (trim(fgets($fp, 2048)) != ''); // skip rest of headers - while ($chunk = fread($fp, 10240)) { - $response .= $chunk; - } - fclose($fp); - $ret = xmlrpc_decode($response); - if (is_array($ret) && isset($ret['__PEAR_TYPE__'])) { - if ($ret['__PEAR_TYPE__'] == 'error') { - if (isset($ret['__PEAR_CLASS__'])) { - $class = $ret['__PEAR_CLASS__']; - } else { - $class = "PEAR_Error"; - } - if ($ret['code'] === '') $ret['code'] = null; - if ($ret['message'] === '') $ret['message'] = null; - if ($ret['userinfo'] === '') $ret['userinfo'] = null; - if (strtolower($class) == 'db_error') { - $ret = $this->raiseError(DB::errorMessage($ret['code']), - $ret['code'], null, null, - $ret['userinfo']); - } else { - $ret = $this->raiseError($ret['message'], $ret['code'], - null, null, $ret['userinfo']); - } - } - } elseif (is_array($ret) && sizeof($ret) == 1 && - isset($ret[0]['faultString']) && - isset($ret[0]['faultCode'])) { - extract($ret[0]); - $faultString = "XML-RPC Server Fault: " . - str_replace("\n", " ", $faultString); - return $this->raiseError($faultString, $faultCode); - } - return $ret; - } - - // }}} - - // {{{ _encode - - // a slightly extended version of XML_RPC_encode - function _encode($php_val) - { - global $XML_RPC_Boolean, $XML_RPC_Int, $XML_RPC_Double; - global $XML_RPC_String, $XML_RPC_Array, $XML_RPC_Struct; - - $type = gettype($php_val); - $xmlrpcval = new XML_RPC_value; - - switch($type) { - case "array": - reset($php_val); - $firstkey = key($php_val); - end($php_val); - $lastkey = key($php_val); - if ($firstkey === 0 && is_int($lastkey) && - ($lastkey + 1) == count($php_val)) { - $is_continous = true; - reset($php_val); - for ($expect = 0; $expect < count($php_val); $expect++) { - if (key($php_val) !== $expect) { - $is_continous = false; - break; - } - } - if ($is_continous) { - reset($php_val); - $arr = array(); - while (list($k, $v) = each($php_val)) { - $arr[$k] = $this->_encode($v); - } - $xmlrpcval->addArray($arr); - break; - } - } - // fall though if not numerical and continous - case "object": - $arr = array(); - while (list($k, $v) = each($php_val)) { - $arr[$k] = $this->_encode($v); - } - $xmlrpcval->addStruct($arr); - break; - case "integer": - $xmlrpcval->addScalar($php_val, $XML_RPC_Int); - break; - case "double": - $xmlrpcval->addScalar($php_val, $XML_RPC_Double); - break; - case "string": - case "NULL": - $xmlrpcval->addScalar($php_val, $XML_RPC_String); - break; - case "boolean": - $xmlrpcval->addScalar($php_val, $XML_RPC_Boolean); - break; - case "unknown type": - default: - return null; - } - return $xmlrpcval; - } - - // }}} - -} - -?>
\ No newline at end of file diff --git a/pear/PEAR/WebInstaller.php b/pear/PEAR/WebInstaller.php deleted file mode 100644 index 39ea212c98..0000000000 --- a/pear/PEAR/WebInstaller.php +++ /dev/null @@ -1,639 +0,0 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4; */ -// +---------------------------------------------------------------------+ -// | PHP version 4.0 | -// +---------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +---------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +---------------------------------------------------------------------+ -// | Authors: Christian Stocker <chregu@phant.ch> | -// +---------------------------------------------------------------------+ - - -/* - - WARNING: Due to internal changes in PEAR, the webinstaller is - currently not supported! - -*/ - - -/* This class should simplify the task of installing PEAR-packages, if you - * don't have a cgi-php binary on your system or you don't have access to - * the system-wide pear directory. - * - * To use it, make the following php-script: - * - * <?php - * require("PEAR/WebInstaller.php"); - * $installer = new PEAR_WebInstaller("/path/to/your/install/dir","http://php.chregu.tv/pear/"); - * $installer->start(); - * ?> - * - * and put PEAR/WebInstaller.php (this script) anywhere in your include_path. - * - * (http://php.chregu.tv/pear/ is just for testing purposes until this - * system runs on pear.php.net, but feel free to use it till then) - * - * Both parameters are optional. If the install dir is ommitted, the - * installer takes either the system wide pear-directory (mostly - * /usr/local/lib/php on unix), if it's writeable, or else the directory - * the script is started. Be advised, that the directory, where the - * PEAR::Packages will be installed, has to be writeable for the web-server. - * - * The second parameter points to the server/directory where all the - * packages and especially Packages.xml is located. If not given, the - * standard PEAR-Repository is taken (http://pear.php.net/whatever..) - * - * After installation, just add the install-dir to your include_path and - * the packages should work. - * - * If you are System Adminisitrator and want the installed packages to be - * made available for everyone, just copy the files to the systemwide - * pear-dir after installation on the commandline. Or also add the - * install-dir to the systemwide include_path (and maybe don't forget to - * take the writeable off the directory..) - * - * TODO: - * - More Error Detection - * - Grouping of Packages - * - Show installed Packages (from /var/lib/php/packages.lst?) - * - Add possibility to install a package (.tgz) from the local file - * system without a global Packages.xml (useful if no cgi-php - * around and you need this package you downloaded installed :) ) - * - Search Function (maybe needed if we have hundreds of packages) - * - Only download Packages.xml, if it actually changed. - * - * This Code is highly experimental. - */ - -require_once "PEAR.php"; - -class PEAR_WebInstaller extends PEAR -{ - // {{{ properties - - /** stack of elements, gives some sort of XML context */ - var $element_stack; - - /** name of currently parsed XML element */ - var $current_element; - - /** array of attributes of the currently parsed XML element */ - var $current_attributes = array(); - - /** assoc with information about a package */ - var $pkginfo = array(); - - /** assoc with information about all packages */ - var $AllPackages; - - /** URL to the server containing all packages in tgz-Format and the Package.xml */ - var $remotedir = "http://php.chregu.tv/pear/"; - - /* Directory where the to be installed files should be put - per default PEAR_INSTALL_DIR (/usr/local/lib/php) if it's writeable for the webserver, - else current directory, or user defined directory (provided as first parameter in constructor) - The Directory hast to be writeable for the php-module (webserver) - */ - var $installdir; - - /** how many seconds we should cache Packages.xml */ - var $cachetime = 3600; - - var $printlogger = True; - // }}} - - // {{{ constructor - - function PEAR_Webinstaller($installdir = Null,$remotedir = Null) - { - $this->PEAR(); - if ($installdir) - { - $this->installdir = $installdir; - } - else - { - if (is_writeable(PEAR_INSTALL_DIR)) - { - $this->installdir = PEAR_INSTALL_DIR; - } - else - { - $this->installdir = getcwd(); - } - } - - if ($remotedir) - { - $this->remotedir = $remotedir; - } - } - - // }}} - // {{{ start() - - function start() { - global $HTTP_POST_VARS,$HTTP_GET_VARS; - - //print header - $this->header(); - - $this->loggerStart(); - - //if some checkboxes for installation were selected, install. - if ($HTTP_GET_VARS["help"]) { - - $this->help($HTTP_GET_VARS["help"]); - } - - elseif ($HTTP_POST_VARS["InstPack"]) { - $this->installPackages(array_keys($HTTP_POST_VARS["InstPack"])); - } - - //else print all modules - else { - $this->printTable(); - } - $this->footer(); - } - // }}} - // {{{ installPackages() - - /* installs the Packages and prints if successfull or not */ - - function installPackages($packages) - { - require_once "PEAR/Installer.php"; - $installer =& new PEAR_Installer(); - $installer->phpdir = $this->installdir; - $this->loggerEnd(); - print "<TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>"; - print "<TR><TD BGCOLOR=\"#000000\">\n"; - print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=100%>\n"; - print " <TR BGCOLOR=\"#e0e0e0\">\n"; - print " <TH>Package</TH>\n"; - print " <TH>Status</TH>\n"; - - foreach ($packages as $package) - { - - - if (++$i % 2) { - $bg1 = "#ffffff"; - $bg2 = "#f0f0f0"; - } - else { - $bg1 = "#f0f0f0"; - $bg2 = "#e0e0e0"; - } - print " <TR>\n"; - - print "<TD BGCOLOR=\"$bg1\">"; - print $package; - print "</TD>\n"; - - - /* - print "<TD BGCOLOR=\"$bg2\">"; - print "Installing ..."; - print "</td>"; - print " <TR>\n"; - print "<TD BGCOLOR=\"$bg1\">"; - print " "; - print "</TD>\n"; - */ - print "<TD BGCOLOR=\"$bg2\">"; - if (PEAR::isError($installer->Install($this->remotedir."/".$package.".tgz"))) { - print "\ninstall failed\n"; - } - else { - - print "install ok\n"; - } - print "</td></tr>\n"; - } - print "</td></tr>"; - print "</table>"; - print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n"; - print " <TR BGCOLOR=\"$bg1\">\n"; - print "<th colspan=\"2\">"; - print "<a href=\"$GLOBALS[PHP_SELF]\">Back to the Packages</a>\n"; - print "</th></tr></table>"; - print"</td></tr></table>"; - } - - // }}} - // {{{ printTable() - /* Prints a table with all modules available on the server-directory */ - - function printTable() - { - global $PHP_SELF; - $Packages = $this->getPackages(); - if (PEAR::IsError($Packages)) - { - if ($this->printlogger) { - $this->logger($Packages->message); - } - else - { - print $Packages->message; - } - return $Packages; - } - $this->loggerEnd(); - print "<FORM action=\"$GLOBALS[PHP_SELF]\" method=\"post\">\n"; - print "<TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>"; - print "<TR><TD BGCOLOR=\"#000000\">\n"; - print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n"; - print "<tr bgcolor=\"f0f0f0\">"; - print "<td COLSPAN=\"6\" ><input type=\"submit\" value=\"Install\"></td>"; - print "</tr>"; - - print " <TR BGCOLOR=\"#e0e0e0\" >\n"; - print " <TH>Inst.</TH>\n"; - print " <TH>Package</TH>\n"; - print " <TH>Summary</TH>\n"; - print " <TH>Version</TH>\n"; - print " <TH>Release date</TH>\n"; - print " <TH>Release notes</TH>\n"; - print " </TR>\n"; - $i = 0; - - ksort($Packages); - foreach ( $Packages as $package) { - - if (++$i % 2) { - $bg1 = "#ffffff"; - $bg2 = "#f0f0f0"; - } - else { - $bg1 = "#f0f0f0"; - $bg2 = "#e0e0e0"; - } - - - print "<TR>\n"; - - print "<TD align=\"middle\" BGCOLOR=\"$bg2\">"; - print "<input type=\"checkbox\" name=\"InstPack[".$package["name"]."-".$package["version"]."]\">\n"; - print "</TD>\n"; - - print " <TD BGCOLOR=\"$bg1\">"; - print $this->printCell ($package["name"],"http://pear.php.net/pkginfo.php?package=$package[name]"); - print "</TD>\n"; - - print "<TD BGCOLOR=\"$bg2\">"; - $this->printCell ($package["summary"]); - print "</TD>\n"; - - print "<TD BGCOLOR=\"$bg2\">"; - $this->printCell ($package["version"],$this->remotedir."/".$package["name"]."-".$package["version"].".tgz"); - print "</TD>\n"; - - print "<TD BGCOLOR=\"$bg2\">"; - $this->printCell ($package["release_date"]); - print "</TD>\n"; - - print "<TD BGCOLOR=\"$bg2\">"; - $this->printCell (nl2br($package["release_notes"])); - print "</TD>\n"; - print " </TR>\n"; - - } - print "<tr bgcolor=\"$bg1\">"; - print "<td COLSPAN=\"6\" ><input type=\"submit\" value=\"Install\"></td>"; - print "</tr>"; - print "</TABLE> \n"; - - - print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n"; - print " <TR BGCOLOR=\"#e0e0e0\">\n"; - - print "<th align=left width=\"10%\" nowrap>\n"; - print "Install Directory: </th><td>$this->installdir"; - if (!is_writable($this->installdir)) - { - print " <font color=\"red\">(Directory is NOT writeable!)</font>"; - } - - print "</td></tr>\n"; - - print " <TR BGCOLOR=\"#f0f0f0\">\n"; - print "<th align=left width=\"10%\" nowrap>\n"; - print "PEAR Repository: </th><td>$this->remotedir</td></tr>\n"; - - print " <TR BGCOLOR=\"#e0e0e0\">\n"; - print "<th align=left width=\"10%\" nowrap>\n"; - print "Caching Time: </th><td>$this->cachetime seconds</td></tr>\n"; - - print "</table>\n"; - print "</tr></td></table></FORM>\n"; - print "<a href=\"$PHP_SELF?help=1\">Help</A>\n"; - } - - // }}} - // {{{ getPackages() - - /** gets the Packages.xml from the server and saves it on the local disc for caching (if possible) - * If the zlib-extension is compiled in, Packages.xml.gz is used instead. - */ - - function getPackages ($TryGz = True) - { - - // if we can write to the installdir, cache the Packages.xml there - - $PackageFile = "Packages.xml"; - - // check if we have the zlib-extension compiled in - if ($TryGz && function_exists("gzfile")) { $useGz = True; $PackageFile .= ".gz";} - - // check if we can write the Package.xml file for caching - - if ( (file_exists($this->installdir."/$PackageFile") && is_writeable($this->installdir."/$PackageFile")) || !file_exists($this->installdir."/$PackageFile") && is_writeable($this->installdir) ) - { - $time = filemtime($this->installdir."/$PackageFile"); - - if ($time < (time () - $this->cachetime )) { - $this->logger("$PackageFile too old. Get new one."); - $fp = @fopen($this->remotedir."/$PackageFile","r"); - if (!$fp) { - if ($useGz) - { - $this->logger("$PackageFile could not be read. Try uncompressed one"); - return $this->getPackages(False); - } - else { - $this->logger("$PackageFile could not be read."); - return $this->raiseError("$PackageFile could not be read."); - } - } - $fout = fopen($this->installdir."/$PackageFile","w"); - while ($data = fread($fp,8192)) { - fwrite ($fout, $data); - } - fclose($fout); - fclose($fp); - $this->logger("Got $PackageFile"); - } - else { - $this->logger("Cached $PackageFile seems new enough"); - } - $Packages = $this->infoFromDescriptionFile($this->installdir."/$PackageFile"); - } - else - { - $this->logger("$PackageFile can not be cached, because Install-Dir or $PackageFile is not writeable. Get it each time from the server"); - $Packages = $this->infoFromDescriptionFile($this->remotedir."/Packages.xml"); - } - $this->logger("Got Packages"); - return $Packages; - } - - // }}} - // {{{ printCell() - - function printCell($text,$link = Null) - { - if ($text) - { - if ($link) { - print "<a href=\"$link\" style=\"color: #000000;\">"; - } - - print "$text"; - - if ($link) { - print "</a>"; - } - - } - else - { - print " "; - } - } - - // }}} - /* The following 4 functions are taken from PEAR/Common.php written by Stig Bakken - I had to adjust to use the Packages.xml format. - */ - // {{{ _element_start() - - - function _element_start($xp, $name, $attribs) - { - array_push($this->element_stack, $name); - $this->current_element = $name; - $this->current_attributes = $attribs; - } - - // }}} - // {{{ _element_end() - - function _element_end($xp, $name) - { - array_pop($this->element_stack); - if ($name == "PACKAGE") - { - $this->AllPackages[$this->pkginfo["name"]] = $this->pkginfo; - $this->pkginfo = array(); - - } - - $this->current_element = $this->element_stack[sizeof($this->element_stack)-1]; - } - - // }}} - // {{{ _pkginfo_cdata() - - function _pkginfo_cdata($xp, $data) - { - $next = $this->element_stack[sizeof($this->element_stack)-1]; - switch ($this->current_element) { - case "NAME": - $this->pkginfo["name"] .= $data; - break; - case "SUMMARY": - $this->pkginfo["summary"] .= $data; - break; - case "USER": - $this->pkginfo["maintainer_handle"] .= $data; - break; - case "EMAIL": - $this->pkginfo["maintainer_email"] .= $data; - break; - case "VERSION": - $this->pkginfo["version"] .= $data; - break; - case "DATE": - $this->pkginfo["release_date"] .= $data; - break; - case "NOTES": - $this->pkginfo["release_notes"] .= $data; - break; - case "DIR": - if (!$this->installdir) { - break; - } - $dir = trim($data); - // XXX add to file list - break; - case "FILE": - $role = strtolower($this->current_attributes["ROLE"]); - $file = trim($data); - // XXX add to file list - break; - } - } - - // }}} - // {{{ infoFromDescriptionFile() - - function infoFromDescriptionFile($descfile) - { - $fp = @fopen($descfile,"r"); - if (!$fp) { - return $this->raiseError("Unable to open $descfile in ".__FILE__.":".__LINE__); - } - $xp = @xml_parser_create(); - - if (!$xp) { - return $this->raiseError("Unable to create XML parser."); - } - - xml_set_object($xp, $this); - - xml_set_element_handler($xp, "_element_start", "_element_end"); - xml_set_character_data_handler($xp, "_pkginfo_cdata"); - xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, true); - - $this->element_stack = array(); - $this->pkginfo = array(); - $this->current_element = false; - $this->destdir = ''; - - // read the whole thing so we only get one cdata callback - // for each block of cdata - - if (preg_match("/\.gz$/",$descfile)) - { - $data = implode("",gzfile($descfile)); - } - else - { - $data = implode("",file($descfile)); - } - - if (!@xml_parse($xp, $data, 1)) { - $msg = sprintf("XML error: %s at line %d", - xml_error_string(xml_get_error_code($xp)), - xml_get_current_line_number($xp)); - xml_parser_free($xp); - return $this->raiseError($msg); - } - - xml_parser_free($xp); - - foreach ($this->pkginfo as $k => $v) { - $this->pkginfo[$k] = trim($v); - } - - return $this->AllPackages; - } - - // }}} - // {{{ header() - - function header () - { - print "<html> - <head> - <title>PEAR::WebInstaller</title>\n"; - if (file_exists("./style.css")) - { - print '<link rel="stylesheet" href="/style.css">'; - } - print "</head> - <body bgcolor=\"#FFFFFF\"> - <h3>PEAR::WebInstaller</h3>"; - - } - - // }}} - // {{{ footer() - - function footer () { - print "</body></html>"; - } - - // }}} - - function logger ($text) { - - if ($this->printlogger) { - if (++$this->logcol % 2) { - $bg1 = "#ffffff"; - $bg2 = "#f0f0f0"; - } - else { - $bg1 = "#f0f0f0"; - $bg2 = "#e0e0e0"; - } - print "<TR>\n"; - print "<TD BGCOLOR=\"$bg1\">".date("h:m:i",time())."</td>"; - print "<TD BGCOLOR=\"$bg2\">"; - print "$text\n"; - print "</TD>\n"; - print "</tr>"; - } - } - function loggerStart () { - if ($this->printlogger) { - print "<TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>"; - print "<TR><TD BGCOLOR=\"#000000\">\n"; - print "<TABLE CELLSPACING=1 BORDER=0 CELLPADDING=3 width=\"100%\">\n"; - } - } - - function loggerEnd () { - if ($this->printlogger) { - print "</table></td></tr></table>"; - } - } - function help ($Full = False) { - global $PHP_SELF; - $this->loggerEnd(); - print "From the WebInstaller.php introduction: <p>"; - - $file = file(__FILE__); - foreach($file as $line) - { - if ($Full != 2 && strstr($line,"require_once")){ - break; - } - $help .= $line; - } - - highlight_string($help); - print "<p>"; - if ($Full != 2) { - print "<a href=\"$PHP_SELF?help=2\">See the full source</a><p>\n"; - } - - print "<a href=\"$PHP_SELF\">Back to the packages overview</A>\n"; - } - -} - -?> diff --git a/pear/README b/pear/README deleted file mode 100644 index c953c26b13..0000000000 --- a/pear/README +++ /dev/null @@ -1,18 +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. - - -DOCUMENTATION - -Documentation for PEAR can be found at http://pear.php.net/manual/. diff --git a/pear/System.php b/pear/System.php deleted file mode 100644 index 98d9b8eae7..0000000000 --- a/pear/System.php +++ /dev/null @@ -1,412 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - -require_once 'PEAR.php'; -require_once 'Console/Getopt.php'; - -/** -* System offers cross plattform compatible system functions -* -* Static functions for different operations. Should work under -* Unix and Windows. The names and usage has been taken from its respectively -* GNU commands. The functions will return (bool) false on error and will -* trigger the error with the PHP trigger_error() function (you can silence -* the error by prefixing a '@' sign after the function call). -* -* Documentation on this class you can find in: -* http://pear.php.net/manual/ -* -* Example usage: -* if (!@System::rm('-r file1 dir1')) { -* print "could not delete file1 or dir1"; -* } -* -* @package System -* @author Tomas V.V.Cox <cox@idecnet.com> -* @version $Revision$ -* @access public -* @see http://pear.php.net/manual/ -*/ -class System extends PEAR -{ - /** - * returns the commandline arguments of a function - * - * @param string $argv the commandline - * @param string $short_options the allowed option short-tags - * @param string $long_options the allowed option long-tags - * @return array the given options and there values - * @access private - */ - function _parseArgs($argv, $short_options, $long_options = null) - { - if (!is_array($argv) && $argv !== null) { - $argv = preg_split('/\s+/', $argv); - } - return Console_Getopt::getopt($argv, $short_options); - } - - /** - * Output errors with PHP trigger_error(). You can silence the errors - * with prefixing a "@" sign to the function call: @System::mkdir(..); - * - * @param mixed $error a PEAR error or a string with the error message - * @return bool false - * @access private - */ - function raiseError($error) - { - if (PEAR::isError($error)) { - $error = $error->getMessage(); - } - trigger_error($error, E_USER_WARNING); - return false; - } - - /** - * Creates a nested array representing the structure of a directory - * - * System::_dirToStruct('dir1', 0) => - * Array - * ( - * [dirs] => Array - * ( - * [0] => dir1 - * ) - * - * [files] => Array - * ( - * [0] => dir1/file2 - * [1] => dir1/file3 - * ) - * ) - * @param string $sPath Name of the directory - * @param integer $maxinst max. deep of the lookup - * @param integer $aktinst starting deep of the lookup - * @return array the structure of the dir - * @access private - */ - - function _dirToStruct($sPath, $maxinst, $aktinst = 0) - { - $struct = array('dirs' => array(), 'files' => array()); - if (($dir = @opendir($sPath)) === false) { - System::raiseError("Could not open dir $sPath"); - return $struct; // XXX could not open error - } - $struct['dirs'][] = $sPath; // XXX don't add if '.' or '..' ? - $list = array(); - while ($file = readdir($dir)) { - if ($file != '.' && $file != '..') { - $list[] = $file; - } - } - closedir($dir); - sort($list); - foreach($list as $val) { - $path = $sPath . DIRECTORY_SEPARATOR . $val; - if (is_dir($path)) { - if ($aktinst < $maxinst || $maxinst == 0) { - $tmp = System::_dirToStruct($path, $maxinst, $aktinst+1); - $struct = array_merge_recursive($tmp, $struct); - } - } else { - $struct['files'][] = $path; - } - } - return $struct; - } - - /** - * Creates a nested array representing the structure of a directory and files - * - * @param array $files Array listing files and dirs - * @return array - * @see System::_dirToStruct() - */ - function _multipleToStruct($files) - { - $struct = array('dirs' => array(), 'files' => array()); - foreach($files as $file) { - if (is_dir($file)) { - $tmp = System::_dirToStruct($file, 0); - $struct = array_merge_recursive($tmp, $struct); - } else { - $struct['files'][] = $file; - } - } - return $struct; - } - - /** - * The rm command for removing files. - * Supports multiple files and dirs and also recursive deletes - * - * @param string $args the arguments for rm - * @return mixed PEAR_Error or true for success - * @access public - */ - function rm($args) - { - $opts = System::_parseArgs($args, 'rf'); // "f" do nothing but like it :-) - if (PEAR::isError($opts)) { - return System::raiseError($opts); - } - foreach($opts[0] as $opt) { - if ($opt[0] == 'r') { - $do_recursive = true; - } - } - $ret = true; - if (isset($do_recursive)) { - $struct = System::_multipleToStruct($opts[1]); - foreach($struct['files'] as $file) { - if (!unlink($file)) { - $ret = false; - } - } - foreach($struct['dirs'] as $dir) { - if (!rmdir($dir)) { - $ret = false; - } - } - } else { - foreach ($opts[1] as $file) { - $delete = (is_dir($file)) ? 'rmdir' : 'unlink'; - if (!$delete($file)) { - $ret = false; - } - } - } - return $ret; - } - - /** - * Make directories - * - * @param string $args the name of the director(y|ies) to create - * @return bool True for success - * @access public - */ - function mkDir($args) - { - $opts = System::_parseArgs($args, 'pm:'); - if (PEAR::isError($opts)) { - return System::raiseError($opts); - } - $mode = 0777; // default mode - foreach($opts[0] as $opt) { - if ($opt[0] == 'p') { - $create_parents = true; - } elseif($opt[0] == 'm') { - $mode = $opt[1]; - } - } - $ret = true; - if (isset($create_parents)) { - foreach($opts[1] as $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, $mode)) { - $ret = false; - } - } - } - } else { - foreach($opts[1] as $dir) { - if (!@is_dir($dir) && !mkdir($dir, $mode)) { - $ret = false; - } - } - } - return $ret; - } - - /** - * Concatenate files - * - * Usage: - * 1) $var = System::cat('sample.txt test.txt'); - * 2) System::cat('sample.txt test.txt > final.txt'); - * 3) System::cat('sample.txt test.txt >> final.txt'); - * - * Note: as the class use fopen, urls should work also (test that) - * - * @param string $args the arguments - * @return boolean true on success - * @access public - */ - function &cat($args) - { - $ret = null; - $files = array(); - if (!is_array($args)) { - $args = preg_split('/\s+/', $args); - } - for($i=0; $i < count($args); $i++) { - if ($args[$i] == '>') { - $mode = 'wb'; - $outputfile = $args[$i+1]; - break; - } elseif ($args[$i] == '>>') { - $mode = 'ab+'; - $outputfile = $args[$i+1]; - break; - } else { - $files[] = $args[$i]; - } - } - if (isset($mode)) { - if (!$outputfd = fopen($outputfile, $mode)) { - return System::raiseError("Could not open $outputfile"); - } - $ret = true; - } - foreach ($files as $file) { - if (!$fd = fopen($file, 'r')) { - System::raiseError("Could not open $file"); - continue; - } - while(!feof($fd)) { - $cont = fread($fd, 2048); - if (isset($outputfd)) { - fwrite($outputfd, $cont); - } else { - $ret .= $cont; - } - } - fclose($fd); - } - if (@is_resource($outputfd)) { - fclose($outputfd); - } - return $ret; - } - - /** - * Creates temporal files or directories - * - * Usage: - * 1) $tempfile = System::mktemp("prefix"); - * 2) $tempdir = System::mktemp("-d prefix"); - * 3) $tempfile = System::mktemp(); - * 4) $tempfile = System::mktemp("-t /var/tmp prefix"); - * - * prefix -> The string that will be prepended to the temp name - * (defaults to "tmp"). - * -d -> A temporal dir will be created instead of a file. - * -t -> The target dir where the temporal (file|dir) will be created. If - * this param is missing by default the env vars TMP on Windows or - * TMPDIR in Unix will be used. If these vars are also missing - * c:\windows\temp or /tmp will be used. - * - * @param string $args The arguments - * @return mixed the full path of the created (file|dir) or false - * @see System::tmpdir() - * @access public - */ - function mktemp($args = null) - { - $opts = System::_parseArgs($args, 't:d'); - if (PEAR::isError($opts)) { - return System::raiseError($opts); - } - foreach($opts[0] as $opt) { - if($opt[0] == 'd') { - $tmp_is_dir = true; - } elseif($opt[0] == 't') { - $tmpdir = $opt[1]; - } - } - $prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp'; - if (!isset($tmpdir)) { - $tmpdir = System::tmpdir(); - } - if (!System::mkDir("-p $tmpdir")) { - return false; - } - $tmp = tempnam($tmpdir, $prefix); - if (isset($tmp_is_dir)) { - unlink($tmp); // be careful possible race condition here - if (!mkdir($tmp, 0700)) { - return System::raiseError("Unable to create temporary directory $tmpdir"); - } - } - return $tmp; - } - - /** - * Get the path of the temporal directory set in the system - * by looking in its environments variables. - * - * @return string The temporal directory on the system - */ - function tmpdir() - { - if (OS_WINDOWS){ - if (isset($_ENV['TEMP'])) { - return $_ENV['TEMP']; - } - if (isset($_ENV['TMP'])) { - return $_ENV['TMP']; - } - if (isset($_ENV['windir'])) { - return $_ENV['windir'] . '\temp'; - } - return $_ENV['SystemRoot'] . '\temp'; - } - if (isset($_ENV['TMPDIR'])) { - return $_ENV['TMPDIR']; - } - return '/tmp'; - } - - /** - * The "type" command (show the full path of a command) - * - * @param string $program The command to search for - * @return mixed A string with the full path or false if not found - * @author Stig Bakken <ssb@fast.no> - */ - function type($program) - { - // full path given - if (basename($program) != $program) { - return (@is_executable($program)) ? $program : false; - } - // XXX FIXME honor safe mode - $path_delim = OS_WINDOWS ? ';' : ':'; - $exe_suffix = OS_WINDOWS ? '.exe' : ''; - $path_elements = explode($path_delim, getenv('PATH')); - foreach ($path_elements as $dir) { - $file = $dir . DIRECTORY_SEPARATOR . $program . $exe_suffix; - if (@is_file($file) && @is_executable($file)) { - return $file; - } - } - return false; - } -} -?>
\ No newline at end of file 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-Archive_Tar.xml b/pear/package-Archive_Tar.xml deleted file mode 100644 index 7644ebf240..0000000000 --- a/pear/package-Archive_Tar.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE package SYSTEM "../package.dtd"> -<!-- do not use the "Type" attribute here, that one is only for - generated package.xml files --> -<package version="1.0"> - <name>Archive_Tar</name> - <summary>Tar file management class</summary> - <description>This class provides handling of tar files in PHP. -It supports creating, listing, extracting and adding to tar files. -Gzip support is available if PHP has the zlib extension built-in or -loaded. -</description> - <license>PHP License</license> - <maintainers> - <maintainer> - <user>vblavet</user> - <role>lead</role> - <name>Vincent Blavet</name> - <email>vincent@blavet.net</email> - </maintainer> - <maintainer> - <user>ssb</user> - <role>helper</role> - <name>Stig Sæther Bakken</name> - <email>stig@php.net</email> - </maintainer> - </maintainers> - <release> - <version>0.3</version> - <date>2002-04-13</date> - <notes>Windows bugfix: used wrong directory separators</notes> - <state>stable</state> - <filelist> - <file role="php" baseinstalldir="Archive" name="Archive/Tar.php"/> - </filelist> - </release> - <changelog> - <release> - <version>0.2</version> - <date>2002-02-18</date> - <notes>From initial commit to stable</notes> - <state>stable</state> - <filelist> - <dir name="/" baseinstalldir="Archive"> - <file role="php">Tar.php</file> - <dir name="docs" role="doc"> - <file>Tar.txt</file> - </dir> - </dir> - </filelist> - </release> - </changelog> -</package> diff --git a/pear/package-Console_Getopt.xml b/pear/package-Console_Getopt.xml deleted file mode 100644 index b782e09e03..0000000000 --- a/pear/package-Console_Getopt.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE package SYSTEM "../package.dtd"> -<!-- do not use the "Type" attribute here, that one is only for - generated package.xml files --> -<package version="1.0"> - <name>Console_Getopt</name> - <summary>Command-line option parser</summary> - <description>This is a PHP implementation of "getopt" supporting both -short and long options.</description> - <license>PHP License</license> - <maintainers> - <maintainer> - <user>andrei</user> - <role>lead</role> - <name>Andrei Zmievski</name> - <email>andrei@php.net</email> - </maintainer> - <maintainer> - <user>ssb</user> - <role>helper</role> - <name>Stig Bakken</name> - <email>stig@php.net</email> - </maintainer> - </maintainers> - <release> - <version>0.9</version> - <date>2002-05-12</date> - <notes>Initial release</notes> - <state>beta</state> - <filelist> - <file role="php" baseinstalldir="Console" name="Console/Getopt.php"/> - </filelist> - </release> -</package> diff --git a/pear/package-PEAR.xml b/pear/package-PEAR.xml deleted file mode 100644 index 340f9cd629..0000000000 --- a/pear/package-PEAR.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE package SYSTEM "package.dtd"> -<package version="1.0"> - <name>PEAR</name> - <summary>PEAR Base System</summary> - <description>The PEAR package contains: - * the PEAR base class - * the PEAR_Error error handling mechanism - * the PEAR command-line toolkit, for creating, distributing - and installing packages -</description> - <license>PHP License</license> - <maintainers> - <maintainer> - <user>ssb</user> - <role>lead</role> - <name>Stig Sæther Bakken</name> - <email>stig@php.net</email> - </maintainer> - <maintainer> - <user>cox</user> - <role>developer</role> - <name>Tomas V.V.Cox</name> - <email>cox@idecnet.com</email> - </maintainer> - </maintainers> - <release> - <version>0.10-dev</version> - <state>beta</state> - <date>yyyy-mm-dd</date> - <notes> -* HTTP proxy support when downloading packages -</notes> - <filelist> - <file role="php" name="PEAR.php"/> - <dir name="PEAR"> - <file role="php" name="Autoloader.php"/> - <file role="php" name="Command.php"/> - <dir name="Command"> - <file role="php" name="Auth.php"/> - <file role="php" name="Common.php"/> - <file role="php" name="Config.php"/> - <file role="php" name="Install.php"/> - <file role="php" name="Package.php"/> - <file role="php" name="Registry.php"/> - <file role="php" name="Remote.php"/> - </dir> - <file role="php" name="Common.php"/> - <file role="php" name="Config.php"/> - <file role="php" name="Dependency.php"/> - <dir name="Frontend"> - <file role="php" name="CLI.php"/> - <file role="php" name="Gtk.php"/> - </dir> - <file role="php" name="Installer.php"/> - <file role="php" name="Packager.php"/> - <file role="php" name="Registry.php"/> - <file role="php" name="Remote.php"/> - </dir> - <dir name="OS"> - <file role="php" name="Guess.php"/> - </dir> - <dir name="scripts"> - <file baseinstalldir="/" role="script" install-as="pear" name="pear.in"> - <replace from="@prefix@/bin" to="PHP_BINDIR" type="php-const"/> - </file> - <file baseinstalldir="/" role="script" name="pear.bat"></file> - </dir> - </filelist> - <deps> - <dep type="php" rel="ge" version="4.1"/> - <dep type="pkg" rel="has">Archive_Tar</dep> - <dep type="pkg" rel="has">Console_Getopt</dep> - </deps> - </release> - <changelog> - <release> - <version>0.9</version> - <state>beta</state> - <date>2002-04-07</date> - <notes> -First package release. Commands implemented: - remote-package-info - list-upgrades - list-remote-packages - download - config-show - config-get - config-set - list-installed - shell-test - install - uninstall - upgrade - package - package-list - package-info - login - logout -</notes> - </release> - </changelog> -</package> diff --git a/pear/package.dtd b/pear/package.dtd deleted file mode 100644 index 18638597e4..0000000000 --- a/pear/package.dtd +++ /dev/null @@ -1,105 +0,0 @@ -<!-- - $Id: package.dtd,v 1.24 2002-04-28 07:58:41 ssb Exp $ - - This is the PEAR package description, version 1.0b7. - It should be used with the informal public identifier: - - "-//PHP Group//DTD PEAR Package 1.0b7//EN//XML" - - Copyright (c) 1997-2002 The PHP Group - - This source file is subject to version 2.02 of the PHP license, - that is bundled with this package in the file LICENSE, and is - available at through the world-wide-web at - http://www.php.net/license/2_02.txt. - If you did not receive a copy of the PHP license and are unable to - obtain it through the world-wide-web, please send a note to - license@php.net so we can mail you a copy immediately. - - Authors: - Stig S. Bakken <ssb@fast.no> - - --> - -<!ELEMENT package (name|summary|description|license|maintainers|release|changelog)+> -<!ATTLIST package type (source|binary|empty) "empty" - version CDATA #REQUIRED> - -<!ELEMENT name (#PCDATA)> - -<!ELEMENT summary (#PCDATA)> - -<!ELEMENT description (#PCDATA)> - -<!ELEMENT maintainers (maintainer)+> - -<!ELEMENT maintainer (user|role|name|email)+> - -<!ELEMENT user (#PCDATA)> - -<!ELEMENT role (#PCDATA)> - -<!ELEMENT email (#PCDATA)> - -<!ELEMENT changelog (release)+> - -<!ELEMENT release (version|license|state|date|notes|filelist|deps|provides|script)+> - -<!ELEMENT version (#PCDATA)> - -<!ELEMENT state (#PCDATA)> - -<!ELEMENT date (#PCDATA)> - -<!ELEMENT notes (#PCDATA)> - -<!ELEMENT filelist (dir|file|libfile)+> - -<!ELEMENT dir (dir|file|libfile)+> -<!ATTLIST dir name CDATA #REQUIRED - baseinstalldir CDATA #IMPLIED> - -<!ELEMENT file (replace*)> -<!ATTLIST file role (php|ext|test|doc|data|script) 'php' - debug (na|on|off) 'na' - threaded (na|on|off) 'na' - format CDATA #IMPLIED - baseinstalldir CDATA #IMPLIED - platform CDATA #IMPLIED - md5sum CDATA #IMPLIED - name CDATA #REQUIRED - install-as CDATA #IMPLIED> - -<!ELEMENT replace EMPTY> -<!ATTLIST replace from CDATA #REQUIRED - to CDATA #REQUIRED - type CDATA #REQUIRED> - -<!ELEMENT libfile (libname|sources|includes|libadd)+> - -<!ELEMENT libname (#PCDATA)> - -<!ELEMENT sources (#PCDATA)> - -<!ELEMENT libadd (#PCDATA)> - -<!ELEMENT deps (dep)+> - -<!ELEMENT dep (#PCDATA)> -<!ATTLIST dep - type (pkg|ext|php|prog|ldlib|rtlib|os|websrv|sapi) #REQUIRED - rel (has|eq|lt|le|gt|ge) 'has' - version CDATA #IMPLIED> - -<!ELEMENT provides (#PCDATA)> -<!ATTLIST provides - type (ext|prog|class|function|feature|api) #REQUIRED - name CDATA #REQUIRED> - -<!ELEMENT script (#PCDATA)> -<!ATTLIST script - phase (pre-install |post-install | - pre-uninstall|post-uninstall| - pre-build |post-build | - pre-configure|post-configure| - pre-setup |post-setup ) #REQUIRED> diff --git a/pear/packages/DB-1.2.tar b/pear/packages/DB-1.2.tar Binary files differdeleted file mode 100644 index 7a9d1c0ddd..0000000000 --- a/pear/packages/DB-1.2.tar +++ /dev/null diff --git a/pear/packages/XML_Parser-1.0.tar b/pear/packages/XML_Parser-1.0.tar Binary files differdeleted file mode 100644 index a9f416d56a..0000000000 --- a/pear/packages/XML_Parser-1.0.tar +++ /dev/null diff --git a/pear/packages/XML_RPC-1.0.2.tar b/pear/packages/XML_RPC-1.0.2.tar Binary files differdeleted file mode 100644 index fe83523a12..0000000000 --- a/pear/packages/XML_RPC-1.0.2.tar +++ /dev/null diff --git a/pear/pear.m4 b/pear/pear.m4 deleted file mode 100644 index c6f8cf0a0a..0000000000 --- a/pear/pear.m4 +++ /dev/null @@ -1,118 +0,0 @@ -dnl This file becomes configure.in for self-contained extensions. - -AC_INIT(config.m4) - -PHP_INIT_BUILD_SYSTEM - -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) -]) -dnl -AC_DEFUN(PHP_EXT_BUILDDIR,[.])dnl -AC_DEFUN(PHP_EXT_DIR,[""])dnl -AC_DEFUN(PHP_EXT_SRCDIR,[$abs_srcdir])dnl -AC_DEFUN(PHP_ALWAYS_SHARED,[ - ext_output="yes, shared" - ext_shared=yes - test "[$]$1" = "no" && $1=yes -])dnl -dnl -abs_srcdir=`(cd $srcdir && pwd)` -abs_builddir=`pwd` - -PHP_CONFIG_NICE(config.nice) - -AC_PROG_CC -AC_PROG_CC_C_O - -PHP_SHLIB_SUFFIX_NAME -PHP_WITH_PHP_CONFIG - -PHP_BUILD_SHARED - -AC_PREFIX_DEFAULT() - -AC_ARG_WITH(openssl, -[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.5) ], -[ - if test "$withval" != "no"; then - PHP_WITH_SHARED - PHP_OPENSSL=$withval - ext_openssl_shared=yes - ext_shared=yes - PHP_SETUP_OPENSSL - fi -]) - -sinclude(config.m4) - -enable_static=no -enable_shared=yes - -AC_PROG_LIBTOOL - -all_targets='$(PHP_MODULES)' -install_targets=install-modules -phplibdir="`pwd`/modules" -CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H" - -test "$prefix" = "NONE" && prefix="/usr/local" -test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)' - -PHP_SUBST(PHP_MODULES) -PHP_SUBST(all_targets) -PHP_SUBST(install_targets) - -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(LDFLAGS) -PHP_SUBST(SHARED_LIBTOOL) -PHP_SUBST(LIBTOOL) -PHP_SUBST(SHELL) - -PHP_GEN_BUILD_DIRS -PHP_GEN_GLOBAL_MAKEFILE - -test -d modules || mkdir modules -touch .deps - -AC_CONFIG_HEADER(config.h) - -AC_OUTPUT() diff --git a/pear/scripts/pear.bat b/pear/scripts/pear.bat deleted file mode 100755 index e495634970..0000000000 --- a/pear/scripts/pear.bat +++ /dev/null @@ -1,31 +0,0 @@ -@ECHO OFF - -REM ---------------------------------------------------------------------- -REM PHP version 4.0 -REM ---------------------------------------------------------------------- -REM Copyright (c) 1997-2002 The PHP Group -REM ---------------------------------------------------------------------- -REM This source file is subject to version 2.02 of the PHP license, -REM that is bundled with this package in the file LICENSE, and is -REM available at through the world-wide-web at -REM http://www.php.net/license/2_02.txt. -REM If you did not receive a copy of the PHP license and are unable to -REM obtain it through the world-wide-web, please send a note to -REM license@php.net so we can mail you a copy immediately. -REM ---------------------------------------------------------------------- -REM Authors: Alexander Merz (alexmerz@php.net) -REM ---------------------------------------------------------------------- -REM -REM $Id: pear.bat,v 1.6 2002/04/09 09:28:04 alexmerz Exp $ - -REM change this four lines to match the paths of your system -REM ------------------- -set PHP_PATH=c:\php -set PEAR_INSTALL_DIR=c:\php\pear -set PEAR_EXTENSION_DIR=c:\php\extensions -set PEAR_DOC_DIR=c:\php\pear\docs -REM ------------------- -set DIRECTORY_SEPARATOR=\ - -%PHP_PATH%\php.exe -q %PEAR_INSTALL_DIR%\scripts\pear.in %1 %2 %3 %4 %5 %6 %7 %8 %9 -@ECHO ON
\ No newline at end of file diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in deleted file mode 100644 index 99d6d93c67..0000000000 --- a/pear/scripts/pear.in +++ /dev/null @@ -1,238 +0,0 @@ -#!@prefix@/bin/php -Cq -<?php // -*- PHP -*- -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// - -ini_set('allow_url_fopen', true); -set_time_limit(0); -ob_implicit_flush(true); -ini_set('track_errors', true); -ini_set('html_errors', false); - -require_once 'PEAR.php'; -require_once 'PEAR/Config.php'; -require_once 'PEAR/Command.php'; -require_once 'Console/Getopt.php'; - -PEAR_Command::setFrontendType('CLI'); -$all_commands = PEAR_Command::getCommands(); - -$argv = Console_Getopt::readPHPArgv(); -$progname = basename(array_shift($argv)); -$options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:v"); -if (PEAR::isError($options)) { - usage($options); -} - -$opts = $options[0]; - -$fetype = 'CLI'; -if ($progname == 'gpear' || $progname == 'pear-gtk') { - $fetype = 'Gtk'; -} else { - foreach ($opts as $opt) { - if ($opt[0] == 'G') { - $fetype = 'Gtk'; - } - } -} -PEAR_Command::setFrontendType($fetype); -$ui = &PEAR_Command::getFrontendObject(); -PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); - -$pear_user_config = ''; -$pear_system_config = ''; -$store_user_config = false; -$store_system_config = false; -$verbose = 1; - -foreach ($opts as $opt) { - switch ($opt[0]) { - case 'c': - $pear_user_config = $opt[1]; - break; - case 'C': - $pear_system_config = $opt[1]; - break; - } -} - -$config = &PEAR_Config::singleton($pear_user_config, $pear_system_config); -$verbose = $config->get("verbose"); -$cmdopts = array(); - -foreach ($opts as $opt) { - $param = !empty($opt[1]) ? $opt[1] : true; - switch ($opt[0]) { - case 'd': - list($key, $value) = explode('=', $param); - $config->set($key, $value, 'user'); - break; - case 'D': - list($key, $value) = explode('=', $param); - $config->set($key, $value, 'system'); - break; - case 's': - $store_user_config = true; - break; - case 'S': - $store_system_config = true; - break; - case 'u': - $config->remove($param, 'user'); - break; - case 'v': - $config->set('verbose', $verbose + 1); - break; - case 'q': - $config->set('verbose', $verbose - 1); - break; - default: - // all non pear params goes to the command - $cmdopts[$opt[0]] = $param; - break; - } -} - -if ($store_system_config) { - $config->store('system'); -} - -if ($store_user_config) { - $config->store('user'); -} - -$command = (isset($options[1][0])) ? array_shift($options[1]) : null; - -if (empty($command) && ($store_user_config || $store_system_config)) { - exit; -} - -if ($fetype == 'Gtk') { - Gtk::main(); -} else do { - if (empty($all_commands[$command]) || $command == 'help') { - usage(null, @$options[1][2]); - } - - $cmd = PEAR_Command::factory($command, $config); - if (PEAR::isError($cmd)) { - die($cmd->getMessage()); - } - - $short_args = $long_args = null; - PEAR_Command::getGetoptArgs($command, $short_args, $long_args); - if (PEAR::isError($tmp = Console_Getopt::getopt($options[1], $short_args, $long_args))) { - break; - } - list($tmpopt, $params) = $tmp; - $opts = array(); - foreach ($tmpopt as $foo => $tmp2) { - list($opt, $value) = $tmp2; - if ($value === null) { - $value = true; // options without args - } - if (strlen($opt) == 1) { - $cmdoptions = $cmd->getOptions($command); - foreach ($cmdoptions as $o => $d) { - if (@$d['shortopt'] == $opt) { - $opts[$o] = $value; - } - } - } else { - if (substr($opt, 0, 2) == '--') { - $opts[substr($opt, 2)] = $value; - } - } - } - $ok = $cmd->run($command, $opts, $params); - if ($ok === false) { - PEAR::raiseError("unknown command `$command'"); - } -} while (false); - -// {{{ usage() - -function usage($error = null, $helpsubject = null) -{ - global $progname, $all_commands; - $stderr = fopen('php://stderr', 'w'); - fputs($stderr, "\n"); - if (PEAR::isError($error)) { - fputs($stderr, $error->getMessage() . "\n"); - } elseif ($error !== null) { - fputs($stderr, "$error\n"); - } - if ($helpsubject != null) { - $put = cmdHelp($helpsubject); - } else { - $put = - "Usage: $progname [options] command [command-options] <parameters>\n". - "Type \"$progname help options\" to list all options.\n". - "Type \"$progname help <command>\" to get the help for the specified command.\n". - "Commands:\n"; - $maxlen = max(array_map("strlen", $all_commands)); - $formatstr = "%-{$maxlen}s %s\n"; - foreach ($all_commands as $cmd => $class) { - $put .= sprintf($formatstr, $cmd, PEAR_Command::getDescription($cmd)); - } - } - fputs($stderr, "$put\n"); - fclose($stderr); - exit; -} - -function cmdHelp($command) -{ - global $progname, $all_commands, $config; - if ($command == "options") { - return - "Options:\n". - " -v increase verbosity level (default 1)\n". - " -q be quiet, decrease verbosity level\n". - " -c file find user configuration in `file'\n". - " -C file find system configuration in `file'\n". - " -d foo=bar set user config variable `foo' to `bar'\n". - " -D foo=bar set system config variable `foo' to `bar'\n". - " -G start in graphical (Gtk) mode\n". - " -s store user configuration\n". - " -S store system configuration\n". - " -u foo unset `foo' in the user configuration\n". - " -h, -? display help/usage (this message)\n"; - } elseif ($help = PEAR_Command::getHelp($command)) { - if (is_string($help)) { - return "Usage : $help"; - } - return "Usage : $progname $command {$help[0]}\n{$help[1]}"; - } - return "No such command"; -} - -// }}} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ -// vim600:syn=php - -?> diff --git a/pear/scripts/pearize.in b/pear/scripts/pearize.in deleted file mode 100644 index 0a9beec459..0000000000 --- a/pear/scripts/pearize.in +++ /dev/null @@ -1,225 +0,0 @@ -#!@prefix@/bin/php -Cq -<?php // -*- PHP -*- -main($argc, $argv, $_ENV); - -// {{{ main() - -function main(&$argc, &$argv, &$env) -{ - global $debug; - $debug = false; - $file = check_options($argc, $argv, $env); - parse_package_file($file); - make_makefile_in($env); -} - -// }}} -// {{{ check_options() - -function check_options($argc, $argv, $env) -{ - global $debug; - array_shift($argv); - while ($argv[0]{0} == '-' && $argv[0] != '-') { - $opt = array_shift($argv); - switch ($opt) { - case '--': { - break 2; - } - case '-d': { - $debug = true; - break; - } - default: { - die("pearize: unrecognized option `$opt'\n"); - } - } - } - $file = array_shift($argv); - if (empty($file)) { - $file = "package.xml"; - } elseif ($file == '-') { - $file = "php://stdin"; - } - return $file; -} - -// }}} -// {{{ make_makefile_in() - -function make_makefile_in(&$env) -{ - global $libdata, $debug; - if (sizeof($libdata) > 1) { - die("No support yet for multiple libraries in one package.\n"); - } - - if ($debug) { - $wp = fopen("php://stdout", "w"); - } else { - $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"); - } - - $who = $env["USER"]; - $when = gmdate('Y-m-d h:i'); - fwrite($wp, "# This file was generated by `pearize' by $who at $when GMT\n\n"); - - foreach ($libdata as $lib => $info) { - extract($info); - fwrite($wp, "\ -INCLUDES = $includes -LTLIBRARY_NAME = lib{$lib}.la -LTLIBRARY_SOURCES = $sources -LTLIBRARY_SHARED_NAME = {$lib}.la -LTLIBRARY_SHARED_LIBADD = $libadd -"); - } - - if (sizeof($libdata) > 0) { - fwrite($wp, "include \$(top_srcdir)/build/dynlib.mk\n"); - } - fclose($wp); - print "done.\n"; -} - -// }}} -// {{{ parse_package_file() - -function parse_package_file($file) -{ - global $in_file, $curlib, $curelem, $libdata, $cdata; - global $currinstalldir, $baseinstalldir; - - $in_file = false; - $curlib = ''; - $curelem = ''; - $libdata = array(); - $cdata = array(); - $baseinstalldir = array(); - $currinstalldir = 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, $curfile, $filerole; - global $baseinstalldir, $currinstalldir; - switch ($elem) { - case "file": { - $curfile = ''; - $filerole = $attrs['role']; - switch ($filerole) { - case "ext": { - $in_file = true; - $cdata = array(); - break; - } - case "php": default: { - break; - } - } - break; - } - case "dir": { - $cdir = $currinstalldir[sizeof($currinstalldir)-1]; - $bdir = $baseinstalldir[sizeof($baseinstalldir)-1]; - array_push($currinstalldir, "$cdir/{$attrs[name]}"); - if (isset($attrs["baseinstalldir"])) { - array_push($baseinstalldir, "$bdir/{$attrs[baseinstalldir]}"); - } else { - array_push($baseinstalldir, $bdir); - } - 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; - global $baseinstalldir, $currinstalldir; - 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; - } - case "dir": { - array_pop($currinstalldir); - array_pop($baseinstalldir); - break; - } - } -} - -// }}} -// {{{ cdata_handler() - -function cdata_handler($xp, $data) -{ - global $curelem, $cdata, $curfile; - switch ($curelem) { - case "file": { - $curfile .= $data; - break; - } - 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: - */ -// vim600:syn=php -?> diff --git a/pear/scripts/pearwin.php b/pear/scripts/pearwin.php deleted file mode 100644 index d3383918a4..0000000000 --- a/pear/scripts/pearwin.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2002 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 2.02 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/2_02.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Stig Bakken <ssb@fast.no> | -// | Tomas V.V.Cox <cox@idecnet.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ - -require_once 'PEAR.php'; -require_once 'PEAR/Common.php'; -require_once 'PEAR/Config.php'; -require_once 'PEAR/Remote.php'; -require_once 'PEAR/Registry.php'; -require_once 'Console/Getopt.php'; - -error_reporting(E_ALL ^ E_NOTICE); - -$progname = basename($argv[0]); - -PEAR::setErrorHandling(PEAR_ERROR_PRINT, "$progname: %s\n"); - -$argv = Console_Getopt::readPHPArgv(); -if (PEAR::isError($argv)) { - die($argv->getMessage()); -} -$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sSqu:v"); -if (PEAR::isError($options)) { - usage($options); -} - - -$php_sysconfdir = getenv('PHP_SYSCONFDIR'); -if (!empty($php_sysconfdir)) { - $pear_default_config = $php_sysconfdir.DIRECTORY_SEPARATOR.'pearsys.ini'; - $pear_user_config = $php_sysconfdir.DIRECTORY_SEPARATOR.'pear.ini'; -} else { - $pear_default_config = PHP_SYSCONFDIR.DIRECTORY_SEPARATOR.'pearsys.ini'; - $pear_user_config = PHP_SYSCONFDIR.DIRECTORY_SEPARATOR.'pear.ini'; -} - -$opts = $options[0]; - -//echo "ini_get : ".ini_get("pear_install_dir")."\n"; -//echo "get_cfg_var : ".get_cfg_var("pear_install_dir")."\n"; - -foreach ($opts as $opt) { - switch ($opt[0]) { - case 'c': - $pear_user_config = $opt[1]; - break; - case 'C': - $pear_default_config = $opt[1]; - break; - } -} - -$config = new PEAR_Config($pear_user_config, $pear_default_config); -$store_user_config = false; -$store_default_config = false; -$verbose = 1; - -foreach ($opts as $opt) { - $param = $opt[1]; - switch ($opt[0]) { - case 'd': - list($key, $value) = explode('=', $param); - $config->set($key, $value); - break; - case 'D': - list($key, $value) = explode('=', $param); - $config->set($key, $value, true); - break; - case 's': - $store_user_config = true; - break; - case 'S': - $store_default_config = true; - break; - case 'u': - $config->toDefault($param); - break; - case 'v': - $verbose++; - break; - case 'q': - $verbose--; - break; - } -} - -if ($store_default_config) { - if (@is_writeable($pear_default_config)) { - $config->writeConfigFile($pear_default_config, 'default'); - } else { - die("You don't have write access to $pear_default_config, exiting!\n"); - } -} - -if ($store_user_config) { - $config->writeConfigFile($pear_user_config, 'userdefined'); -} - -$fallback_config = array( - 'master_server' => 'pear.php.net', - 'php_dir' => getenv('PEAR_INSTALL_DIR'), - 'ext_dir' => getenv('PEAR_EXTENSION_DIR'), - 'doc_dir' => getenv('PHP_DATADIR') . DIRECTORY_SEPARATOR . 'pear' . - DIRECTORY_SEPARATOR . 'doc', - 'verbose' => true, -); -$fallback_done = array(); - -foreach ($fallback_config as $key => $value) { - if (!$config->isDefined($key)) { - $config->set($key, $value); - $fallback_done[$key] = true; - } -} - -//$verbose = $config->get("verbose"); -$script_dir = $config->get("php_dir"); -$ext_dir = $config->get("ext_dir"); -$doc_dir = $config->get("doc_dir"); - -PEAR::setErrorHandling(PEAR_ERROR_PRINT); - -$command = (isset($options[1][1])) ? $options[1][1] : null; -$rest = array_slice($options[1], 2); - -if (isset($command_options[$command])) { - $tmp = Console_Getopt::getopt($rest, $command_options[$command]); - if (PEAR::isError($tmp)) { - usage($tmp); - } - $cmdopts = $tmp[0]; - $cmdargs = $tmp[1]; -} else { - $cmdopts = array(); - $cmdargs = $rest; -} - - -/* Extracted from pearcmd-common.php */ -function heading($text) -{ - $l = strlen(trim($text)); - print rtrim($text) . "\n" . str_repeat("=", $l) . "\n"; -} - -switch ($command) { - case 'install': - include 'pearcmd-install.php'; - break; - case 'uninstall': - include 'pearcmd-uninstall.php'; - break; - case 'list': - include 'pearcmd-list.php'; - break; - case 'package': - include 'pearcmd-package.php'; - break; - case 'remote-list': - include 'pearcmd-remote-list.php'; - break; - case 'show-config': - $keys = $config->getKeys(); - foreach ($keys as $key) { - $value = $config->get($key); - $xi = ""; - if ($config->isDefaulted($key)) { - $xi .= " (default)"; - } - if (isset($fallback_done[$key])) { - $xi .= " (built-in)"; - } - printf("%s = %s%s\n", $key, $value, $xi); - } - break; - default: { - if (!$store_default_config && !$store_user_config) { - usage(); - } - break; - } -} - -function usage($obj = null) -{ - $stderr = fopen('php://stderr', 'w'); - if ($obj !== null) { - fputs($stderr, $obj->getMessage()); - } - fputs($stderr, - "Usage: pear [options] command [command-options] <parameters>\n". - "Options:\n". - " -v increase verbosity level (default 1)\n". - " -q be quiet, decrease verbosity level\n". - " -c file find user configuration in `file'\n". - " -C file find system configuration in `file'\n". - " -d \"foo=bar\" set user config variable `foo' to `bar'\n". - " -D \"foo=bar\" set system config variable `foo' to `bar'\n". - " -s store user configuration\n". - " -S store system configuration\n". - " -u foo unset `foo' in the user configuration\n". - " -h, -? display help/usage (this message)\n". - "Commands:\n". - " help [command]\n". - " install [-r] <package file>\n". - " uninstall [-r] <package name>\n". - " package [package info file]\n". - " list\n". - " remote-list\n". - " show-config\n". - "\n"); - fclose($stderr); - exit; -} - -?>
\ No newline at end of file diff --git a/pear/scripts/php-config.in b/pear/scripts/php-config.in deleted file mode 100644 index bcb6ef35f8..0000000000 --- a/pear/scripts/php-config.in +++ /dev/null @@ -1,26 +0,0 @@ -#! /bin/sh - -prefix="@prefix@" -version="@PHP_VERSION@" -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;; ---version) - echo $version;; -*) - echo "Usage: $0 [--prefix|--includes|--extension-dir|--version]" - 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 daf22c9cd5..0000000000 --- a/pear/scripts/phpize.in +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh - -prefix='@prefix@' -phpdir="$prefix/lib/php/build" -includedir="$prefix/include/php" -builddir="`pwd`" -FILES_BUILD="mkdep.awk shtool" -FILES="acinclude.m4 Makefile.global scan_makefile_in.awk" - -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) - -sed \ --e "s#@prefix@#$prefix#" \ -< $phpdir/pear.m4 > configure.in - -touch install-sh mkinstalldirs missing - -aclocal -autoconf -autoheader -libtoolize -f -c - -# dumping API NOs: -PHP_API_VERSION=`egrep '#define PHP_API_VERSION' $includedir/main/php.h|sed 's/#define PHP_API_VERSION//'` -ZEND_MODULE_API_NO=`egrep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|sed 's/#define ZEND_MODULE_API_NO//'` -ZEND_EXTENSION_API_NO=`egrep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|sed 's/#define ZEND_EXTENSION_API_NO//'` - -echo "Configuring for:" -echo " PHP Api Version: "$PHP_API_VERSION -echo " Zend Module Api No: "$ZEND_MODULE_API_NO -echo " Zend Extension Api No: "$ZEND_EXTENSION_API_NO diff --git a/pear/scripts/phptar.in b/pear/scripts/phptar.in deleted file mode 100755 index 08361c1d0a..0000000000 --- a/pear/scripts/phptar.in +++ /dev/null @@ -1,236 +0,0 @@ -#!@prefix@/bin/php -Cq -<?php // -*- PHP -*- - -// {{{ setup - -define('S_IFDIR', 0040000); // Directory -define('S_IFCHR', 0020000); // Character device -define('S_IFBLK', 0060000); // Block device -define('S_IFREG', 0100000); // Regular file -define('S_IFIFO', 0010000); // FIFO -define('S_IFLNK', 0120000); // Symbolic link -define('S_IFSOCK', 0140000); // Socket - -require_once "PEAR.php"; -require_once "Archive/Tar.php"; -require_once "Console/Getopt.php"; - -// }}} -// {{{ options - -$verbose = false; -$op_create = false; -$op_list = false; -$op_extract = false; -$use_gzip = false; -$file = ''; - -$progname = basename(array_shift($argv)); - -$options = Console_Getopt::getopt($argv, "h?ctxvzf:"); -if (PEAR::isError($options)) { - usage($options); -} - -$opts = $options[0]; -foreach ($opts as $opt) { - switch ($opt[0]) { - case 'v': { - $verbose = true; - break; - } - case 'c': { - $op_create = true; - break; - } - case 't': { - $op_list = true; - break; - } - case 'x': { - $op_extract = true; - break; - } - case 'z': { - $use_gzip = true; - break; - } - case 'f': { - $file = $opt[1]; - break; - } - case 'h': - case '?': { - usage(); - break; - } - } -} - -if ($op_create + $op_list + $op_extract > 1) { - usage("Only one of -c, -t and -x can be specified at once!"); -} - -if ($op_create + $op_list + $op_extract == 0) { - usage("Please specify either -c, -t or -x!"); -} - -if (empty($file)) { - if ($op_create) { - $file = "php://stdout"; - } else { - $file = "php://stdin"; - } -} - -// }}} - -$tar = new Archive_Tar($file, $use_gzip); -$tar->setErrorHandling(PEAR_ERROR_DIE, "$progname error: %s\n"); - -if ($op_create) { - do_create($tar, $options[1]); - $tar->create($options[1]); -} elseif ($op_list) { - do_list($tar, $verbose); -} elseif ($op_extract) { - do_extract($tar); -} - -// {{{ getrwx() - -function getrwx($bits) { - $str = ''; - $str .= ($bits & 4) ? 'r' : '-'; - $str .= ($bits & 2) ? 'w' : '-'; - $str .= ($bits & 1) ? 'x' : '-'; - return $str; -} - -// }}} -// {{{ getfiletype() - -function getfiletype($bits) { - static $map = array( - '-' => S_IFREG, - 'd' => S_IFDIR, - 'l' => S_IFLNK, - 'c' => S_IFCHR, - 'b' => S_IFBLK, - 'p' => S_IFIFO, - 's' => S_IFSOCK, - ); - foreach ($map as $char => $mask) { - if ($bits & $mask) { - return $char; - } - } -} - -// }}} -// {{{ getuser() - -function getuser($uid) { - static $cache = array(); - if (isset($cache[$uid])) { - return $cache[$uid]; - } - if (function_exists("posix_getpwuid")) { - if (is_array($user = @posix_getpwuid($uid))) { - $cache[$uid] = $user['name']; - return $user['name']; - } - } - $cache[$uid] = $uid; - return $uid; -} - -// }}} -// {{{ getgroup() - -function getgroup($gid) { - static $cache = array(); - if (isset($cache[$gid])) { - return $cache[$gid]; - } - if (function_exists("posix_getgrgid")) { - if (is_array($group = @posix_getgrgid($gid))) { - $cache[$gid] = $group['name']; - return $group['name']; - } - } - $cache[$gid] = $gid; - return $gid; -} - -// }}} -// {{{ do_create() - -function do_create(&$tar, &$files) -{ - $tar->create($files); -} - -// }}} -// {{{ do_list() - -function do_list(&$tar, $verbose) -{ - static $rwx = array(4 => 'r', 2 => 'w', 1 => 'x'); - $files = $tar->listContent(); - if (is_array($files) && sizeof($files) > 0) { - foreach ($files as $file) { - if ($verbose) { - $fm = (int)$file['mode']; - $mode = sprintf('%s%s%s%s', getfiletype($fm), - getrwx(($fm >> 6) & 7), getrwx(($fm >> 3) & 7), - getrwx($fm & 7)); - $owner = getuser($file['uid']) . '/' . getgroup($file['gid']); - printf("%10s %-11s %7d %s %s\n", $mode, $owner, $file['size'], - date('Y-m-d H:i:s', $file['mtime']), $file['filename']); - } else { - printf("%s\n", $file['filename']); - } - } - } -} - -// }}} -// {{{ do_extract() - -function do_extract(&$tar, $destdir = ".") -{ - $tar->extract($destdir); -} - -// }}} -// {{{ usage() - -function usage($errormsg = '') -{ - global $progname; - $fp = fopen("php://stderr", "w"); - if ($errormsg) { - if (PEAR::isError($errormsg)) { - fwrite($fp, $errormsg->getMessage() . "\n"); - } else { - fwrite($fp, "$errormsg\n"); - } - } - fwrite($fp, "$progname [-h|-?] {-c|-t|-x} [-z] [-v] [-f file] [file(s)...] -Options: - -h, -? Show this screen - -c Create archive - -t List archive - -x Extract archive - -z Run input/output through gzip - -f file Use <file> as input or output (default is stdin/stdout) - -"); - fclose($fp); - exit; -} - -// }}} - -?> diff --git a/pear/tests/merge.input b/pear/tests/merge.input deleted file mode 100644 index 440106ea45..0000000000 --- a/pear/tests/merge.input +++ /dev/null @@ -1 +0,0 @@ -a:1:{s:7:"verbose";i:100;}
\ No newline at end of file diff --git a/pear/tests/pear1.phpt b/pear/tests/pear1.phpt deleted file mode 100644 index c1d5c1d679..0000000000 --- a/pear/tests/pear1.phpt +++ /dev/null @@ -1,87 +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 { -} - -// test for bug http://bugs.php.net/bug.php?id=14744 -class Other extends Pear { - - var $a = 'default value'; - - function Other() { - $this->PEAR(); - } - - function _Other() { - // $a was modified but here misteriously returns to be - // the original value. That makes the destructor useless - // The correct value for $a in the destructor shoud be "new value" - echo "#bug 14744# Other class destructor: other->a == '" . $this->a ."'\n"; - } -} - -print "testing plain destructors\n"; -$o = new TestPEAR("test1"); -$p = new TestPEAR("test2"); -print "..\n"; -print "testing inherited destructors\n"; -$q = new Test3; - -echo "...\ntesting bug #14744\n"; -$other =& new Other; -echo "#bug 14744# Other class constructor: other->a == '" . $other->a ."'\n"; -// Modify $a -$other->a = 'new value'; -echo "#bug 14744# Other class modified: other->a == '" . $other->a ."'\n"; - -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 -... -testing bug #14744 -#bug 14744# Other class constructor: other->a == 'default value' -#bug 14744# Other class modified: other->a == 'new value' -.. -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 -#bug 14744# Other class destructor: other->a == 'new value' diff --git a/pear/tests/pear_autoloader.phpt b/pear/tests/pear_autoloader.phpt deleted file mode 100644 index d75189c2b3..0000000000 --- a/pear/tests/pear_autoloader.phpt +++ /dev/null @@ -1,80 +0,0 @@ ---TEST-- -PEAR_Autoloader ---SKIPIF-- -<?php if (!extension_loaded("overload")) die("skip\n"); ?> ---FILE-- -<?php - -include dirname(__FILE__)."/../PEAR/Autoloader.php"; - -class test1 extends PEAR_Autoloader { - function test1() { - $this->addAutoload(array( - 'testfunc1' => 'testclass1', - 'testfunca' => 'testclass1', - 'testfunc2' => 'testclass2', - 'testfuncb' => 'testclass2', - )); - } -} - -class testclass1 { - function testfunc1($a) { - print "testfunc1 arg=";var_dump($a); - return 1; - } - function testfunca($a) { - print "testfunca arg=";var_dump($a); - return 2; - } -} - -class testclass2 { - function testfunc2($b) { - print "testfunc2 arg=";var_dump($b); - return 3; - } - function testfuncb($b) { - print "testfuncb arg=";var_dump($b); - return 4; - } -} - -function dump($obj) { - print "mapped methods:"; - foreach ($obj->_method_map as $method => $object) { - print " $method"; - } - print "\n"; -} - -function call($msg, $retval) { - print "calling $msg returned $retval\n"; -} - -$obj = new test1; -dump($obj); -call("testfunc1", $obj->testfunc1(2)); -dump($obj); -call("testfunca", $obj->testfunca(2)); -dump($obj); -call("testfunc2", $obj->testfunc2(2)); -dump($obj); -call("testfuncb", $obj->testfuncb(2)); -dump($obj); - -?> ---EXPECT-- -mapped methods: -testfunc1 arg=int(2) -calling testfunc1 returned 1 -mapped methods: testfunc1 testfunca -testfunca arg=int(2) -calling testfunca returned 2 -mapped methods: testfunc1 testfunca -testfunc2 arg=int(2) -calling testfunc2 returned 3 -mapped methods: testfunc1 testfunca testfunc2 testfuncb -testfuncb arg=int(2) -calling testfuncb returned 4 -mapped methods: testfunc1 testfunca testfunc2 testfuncb diff --git a/pear/tests/pear_config.phpt b/pear/tests/pear_config.phpt deleted file mode 100644 index ce6af34c07..0000000000 --- a/pear/tests/pear_config.phpt +++ /dev/null @@ -1,215 +0,0 @@ ---TEST-- -PEAR_Config ---FILE-- -<?php - -error_reporting(E_ALL); -chdir(dirname(__FILE__)); -include "../PEAR/Config.php"; -copy("system.input", "system.conf"); -copy("user.input", "user.conf"); -copy("user2.input", "user2.conf"); -copy("merge.input", "merge.conf"); -PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s\n"); - -print "#0 starting up\n"; -dump_files(); - -print "#1 testing: constructor\n"; -$config = new PEAR_Config("user.conf", "system.conf"); -dump_array("files", $config->files); - -print "#2 testing: singleton\n"; -$o1 = &PEAR_Config::singleton(); -$o1->blah = 'blah'; -$o2 = &PEAR_Config::singleton(); -var_dump($o1->blah); -@var_dump($o2->blah); - -print "#3 testing: readConfigFile\n"; -$config->readConfigFile("user2.conf", "user"); -dump_config($config); -$config->readConfigFile("user.conf"); -dump_config($config); - -print "#4 testing: mergeConfigFile\n"; -$config->readConfigFile("user2.conf"); -dump_config($config, "user"); -$config->mergeConfigFile("merge.conf", true); -dump_config($config, "user"); -$config->readConfigFile("user2.conf"); -$config->mergeConfigFile("merge.conf", false); -dump_config($config, "user"); -$config->readConfigFile("user.conf"); -dump_config($config, "user"); -$config->mergeConfigFile("merge.conf", true, "xyzzy"); - -print "#5 testing: config file version detection\n"; -$config->readConfigFile("user.conf", "user"); -$config->readConfigFile("toonew.conf", "user"); - -print "#6 testing: get/set/remove\n"; -var_dump($config->get("verbose")); -$config->set("verbose", 100, "system"); -var_dump($config->get("verbose")); -$config->set("verbose", 2, "user"); -var_dump($config->get("verbose")); -$config->set("verbose", 2, "system"); -$config->set("verbose", 50, "user"); -var_dump($config->get("verbose")); -$config->remove("verbose", "user"); -var_dump($config->get("verbose")); -$config->remove("verbose", "system"); -var_dump($config->get("verbose")); - -print "#7 testing: getType\n"; -var_dump($config->getType("__unknown__")); -var_dump($config->getType("verbose")); -var_dump($config->getType("master_server")); -var_dump($config->getType("ext_dir")); - -print "#8 testing: getDocs\n"; -print "master_server: " . $config->getDocs("master_server") . "\n"; - -print "#9 testing: getKeys\n"; -$keys = $config->getKeys(); -sort($keys); -print implode(" ", $keys) . "\n"; - -print "#10 testing: definedBy\n"; -var_dump($config->definedBy("verbose")); -$config->set("verbose", 6, "system"); -$config->set("verbose", 3, "user"); -var_dump($config->definedBy("verbose")); -$config->remove("verbose", "system"); -var_dump($config->definedBy("verbose")); -$config->set("verbose", 6, "system"); -$config->remove("verbose", "user"); -var_dump($config->definedBy("verbose")); -$config->remove("verbose", "system"); -var_dump($config->definedBy("verbose")); - -print "#11 testing: isDefined\n"; -var_dump($config->isDefined("php_dir")); -var_dump($config->isDefined("verbose")); -var_dump($config->isDefined("HTTP_GET_VARS")); -var_dump($config->isDefined("query")); - -/* -print "setting user values\n"; -var_dump($config->set("master_server", "pear.localdomain")); -var_dump($config->writeConfigFile(null, "user")); -dumpall(); - -print "going back to defaults\n"; -$config->remove("master_server", "user"); -$config->writeConfigFile(null, "user"); -dumpall(); -*/ - -// - -print "done\n"; - -unlink("user.conf"); -unlink("user2.conf"); -unlink("system.conf"); -unlink("merge.conf"); - -// ------------------------------------------------------------------------- // - -function dump_file($file) -{ - print "..$file:"; - $data = PEAR_Config::_readConfigDataFrom($file); - if (empty($data)) { - print " <empty>\n"; - return; - } - foreach ($data as $k => $v) { - print " $k=\"$v\""; - } - print "\n"; -} - -function dump_files() { - dump_file("system.conf"); - dump_file("user.conf"); -} - -function dump_array($name, $arr) { - print "$name:"; - if (empty($arr)) { - print " <empty>"; - } else { - foreach ($arr as $k => $v) { - print " $k=\"$v\""; - } - } - print "\n"; -} - -function dump_config(&$obj, $layer = null) { - if ($layer !== null) { - dump_array($layer, $obj->configuration[$layer]); - return; - } - foreach ($obj->configuration as $layer => $data) { - if ($layer == "default") { - continue; - } - dump_array($layer, $data); - } -} - -?> ---EXPECT-- -#0 starting up -..system.conf: master_server="pear.php.net" -..user.conf: <empty> -#1 testing: constructor -files: system="system.conf" user="user.conf" -#2 testing: singleton -string(4) "blah" -string(4) "blah" -#3 testing: readConfigFile -user: verbose="2" -system: master_server="pear.php.net" -user: <empty> -system: master_server="pear.php.net" -#4 testing: mergeConfigFile -user: verbose="2" -user: verbose="100" -user: verbose="2" -user: <empty> -unknown config file type `xyzzy' -#5 testing: config file version detection -toonew.conf: unknown version `2.0' -#6 testing: get/set/remove -int(1) -int(100) -int(2) -int(50) -int(2) -int(1) -#7 testing: getType -bool(false) -string(7) "integer" -string(6) "string" -string(9) "directory" -#8 testing: getDocs -master_server: name of the main PEAR server -#9 testing: getKeys -bin_dir doc_dir ext_dir http_proxy master_server password php_dir preferred_state umask username verbose -#10 testing: definedBy -string(7) "default" -string(4) "user" -string(4) "user" -string(6) "system" -string(7) "default" -#11 testing: isDefined -bool(true) -bool(true) -bool(false) -bool(false) -done diff --git a/pear/tests/pear_error.phpt b/pear/tests/pear_error.phpt deleted file mode 100644 index e602aa2887..0000000000 --- a/pear/tests/pear_error.phpt +++ /dev/null @@ -1,153 +0,0 @@ ---TEST-- -PEAR_Error: basic test ---SKIPIF-- ---FILE-- -<?php // -*- PHP -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::isError static method - -include dirname(__FILE__)."/../PEAR.php"; - -function test_error_handler($errno, $errmsg, $file, $line, $vars) { - $errortype = array ( - 1 => "Error", - 2 => "Warning", - 4 => "Parsing Error", - 8 => "Notice", - 16 => "Core Error", - 32 => "Core Warning", - 64 => "Compile Error", - 128 => "Compile Warning", - 256 => "User Error", - 512 => "User Warning", - 1024=> "User Notice" - ); - if (preg_match('/^The call_user_method.. function is deprecated/', - $errmsg)) { - return; - } - $prefix = $errortype[$errno]; - $file = basename($file); - print "\n$prefix: $errmsg in $file on line XXX\n"; -} - -error_reporting(E_ALL); -set_error_handler("test_error_handler"); - -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" info=""] -default PEAR_Error: [pear_error: message="unknown error" code=0 mode=return level=notice prefix="" 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="" info=""] -different message,code: [pear_error: message="test error" code=-42 mode=return level=notice prefix="" info=""] -mode=print: test error[pear_error: message="test error" code=-42 mode=print level=notice prefix="" info=""] -mode=callback(function): errorhandler function called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorhandler prefix="" info=""] -mode=callback(method): errorhandler method called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorclass::errorhandler prefix="" info=""] -mode=print&trigger: test error -User Notice: test error in PEAR.php on line XXX -[pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" info=""] -mode=trigger: -User Notice: test error in PEAR.php on line XXX -[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" info=""] -mode=trigger,level=notice: -User Notice: test error in PEAR.php on line XXX -[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" info=""] -mode=trigger,level=warning: -User Warning: test error in PEAR.php on line XXX -[pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" info=""] -mode=trigger,level=error: -User Error: test error in PEAR.php on line XXX -[pear_error: message="test error" code=-42 mode=trigger level=error prefix="" info=""] diff --git a/pear/tests/pear_error2.phpt b/pear/tests/pear_error2.phpt deleted file mode 100644 index 476374cba4..0000000000 --- a/pear/tests/pear_error2.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -PEAR_Error: die mode ---SKIPIF-- ---FILE-- -<?php // -*- C++ -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::isError static method -// testing PEAR_Error - -include dirname(__FILE__)."/../PEAR.php"; - -error_reporting(E_ALL); - -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 fb26c9a2b0..0000000000 --- a/pear/tests/pear_error3.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -PEAR_Error: default error handling ---FILE-- -<?php // -*- PHP -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::setErrorHandling -// - PEAR::raiseError method - -include dirname(__FILE__)."/../PEAR.php"; - -error_reporting(E_ALL); - -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"; - } -} - -// Test 1 -PEAR::setErrorHandling(PEAR_ERROR_PRINT, "OOPS: %s\n"); -$tmp = new PEAR; -$tmp->raiseError("error happens"); - -// Return PEAR to its original state -$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; -$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; -$GLOBALS['_PEAR_default_error_callback'] = ''; - -// Test 2 -$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"); -$obj->setErrorHandling(PEAR_ERROR_PRINT); -$obj->raiseError("error 4\n"); - -?> ---EXPECT-- -OOPS: error happens -error 1 -errorhandler called with an error object. -error message: error 3 -error 4
\ No newline at end of file diff --git a/pear/tests/pear_error4.phpt b/pear/tests/pear_error4.phpt deleted file mode 100644 index 5ceee5a8ad..0000000000 --- a/pear/tests/pear_error4.phpt +++ /dev/null @@ -1,89 +0,0 @@ ---TEST-- -PEAR_Error: expected errors ---FILE-- -<?php // -*- PHP -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::expectError -// - PEAR::popExpect - -include dirname(__FILE__)."/../PEAR.php"; - -error_reporting(E_ALL); - -function errorhandler($eobj) -{ - if (PEAR::isError($eobj)) { - print "error: ".$eobj->getMessage()."\n"; - } else { - print "errorhandler called without error object\n"; - } -} - -$obj = new PEAR; -$obj->setErrorHandling(PEAR_ERROR_CALLBACK, "errorhandler"); - -print "subtest 1\n"; -$obj->expectError(1); -$obj->raiseError("1", 1); -$obj->popExpect(); -$obj->raiseError("2", 2); - -print "subtest 2\n"; -$obj->expectError(3); -$obj->expectError(2); -$obj->raiseError("3", 3); - -print "subtest 3\n"; -$obj->popExpect(); -$obj->raiseError("3", 3); -$obj->popExpect(); - -print "subtest 4\n"; -$obj->expectError(array(1,2,3,4,5)); -$obj->raiseError("0", 0); -$obj->raiseError("1", 1); -$obj->raiseError("2", 2); -$obj->raiseError("3", 3); -$obj->raiseError("4", 4); -$obj->raiseError("5", 5); -$obj->raiseError("6", 6); -$obj->raiseError("error"); -$obj->popExpect(); - -print "subtest 5\n"; -$obj->expectError("*"); -$obj->raiseError("42", 42); -$obj->raiseError("75", 75); -$obj->raiseError("13", 13); -$obj->popExpect(); - -print "subtest 6\n"; -$obj->expectError(); -$obj->raiseError("123", 123); -$obj->raiseError("456", 456); -$obj->raiseError("789", 789); -$obj->popExpect(); - -print "subtest 7\n"; -$obj->expectError("syntax error"); -$obj->raiseError("type mismatch"); -$obj->raiseError("syntax error"); -$obj->popExpect(); - -?> ---EXPECT-- -subtest 1 -error: 2 -subtest 2 -error: 3 -subtest 3 -subtest 4 -error: 0 -error: 6 -error: error -subtest 5 -subtest 6 -subtest 7 -error: type mismatch diff --git a/pear/tests/pear_registry.phpt b/pear/tests/pear_registry.phpt deleted file mode 100644 index 214ecbfe79..0000000000 --- a/pear/tests/pear_registry.phpt +++ /dev/null @@ -1,93 +0,0 @@ ---TEST-- -PEAR_Registry ---FILE-- -<?php - -error_reporting(E_ALL); -include dirname(__FILE__)."/../PEAR/Registry.php"; -PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s\n"); -cleanall(); - -print "creating registry object\n"; -$reg = new PEAR_Registry; -$reg->statedir = getcwd(); -dumpall($reg); -$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0")); -dumpall($reg); -$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0")); -$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0")); -dumpall($reg); -$reg->updatePackage("pkg2", array("version" => "2.1")); -dumpall($reg); -var_dump($reg->deletePackage("pkg2")); -dumpall($reg); -var_dump($reg->deletePackage("pkg2")); -dumpall($reg); -$reg->updatePackage("pkg3", array("version" => "3.1b1", "status" => "beta")); -dumpall($reg); - -print "tests done\n"; - -cleanall(); - -// ------------------------------------------------------------------------- // - -function cleanall() -{ - $dp = opendir("."); - while ($ent = readdir($dp)) { - if (substr($ent, -4) == ".reg") { - unlink($ent); - } - } -} - -function dumpall(&$reg) -{ - print "dumping registry...\n"; - $info = $reg->packageInfo(); - foreach ($info as $pkg) { - print $pkg["name"] . ":"; - unset($pkg["name"]); - foreach ($pkg as $k => $v) { - if ($k == '_lastmodified') continue; - print " $k=\"$v\""; - } - print "\n"; - } - print "dump done\n"; -} - -?> ---EXPECT-- -creating registry object -dumping registry... -dump done -dumping registry... -pkg1: version="1.0" -dump done -dumping registry... -pkg1: version="1.0" -pkg2: version="2.0" -pkg3: version="3.0" -dump done -dumping registry... -pkg1: version="1.0" -pkg2: version="2.1" -pkg3: version="3.0" -dump done -bool(true) -dumping registry... -pkg1: version="1.0" -pkg3: version="3.0" -dump done -bool(false) -dumping registry... -pkg1: version="1.0" -pkg3: version="3.0" -dump done -dumping registry... -pkg1: version="1.0" -pkg3: version="3.1b1" status="beta" -dump done -tests done diff --git a/pear/tests/pear_system.phpt b/pear/tests/pear_system.phpt deleted file mode 100644 index 3c8e3371b5..0000000000 --- a/pear/tests/pear_system.phpt +++ /dev/null @@ -1,95 +0,0 @@ ---TEST-- -System commands tests ---SKIPIF-- ---FILE-- -<?php -error_reporting(E_ALL); -require_once 'System.php'; - -$sep = DIRECTORY_SEPARATOR; - -/******************* - mkDir -********************/ - -// Multiple directory creation -System::mkDir('dir1 dir2 dir3'); -if (!@is_dir('dir1') || !@is_dir('dir2') || !@is_dir('dir3')) { - print "System::mkDir('dir1 dir2 dir3'); failed\n"; -} - -// Parent creation without "-p" fail -if (@System::mkDir("dir4{$sep}dir3")) { - print "System::mkDir(\"dir4{$sep}dir3\") did not failed\n"; -} - -// Create a directory which is a file already fail -touch('file4'); -$res = @System::mkDir('file4 dir5'); -if ($res) { - print "System::mkDir('file4 dir5') did not failed\n"; -} -if (!@is_dir('dir5')) { - print "System::mkDir('file4 dir5') failed\n"; -} - -// Parent directory creation -System::mkDir("-p dir2{$sep}dir21 dir6{$sep}dir61{$sep}dir611"); -if (!@is_dir("dir2{$sep}dir21") || !@is_dir("dir6{$sep}dir61{$sep}dir611")) { - print "System::mkDir(\"-p dir2{$sep}dir21 dir6{$sep}dir61{$sep}dir611\")); failed\n"; -} - -/******************* - mkTemp -********************/ - -// Create a temporal file with "tst" as filename prefix -$tmpfile = System::mkTemp('tst'); -$tmpenv = System::tmpDir(); -if (!@is_file($tmpfile) || !ereg("^$tmpenv{$sep}tst", $tmpfile)) { - print "System::mkTemp('tst') failed\n"; -} - -// Create a temporal dir in "dir1" with default prefix "tmp" -$tmpdir = System::mkTemp('-d -t dir1'); -if (!@is_dir($tmpdir) || !ereg("^dir1{$sep}tmp", $tmpdir)) { - print "System::mkTemp('-d -t dir1') failed\n"; -} - -/******************* - rm -********************/ - -// Try to delete a dir without "-r" option -if (@System::rm('dir1')) { - print "System::rm('dir1') did not fail\n"; -} - -// Multiple and recursive delete -$del = "dir1 dir2 dir3 file4 dir5 dir6"; -if (!@System::rm("-r $del")) { - print "System::rm(\"-r $del\") failed\n"; -} - -/******************* - type -********************/ - -if (OS_UNIX) { - if (System::type('ls') != '/bin/ls') { - print "System::type('ls') failed\n"; - } - if (System::type('i_am_not_a_command')) { - print "System::type('i_am_not_a_command') did not failed\n"; - } -} // XXX Windows test - -/******************* - cat -********************/ -// Missing tests yet - -print "end\n"; -?> ---EXPECT-- -end 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=.. diff --git a/pear/tests/system.input b/pear/tests/system.input deleted file mode 100644 index 9c6bece157..0000000000 --- a/pear/tests/system.input +++ /dev/null @@ -1 +0,0 @@ -a:1:{s:13:"master_server";s:12:"pear.php.net";}
\ No newline at end of file diff --git a/pear/tests/toonew.conf b/pear/tests/toonew.conf deleted file mode 100644 index 6f0c72fe4b..0000000000 --- a/pear/tests/toonew.conf +++ /dev/null @@ -1,2 +0,0 @@ -#PEAR_Config 2.0 -master_server = pear.php.net diff --git a/pear/tests/user.input b/pear/tests/user.input deleted file mode 100644 index e69de29bb2..0000000000 --- a/pear/tests/user.input +++ /dev/null diff --git a/pear/tests/user2.input b/pear/tests/user2.input deleted file mode 100644 index ac9a8afc0d..0000000000 --- a/pear/tests/user2.input +++ /dev/null @@ -1 +0,0 @@ -a:1:{s:7:"verbose";i:2;}
\ No newline at end of file |