diff options
author | SVN Migration <svn@php.net> | 2002-12-13 02:20:34 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2002-12-13 02:20:34 +0000 |
commit | ae52101b3b490dd523a9504d338ee6efbc54892c (patch) | |
tree | c1bf723d69d9e1bc71e87067b0f8aa84dd370750 /pear | |
parent | 854b9b9ac1c0741b41999918bf31763bc926c3d6 (diff) | |
download | php-git-RELEASE_1_0b3.tar.gz |
This commit was manufactured by cvs2svn to create tag 'RELEASE_1_0b3'.RELEASE_1_0b3
Diffstat (limited to 'pear')
41 files changed, 0 insertions, 4507 deletions
diff --git a/pear/Archive/Tar.php b/pear/Archive/Tar.php deleted file mode 100644 index c2a89c7b3c..0000000000 --- a/pear/Archive/Tar.php +++ /dev/null @@ -1,1194 +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 = null) - { - $this->PEAR(); - if ($p_compress === null) { - if (@file_exists($p_tarname)) { - if ($fp = @fopen($p_tarname, "r")) { - // look for gzip magic cookie - $data = fread($fp, 2); - if ($data == "\37\213") { - $p_compress = true; - } - } - } else { - // probably a remote file or some file accessible - // through a stream interface - if (substr($p_tarname, -2) == 'gz') { - $p_compress = true; - } - } - } - $this->_tarname = $p_tarname; - if ($p_compress) { // assert zlib extension support - $extname = 'zlib'; - if (!extension_loaded($extname)) { - if (OS_WINDOWS) { - @dl("php_$extname.dll"); - } else { - @dl("$extname.so"); - } - } - 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 = (bool)$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)) { - fclose($this->_file); - 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() - - /** - * Check if a directory exists and create it (including parent - * dirs) if not. - * - * @param string $p_dir directory to check - * - * @return bool TRUE if the directory exists or was created - */ - 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() - - /** - * Compress path by changing for example "/dir/foo/../bar" to "/dir/bar", and - * remove double slashes. - * - * @param string $p_dir path to reduce - * - * @return string reduced path - * - * @access private - * - */ - 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/Archive/docs/Tar.txt b/pear/Archive/docs/Tar.txt deleted file mode 100644 index 73bee0d786..0000000000 --- a/pear/Archive/docs/Tar.txt +++ /dev/null @@ -1,424 +0,0 @@ -Documentation for class Archive_Tar -=================================== -Last update : 2001-08-15 - - - -Overview : ----------- - - The Archive_Tar class helps in creating and managing GNU TAR format - files compressed by GNU ZIP or not. - The class offers basic functions like creating an archive, adding - files in the archive, extracting files from the archive and listing - the archive content. - It also provide advanced functions that allow the adding and - extraction of files with path manipulation. - - -Sample : --------- - - // ----- Creating the object (uncompressed archive) - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); - - // ----- Creating the archive - $v_list[0]="file.txt"; - $v_list[1]="data/"; - $v_list[2]="file.log"; - $tar_object->create($v_list); - - // ----- Adding files - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; - $v_list[2]="log/file.log"; - $tar_object->add($v_list); - - // ----- Adding more files - $tar_object->add("release/newfile.log release/readme.txt"); - - // ----- Listing the content - if (($v_list = $tar_object->listContent()) != 0) - for ($i=0; $i<sizeof($v_list); $i++) - { - echo "Filename :'".$v_list[$i][filename]."'<br>"; - echo " .size :'".$v_list[$i][size]."'<br>"; - echo " .mtime :'".$v_list[$i][mtime]."' (".date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>"; - echo " .mode :'".$v_list[$i][mode]."'<br>"; - echo " .uid :'".$v_list[$i][uid]."'<br>"; - echo " .gid :'".$v_list[$i][gid]."'<br>"; - echo " .typeflag :'".$v_list[$i][typeflag]."'<br>"; - } - - // ----- Extracting the archive in directory "install" - $tar_object->extract("install"); - - -Public arguments : ------------------- - -None - - -Public Methods : ----------------- - -Method : Archive_Tar($p_tarname, $compress = false) -Description : - 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. -Arguments : - $p_tarname : A valid filename for the tar archive file. - $p_compress : true/false. Indicate if the archive need to be - compressed or not. -Return value : - The Archive_Tar object. -Sample : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object_compressed = new Archive_Tar("tarname.tgz", true); -How it works : - Initialize the object. - -Method : create($p_filelist) -Description : - 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. - See also createModify() method for more details. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. -Return value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $v_list[0]="file.txt"; - $v_list[1]="data/"; (Optional '/' at the end) - $v_list[2]="file.log"; - $tar_object->create($v_list); -Sample 2 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $tar_object->create("file.txt data/ file.log"); -How it works : - Just calling the createModify() method with the right parameters. - -Method : createModify($p_filelist, $p_add_dir, $p_remove_dir = "") -Description : - 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. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. - $p_add_dir : A string which contains a path to be added to the - memorized path of each element in the list. - $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 value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $v_list[0]="file.txt"; - $v_list[1]="data/"; (Optional '/' at the end) - $v_list[2]="file.log"; - $tar_object->createModify($v_list, "install"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/file.log -Sample 2 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->createModify($v_list, "install", "dev"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/log/file.log -How it works : - Open the file in write mode (erasing the existing one if one), - call the _addList() method for adding the files in an empty archive, - add the tar footer (512 bytes block), close the tar file. - - -Method : addModify($p_filelist, $p_add_dir, $p_remove_dir="") -Description : - 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. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. - $p_add_dir : A string which contains a path to be added to the - memorized path of each element in the list. - $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 value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->addModify($v_list, "install"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/file.log -Sample 2 : - $tar_object = new Archive_Tar("tarname.tar"); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->addModify($v_list, "install", "dev"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/log/file.log -How it works : - If the archive does not exists it create it and add the files. - If the archive does exists and is not compressed, it open it, jump - before the last empty 512 bytes block (tar footer) and add the files - at this point. - If the archive does exists and is compressed, a temporary copy file - is created. This temporary file is then 'gzip' read block by block - until the last empty block. The new files are then added in the - compressed file. - The adding of files is done by going through the file/dir list, - adding files per files, in a recursive way through the - directory. Each time a path need to be added/removed it is done - before writing the file header in the archive. - -Method : add($p_filelist) -Description : - 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. - See addModify() method for details and limitations. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. -Return value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->add($v_list); -Sample 2 : - $tar_object = new Archive_Tar("tarname.tgz", true); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->add($v_list); -How it works : - Simply call the addModify() method with the right parameters. - -Method : extract($p_path = "") -Description : - This method extract all the content of the archive in the directory - indicated by $p_path.If $p_path is optional, if not set the archive - is extracted in the current directory. - While extracting a file, if the directory path does not exists it is - created. - See extractModify() for details and limitations. -Arguments : - $p_path : Optional path where the files/dir need to by extracted. -Return value : - true on success, false on error. -Sample : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->extract(); -How it works : - Simply call the extractModify() method with appropriate parameters. - -Method : extractModify($p_path, $p_remove_path) -Description : - 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. -Arguments : - $p_path : The path of the directory where the files/dir need to by - extracted. - $p_remove_path : Part of the memorized path that can be removed if - present at the beginning of the file/dir path. -Return value : - true on success, false on error. -Sample : - // Imagine tarname.tar with files : - // dev/data/file.txt - // dev/data/log.txt - // readme.txt - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->extractModify("install", "dev"); - // Files will be extracted there : - // install/data/file.txt - // install/data/log.txt - // install/readme.txt -How it works : - Open the archive and call a more generic function that can extract - only a part of the archive or all the archive. - See extractList() method for more details. - -Method : listContent() -Description : - This method returns an array of arrays that describe each - file/directory present in the archive. - The array is not sorted, so it show the position of the file in the - archive. - The file informations are : - $file[filename] : Name and path of the file/dir. - $file[mode] : File permissions (result of fileperms()) - $file[uid] : user id - $file[gid] : group id - $file[size] : filesize - $file[mtime] : Last modification time (result of filemtime()) - $file[typeflag] : "" for file, "5" for directory -Arguments : -Return value : - An array of arrays or 0 on error. -Sample : - $tar_object = new Archive_Tar("tarname.tar"); - if (($v_list = $tar_object->listContent()) != 0) - for ($i=0; $i<sizeof($v_list); $i++) - { - echo "Filename :'".$v_list[$i][filename]."'<br>"; - echo " .size :'".$v_list[$i][size]."'<br>"; - echo " .mtime :'".$v_list[$i][mtime]."' (". - date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>"; - echo " .mode :'".$v_list[$i][mode]."'<br>"; - echo " .uid :'".$v_list[$i][uid]."'<br>"; - echo " .gid :'".$v_list[$i][gid]."'<br>"; - echo " .typeflag :'".$v_list[$i][typeflag]."'<br>"; - } -How it works : - Call the same function as an extract however with a flag to only go - through the archive without extracting the files. - -Method : extractList($p_filelist, $p_path = "", $p_remove_path = "") -Description : - 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. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. - $p_path : The path of the directory where the files/dir need to by - extracted. - $p_remove_path : Part of the memorized path that can be removed if - present at the beginning of the file/dir path. -Return value : - true on success, false on error. -Sample : - // Imagine tarname.tar with files : - // dev/data/file.txt - // dev/data/log.txt - // readme.txt - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->extractList("dev/data/file.txt readme.txt", "install", - "dev"); - // Files will be extracted there : - // install/data/file.txt - // install/readme.txt -How it works : - Go through the archive and extract only the files present in the - list. - 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 964421943f..0000000000 --- a/pear/Console/Getopt.php +++ /dev/null @@ -1,225 +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; - } - if (empty($args)) { - return array(array(), array()); - } - $opts = array(); - $non_opts = array(); - - settype($args, 'array'); - - if ($long_options) { - sort($long_options); - } - if (isset($args[0]{0}) && $args[0]{0} != '-') { - array_shift($args); - } - 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($GLOBALS['HTTP_SERVER_VARS']['argv'])) { - return PEAR::raiseError("Console_Getopt: Could not read cmd args (register_argc_argv=Off?)"); - } - return $GLOBALS['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 3985dc9beb..0000000000 --- a/pear/Console/tests/001-getopt.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -Console_Getopt ---SKIPIF-- -skip ---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/Makefile.frag b/pear/Makefile.frag deleted file mode 100644 index 2b02b50109..0000000000 --- a/pear/Makefile.frag +++ /dev/null @@ -1,94 +0,0 @@ -# -*- makefile -*- - -pear_install_targets = \ - install-pear \ - install-headers \ - install-build \ - install-programs - -peardir=$(PEAR_INSTALLDIR) - -# Skip all php.ini files altogether -PEAR_INSTALL_FLAGS = -n -dsafe_mode=0 - -install-pear-installer: $(top_builddir)/sapi/cli/php - @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php $(srcdir)/package-*.xml - -install-pear-packages: $(top_builddir)/sapi/cli/php - @$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) $(srcdir)/install-pear.php $(srcdir)/packages/*.tar - -install-pear: - @echo "Installing PEAR environment: $(INSTALL_ROOT)$(peardir)/" - @if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \ - $(MAKE) -s install-pear-installer 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 -bin_src_SCRIPTS = phpextdist - -install-build: - @echo "Installing build environment: $(INSTALL_ROOT)$(phpbuilddir)/" - @$(mkinstalldirs) $(INSTALL_ROOT)$(phpbuilddir) $(INSTALL_ROOT)$(bindir) && \ - (cd $(top_srcdir) && cp $(BUILD_FILES) $(INSTALL_ROOT)$(phpbuilddir)) - -install-programs: - @echo "Installing helper programs: $(INSTALL_ROOT)$(bindir)/" - @for prog in $(bin_SCRIPTS); do \ - echo " program: $$prog"; \ - $(INSTALL) -m 755 $(builddir)/scripts/$$prog $(INSTALL_ROOT)$(bindir)/$$prog; \ - done - @for prog in $(bin_src_SCRIPTS); do \ - echo " 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: $(INSTALL_ROOT)$(phpincludedir)/" && \ - 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; \ - cd $(top_srcdir)/sapi/embed && cp -p *.h $(INSTALL_ROOT)$(phpincludedir)/main - -#$(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/php-config: $(srcdir)/scripts/php-config.in $(top_builddir)/config.status - (CONFIG_FILES=$@ CONFIG_HEADERS= $(top_builddir)/config.status) 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/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/docs/Archive_Tar.txt b/pear/docs/Archive_Tar.txt deleted file mode 100644 index 73bee0d786..0000000000 --- a/pear/docs/Archive_Tar.txt +++ /dev/null @@ -1,424 +0,0 @@ -Documentation for class Archive_Tar -=================================== -Last update : 2001-08-15 - - - -Overview : ----------- - - The Archive_Tar class helps in creating and managing GNU TAR format - files compressed by GNU ZIP or not. - The class offers basic functions like creating an archive, adding - files in the archive, extracting files from the archive and listing - the archive content. - It also provide advanced functions that allow the adding and - extraction of files with path manipulation. - - -Sample : --------- - - // ----- Creating the object (uncompressed archive) - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); - - // ----- Creating the archive - $v_list[0]="file.txt"; - $v_list[1]="data/"; - $v_list[2]="file.log"; - $tar_object->create($v_list); - - // ----- Adding files - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; - $v_list[2]="log/file.log"; - $tar_object->add($v_list); - - // ----- Adding more files - $tar_object->add("release/newfile.log release/readme.txt"); - - // ----- Listing the content - if (($v_list = $tar_object->listContent()) != 0) - for ($i=0; $i<sizeof($v_list); $i++) - { - echo "Filename :'".$v_list[$i][filename]."'<br>"; - echo " .size :'".$v_list[$i][size]."'<br>"; - echo " .mtime :'".$v_list[$i][mtime]."' (".date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>"; - echo " .mode :'".$v_list[$i][mode]."'<br>"; - echo " .uid :'".$v_list[$i][uid]."'<br>"; - echo " .gid :'".$v_list[$i][gid]."'<br>"; - echo " .typeflag :'".$v_list[$i][typeflag]."'<br>"; - } - - // ----- Extracting the archive in directory "install" - $tar_object->extract("install"); - - -Public arguments : ------------------- - -None - - -Public Methods : ----------------- - -Method : Archive_Tar($p_tarname, $compress = false) -Description : - 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. -Arguments : - $p_tarname : A valid filename for the tar archive file. - $p_compress : true/false. Indicate if the archive need to be - compressed or not. -Return value : - The Archive_Tar object. -Sample : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object_compressed = new Archive_Tar("tarname.tgz", true); -How it works : - Initialize the object. - -Method : create($p_filelist) -Description : - 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. - See also createModify() method for more details. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. -Return value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $v_list[0]="file.txt"; - $v_list[1]="data/"; (Optional '/' at the end) - $v_list[2]="file.log"; - $tar_object->create($v_list); -Sample 2 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $tar_object->create("file.txt data/ file.log"); -How it works : - Just calling the createModify() method with the right parameters. - -Method : createModify($p_filelist, $p_add_dir, $p_remove_dir = "") -Description : - 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. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. - $p_add_dir : A string which contains a path to be added to the - memorized path of each element in the list. - $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 value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $v_list[0]="file.txt"; - $v_list[1]="data/"; (Optional '/' at the end) - $v_list[2]="file.log"; - $tar_object->createModify($v_list, "install"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/file.log -Sample 2 : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->createModify($v_list, "install", "dev"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/log/file.log -How it works : - Open the file in write mode (erasing the existing one if one), - call the _addList() method for adding the files in an empty archive, - add the tar footer (512 bytes block), close the tar file. - - -Method : addModify($p_filelist, $p_add_dir, $p_remove_dir="") -Description : - 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. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. - $p_add_dir : A string which contains a path to be added to the - memorized path of each element in the list. - $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 value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->addModify($v_list, "install"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/file.log -Sample 2 : - $tar_object = new Archive_Tar("tarname.tar"); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->addModify($v_list, "install", "dev"); - // files are stored in the archive as : - // install/file.txt - // install/data - // install/data/file1.txt - // install/data/... all the files and sub-dirs of data/ - // install/log/file.log -How it works : - If the archive does not exists it create it and add the files. - If the archive does exists and is not compressed, it open it, jump - before the last empty 512 bytes block (tar footer) and add the files - at this point. - If the archive does exists and is compressed, a temporary copy file - is created. This temporary file is then 'gzip' read block by block - until the last empty block. The new files are then added in the - compressed file. - The adding of files is done by going through the file/dir list, - adding files per files, in a recursive way through the - directory. Each time a path need to be added/removed it is done - before writing the file header in the archive. - -Method : add($p_filelist) -Description : - 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. - See addModify() method for details and limitations. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. -Return value : - true on success, false on error. -Sample 1 : - $tar_object = new Archive_Tar("tarname.tar"); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->add($v_list); -Sample 2 : - $tar_object = new Archive_Tar("tarname.tgz", true); - [...] - $v_list[0]="dev/file.txt"; - $v_list[1]="dev/data/"; (Optional '/' at the end) - $v_list[2]="log/file.log"; - $tar_object->add($v_list); -How it works : - Simply call the addModify() method with the right parameters. - -Method : extract($p_path = "") -Description : - This method extract all the content of the archive in the directory - indicated by $p_path.If $p_path is optional, if not set the archive - is extracted in the current directory. - While extracting a file, if the directory path does not exists it is - created. - See extractModify() for details and limitations. -Arguments : - $p_path : Optional path where the files/dir need to by extracted. -Return value : - true on success, false on error. -Sample : - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->extract(); -How it works : - Simply call the extractModify() method with appropriate parameters. - -Method : extractModify($p_path, $p_remove_path) -Description : - 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. -Arguments : - $p_path : The path of the directory where the files/dir need to by - extracted. - $p_remove_path : Part of the memorized path that can be removed if - present at the beginning of the file/dir path. -Return value : - true on success, false on error. -Sample : - // Imagine tarname.tar with files : - // dev/data/file.txt - // dev/data/log.txt - // readme.txt - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->extractModify("install", "dev"); - // Files will be extracted there : - // install/data/file.txt - // install/data/log.txt - // install/readme.txt -How it works : - Open the archive and call a more generic function that can extract - only a part of the archive or all the archive. - See extractList() method for more details. - -Method : listContent() -Description : - This method returns an array of arrays that describe each - file/directory present in the archive. - The array is not sorted, so it show the position of the file in the - archive. - The file informations are : - $file[filename] : Name and path of the file/dir. - $file[mode] : File permissions (result of fileperms()) - $file[uid] : user id - $file[gid] : group id - $file[size] : filesize - $file[mtime] : Last modification time (result of filemtime()) - $file[typeflag] : "" for file, "5" for directory -Arguments : -Return value : - An array of arrays or 0 on error. -Sample : - $tar_object = new Archive_Tar("tarname.tar"); - if (($v_list = $tar_object->listContent()) != 0) - for ($i=0; $i<sizeof($v_list); $i++) - { - echo "Filename :'".$v_list[$i][filename]."'<br>"; - echo " .size :'".$v_list[$i][size]."'<br>"; - echo " .mtime :'".$v_list[$i][mtime]."' (". - date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>"; - echo " .mode :'".$v_list[$i][mode]."'<br>"; - echo " .uid :'".$v_list[$i][uid]."'<br>"; - echo " .gid :'".$v_list[$i][gid]."'<br>"; - echo " .typeflag :'".$v_list[$i][typeflag]."'<br>"; - } -How it works : - Call the same function as an extract however with a flag to only go - through the archive without extracting the files. - -Method : extractList($p_filelist, $p_path = "", $p_remove_path = "") -Description : - 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. -Arguments : - $p_filelist : An array of filenames and directory names, or a single - string with names separated by a single blank space. - $p_path : The path of the directory where the files/dir need to by - extracted. - $p_remove_path : Part of the memorized path that can be removed if - present at the beginning of the file/dir path. -Return value : - true on success, false on error. -Sample : - // Imagine tarname.tar with files : - // dev/data/file.txt - // dev/data/log.txt - // readme.txt - $tar_object = new Archive_Tar("tarname.tar"); - $tar_object->extractList("dev/data/file.txt readme.txt", "install", - "dev"); - // Files will be extracted there : - // install/data/file.txt - // install/readme.txt -How it works : - Go through the archive and extract only the files present in the - list. - diff --git a/pear/install-pear.php b/pear/install-pear.php deleted file mode 100644 index c1a2d1341d..0000000000 --- a/pear/install-pear.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php - -/* $Id$ */ - -$pear_dir = dirname(__FILE__); -ini_set('include_path', $pear_dir); -##//include_once 'PEAR/Config.php'; -include_once 'PEAR.php'; -include_once 'PEAR/Installer.php'; -include_once 'PEAR/Registry.php'; -include_once 'PEAR/Frontend/CLI.php'; - -##//$config = &PEAR_Config::singleton(); - -array_shift($argv); -if ($argv[0] == '--force') { - array_shift($argv); - $force = true; -} else { - $force = false; -} -// package => install_file -$install_files = array(); - -/* -$dp = opendir($pear_dir); -while ($ent = readdir($dp)) { - if (ereg('^package-(.*)\.xml$', $ent, $matches)) { - $install_files[$matches[1]] = $ent; - } -} -closedir($dp); -*/ -foreach ($argv as $arg) { - $bn = basename($arg); - if (ereg('^package-(.*)\.xml$', $bn, $matches) || - ereg('^([A-Za-z0-9_:]+)-.*\.(tar|tgz)$', $bn, $matches)) { - $install_files[$matches[1]] = $arg; - } -} - -$config = &PEAR_Config::singleton(); - -// make sure we use only default values -$config_layers = $config->getLayers(); -foreach ($config_layers as $layer) { - if ($layer == 'default') continue; - $config->removeLayer($layer); -} -$config->set('verbose', 0, 'default'); - -$options = array(); -$install_root = getenv("INSTALL_ROOT"); -$php_dir = $config->get('php_dir'); -if (!empty($install_root)) { - $options['installroot'] = $install_root; - $reg_dir = $install_root . $php_dir; -} else { - $reg_dir = $php_dir; -} - -$reg = &new PEAR_Registry($reg_dir); -$ui = &new PEAR_Frontend_CLI(); -$installer = &new PEAR_Installer($ui); -$installer->registry = &$reg; - -foreach ($install_files as $package => $instfile) { - if ($reg->packageExists($package)) { - $info = $installer->infoFromAny($instfile); - if (PEAR::isError($info)) { - $ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage())); - continue; - } - $new_ver = $info['version']; - $old_ver = $reg->packageInfo($package, 'version'); - if (version_compare($new_ver, $old_ver, 'gt')) { - $options['upgrade'] = true; - $err = $installer->install($instfile, $options); - if (PEAR::isError($err)) { - $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); - continue; - } - $ui->outputData(sprintf("[PEAR] %-15s- upgraded: %s", $package, $new_ver)); - } else { - if (@$argv[1] == '--force') { - $options['force'] = true; - $err = $installer->install($instfile, $options); - if (PEAR::isError($err)) { - $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); - continue; - } - $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver)); - } else { - $ui->outputData(sprintf("[PEAR] %-15s- already installed: %s", $package, $old_ver)); - } - } - } else { - $options['nodeps'] = true; - $err = $installer->install($instfile, $options); - if (PEAR::isError($err)) { - $ui->outputData(sprintf("[PEAR] %s: %s", $package, $err->getMessage())); - continue; - } - $new_ver = $reg->packageInfo($package, 'version'); - $ui->outputData(sprintf("[PEAR] %-15s- installed: %s", $package, $new_ver)); - } -} - -?>
\ No newline at end of file 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 64ee07b5c8..0000000000 --- a/pear/package-Archive_Tar.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE package SYSTEM "package.dtd"> -<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.9</version> - <date>2002-05-27</date> - <notes> - * Auto-detect gzip'ed files - </notes> - <state>stable</state> - <filelist> - <dir name="Archive"> - <file role="php" name="Tar.php"/> - </dir> - <file role="doc" name="docs/Archive_Tar.txt" baseinstalldir="/"/> - </filelist> - </release> - <changelog> - <release> - <version>0.4</version> - <date>2002-05-20</date> - <notes>Windows bugfix: use forward slashes inside archives</notes> - <state>stable</state> - </release> - <release> - <version>0.2</version> - <date>2002-02-18</date> - <notes>From initial commit to stable</notes> - <state>stable</state> - </release> - <release> - <version>0.3</version> - <date>2002-04-13</date> - <notes>Windows bugfix: used wrong directory separators</notes> - <state>stable</state> - </release> - </changelog> -</package> diff --git a/pear/package-Console_Getopt.xml b/pear/package-Console_Getopt.xml deleted file mode 100644 index 1bc3eb02da..0000000000 --- a/pear/package-Console_Getopt.xml +++ /dev/null @@ -1,63 +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>developer</role> - <name>Stig Bakken</name> - <email>stig@php.net</email> - </maintainer> - </maintainers> - <release> - <version>1.0</version> - <date>2002-09-13</date> - <notes>Stable release</notes> - <state>stable</state> - <filelist> - <dir name="Console"> - <file role="php" name="Getopt.php"/> - </dir> - </filelist> - </release> - <changelog> - <release> - <version>0.11</version> - <date>2002-05-26</date> - <notes>POSIX getopt compatibility fix: treat first element of args - array as command name - </notes> - <state>beta</state> - <filelist> - <dir name="Console"> - <file role="php" name="Getopt.php"/> - </dir> - </filelist> - </release> - <release> - <version>0.10</version> - <date>2002-05-12</date> - <notes>Packaging fix</notes> - <state>beta</state> - </release> - <release> - <version>0.9</version> - <date>2002-05-12</date> - <notes>Initial release</notes> - <state>beta</state> - </release> - </changelog> -</package> diff --git a/pear/packages/DB-1.3.tar b/pear/packages/DB-1.3.tar Binary files differdeleted file mode 100644 index 7e34293a06..0000000000 --- a/pear/packages/DB-1.3.tar +++ /dev/null diff --git a/pear/packages/HTTP-1.2.tar b/pear/packages/HTTP-1.2.tar Binary files differdeleted file mode 100644 index 8801425e3f..0000000000 --- a/pear/packages/HTTP-1.2.tar +++ /dev/null diff --git a/pear/packages/Mail-1.0.1.tar b/pear/packages/Mail-1.0.1.tar Binary files differdeleted file mode 100644 index 7716adb920..0000000000 --- a/pear/packages/Mail-1.0.1.tar +++ /dev/null diff --git a/pear/packages/Net_SMTP-1.0.tar b/pear/packages/Net_SMTP-1.0.tar Binary files differdeleted file mode 100644 index cfe57cbdd2..0000000000 --- a/pear/packages/Net_SMTP-1.0.tar +++ /dev/null diff --git a/pear/packages/Net_Socket-1.0.1.tar b/pear/packages/Net_Socket-1.0.1.tar Binary files differdeleted file mode 100644 index 7ff4698b69..0000000000 --- a/pear/packages/Net_Socket-1.0.1.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 0847e4e880..0000000000 --- a/pear/packages/XML_Parser-1.0.tar +++ /dev/null diff --git a/pear/packages/XML_RPC-1.0.4.tar b/pear/packages/XML_RPC-1.0.4.tar Binary files differdeleted file mode 100644 index b1eb50e742..0000000000 --- a/pear/packages/XML_RPC-1.0.4.tar +++ /dev/null diff --git a/pear/pear.m4 b/pear/pear.m4 deleted file mode 100644 index 1a3cdec894..0000000000 --- a/pear/pear.m4 +++ /dev/null @@ -1,121 +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_RUNPATH_SWITCH -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 -AC_PROG_AWK - -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_SUBST(AWK) - -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/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 5978ff2885..0000000000 --- a/pear/scripts/php-config.in +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/sh - -prefix="@prefix@" -version="@PHP_VERSION@" -includedir="@includedir@/php" -includes="-I$includedir -I$includedir/main -I$includedir/Zend" -libs="@EXTRA_LIBS@" -if test '@TSRM_DIR@' != ''; then - includes="$includes -I$includedir/TSRM" -fi -extension_dir='@EXTENSION_DIR@' - -case "$1" in ---prefix) - echo $prefix;; ---includes) - echo $includes;; ---libs) - echo $libs;; ---extension-dir) - echo $extension_dir;; ---version) - echo $version;; -*) - echo "Usage: $0 [--prefix|--includes|--libs|--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 c77694f8c3..0000000000 --- a/pear/scripts/phpize.in +++ /dev/null @@ -1,42 +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=`grep -E '#define PHP_API_VERSION' $includedir/main/php.h|sed 's/#define PHP_API_VERSION//'` -ZEND_MODULE_API_NO=`grep -E '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|sed 's/#define ZEND_MODULE_API_NO//'` -ZEND_EXTENSION_API_NO=`grep -E '#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 - -exit 0 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 2961ff7284..0000000000 --- a/pear/tests/pear1.phpt +++ /dev/null @@ -1,88 +0,0 @@ ---TEST-- -PEAR constructor/destructor test ---SKIPIF-- -skip ---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 f25f4a4116..0000000000 --- a/pear/tests/pear_autoloader.phpt +++ /dev/null @@ -1,81 +0,0 @@ ---TEST-- -PEAR_Autoloader ---SKIPIF-- -skip -<?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 7e125ac855..0000000000 --- a/pear/tests/pear_config.phpt +++ /dev/null @@ -1,289 +0,0 @@ ---TEST-- -PEAR_Config ---SKIPIF-- -skip ---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 "\n#0 starting up\n"; -dump_files(); - -print "\n#1 testing: constructor\n"; -$config = new PEAR_Config("user.conf", "system.conf"); -dump_array("files", $config->files); - -print "\n#2 testing: singleton\n"; -$o1 = &PEAR_Config::singleton(); -$o1->blah = 'blah'; -$o2 = &PEAR_Config::singleton(); -var_dump($o1->blah); -@var_dump($o2->blah); - -print "\n#3 testing: readConfigFile\n"; -$config->readConfigFile("user2.conf", "user"); -dump_config($config); -$config->readConfigFile("user.conf"); -dump_config($config); - -print "\n#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 "\n#5 testing: config file version detection\n"; -$config->readConfigFile("user.conf", "user"); -$config->readConfigFile("toonew.conf", "user"); - -print "\n#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 "\n#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 "\n#8 testing: getDocs\n"; -print "master_server: " . $config->getDocs("master_server") . "\n"; - -print "\n#9 testing: getKeys\n"; -$keys = $config->getKeys(); -sort($keys); -print implode(" ", $keys) . "\n"; - -print "\n#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 "\n#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 "\n#12 testing: getGroup\n"; -foreach ($keys as $key) { - print "$key: ".$config->getGroup($key)."\n"; -} - -print "\n#13 testing: getGroups\n"; -$groups = $config->getGroups(); -sort($groups); -print implode(", ", $groups) . "\n"; - -print "\n#14 testing: getGroupKeys\n"; -foreach ($groups as $group) { - $gk = $config->getGroupKeys($group); - sort($gk); - print "$group: " . implode(", ", $gk) . "\n"; -} - -print "\n#15 testing: getPrompt\n"; -foreach ($keys as $key) { - print "$key: ".$config->getPrompt($key)."\n"; -} - - -// - -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 cache_dir cache_ttl data_dir doc_dir ext_dir http_proxy master_server password php_dir preferred_state sig_bin sig_keydir sig_type test_dir 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) - -#12 testing: getGroup -bin_dir: File Locations -cache_dir: File Locations (Advanced) -cache_ttl: Advanced -data_dir: File Locations (Advanced) -doc_dir: File Locations -ext_dir: File Locations -http_proxy: Internet Access -master_server: Internet Access -password: Maintainers -php_dir: File Locations -preferred_state: Advanced -sig_bin: Maintainers -sig_keydir: Maintainers -sig_type: Maintainers -test_dir: File Locations (Advanced) -umask: Advanced -username: Maintainers -verbose: Advanced - -#13 testing: getGroups -Advanced, File Locations, File Locations (Advanced), Internet Access, Maintainers - -#14 testing: getGroupKeys -Advanced: cache_ttl, preferred_state, umask, verbose -File Locations: bin_dir, doc_dir, ext_dir, php_dir -File Locations (Advanced): cache_dir, data_dir, test_dir -Internet Access: http_proxy, master_server -Maintainers: password, sig_bin, sig_keydir, sig_type, username - -#15 testing: getPrompt -bin_dir: PEAR executables directory -cache_dir: PEAR Installer cache directory -cache_ttl: Cache TimeToLive -data_dir: PEAR data directory -doc_dir: PEAR documentation directory -ext_dir: PHP extension directory -http_proxy: HTTP Proxy Server Address -master_server: PEAR server -password: PEAR password (for maintainers) -php_dir: PEAR directory -preferred_state: Preferred Package State -sig_bin: Signature Handling Program -sig_keydir: Signature Key Directory -sig_type: Package Signature Type -test_dir: PEAR test directory -umask: Unix file mask -username: PEAR username (for maintainers) -verbose: Debug Log Level -done diff --git a/pear/tests/pear_error.phpt b/pear/tests/pear_error.phpt deleted file mode 100644 index 51493633ea..0000000000 --- a/pear/tests/pear_error.phpt +++ /dev/null @@ -1,154 +0,0 @@ ---TEST-- -PEAR_Error: basic test ---SKIPIF-- -skip ---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 4ae1c4b701..0000000000 --- a/pear/tests/pear_error2.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -PEAR_Error: die mode ---SKIPIF-- -skip ---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 4c89ae5a69..0000000000 --- a/pear/tests/pear_error3.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -PEAR_Error: default error handling ---SKIPIF-- -skip ---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 57f69359b8..0000000000 --- a/pear/tests/pear_error4.phpt +++ /dev/null @@ -1,104 +0,0 @@ ---TEST-- -PEAR_Error: expected errors ---SKIPIF-- -skip ---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(); - -print "subtest 8\n"; -$obj->expectError(array(1, 2, 3)); -$obj->expectError(array(3, 4, 5)); -$obj->raiseError(4); -$obj->delExpect(2); -$obj->raiseError(3); -$obj->delExpect(1, 3, 4, 5); -$err = $obj->delExpect(2); - -?> ---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 -subtest 8 -error: 4 -error: 3 -error: The expected error you submitted does not exist diff --git a/pear/tests/pear_registry.phpt b/pear/tests/pear_registry.phpt deleted file mode 100644 index 0295ed922e..0000000000 --- a/pear/tests/pear_registry.phpt +++ /dev/null @@ -1,168 +0,0 @@ ---TEST-- -PEAR_Registry ---SKIPIF-- -skip ---FILE-- -<?php - -error_reporting(E_ALL); -include dirname(__FILE__)."/../PEAR/Registry.php"; -PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s\n"); -cleanall(); - -$files1 = array( - "pkg1-1.php" => array( - "role" => "php", - ), - "pkg1-2.php" => array( - "role" => "php", - "baseinstalldir" => "pkg1", - ), - ); -$files2 = array( - "pkg2-1.php" => array( - "role" => "php", - ), - "pkg2-2.php" => array( - "role" => "php", - "baseinstalldir" => "pkg2", - ), - ); -$files3 = array( - "pkg3-1.php" => array( - "role" => "php", - ), - "pkg3-2.php" => array( - "role" => "php", - "baseinstalldir" => "pkg3", - ), - ); -$files3_new = array( - "pkg3-3.php" => array( - "role" => "php", - "baseinstalldir" => "pkg3", - ), - "pkg3-4.php" => array( - "role" => "php", - ), - ); - -print "creating registry object\n"; -$reg = new PEAR_Registry; -$reg->statedir = getcwd(); -dumpall($reg); - -$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0", "filelist" => $files1)); -dumpall($reg); - -$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0", "filelist" => $files2)); -$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0", "filelist" => $files3)); -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_r($reg->checkFilemap(array_merge($files3, $files2))); - -$reg->updatePackage("pkg3", array("filelist" => $files3_new)); -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; - if (is_array($v) && $k == 'filelist') { - print " $k=array("; - $i = 0; - foreach ($v as $k2 => $v2) { - if ($i++ > 0) print ","; - print "{$k2}["; - $j = 0; - foreach ($v2 as $k3 => $v3) { - if ($j++ > 0) print ","; - print "$k3=$v3"; - } - print "]"; - } - print ")"; - } else { - print " $k=\"$v\""; - } - } - print "\n"; - } - print "dump done\n"; -} - -?> ---EXPECT-- -creating registry object -dumping registry... -dump done -dumping registry... -pkg1: version="1.0" filelist=array(pkg1-1.php[role=php],pkg1-2.php[role=php,baseinstalldir=pkg1]) -dump done -dumping registry... -pkg1: version="1.0" filelist=array(pkg1-1.php[role=php],pkg1-2.php[role=php,baseinstalldir=pkg1]) -pkg2: version="2.0" filelist=array(pkg2-1.php[role=php],pkg2-2.php[role=php,baseinstalldir=pkg2]) -pkg3: version="3.0" filelist=array(pkg3-1.php[role=php],pkg3-2.php[role=php,baseinstalldir=pkg3]) -dump done -dumping registry... -pkg1: version="1.0" filelist=array(pkg1-1.php[role=php],pkg1-2.php[role=php,baseinstalldir=pkg1]) -pkg2: version="2.1" filelist=array(pkg2-1.php[role=php],pkg2-2.php[role=php,baseinstalldir=pkg2]) -pkg3: version="3.0" filelist=array(pkg3-1.php[role=php],pkg3-2.php[role=php,baseinstalldir=pkg3]) -dump done -bool(true) -dumping registry... -pkg1: version="1.0" filelist=array(pkg1-1.php[role=php],pkg1-2.php[role=php,baseinstalldir=pkg1]) -pkg3: version="3.0" filelist=array(pkg3-1.php[role=php],pkg3-2.php[role=php,baseinstalldir=pkg3]) -dump done -bool(false) -dumping registry... -pkg1: version="1.0" filelist=array(pkg1-1.php[role=php],pkg1-2.php[role=php,baseinstalldir=pkg1]) -pkg3: version="3.0" filelist=array(pkg3-1.php[role=php],pkg3-2.php[role=php,baseinstalldir=pkg3]) -dump done -dumping registry... -pkg1: version="1.0" filelist=array(pkg1-1.php[role=php],pkg1-2.php[role=php,baseinstalldir=pkg1]) -pkg3: version="3.1b1" filelist=array(pkg3-1.php[role=php],pkg3-2.php[role=php,baseinstalldir=pkg3]) status="beta" -dump done -Array -( - [pkg3-1.php] => pkg3 - [pkg3/pkg3-2.php] => pkg3 -) -dumping registry... -pkg1: version="1.0" filelist=array(pkg1-1.php[role=php],pkg1-2.php[role=php,baseinstalldir=pkg1]) -pkg3: version="3.1b1" filelist=array(pkg3-3.php[role=php,baseinstalldir=pkg3],pkg3-4.php[role=php]) 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 64f3d1143e..0000000000 --- a/pear/tests/pear_system.phpt +++ /dev/null @@ -1,101 +0,0 @@ ---TEST-- -System commands tests ---SKIPIF-- -skip ---FILE-- -<?php -error_reporting(E_ALL); -require_once 'System.php'; - -$sep = DIRECTORY_SEPARATOR; - -/******************* - mkDir -********************/ -// Single directory creation -System::mkDir('singledir'); -if( !is_dir('singledir') ){ - print "System::mkDir('singledir'); failed\n"; -} - -// 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"; -} - -/******************* - which -********************/ - -if (OS_UNIX) { - if (System::which('ls') != '/bin/ls') { - print "System::which('ls') failed\n"; - } - if (System::which('i_am_not_a_command')) { - print "System::which('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 |