From 841016153d92bbafb270ca57972c4251653d1cfd Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 16 May 2011 16:10:15 +0200 Subject: [PATCH] cleanup 3dparty --- 3dparty/Archive/Tar.php | 1762 ----------------- 3dparty/Console/Getopt.php | 251 --- 3dparty/Log.php | 635 ------ 3dparty/Log/composite.php | 196 -- 3dparty/Log/console.php | 190 -- 3dparty/Log/daemon.php | 229 --- 3dparty/Log/display.php | 108 - 3dparty/Log/error_log.php | 104 - 3dparty/Log/file.php | 286 --- 3dparty/Log/mail.php | 222 --- 3dparty/Log/mcal.php | 171 -- 3dparty/Log/null.php | 68 - 3dparty/Log/observer.php | 126 -- 3dparty/Log/sql.php | 225 --- 3dparty/Log/sqlite.php | 238 --- 3dparty/Log/syslog.php | 160 -- 3dparty/Log/win.php | 256 --- 3dparty/Mail.php | 212 -- 3dparty/Mail/RFC822.php | 923 --------- 3dparty/Mail/mail.php | 130 -- 3dparty/Mail/mime.php | 713 ------- 3dparty/Mail/mimeDecode.php | 837 -------- 3dparty/Mail/mimePart.php | 351 ---- 3dparty/Mail/null.php | 60 - 3dparty/Mail/sendmail.php | 145 -- 3dparty/Mail/smtp.php | 223 --- 3dparty/Mail/xmail.dtd | 19 - 3dparty/Mail/xmail.xsl | 70 - 3dparty/Net/SMTP.php | 970 --------- 3dparty/Net/Socket.php | 528 ----- 3dparty/OS/Guess.php | 287 --- 3dparty/PHPUnit.php | 83 - 3dparty/PHPUnit/Assert.php | 384 ---- 3dparty/PHPUnit/GUI/Gtk.php | 698 ------- 3dparty/PHPUnit/GUI/HTML.php | 210 -- 3dparty/PHPUnit/GUI/SetupDecorator.php | 167 -- 3dparty/PHPUnit/RepeatedTest.php | 112 -- 3dparty/PHPUnit/Skeleton.php | 406 ---- 3dparty/PHPUnit/TestCase.php | 237 --- 3dparty/PHPUnit/TestDecorator.php | 110 - 3dparty/PHPUnit/TestFailure.php | 88 - 3dparty/PHPUnit/TestListener.php | 120 -- 3dparty/PHPUnit/TestResult.php | 300 --- 3dparty/PHPUnit/TestSuite.php | 220 -- 3dparty/System.php | 540 ----- 3dparty/docs/HTTP_WebDAV_Server/README | 10 - 3dparty/docs/HTTP_WebDAV_Server/dav.txt | 229 --- .../docs/HTTP_WebDAV_Server/db/Fileserver.sql | 49 - 3dparty/package.dtd | 110 - 3dparty/packages/Archive_Tar.xml | 122 -- 3dparty/packages/Console_Getopt.xml | 69 - 3dparty/packages/DB.xml | 348 ---- 3dparty/packages/Log.xml | 315 --- 3dparty/packages/Mail.xml | 122 -- 3dparty/packages/Mail_Mime.xml | 113 -- 3dparty/packages/Net_SMTP.xml | 137 -- 3dparty/packages/Net_Socket.xml | 84 - 3dparty/packages/PEAR.xml | 282 --- 3dparty/packages/PHPUnit.xml | 224 --- 3dparty/packages/XML_Parser.xml | 254 --- 3dparty/packages/XML_RPC.xml | 266 --- 3dparty/pearcmd.php | 318 --- 62 files changed, 17422 deletions(-) delete mode 100644 3dparty/Archive/Tar.php delete mode 100644 3dparty/Console/Getopt.php delete mode 100644 3dparty/Log.php delete mode 100644 3dparty/Log/composite.php delete mode 100644 3dparty/Log/console.php delete mode 100644 3dparty/Log/daemon.php delete mode 100644 3dparty/Log/display.php delete mode 100644 3dparty/Log/error_log.php delete mode 100644 3dparty/Log/file.php delete mode 100644 3dparty/Log/mail.php delete mode 100644 3dparty/Log/mcal.php delete mode 100644 3dparty/Log/null.php delete mode 100644 3dparty/Log/observer.php delete mode 100644 3dparty/Log/sql.php delete mode 100644 3dparty/Log/sqlite.php delete mode 100644 3dparty/Log/syslog.php delete mode 100644 3dparty/Log/win.php delete mode 100644 3dparty/Mail.php delete mode 100644 3dparty/Mail/RFC822.php delete mode 100644 3dparty/Mail/mail.php delete mode 100644 3dparty/Mail/mime.php delete mode 100644 3dparty/Mail/mimeDecode.php delete mode 100644 3dparty/Mail/mimePart.php delete mode 100644 3dparty/Mail/null.php delete mode 100644 3dparty/Mail/sendmail.php delete mode 100644 3dparty/Mail/smtp.php delete mode 100644 3dparty/Mail/xmail.dtd delete mode 100644 3dparty/Mail/xmail.xsl delete mode 100644 3dparty/Net/SMTP.php delete mode 100644 3dparty/Net/Socket.php delete mode 100644 3dparty/OS/Guess.php delete mode 100644 3dparty/PHPUnit.php delete mode 100644 3dparty/PHPUnit/Assert.php delete mode 100644 3dparty/PHPUnit/GUI/Gtk.php delete mode 100644 3dparty/PHPUnit/GUI/HTML.php delete mode 100644 3dparty/PHPUnit/GUI/SetupDecorator.php delete mode 100644 3dparty/PHPUnit/RepeatedTest.php delete mode 100644 3dparty/PHPUnit/Skeleton.php delete mode 100644 3dparty/PHPUnit/TestCase.php delete mode 100644 3dparty/PHPUnit/TestDecorator.php delete mode 100644 3dparty/PHPUnit/TestFailure.php delete mode 100644 3dparty/PHPUnit/TestListener.php delete mode 100644 3dparty/PHPUnit/TestResult.php delete mode 100644 3dparty/PHPUnit/TestSuite.php delete mode 100644 3dparty/System.php delete mode 100644 3dparty/docs/HTTP_WebDAV_Server/README delete mode 100644 3dparty/docs/HTTP_WebDAV_Server/dav.txt delete mode 100644 3dparty/docs/HTTP_WebDAV_Server/db/Fileserver.sql delete mode 100644 3dparty/package.dtd delete mode 100644 3dparty/packages/Archive_Tar.xml delete mode 100644 3dparty/packages/Console_Getopt.xml delete mode 100644 3dparty/packages/DB.xml delete mode 100644 3dparty/packages/Log.xml delete mode 100644 3dparty/packages/Mail.xml delete mode 100644 3dparty/packages/Mail_Mime.xml delete mode 100644 3dparty/packages/Net_SMTP.xml delete mode 100644 3dparty/packages/Net_Socket.xml delete mode 100644 3dparty/packages/PEAR.xml delete mode 100644 3dparty/packages/PHPUnit.xml delete mode 100644 3dparty/packages/XML_Parser.xml delete mode 100644 3dparty/packages/XML_RPC.xml delete mode 100644 3dparty/pearcmd.php diff --git a/3dparty/Archive/Tar.php b/3dparty/Archive/Tar.php deleted file mode 100644 index d6e6e29350e..00000000000 --- a/3dparty/Archive/Tar.php +++ /dev/null @@ -1,1762 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Tar.php,v 1.29 2005/03/17 21:02:31 vblavet Exp $ - -require_once 'PEAR.php'; - - -define ('ARCHIVE_TAR_ATT_SEPARATOR', 90001); - -/** -* Creates a (compressed) Tar archive -* -* @author Vincent Blavet -* @version $Revision: 1.29 $ -* @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 string Type of compression : 'none', 'gz' or 'bz2' - */ - var $_compress_type='none'; - - /** - * @var string Explode separator - */ - var $_separator=' '; - - /** - * @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 or bz2 compressed TAR file. - * - * @param string $p_tarname The name of the tar archive to create - * @param string $p_compress can be null, 'gz' or 'bz2'. This - * parameter indicates if gzip or bz2 compression - * is required. For compatibility reason the - * boolean value 'true' means 'gz'. - * @access public - */ - function Archive_Tar($p_tarname, $p_compress = null) - { - $this->PEAR(); - $this->_compress = false; - $this->_compress_type = 'none'; - if (($p_compress === null) || ($p_compress == '')) { - if (@file_exists($p_tarname)) { - if ($fp = @fopen($p_tarname, "rb")) { - // look for gzip magic cookie - $data = fread($fp, 2); - fclose($fp); - if ($data == "\37\213") { - $this->_compress = true; - $this->_compress_type = 'gz'; - // No sure it's enought for a magic code .... - } elseif ($data == "BZ") { - $this->_compress = true; - $this->_compress_type = 'bz2'; - } - } - } else { - // probably a remote file or some file accessible - // through a stream interface - if (substr($p_tarname, -2) == 'gz') { - $this->_compress = true; - $this->_compress_type = 'gz'; - } elseif ((substr($p_tarname, -3) == 'bz2') || - (substr($p_tarname, -2) == 'bz')) { - $this->_compress = true; - $this->_compress_type = 'bz2'; - } - } - } else { - if (($p_compress === true) || ($p_compress == 'gz')) { - $this->_compress = true; - $this->_compress_type = 'gz'; - } else if ($p_compress == 'bz2') { - $this->_compress = true; - $this->_compress_type = 'bz2'; - } else { - die("Unsupported compression type '$p_compress'\n". - "Supported types are 'gz' and 'bz2'.\n"); - return false; - } - } - $this->_tarname = $p_tarname; - if ($this->_compress) { // assert zlib or bz2 extension support - if ($this->_compress_type == 'gz') - $extname = 'zlib'; - else if ($this->_compress_type == 'bz2') - $extname = 'bz2'; - - if (!extension_loaded($extname)) { - PEAR::loadExtension($extname); - } - 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; - } - } - } - // }}} - - // {{{ 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); - $v_list_detail = 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($this->_separator, $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. - * - * @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 (!$this->_isArchive()) - $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($this->_separator, $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; - } - // }}} - - // {{{ addString() - /** - * This method add a single string as a file at the - * end of the existing archive. If the archive does not yet exists it - * is created. - * - * @param string $p_filename A string which contains the full - * filename path that will be associated - * with the string. - * @param string $p_string The content of the file added in - * the archive. - * @return true on success, false on error. - * @access public - */ - function addString($p_filename, $p_string) - { - $v_result = true; - - if (!$this->_isArchive()) { - if (!$this->_openWrite()) { - return false; - } - $this->_close(); - } - - if (!$this->_openAppend()) - return false; - - // Need to check the get back to the temporary file ? .... - $v_result = $this->_addString($p_filename, $p_string); - - $this->_writeFooter(); - - $this->_close(); - - 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; - } - // }}} - - // {{{ extractInString() - /** - * This method extract from the archive one file identified by $p_filename. - * The return value is a string with the file content, or NULL on error. - * @param string $p_filename The path of the file to extract in a string. - * @return a string with the file content or NULL. - * @access public - */ - function extractInString($p_filename) - { - if ($this->_openRead()) { - $v_result = $this->_extractInString($p_filename); - $this->_close(); - } else { - $v_result = NULL; - } - - 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($this->_separator, $p_filelist); - else { - $this->_error('Invalid string list'); - return false; - } - - if ($v_result = $this->_openRead()) { - $v_result = $this->_extractList($p_path, $v_list_detail, "partial", - $v_list, $p_remove_path); - $this->_close(); - } - - return $v_result; - } - // }}} - - // {{{ setAttribute() - /** - * This method set specific attributes of the archive. It uses a variable - * list of parameters, in the format attribute code + attribute values : - * $arch->setAttribute(ARCHIVE_TAR_ATT_SEPARATOR, ','); - * @param mixed $argv variable list of attributes and values - * @return true on success, false on error. - * @access public - */ - function setAttribute() - { - $v_result = true; - - // ----- Get the number of variable list of arguments - if (($v_size = func_num_args()) == 0) { - return true; - } - - // ----- Get the arguments - $v_att_list = &func_get_args(); - - // ----- Read the attributes - $i=0; - while ($i<$v_size) { - - // ----- Look for next option - switch ($v_att_list[$i]) { - // ----- Look for options that request a string value - case ARCHIVE_TAR_ATT_SEPARATOR : - // ----- Check the number of parameters - if (($i+1) >= $v_size) { - $this->_error('Invalid number of parameters for ' - .'attribute ARCHIVE_TAR_ATT_SEPARATOR'); - return false; - } - - // ----- Get the value - $this->_separator = $v_att_list[$i+1]; - $i++; - break; - - default : - $this->_error('Unknow attribute code '.$v_att_list[$i].''); - return false; - } - - // ----- Next attribute - $i++; - } - - 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); - } - // }}} - - // {{{ _isArchive() - function _isArchive($p_filename=NULL) - { - if ($p_filename == NULL) { - $p_filename = $this->_tarname; - } - clearstatcache(); - return @is_file($p_filename); - } - // }}} - - // {{{ _openWrite() - function _openWrite() - { - if ($this->_compress_type == 'gz') - $this->_file = @gzopen($this->_tarname, "wb9"); - else if ($this->_compress_type == 'bz2') - $this->_file = @bzopen($this->_tarname, "wb"); - else if ($this->_compress_type == 'none') - $this->_file = @fopen($this->_tarname, "wb"); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - - 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_type == 'gz') - $this->_file = @gzopen($v_filename, "rb"); - else if ($this->_compress_type == 'bz2') - $this->_file = @bzopen($v_filename, "rb"); - else if ($this->_compress_type == 'none') - $this->_file = @fopen($v_filename, "rb"); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - - if ($this->_file == 0) { - $this->_error('Unable to open in read mode \''.$v_filename.'\''); - return false; - } - - return true; - } - // }}} - - // {{{ _openReadWrite() - function _openReadWrite() - { - if ($this->_compress_type == 'gz') - $this->_file = @gzopen($this->_tarname, "r+b"); - else if ($this->_compress_type == 'bz2') - $this->_file = @bzopen($this->_tarname, "r+b"); - else if ($this->_compress_type == 'none') - $this->_file = @fopen($this->_tarname, "r+b"); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - - 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 (is_resource($this->_file)) { - if ($this->_compress_type == 'gz') - @gzclose($this->_file); - else if ($this->_compress_type == 'bz2') - @bzclose($this->_file); - else if ($this->_compress_type == 'none') - @fclose($this->_file); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - - $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; - } - // }}} - - // {{{ _writeBlock() - function _writeBlock($p_binary_data, $p_len=null) - { - if (is_resource($this->_file)) { - if ($p_len === null) { - if ($this->_compress_type == 'gz') - @gzputs($this->_file, $p_binary_data); - else if ($this->_compress_type == 'bz2') - @bzwrite($this->_file, $p_binary_data); - else if ($this->_compress_type == 'none') - @fputs($this->_file, $p_binary_data); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - } else { - if ($this->_compress_type == 'gz') - @gzputs($this->_file, $p_binary_data, $p_len); - else if ($this->_compress_type == 'bz2') - @bzwrite($this->_file, $p_binary_data, $p_len); - else if ($this->_compress_type == 'none') - @fputs($this->_file, $p_binary_data, $p_len); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - - } - } - return true; - } - // }}} - - // {{{ _readBlock() - function _readBlock() - { - $v_block = null; - if (is_resource($this->_file)) { - if ($this->_compress_type == 'gz') - $v_block = @gzread($this->_file, 512); - else if ($this->_compress_type == 'bz2') - $v_block = @bzread($this->_file, 512); - else if ($this->_compress_type == 'none') - $v_block = @fread($this->_file, 512); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - } - return $v_block; - } - // }}} - - // {{{ _jumpBlock() - function _jumpBlock($p_len=null) - { - if (is_resource($this->_file)) { - if ($p_len === null) - $p_len = 1; - - if ($this->_compress_type == 'gz') { - @gzseek($this->_file, @gztell($this->_file)+($p_len*512)); - } - else if ($this->_compress_type == 'bz2') { - // ----- Replace missing bztell() and bzseek() - for ($i=0; $i<$p_len; $i++) - $this->_readBlock(); - } else if ($this->_compress_type == 'none') - @fseek($this->_file, @ftell($this->_file)+($p_len*512)); - else - $this->_error('Unknown or missing compression type (' - .$this->_compress_type.')'); - - } - return true; - } - // }}} - - // {{{ _writeFooter() - function _writeFooter() - { - if (is_resource($this->_file)) { - // ----- Write the last 0 filled block for end of archive - $v_binary_data = pack("a512", ''); - $this->_writeBlock($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; - - foreach ($p_list as $v_filename) { - if (!$v_result) { - break; - } - - // ----- 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; - } - while (false !== ($p_hitem = readdir($p_hdir))) { - if (($p_hitem != '.') && ($p_hitem != '..')) { - 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 ($this->_isArchive($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"); - $this->_writeBlock($v_binary_data); - } - - fclose($v_file); - - } else { - // ----- Only header for dir - if (!$this->_writeHeader($p_filename, $v_stored_filename)) - return false; - } - - return true; - } - // }}} - - // {{{ _addString() - function _addString($p_filename, $p_string) - { - 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);; - - if (!$this->_writeHeaderBlock($p_filename, strlen($p_string), - 0, 0, "", 0, 0)) - return false; - - $i=0; - while (($v_buffer = substr($p_string, (($i++)*512), 512)) != '') { - $v_binary_data = pack("a512", $v_buffer); - $this->_writeBlock($v_binary_data); - } - - 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); - - if (strlen($v_reduce_filename) > 99) { - if (!$this->_writeLongHeader($v_reduce_filename)) - return false; - } - - $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 - $this->_writeBlock($v_binary_data_first, 148); - - // ----- Write the calculated checksum - $v_checksum = sprintf("%6s ", DecOct($v_checksum)); - $v_binary_data = pack("a8", $v_checksum); - $this->_writeBlock($v_binary_data, 8); - - // ----- Write the last 356 bytes of the header in the archive - $this->_writeBlock($v_binary_data_last, 356); - - return true; - } - // }}} - - // {{{ _writeHeaderBlock() - function _writeHeaderBlock($p_filename, $p_size, $p_mtime=0, $p_perms=0, - $p_type='', $p_uid=0, $p_gid=0) - { - $p_filename = $this->_pathReduction($p_filename); - - if (strlen($p_filename) > 99) { - if (!$this->_writeLongHeader($p_filename)) - return false; - } - - if ($p_type == "5") { - $v_size = sprintf("%11s ", DecOct(0)); - } else { - $v_size = sprintf("%11s ", DecOct($p_size)); - } - - $v_uid = sprintf("%6s ", DecOct($p_uid)); - $v_gid = sprintf("%6s ", DecOct($p_gid)); - $v_perms = sprintf("%6s ", DecOct($p_perms)); - - $v_mtime = sprintf("%11s", DecOct($p_mtime)); - - $v_linkname = ''; - - $v_magic = ''; - - $v_version = ''; - - $v_uname = ''; - - $v_gname = ''; - - $v_devmajor = ''; - - $v_devminor = ''; - - $v_prefix = ''; - - $v_binary_data_first = pack("a100a8a8a8a12A12", - $p_filename, $v_perms, $v_uid, $v_gid, - $v_size, $v_mtime); - $v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", - $p_type, $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 - $this->_writeBlock($v_binary_data_first, 148); - - // ----- Write the calculated checksum - $v_checksum = sprintf("%6s ", DecOct($v_checksum)); - $v_binary_data = pack("a8", $v_checksum); - $this->_writeBlock($v_binary_data, 8); - - // ----- Write the last 356 bytes of the header in the archive - $this->_writeBlock($v_binary_data_last, 356); - - return true; - } - // }}} - - // {{{ _writeLongHeader() - function _writeLongHeader($p_filename) - { - $v_size = sprintf("%11s ", DecOct(strlen($p_filename))); - - $v_typeflag = 'L'; - - $v_linkname = ''; - - $v_magic = ''; - - $v_version = ''; - - $v_uname = ''; - - $v_gname = ''; - - $v_devmajor = ''; - - $v_devminor = ''; - - $v_prefix = ''; - - $v_binary_data_first = pack("a100a8a8a8a12A12", - '././@LongLink', 0, 0, 0, $v_size, 0); - $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 - $this->_writeBlock($v_binary_data_first, 148); - - // ----- Write the calculated checksum - $v_checksum = sprintf("%6s ", DecOct($v_checksum)); - $v_binary_data = pack("a8", $v_checksum); - $this->_writeBlock($v_binary_data, 8); - - // ----- Write the last 356 bytes of the header in the archive - $this->_writeBlock($v_binary_data_last, 356); - - // ----- Write the filename as content of the block - $i=0; - while (($v_buffer = substr($p_filename, (($i++)*512), 512)) != '') { - $v_binary_data = pack("a512", "$v_buffer"); - $this->_writeBlock($v_binary_data); - } - - 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 for file "'.$v_data['filename'] - .'" : '.$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; - } - // }}} - - // {{{ _readLongHeader() - function _readLongHeader(&$v_header) - { - $v_filename = ''; - $n = floor($v_header['size']/512); - for ($i=0; $i<$n; $i++) { - $v_content = $this->_readBlock(); - $v_filename .= $v_content; - } - if (($v_header['size'] % 512) != 0) { - $v_content = $this->_readBlock(); - $v_filename .= $v_content; - } - - // ----- Read the next header - $v_binary_data = $this->_readBlock(); - - if (!$this->_readHeader($v_binary_data, $v_header)) - return false; - - $v_header['filename'] = $v_filename; - - return true; - } - // }}} - - // {{{ _extractInString() - /** - * This method extract from the archive one file identified by $p_filename. - * The return value is a string with the file content, or NULL on error. - * @param string $p_filename The path of the file to extract in a string. - * @return a string with the file content or NULL. - * @access private - */ - function _extractInString($p_filename) - { - $v_result_str = ""; - - While (strlen($v_binary_data = $this->_readBlock()) != 0) - { - if (!$this->_readHeader($v_binary_data, $v_header)) - return NULL; - - if ($v_header['filename'] == '') - continue; - - // ----- Look for long filename - if ($v_header['typeflag'] == 'L') { - if (!$this->_readLongHeader($v_header)) - return NULL; - } - - if ($v_header['filename'] == $p_filename) { - if ($v_header['typeflag'] == "5") { - $this->_error('Unable to extract in string a directory ' - .'entry {'.$v_header['filename'].'}'); - return NULL; - } else { - $n = floor($v_header['size']/512); - for ($i=0; $i<$n; $i++) { - $v_result_str .= $this->_readBlock(); - } - if (($v_header['size'] % 512) != 0) { - $v_content = $this->_readBlock(); - $v_result_str .= substr($v_content, 0, - ($v_header['size'] % 512)); - } - return $v_result_str; - } - } else { - $this->_jumpBlock(ceil(($v_header['size']/512))); - } - } - - return NULL; - } - // }}} - - // {{{ _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 (strlen($v_binary_data = $this->_readBlock()) != 0) - { - $v_extract_file = FALSE; - $v_extraction_stopped = 0; - - if (!$this->_readHeader($v_binary_data, $v_header)) - return false; - - if ($v_header['filename'] == '') { - continue; - } - - // ----- Look for long filename - if ($v_header['typeflag'] == 'L') { - if (!$this->_readLongHeader($v_header)) - return false; - } - - 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 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 ( ($this->_isArchive($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++) { - $v_content = $this->_readBlock(); - fwrite($v_dest_file, $v_content, 512); - } - if (($v_header['size'] % 512) != 0) { - $v_content = $this->_readBlock(); - 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_header['filename']) - .'\' ('.$v_header['size'] - .' expected). Archive may be corrupted.'); - return false; - } - } - } else { - $this->_jumpBlock(ceil(($v_header['size']/512))); - } - } else { - $this->_jumpBlock(ceil(($v_header['size']/512))); - } - - /* TBC : Seems to be unused ... - 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; - } - // }}} - - // {{{ _openAppend() - function _openAppend() - { - if (filesize($this->_tarname) == 0) - return $this->_openWrite(); - - 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 ($this->_compress_type == 'gz') - $v_temp_tar = @gzopen($this->_tarname.".tmp", "rb"); - elseif ($this->_compress_type == 'bz2') - $v_temp_tar = @bzopen($this->_tarname.".tmp", "rb"); - - if ($v_temp_tar == 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; - } - - if ($this->_compress_type == 'gz') { - $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); - $this->_writeBlock($v_binary_data); - $v_buffer = @gzread($v_temp_tar, 512); - - } while (!@gzeof($v_temp_tar)); - } - - @gzclose($v_temp_tar); - } - elseif ($this->_compress_type == 'bz2') { - $v_buffered_lines = array(); - $v_buffered_lines[] = @bzread($v_temp_tar, 512); - - // ----- Read the following blocks but not the last one - while (strlen($v_buffered_lines[] - = @bzread($v_temp_tar, 512)) > 0) { - $v_binary_data = pack("a512", - array_shift($v_buffered_lines)); - $this->_writeBlock($v_binary_data); - } - - @bzclose($v_temp_tar); - } - - if (!@unlink($this->_tarname.".tmp")) { - $this->_error('Error while deleting temporary file \'' - .$this->_tarname.'.tmp\''); - } - - } else { - // ----- 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); - } - - return true; - } - // }}} - - // {{{ _append() - function _append($p_filelist, $p_add_dir='', $p_remove_dir='') - { - if (!$this->_openAppend()) - return false; - - 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", - * rand emove 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; - } - // }}} - -} -?> diff --git a/3dparty/Console/Getopt.php b/3dparty/Console/Getopt.php deleted file mode 100644 index aec980b34d5..00000000000 --- a/3dparty/Console/Getopt.php +++ /dev/null @@ -1,251 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Getopt.php,v 1.21.4.7 2003/12/05 21:57:01 andrei Exp $ - -require_once( 'PEAR.php'); - -/** - * Command-line options parsing class. - * - * @author Andrei Zmievski - * - */ -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 getopt2($args, $short_options, $long_options = null) - { - return Console_Getopt::doGetopt(2, $args, $short_options, $long_options); - } - - /** - * This function expects $args to start with the script name (POSIX-style). - * Preserved for backwards compatibility. - * @see getopt2() - */ - function getopt($args, $short_options, $long_options = null) - { - return Console_Getopt::doGetopt(1, $args, $short_options, $long_options); - } - - /** - * The actual implementation of the argument parsing code. - */ - function doGetopt($version, $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); - } - - /* - * Preserve backwards compatibility with callers that relied on - * erroneous POSIX fix. - */ - if ($version < 2) { - 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 (!strlen($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/3dparty/Log.php b/3dparty/Log.php deleted file mode 100644 index 8f084640bc9..00000000000 --- a/3dparty/Log.php +++ /dev/null @@ -1,635 +0,0 @@ - - * @author Jon Parise - * @since Horde 1.3 - * @package Log - */ -class Log -{ - /** - * Indicates whether or not the log can been opened / connected. - * - * @var boolean - * @access private - */ - var $_opened = false; - - /** - * Instance-specific unique identification number. - * - * @var integer - * @access private - */ - var $_id = 0; - - /** - * The label that uniquely identifies this set of log messages. - * - * @var string - * @access private - */ - var $_ident = ''; - - /** - * The default priority to use when logging an event. - * - * @var integer - * @access private - */ - var $_priority = PEAR_LOG_INFO; - - /** - * The bitmask of allowed log levels. - * @var integer - * @access private - */ - var $_mask = PEAR_LOG_ALL; - - /** - * Holds all Log_observer objects that wish to be notified of new messages. - * - * @var array - * @access private - */ - var $_listeners = array(); - - - /** - * Attempts to return a concrete Log instance of type $handler. - * - * @param string $handler The type of concrete Log subclass to return. - * Attempt to dynamically include the code for - * this subclass. Currently, valid values are - * 'console', 'syslog', 'sql', 'file', and 'mcal'. - * - * @param string $name The name of the actually log file, table, or - * other specific store to use. Defaults to an - * empty string, with which the subclass will - * attempt to do something intelligent. - * - * @param string $ident The identity reported to the log system. - * - * @param array $conf A hash containing any additional configuration - * information that a subclass might need. - * - * @param int $level Log messages up to and including this level. - * - * @return object Log The newly created concrete Log instance, or an - * false on an error. - * @access public - * @since Log 1.0 - */ - function &factory($handler, $name = '', $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $handler = strtolower($handler); - $class = 'Log_' . $handler; - $classfile = 'Log/' . $handler . '.php'; - - /* - * Attempt to include our version of the named class, but don't treat - * a failure as fatal. The caller may have already included their own - * version of the named class. - */ - @include_once $classfile; - - /* If the class exists, return a new instance of it. */ - if (class_exists($class)) { - return new $class($name, $ident, $conf, $level); - } - - return false; - } - - /** - * Attempts to return a reference to a concrete Log instance of type - * $handler, only creating a new instance if no log instance with the same - * parameters currently exists. - * - * You should use this if there are multiple places you might create a - * logger, you don't want to create multiple loggers, and you don't want to - * check for the existance of one each time. The singleton pattern does all - * the checking work for you. - * - * You MUST call this method with the $var = &Log::singleton() syntax. - * Without the ampersand (&) in front of the method name, you will not get - * a reference, you will get a copy. - * - * @param string $handler The type of concrete Log subclass to return. - * Attempt to dynamically include the code for - * this subclass. Currently, valid values are - * 'console', 'syslog', 'sql', 'file', and 'mcal'. - * - * @param string $name The name of the actually log file, table, or - * other specific store to use. Defaults to an - * empty string, with which the subclass will - * attempt to do something intelligent. - * - * @param string $ident The identity reported to the log system. - * - * @param array $conf A hash containing any additional configuration - * information that a subclass might need. - * - * @param int $level Log messages up to and including this level. - * - * @return object Log The newly created concrete Log instance, or an - * false on an error. - * @access public - * @since Log 1.0 - */ - function &singleton($handler, $name = '', $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - static $instances; - if (!isset($instances)) $instances = array(); - - $signature = serialize(array($handler, $name, $ident, $conf, $level)); - if (!isset($instances[$signature])) { - $instances[$signature] = &Log::factory($handler, $name, $ident, - $conf, $level); - } - - return $instances[$signature]; - } - - /** - * Abstract implementation of the open() method. - * @since Log 1.0 - */ - function open() - { - return false; - } - - /** - * Abstract implementation of the close() method. - * @since Log 1.0 - */ - function close() - { - return false; - } - - /** - * Abstract implementation of the flush() method. - * @since Log 1.8.2 - */ - function flush() - { - return false; - } - - /** - * Abstract implementation of the log() method. - * @since Log 1.0 - */ - function log($message, $priority = null) - { - return false; - } - - /** - * A convenience function for logging a emergency event. It will log a - * message at the PEAR_LOG_EMERG log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function emerg($message) - { - return $this->log($message, PEAR_LOG_EMERG); - } - - /** - * A convenience function for logging an alert event. It will log a - * message at the PEAR_LOG_ALERT log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function alert($message) - { - return $this->log($message, PEAR_LOG_ALERT); - } - - /** - * A convenience function for logging a critical event. It will log a - * message at the PEAR_LOG_CRIT log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function crit($message) - { - return $this->log($message, PEAR_LOG_CRIT); - } - - /** - * A convenience function for logging a error event. It will log a - * message at the PEAR_LOG_ERR log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function err($message) - { - return $this->log($message, PEAR_LOG_ERR); - } - - /** - * A convenience function for logging a warning event. It will log a - * message at the PEAR_LOG_WARNING log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function warning($message) - { - return $this->log($message, PEAR_LOG_WARNING); - } - - /** - * A convenience function for logging a notice event. It will log a - * message at the PEAR_LOG_NOTICE log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function notice($message) - { - return $this->log($message, PEAR_LOG_NOTICE); - } - - /** - * A convenience function for logging a information event. It will log a - * message at the PEAR_LOG_INFO log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function info($message) - { - return $this->log($message, PEAR_LOG_INFO); - } - - /** - * A convenience function for logging a debug event. It will log a - * message at the PEAR_LOG_DEBUG log level. - * - * @param mixed $message String or object containing the message - * to log. - * - * @return boolean True if the message was successfully logged. - * - * @access public - * @since Log 1.7.0 - */ - function debug($message) - { - return $this->log($message, PEAR_LOG_DEBUG); - } - - /** - * Returns the string representation of the message data. - * - * If $message is an object, _extractMessage() will attempt to extract - * the message text using a known method (such as a PEAR_Error object's - * getMessage() method). If a known method, cannot be found, the - * serialized representation of the object will be returned. - * - * If the message data is already a string, it will be returned unchanged. - * - * @param mixed $message The original message data. This may be a - * string or any object. - * - * @return string The string representation of the message. - * - * @access private - */ - function _extractMessage($message) - { - /* - * If we've been given an object, attempt to extract the message using - * a known method. If we can't find such a method, default to the - * "human-readable" version of the object. - * - * We also use the human-readable format for arrays. - */ - if (is_object($message)) { - if (method_exists($message, 'getmessage')) { - $message = $message->getMessage(); - } else if (method_exists($message, 'tostring')) { - $message = $message->toString(); - } else if (method_exists($message, '__tostring')) { - $message = (string)$message; - } else { - $message = print_r($message, true); - } - } else if (is_array($message)) { - if (isset($message['message'])) { - $message = $message['message']; - } else { - $message = print_r($message, true); - } - } - - /* Otherwise, we assume the message is a string. */ - return $message; - } - - /** - * Returns the string representation of a PEAR_LOG_* integer constant. - * - * @param int $priority A PEAR_LOG_* integer constant. - * - * @return string The string representation of $level. - * - * @since Log 1.0 - */ - function priorityToString($priority) - { - $levels = array( - PEAR_LOG_EMERG => 'emergency', - PEAR_LOG_ALERT => 'alert', - PEAR_LOG_CRIT => 'critical', - PEAR_LOG_ERR => 'error', - PEAR_LOG_WARNING => 'warning', - PEAR_LOG_NOTICE => 'notice', - PEAR_LOG_INFO => 'info', - PEAR_LOG_DEBUG => 'debug' - ); - - return $levels[$priority]; - } - - /** - * Calculate the log mask for the given priority. - * - * @param integer $priority The priority whose mask will be calculated. - * - * @return integer The calculated log mask. - * - * @access public - * @since Log 1.7.0 - */ - function MASK($priority) - { - return (1 << $priority); - } - - /** - * Calculate the log mask for all priorities up to the given priority. - * - * @param integer $priority The maximum priority covered by this mask. - * - * @return integer The calculated log mask. - * - * @access public - * @since Log 1.7.0 - */ - function UPTO($priority) - { - return ((1 << ($priority + 1)) - 1); - } - - /** - * Set and return the level mask for the current Log instance. - * - * @param integer $mask A bitwise mask of log levels. - * - * @return integer The current level mask. - * - * @access public - * @since Log 1.7.0 - */ - function setMask($mask) - { - $this->_mask = $mask; - - return $this->_mask; - } - - /** - * Returns the current level mask. - * - * @return interger The current level mask. - * - * @access public - * @since Log 1.7.0 - */ - function getMask() - { - return $this->_mask; - } - - /** - * Check if the given priority is included in the current level mask. - * - * @param integer $priority The priority to check. - * - * @return boolean True if the given priority is included in the current - * log mask. - * - * @access private - * @since Log 1.7.0 - */ - function _isMasked($priority) - { - return (Log::MASK($priority) & $this->_mask); - } - - /** - * Returns the current default priority. - * - * @return integer The current default priority. - * - * @access public - * @since Log 1.8.4 - */ - function getPriority() - { - return $this->_priority; - } - - /** - * Sets the default priority to the specified value. - * - * @param integer $priority The new default priority. - * - * @access public - * @since Log 1.8.4 - */ - function setPriority($priority) - { - $this->_priority = $priority; - } - - /** - * Adds a Log_observer instance to the list of observers that are listening - * for messages emitted by this Log instance. - * - * @param object $observer The Log_observer instance to attach as a - * listener. - * - * @param boolean True if the observer is successfully attached. - * - * @access public - * @since Log 1.0 - */ - function attach(&$observer) - { - if (!is_a($observer, 'Log_observer')) { - return false; - } - - $this->_listeners[$observer->_id] = &$observer; - - return true; - } - - /** - * Removes a Log_observer instance from the list of observers. - * - * @param object $observer The Log_observer instance to detach from - * the list of listeners. - * - * @param boolean True if the observer is successfully detached. - * - * @access public - * @since Log 1.0 - */ - function detach($observer) - { - if (!is_a($observer, 'Log_observer') || - !isset($this->_listeners[$observer->_id])) { - return false; - } - - unset($this->_listeners[$observer->_id]); - - return true; - } - - /** - * Informs each registered observer instance that a new message has been - * logged. - * - * @param array $event A hash describing the log event. - * - * @access private - */ - function _announce($event) - { - foreach ($this->_listeners as $id => $listener) { - if ($event['priority'] <= $this->_listeners[$id]->_priority) { - $this->_listeners[$id]->notify($event); - } - } - } - - /** - * Indicates whether this is a composite class. - * - * @return boolean True if this is a composite class. - * - * @access public - * @since Log 1.0 - */ - function isComposite() - { - return false; - } - - /** - * Sets this Log instance's identification string. - * - * @param string $ident The new identification string. - * - * @access public - * @since Log 1.6.3 - */ - function setIdent($ident) - { - $this->_ident = $ident; - } - - /** - * Returns the current identification string. - * - * @return string The current Log instance's identification string. - * - * @access public - * @since Log 1.6.3 - */ - function getIdent() - { - return $this->_ident; - } -} - -?> diff --git a/3dparty/Log/composite.php b/3dparty/Log/composite.php deleted file mode 100644 index 104c8966c42..00000000000 --- a/3dparty/Log/composite.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @author Jon Parise - * - * @since Horde 1.3 - * @since Log 1.0 - * @package Log - * - * @example composite.php Using the composite handler. - */ -class Log_composite extends Log -{ - /** - * Array holding all of the Log instances to which log events should be - * sent. - * - * @var array - * @access private - */ - var $_children = array(); - - - /** - * Constructs a new composite Log object. - * - * @param boolean $name This parameter is ignored. - * @param boolean $ident This parameter is ignored. - * @param boolean $conf This parameter is ignored. - * @param boolean $level This parameter is ignored. - * - * @access public - */ - function Log_composite($name = false, $ident = false, $conf = false, - $level = PEAR_LOG_DEBUG) - { - } - - /** - * Opens the child connections. - * - * @access public - */ - function open() - { - if (!$this->_opened) { - foreach ($this->_children as $id => $child) { - $this->_children[$id]->open(); - } - $this->_opened = true; - } - } - - /** - * Closes any child instances. - * - * @access public - */ - function close() - { - if ($this->_opened) { - foreach ($this->_children as $id => $child) { - $this->_children[$id]->close(); - } - $this->_opened = false; - } - } - - /** - * Flushes all open child instances. - * - * @access public - * @since Log 1.8.2 - */ - function flush() - { - if ($this->_opened) { - foreach ($this->_children as $id => $child) { - $this->_children[$id]->flush(); - } - } - } - - /** - * Sends $message and $priority to each child of this composite. - * - * @param mixed $message String or object containing the message - * to log. - * @param string $priority (optional) The priority of the message. - * Valid values are: PEAR_LOG_EMERG, - * PEAR_LOG_ALERT, PEAR_LOG_CRIT, - * PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and - * PEAR_LOG_DEBUG. - * - * @return boolean True if the entry is successfully logged. - * - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - foreach ($this->_children as $id => $child) { - $this->_children[$id]->log($message, $priority); - } - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } - - /** - * Returns true if this is a composite. - * - * @return boolean True if this is a composite class. - * - * @access public - */ - function isComposite() - { - return true; - } - - /** - * Sets this identification string for all of this composite's children. - * - * @param string $ident The new identification string. - * - * @access public - * @since Log 1.6.7 - */ - function setIdent($ident) - { - foreach ($this->_children as $id => $child) { - $this->_children[$id]->setIdent($ident); - } - } - - /** - * Adds a Log instance to the list of children. - * - * @param object $child The Log instance to add. - * - * @return boolean True if the Log instance was successfully added. - * - * @access public - */ - function addChild(&$child) - { - /* Make sure this is a Log instance. */ - if (!is_a($child, 'Log')) { - return false; - } - - $this->_children[$child->_id] = &$child; - - return true; - } - - /** - * Removes a Log instance from the list of children. - * - * @param object $child The Log instance to remove. - * - * @return boolean True if the Log instance was successfully removed. - * - * @access public - */ - function removeChild($child) - { - if (!is_a($child, 'Log') || !isset($this->_children[$child->_id])) { - return false; - } - - unset($this->_children[$child->_id]); - - return true; - } -} - -?> diff --git a/3dparty/Log/console.php b/3dparty/Log/console.php deleted file mode 100644 index 62032e79644..00000000000 --- a/3dparty/Log/console.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @since Log 1.1 - * @package Log - * - * @example console.php Using the console handler. - */ -class Log_console extends Log -{ - /** - * Handle to the current output stream. - * @var resource - * @access private - */ - var $_stream = STDOUT; - - /** - * Should the output be buffered or displayed immediately? - * @var string - * @access private - */ - var $_buffering = false; - - /** - * String holding the buffered output. - * @var string - * @access private - */ - var $_buffer = ''; - - /** - * String containing the format of a log line. - * @var string - * @access private - */ - var $_lineFormat = '%1$s %2$s [%3$s] %4$s'; - - /** - * String containing the timestamp format. It will be passed directly to - * strftime(). Note that the timestamp string will generated using the - * current locale. - * @var string - * @access private - */ - var $_timeFormat = '%b %d %H:%M:%S'; - - /** - * Hash that maps canonical format keys to position arguments for the - * "line format" string. - * @var array - * @access private - */ - var $_formatMap = array('%{timestamp}' => '%1$s', - '%{ident}' => '%2$s', - '%{priority}' => '%3$s', - '%{message}' => '%4$s', - '%\{' => '%%{'); - - /** - * Constructs a new Log_console object. - * - * @param string $name Ignored. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_console($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (!empty($conf['stream'])) { - $this->_stream = $conf['stream']; - } - - if (isset($conf['buffering'])) { - $this->_buffering = $conf['buffering']; - } - - if (!empty($conf['lineFormat'])) { - $this->_lineFormat = str_replace(array_keys($this->_formatMap), - array_values($this->_formatMap), - $conf['lineFormat']); - } - - if (!empty($conf['timeFormat'])) { - $this->_timeFormat = $conf['timeFormat']; - } - - /* - * If output buffering has been requested, we need to register a - * shutdown function that will dump the buffer upon termination. - */ - if ($this->_buffering) { - register_shutdown_function(array(&$this, '_Log_console')); - } - } - - /** - * Destructor - */ - function _Log_console() - { - $this->flush(); - } - - /** - * Flushes all pending ("buffered") data to the output stream. - * - * @access public - * @since Log 1.8.2 - */ - function flush() - { - /* - * If output buffering is enabled, dump the contents of the buffer to - * the output stream. - */ - if ($this->_buffering && (strlen($this->_buffer) > 0)) { - fwrite($this->_stream, $this->_buffer); - $this->_buffer = ''; - } - - return fflush($this->_stream); - } - - /** - * Writes $message to the text console. Also, passes the message - * along to any Log_observer instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - /* Build the string containing the complete log line. */ - $line = sprintf($this->_lineFormat, strftime($this->_timeFormat), - $this->_ident, $this->priorityToString($priority), - $message) . "\n"; - - /* - * If buffering is enabled, append this line to the output buffer. - * Otherwise, print the line to the output stream immediately. - */ - if ($this->_buffering) { - $this->_buffer .= $line; - } else { - fwrite($this->_stream, $line); - } - - /* Notify observers about this log message. */ - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } -} - -?> diff --git a/3dparty/Log/daemon.php b/3dparty/Log/daemon.php deleted file mode 100644 index 739270c9a32..00000000000 --- a/3dparty/Log/daemon.php +++ /dev/null @@ -1,229 +0,0 @@ - - * @version $Revision: 1.1 $ - * @package Log - */ -class Log_daemon extends Log { - - /** - * Integer holding the log facility to use. - * @var string - */ - var $_name = LOG_DAEMON; - - /** - * Var holding the resource pointer to the socket - * @var resource - */ - var $_socket; - - /** - * The ip address or servername - * @see http://www.php.net/manual/en/transports.php - * @var string - */ - var $_ip = '127.0.0.1'; - - /** - * Protocol to use (tcp, udp, etc.) - * @see http://www.php.net/manual/en/transports.php - * @var string - */ - var $_proto = 'udp'; - - /** - * Port to connect to - * @var int - */ - var $_port = 514; - - /** - * Maximum message length in bytes - * @var int - */ - var $_maxsize = 4096; - - /** - * Socket timeout in seconds - * @var int - */ - var $_timeout = 1; - - - /** - * Constructs a new syslog object. - * - * @param string $name The syslog facility. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $maxLevel Maximum level at which to log. - * @access public - */ - function Log_daemon($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - /* Ensure we have a valid integer value for $name. */ - if (empty($name) || !is_int($name)) { - $name = LOG_SYSLOG; - } - - $this->_id = md5(microtime()); - $this->_name = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (isset($conf['ip'])) { - $this->_ip = $conf['ip']; - } - if (isset($conf['proto'])) { - $this->_proto = $conf['proto']; - } - if (isset($conf['port'])) { - $this->_port = $conf['port']; - } - if (isset($conf['maxsize'])) { - $this->_maxsize = $conf['maxsize']; - } - if (isset($conf['timeout'])) { - $this->_timeout = $conf['timeout']; - } - $this->_proto = $this->_proto . '://'; - - register_shutdown_function(array(&$this, '_Log_daemon')); - } - - /** - * Destructor. - * - * @access private - */ - function _Log_daemon() - { - $this->close(); - } - - /** - * Opens a connection to the system logger, if it has not already - * been opened. This is implicitly called by log(), if necessary. - * @access public - */ - function open() - { - if (!$this->_opened) { - $this->_opened = (bool)($this->_socket = @fsockopen( - $this->_proto . $this->_ip, - $this->_port, - $errno, - $errstr, - $this->_timeout)); - } - return $this->_opened; - } - - /** - * Closes the connection to the system logger, if it is open. - * @access public - */ - function close() - { - if ($this->_opened) { - $this->_opened = false; - return fclose($this->_socket); - } - return true; - } - - /** - * Sends $message to the currently open syslog connection. Calls - * open() if necessary. Also passes the message along to any Log_observer - * instances that are observing this Log. - * - * @param string $message The textual message to be logged. - * @param int $priority (optional) The priority of the message. Valid - * values are: LOG_EMERG, LOG_ALERT, LOG_CRIT, - * LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, - * and LOG_DEBUG. The default is LOG_INFO. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* If the connection isn't open and can't be opened, return failure. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - /* Set the facility level. */ - $facility_level = intval($this->_name) + - intval($this->_toSyslog($priority)); - - /* Prepend ident info. */ - if (!empty($this->_ident)) { - $message = $this->_ident . ' ' . $message; - } - - /* Check for message length. */ - if (strlen($message) > $this->_maxsize) { - $message = substr($message, 0, ($this->_maxsize) - 10) . ' [...]'; - } - - /* Write to socket. */ - fwrite($this->_socket, '<' . $facility_level . '>' . $message . "\n"); - - $this->_announce(array('priority' => $priority, 'message' => $message)); - } - - /** - * Converts a PEAR_LOG_* constant into a syslog LOG_* constant. - * - * This function exists because, under Windows, not all of the LOG_* - * constants have unique values. Instead, the PEAR_LOG_* were introduced - * for global use, with the conversion to the LOG_* constants kept local to - * to the syslog driver. - * - * @param int $priority PEAR_LOG_* value to convert to LOG_* value. - * - * @return The LOG_* representation of $priority. - * - * @access private - */ - function _toSyslog($priority) - { - static $priorities = array( - PEAR_LOG_EMERG => LOG_EMERG, - PEAR_LOG_ALERT => LOG_ALERT, - PEAR_LOG_CRIT => LOG_CRIT, - PEAR_LOG_ERR => LOG_ERR, - PEAR_LOG_WARNING => LOG_WARNING, - PEAR_LOG_NOTICE => LOG_NOTICE, - PEAR_LOG_INFO => LOG_INFO, - PEAR_LOG_DEBUG => LOG_DEBUG - ); - - /* If we're passed an unknown priority, default to LOG_INFO. */ - if (!is_int($priority) || !in_array($priority, $priorities)) { - return LOG_INFO; - } - - return $priorities[$priority]; - } -} diff --git a/3dparty/Log/display.php b/3dparty/Log/display.php deleted file mode 100644 index 0d5a93d79da..00000000000 --- a/3dparty/Log/display.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @since Log 1.8.0 - * @package Log - * - * @example display.php Using the display handler. - */ -class Log_display extends Log -{ - /** - * String to output before an error message - * @var string - * @access private - */ - var $_error_prepend = ''; - - /** - * String to output after an error message - * @var string - * @access private - */ - var $_error_append = ''; - - - /** - * Constructs a new Log_display object. - * - * @param string $name Ignored. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_display($name = '', $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (!empty($conf['error_prepend'])) { - $this->_error_prepend = $conf['error_prepend']; - } else { - $this->_error_prepend = ini_get('error_prepend_string'); - } - - if (!empty($conf['error_append'])) { - $this->_error_append = $conf['error_append']; - } else { - $this->_error_append = ini_get('error_append_string'); - } - } - - /** - * Writes $message to the text browser. Also, passes the message - * along to any Log_observer instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - /* Build and output the complete log line. */ - echo $this->_error_prepend . - '' . ucfirst($this->priorityToString($priority)) . ': '. - nl2br(htmlspecialchars($message)) . - $this->_error_append . "
\n"; - - /* Notify observers about this log message. */ - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } -} - -?> diff --git a/3dparty/Log/error_log.php b/3dparty/Log/error_log.php deleted file mode 100644 index 04c0952cd7a..00000000000 --- a/3dparty/Log/error_log.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @since Log 1.7.0 - * @package Log - * - * @example error_log.php Using the error_log handler. - */ -class Log_error_log extends Log -{ - /** - * The error_log() log type. - * @var integer - * @access private - */ - var $_type = PEAR_LOG_TYPE_SYSTEM; - - /** - * The type-specific destination value. - * @var string - * @access private - */ - var $_destination = ''; - - /** - * Additional headers to pass to the mail() function when the - * PEAR_LOG_TYPE_MAIL type is used. - * @var string - * @access private - */ - var $_extra_headers = ''; - - /** - * Constructs a new Log_error_log object. - * - * @param string $name Ignored. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_error_log($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_type = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (!empty($conf['destination'])) { - $this->_destination = $conf['destination']; - } - if (!empty($conf['extra_headers'])) { - $this->_extra_headers = $conf['extra_headers']; - } - } - - /** - * Logs $message using PHP's error_log() function. The message is also - * passed along to any Log_observer instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - $success = error_log($this->_ident . ': ' . $message, $this->_type, - $this->_destination, $this->_extra_headers); - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return $success; - } -} - -?> diff --git a/3dparty/Log/file.php b/3dparty/Log/file.php deleted file mode 100644 index 36f30b42978..00000000000 --- a/3dparty/Log/file.php +++ /dev/null @@ -1,286 +0,0 @@ - - * @author Roman Neuhauser - * @since Log 1.0 - * @package Log - * - * @example file.php Using the file handler. - */ -class Log_file extends Log -{ - /** - * String containing the name of the log file. - * @var string - * @access private - */ - var $_filename = 'php.log'; - - /** - * Handle to the log file. - * @var resource - * @access private - */ - var $_fp = false; - - /** - * Should new log entries be append to an existing log file, or should the - * a new log file overwrite an existing one? - * @var boolean - * @access private - */ - var $_append = true; - - /** - * Integer (in octal) containing the log file's permissions mode. - * @var integer - * @access private - */ - var $_mode = 0644; - - /** - * String containing the format of a log line. - * @var string - * @access private - */ - var $_lineFormat = '%1$s %2$s [%3$s] %4$s'; - - /** - * String containing the timestamp format. It will be passed directly to - * strftime(). Note that the timestamp string will generated using the - * current locale. - * @var string - * @access private - */ - var $_timeFormat = '%b %d %H:%M:%S'; - - /** - * Hash that maps canonical format keys to position arguments for the - * "line format" string. - * @var array - * @access private - */ - var $_formatMap = array('%{timestamp}' => '%1$s', - '%{ident}' => '%2$s', - '%{priority}' => '%3$s', - '%{message}' => '%4$s', - '%\{' => '%%{'); - - /** - * String containing the end-on-line character sequence. - * @var string - * @access private - */ - var $_eol = "\n"; - - /** - * Constructs a new Log_file object. - * - * @param string $name Ignored. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_file($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_filename = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (isset($conf['append'])) { - $this->_append = $conf['append']; - } - - if (!empty($conf['mode'])) { - $this->_mode = $conf['mode']; - } - - if (!empty($conf['lineFormat'])) { - $this->_lineFormat = str_replace(array_keys($this->_formatMap), - array_values($this->_formatMap), - $conf['lineFormat']); - } - - if (!empty($conf['timeFormat'])) { - $this->_timeFormat = $conf['timeFormat']; - } - - if (!empty($conf['eol'])) { - $this->_eol = $conf['eol']; - } else { - $this->_eol = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n"; - } - - register_shutdown_function(array(&$this, '_Log_file')); - } - - /** - * Destructor - */ - function _Log_file() - { - if ($this->_opened) { - $this->close(); - } - } - - /** - * Creates the given directory path. If the parent directories don't - * already exist, they will be created, too. - * - * @param string $path The full directory path to create. - * @param integer $mode The permissions mode with which the - * directories will be created. - * - * @return True if the full path is successfully created or already - * exists. - * - * @access private - */ - function _mkpath($path, $mode = 0700) - { - static $depth = 0; - - /* Guard against potentially infinite recursion. */ - if ($depth++ > 25) { - trigger_error("_mkpath(): Maximum recursion depth (25) exceeded", - E_USER_WARNING); - return false; - } - - /* We're only interested in the directory component of the path. */ - $path = dirname($path); - - /* If the directory already exists, return success immediately. */ - if (is_dir($path)) { - $depth = 0; - return true; - } - - /* - * In order to understand recursion, you must first understand - * recursion ... - */ - if ($this->_mkpath($path, $mode) === false) { - return false; - } - - return @mkdir($path, $mode); - } - - /** - * Opens the log file for output. If the specified log file does not - * already exist, it will be created. By default, new log entries are - * appended to the end of the log file. - * - * This is implicitly called by log(), if necessary. - * - * @access public - */ - function open() - { - if (!$this->_opened) { - /* If the log file's directory doesn't exist, create it. */ - if (!is_dir(dirname($this->_filename))) { - $this->_mkpath($this->_filename); - } - - /* Obtain a handle to the log file. */ - $this->_fp = fopen($this->_filename, ($this->_append) ? 'a' : 'w'); - - $this->_opened = ($this->_fp !== false); - - /* Attempt to set the log file's mode. */ - @chmod($this->_filename, $this->_mode); - } - - return $this->_opened; - } - - /** - * Closes the log file if it is open. - * - * @access public - */ - function close() - { - /* If the log file is open, close it. */ - if ($this->_opened && fclose($this->_fp)) { - $this->_opened = false; - } - - return ($this->_opened === false); - } - - /** - * Flushes all pending data to the file handle. - * - * @access public - * @since Log 1.8.2 - */ - function flush() - { - return fflush($this->_fp); - } - - /** - * Logs $message to the output window. The message is also passed along - * to any Log_observer instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* If the log file isn't already open, open it now. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - /* Build the string containing the complete log line. */ - $line = sprintf($this->_lineFormat, strftime($this->_timeFormat), - $this->_ident, $this->priorityToString($priority), - $message) . $this->_eol; - - /* Write the log line to the log file. */ - $success = (fwrite($this->_fp, $line) !== false); - - /* Notify observers about this log message. */ - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return $success; - } -} - -?> diff --git a/3dparty/Log/mail.php b/3dparty/Log/mail.php deleted file mode 100644 index 064f13c0ed5..00000000000 --- a/3dparty/Log/mail.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @author Jon Parise - * @since Log 1.3 - * @package Log - * - * @example mail.php Using the mail handler. - */ -class Log_mail extends Log -{ - /** - * String holding the recipient's email address. - * @var string - * @access private - */ - var $_recipient = ''; - - /** - * String holding the sender's email address. - * @var string - * @access private - */ - var $_from = ''; - - /** - * String holding the email's subject. - * @var string - * @access private - */ - var $_subject = '[Log_mail] Log message'; - - /** - * String holding an optional preamble for the log messages. - * @var string - * @access private - */ - var $_preamble = ''; - - /** - * String holding the mail message body. - * @var string - * @access private - */ - var $_message = ''; - - - /** - * Constructs a new Log_mail object. - * - * Here is how you can customize the mail driver with the conf[] hash : - * $conf['from'] : the mail's "From" header line, - * $conf['subject'] : the mail's "Subject" line. - * - * @param string $name The filename of the logfile. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_mail($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_recipient = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (!empty($conf['from'])) { - $this->_from = $conf['from']; - } else { - $this->_from = ini_get('sendmail_from'); - } - - if (!empty($conf['subject'])) { - $this->_subject = $conf['subject']; - } - - if (!empty($conf['preamble'])) { - $this->_preamble = $conf['preamble']; - } - - /* register the destructor */ - register_shutdown_function(array(&$this, '_Log_mail')); - } - - /** - * Destructor. Calls close(). - * - * @access private - */ - function _Log_mail() - { - $this->close(); - } - - /** - * Starts a new mail message. - * This is implicitly called by log(), if necessary. - * - * @access public - */ - function open() - { - if (!$this->_opened) { - if (!empty($this->_preamble)) { - $this->_message = $this->_preamble . "\n\n"; - } - $this->_opened = true; - } - - return $this->_opened; - } - - /** - * Closes the message, if it is open, and sends the mail. - * This is implicitly called by the destructor, if necessary. - * - * @access public - */ - function close() - { - if ($this->_opened) { - if (!empty($this->_message)) { - $headers = "From: $this->_from\n"; - $headers .= "User-Agent: Log_mail"; - - if (mail($this->_recipient, $this->_subject, $this->_message, - $headers) == false) { - error_log("Log_mail: Failure executing mail()", 0); - return false; - } - - /* Clear the message string now that the email has been sent. */ - $this->_message = ''; - } - $this->_opened = false; - } - - return ($this->_opened === false); - } - - /** - * Flushes the log output by forcing the email message to be sent now. - * Events that are logged after flush() is called will be appended to a - * new email message. - * - * @access public - * @since Log 1.8.2 - */ - function flush() - { - /* - * It's sufficient to simply call close() to flush the output. - * The next call to log() will cause the handler to be reopened. - */ - return $this->close(); - } - - /** - * Writes $message to the currently open mail message. - * Calls open(), if necessary. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* If the message isn't open and can't be opened, return failure. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - $entry = sprintf("%s %s [%s] %s\n", strftime('%b %d %H:%M:%S'), - $this->_ident, Log::priorityToString($priority), - $message); - - $this->_message .= $entry; - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } -} - -?> diff --git a/3dparty/Log/mcal.php b/3dparty/Log/mcal.php deleted file mode 100644 index a5c46f3dfc6..00000000000 --- a/3dparty/Log/mcal.php +++ /dev/null @@ -1,171 +0,0 @@ - - * @since Horde 1.3 - * @since Log 1.0 - * @package Log - */ -class Log_mcal extends Log { - - /** - * holding the calendar specification to connect to. - * @var string - * @access private - */ - var $_calendar = '{localhost/mstore}'; - - /** - * holding the username to use. - * @var string - * @access private - */ - var $_username = ''; - - /** - * holding the password to use. - * @var string - * @access private - */ - var $_password = ''; - - /** - * holding the options to pass to the calendar stream. - * @var integer - * @access private - */ - var $_options = 0; - - /** - * ResourceID of the MCAL stream. - * @var string - * @access private - */ - var $_stream = ''; - - /** - * Integer holding the log facility to use. - * @var string - * @access private - */ - var $_name = LOG_SYSLOG; - - - /** - * Constructs a new Log_mcal object. - * - * @param string $name The category to use for our events. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_mcal($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_name = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - $this->_calendar = $conf['calendar']; - $this->_username = $conf['username']; - $this->_password = $conf['password']; - $this->_options = $conf['options']; - } - - /** - * Opens a calendar stream, if it has not already been - * opened. This is implicitly called by log(), if necessary. - * @access public - */ - function open() - { - if (!$this->_opened) { - $this->_stream = mcal_open($this->_calendar, $this->_username, - $this->_password, $this->_options); - $this->_opened = true; - } - - return $this->_opened; - } - - /** - * Closes the calendar stream, if it is open. - * @access public - */ - function close() - { - if ($this->_opened) { - mcal_close($this->_stream); - $this->_opened = false; - } - - return ($this->_opened === false); - } - - /** - * Logs $message and associated information to the currently open - * calendar stream. Calls open() if necessary. Also passes the - * message along to any Log_observer instances that are observing - * this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* If the connection isn't open and can't be opened, return failure. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - $date_str = date('Y:n:j:G:i:s'); - $dates = explode(':', $date_str); - - mcal_event_init($this->_stream); - mcal_event_set_title($this->_stream, $this->_ident); - mcal_event_set_category($this->_stream, $this->_name); - mcal_event_set_description($this->_stream, $message); - mcal_event_add_attribute($this->_stream, 'priority', $priority); - mcal_event_set_start($this->_stream, $dates[0], $dates[1], $dates[2], - $dates[3], $dates[4], $dates[5]); - mcal_event_set_end($this->_stream, $dates[0], $dates[1], $dates[2], - $dates[3], $dates[4], $dates[5]); - mcal_append_event($this->_stream); - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } -} - -?> diff --git a/3dparty/Log/null.php b/3dparty/Log/null.php deleted file mode 100644 index 23de3f1a9e5..00000000000 --- a/3dparty/Log/null.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @since Log 1.8.2 - * @package Log - * - * @example null.php Using the null handler. - */ -class Log_null extends Log -{ - /** - * Constructs a new Log_null object. - * - * @param string $name Ignored. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_null($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - } - - /** - * Simply consumes the log event. The message will still be passed - * along to any Log_observer instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } -} - -?> diff --git a/3dparty/Log/observer.php b/3dparty/Log/observer.php deleted file mode 100644 index 187d5070f74..00000000000 --- a/3dparty/Log/observer.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @since Horde 1.3 - * @since Log 1.0 - * @package Log - * - * @example observer_mail.php An example Log_observer implementation. - */ -class Log_observer -{ - /** - * Instance-specific unique identification number. - * - * @var integer - * @access private - */ - var $_id = 0; - - /** - * The minimum priority level of message that we want to hear about. - * PEAR_LOG_EMERG is the highest priority, so we will only hear messages - * with an integer priority value less than or equal to ours. It defaults - * to PEAR_LOG_INFO, which listens to everything except PEAR_LOG_DEBUG. - * - * @var string - * @access private - */ - var $_priority = PEAR_LOG_INFO; - - /** - * Creates a new basic Log_observer instance. - * - * @param integer $priority The highest priority at which to receive - * log event notifications. - * - * @access public - */ - function Log_observer($priority = PEAR_LOG_INFO) - { - $this->_id = md5(microtime()); - $this->_priority = $priority; - } - - /** - * Attempts to return a new concrete Log_observer instance of the requested - * type. - * - * @param string $type The type of concreate Log_observer subclass - * to return. - * @param integer $priority The highest priority at which to receive - * log event notifications. - * @param array $conf Optional associative array of additional - * configuration values. - * - * @return object The newly created concrete Log_observer - * instance, or an false on an error. - */ - function &factory($type, $priority = PEAR_LOG_INFO, $conf = array()) - { - $type = strtolower($type); - $class = 'Log_observer_' . $type; - - /* Support both the new-style and old-style file naming conventions. */ - if (file_exists(dirname(__FILE__) . '/observer_' . $type . '.php')) { - $classfile = 'Log/observer_' . $type . '.php'; - $newstyle = true; - } else { - $classfile = 'Log/' . $type . '.php'; - $newstyle = false; - } - - /* Issue a warning if the old-style conventions are being used. */ - if (!$newstyle) - { - trigger_error('Using old-style Log_observer conventions', - E_USER_WARNING); - } - - /* - * Attempt to include our version of the named class, but don't treat - * a failure as fatal. The caller may have already included their own - * version of the named class. - */ - @include_once $classfile; - - /* If the class exists, return a new instance of it. */ - if (class_exists($class)) { - /* Support both new-style and old-style construction. */ - if ($newstyle) { - return new $class($priority, $conf); - } else { - return new $class($priority); - } - } - - return false; - } - - /** - * This is a stub method to make sure that Log_Observer classes do - * something when they are notified of a message. The default behavior - * is to just print the message, which is obviously not desireable in - * practically any situation - which is why you need to override this - * method. :) - * - * @param array $event A hash describing the log event. - */ - function notify($event) - { - print_r($event); - } -} - -?> diff --git a/3dparty/Log/sql.php b/3dparty/Log/sql.php deleted file mode 100644 index 3a20a0e2faf..00000000000 --- a/3dparty/Log/sql.php +++ /dev/null @@ -1,225 +0,0 @@ - - * @since Horde 1.3 - * @since Log 1.0 - * @package Log - * - * @example sql.php Using the SQL handler. - */ -class Log_sql extends Log { - - /** - * Array containing the dsn information. - * @var string - * @access private - */ - var $_dsn = ''; - - /** - * Object holding the database handle. - * @var object - * @access private - */ - var $_db = null; - - /** - * Flag indicating that we're using an existing database connection. - * @var boolean - * @access private - */ - var $_existingConnection = false; - - /** - * String holding the database table to use. - * @var string - * @access private - */ - var $_table = 'log_table'; - - /** - * String holding the name of the ID sequence. - * @var string - * @access private - */ - var $_sequence = 'log_id'; - - /** - * Maximum length of the $ident string. This corresponds to the size of - * the 'ident' column in the SQL table. - * @var integer - * @access private - */ - var $_identLimit = 16; - - - /** - * Constructs a new sql logging object. - * - * @param string $name The target SQL table. - * @param string $ident The identification field. - * @param array $conf The connection configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_sql($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_table = $name; - $this->_mask = Log::UPTO($level); - - /* If a specific sequence name was provided, use it. */ - if (!empty($conf['sequence'])) { - $this->_sequence = $conf['sequence']; - } - - /* If a specific sequence name was provided, use it. */ - if (isset($conf['identLimit'])) { - $this->_identLimit = $conf['identLimit']; - } - - /* Now that the ident limit is confirmed, set the ident string. */ - $this->setIdent($ident); - - /* If an existing database connection was provided, use it. */ - if (isset($conf['db'])) { - $this->_db = &$conf['db']; - $this->_existingConnection = true; - $this->_opened = true; - } else { - $this->_dsn = $conf['dsn']; - } - } - - /** - * Opens a connection to the database, if it has not already - * been opened. This is implicitly called by log(), if necessary. - * - * @return boolean True on success, false on failure. - * @access public - */ - function open() - { - if (!$this->_opened) { - $this->_db = &DB::connect($this->_dsn, true); - if (DB::isError($this->_db)) { - return false; - } - $this->_opened = true; - } - - return $this->_opened; - } - - /** - * Closes the connection to the database if it is still open and we were - * the ones that opened it. It is the caller's responsible to close an - * existing connection that was passed to us via $conf['db']. - * - * @return boolean True on success, false on failure. - * @access public - */ - function close() - { - if ($this->_opened && !$this->_existingConnection) { - $this->_opened = false; - return $this->_db->disconnect(); - } - - return ($this->_opened === false); - } - - /** - * Sets this Log instance's identification string. Note that this - * SQL-specific implementation will limit the length of the $ident string - * to sixteen (16) characters. - * - * @param string $ident The new identification string. - * - * @access public - * @since Log 1.8.5 - */ - function setIdent($ident) - { - $this->_ident = substr($ident, 0, $this->_identLimit); - } - - /** - * Inserts $message to the currently open database. Calls open(), - * if necessary. Also passes the message along to any Log_observer - * instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* If the connection isn't open and can't be opened, return failure. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - /* Build the SQL query for this log entry insertion. */ - $id = $this->_db->nextId($this->_sequence); - $q = sprintf('insert into %s (id, logtime, ident, priority, message)' . - 'values(%d, CURRENT_TIMESTAMP, %s, %d, %s)', - $this->_table, $id, $this->_db->quote($this->_ident), - $priority, $this->_db->quote($message)); - - $result = $this->_db->query($q); - if (DB::isError($result)) { - return false; - } - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } -} - -?> diff --git a/3dparty/Log/sqlite.php b/3dparty/Log/sqlite.php deleted file mode 100644 index 83b908a9396..00000000000 --- a/3dparty/Log/sqlite.php +++ /dev/null @@ -1,238 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: sqlite.php,v 1.3 2004/01/19 08:02:40 jon Exp $ - -/** - * The Log_sqlite class is a concrete implementation of the Log:: - * abstract class which sends messages to an Sqlite database. - * Each entry occupies a separate row in the database. - * - * This implementation uses PHP native Sqlite functions. - * - * CREATE TABLE log_table ( - * id INTEGER PRIMARY KEY NOT NULL, - * logtime NOT NULL, - * ident CHAR(16) NOT NULL, - * priority INT NOT NULL, - * message - * ); - * - * @author Bertrand Mansion - * @author Jon Parise - * @since Log 1.8.3 - * @package Log - * - * @example sqlite.php Using the Sqlite handler. - */ -class Log_sqlite extends Log -{ - /** - * Array containing the connection defaults - * @var array - * @access private - */ - var $_options = array('mode' => 0666, - 'persistent' => false); - - /** - * Object holding the database handle. - * @var object - * @access private - */ - var $_db = null; - - /** - * Flag indicating that we're using an existing database connection. - * @var boolean - * @access private - */ - var $_existingConnection = false; - - /** - * String holding the database table to use. - * @var string - * @access private - */ - var $_table = 'log_table'; - - - /** - * Constructs a new sql logging object. - * - * @param string $name The target SQL table. - * @param string $ident The identification field. - * @param mixed $conf Can be an array of configuration options used - * to open a new database connection - * or an already opened sqlite connection. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_sqlite($name, $ident = '', &$conf, $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_table = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (is_array($conf)) { - foreach ($conf as $k => $opt) { - $this->_options[$k] = $opt; - } - } else { - // If an existing database connection was provided, use it. - $this->_db =& $conf; - $this->_existingConnection = true; - } - } - - /** - * Opens a connection to the database, if it has not already - * been opened. This is implicitly called by log(), if necessary. - * - * @return boolean True on success, false on failure. - * @access public - */ - function open() - { - if (is_resource($this->_db)) { - $this->_opened = true; - return $this->_createTable(); - } else { - /* Set the connection function based on the 'persistent' option. */ - if (empty($this->_options['persistent'])) { - $connectFunction = 'sqlite_open'; - } else { - $connectFunction = 'sqlite_popen'; - } - - /* Attempt to connect to the database. */ - if ($this->_db = $connectFunction($this->_options['filename'], - (int)$this->_options['mode'], - $error)) { - $this->_opened = true; - return $this->_createTable(); - } - } - - return $this->_opened; - } - - /** - * Closes the connection to the database if it is still open and we were - * the ones that opened it. It is the caller's responsible to close an - * existing connection that was passed to us via $conf['db']. - * - * @return boolean True on success, false on failure. - * @access public - */ - function close() - { - /* We never close existing connections. */ - if ($this->_existingConnection) { - return false; - } - - if ($this->_opened) { - $this->_opened = false; - sqlite_close($this->_db); - } - - return ($this->_opened === false); - } - - /** - * Inserts $message to the currently open database. Calls open(), - * if necessary. Also passes the message along to any Log_observer - * instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* If the connection isn't open and can't be opened, return failure. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - // Extract the string representation of the message. - $message = $this->_extractMessage($message); - - // Build the SQL query for this log entry insertion. - $q = sprintf('INSERT INTO [%s] (logtime, ident, priority, message) ' . - "VALUES ('%s', '%s', %d, '%s')", - $this->_table, - strftime('%Y-%m-%d %H:%M:%S', time()), - sqlite_escape_string($this->_ident), - $priority, - sqlite_escape_string($message)); - if (!($res = @sqlite_unbuffered_query($this->_db, $q))) { - return false; - } - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } - - /** - * Checks whether the log table exists and creates it if necessary. - * - * @return boolean True on success or false on failure. - * @access private - */ - function _createTable() - { - $q = "SELECT name FROM sqlite_master WHERE name='" . $this->_table . - "' AND type='table'"; - - $res = sqlite_query($this->_db, $q); - - if (sqlite_num_rows($res) == 0) { - $q = 'CREATE TABLE [' . $this->_table . '] (' . - 'id INTEGER PRIMARY KEY NOT NULL, ' . - 'logtime NOT NULL, ' . - 'ident CHAR(16) NOT NULL, ' . - 'priority INT NOT NULL, ' . - 'message)'; - - if (!($res = sqlite_unbuffered_query($this->_db, $q))) { - return false; - } - } - - return true; - } -} - -?> diff --git a/3dparty/Log/syslog.php b/3dparty/Log/syslog.php deleted file mode 100644 index 4bafbaa2d9a..00000000000 --- a/3dparty/Log/syslog.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @since Horde 1.3 - * @since Log 1.0 - * @package Log - * - * @example syslog.php Using the syslog handler. - */ -class Log_syslog extends Log -{ - /** - * Integer holding the log facility to use. - * @var string - * @access private - */ - var $_name = LOG_SYSLOG; - - /** - * Constructs a new syslog object. - * - * @param string $name The syslog facility. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_syslog($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - /* Ensure we have a valid integer value for $name. */ - if (empty($name) || !is_int($name)) { - $name = LOG_SYSLOG; - } - - $this->_id = md5(microtime()); - $this->_name = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - } - - /** - * Opens a connection to the system logger, if it has not already - * been opened. This is implicitly called by log(), if necessary. - * @access public - */ - function open() - { - if (!$this->_opened) { - openlog($this->_ident, LOG_PID, $this->_name); - $this->_opened = true; - } - - return $this->_opened; - } - - /** - * Closes the connection to the system logger, if it is open. - * @access public - */ - function close() - { - if ($this->_opened) { - closelog(); - $this->_opened = false; - } - - return ($this->_opened === false); - } - - /** - * Sends $message to the currently open syslog connection. Calls - * open() if necessary. Also passes the message along to any Log_observer - * instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param int $priority (optional) The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* If the connection isn't open and can't be opened, return failure. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - if (!syslog($this->_toSyslog($priority), $message)) { - return false; - } - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } - - /** - * Converts a PEAR_LOG_* constant into a syslog LOG_* constant. - * - * This function exists because, under Windows, not all of the LOG_* - * constants have unique values. Instead, the PEAR_LOG_* were introduced - * for global use, with the conversion to the LOG_* constants kept local to - * to the syslog driver. - * - * @param int $priority PEAR_LOG_* value to convert to LOG_* value. - * - * @return The LOG_* representation of $priority. - * - * @access private - */ - function _toSyslog($priority) - { - static $priorities = array( - PEAR_LOG_EMERG => LOG_EMERG, - PEAR_LOG_ALERT => LOG_ALERT, - PEAR_LOG_CRIT => LOG_CRIT, - PEAR_LOG_ERR => LOG_ERR, - PEAR_LOG_WARNING => LOG_WARNING, - PEAR_LOG_NOTICE => LOG_NOTICE, - PEAR_LOG_INFO => LOG_INFO, - PEAR_LOG_DEBUG => LOG_DEBUG - ); - - /* If we're passed an unknown priority, default to LOG_INFO. */ - if (!is_int($priority) || !in_array($priority, $priorities)) { - return LOG_INFO; - } - - return $priorities[$priority]; - } -} -?> diff --git a/3dparty/Log/win.php b/3dparty/Log/win.php deleted file mode 100644 index e8a09d16e81..00000000000 --- a/3dparty/Log/win.php +++ /dev/null @@ -1,256 +0,0 @@ - - * @since Log 1.7.0 - * @package Log - * - * @example win.php Using the window handler. - */ -class Log_win extends Log -{ - /** - * The name of the output window. - * @var string - * @access private - */ - var $_name = 'LogWindow'; - - /** - * The title of the output window. - * @var string - * @access private - */ - var $_title = 'Log Output Window'; - - /** - * Mapping of log priorities to colors. - * @var array - * @access private - */ - var $_colors = array( - PEAR_LOG_EMERG => 'red', - PEAR_LOG_ALERT => 'orange', - PEAR_LOG_CRIT => 'yellow', - PEAR_LOG_ERR => 'green', - PEAR_LOG_WARNING => 'blue', - PEAR_LOG_NOTICE => 'indigo', - PEAR_LOG_INFO => 'violet', - PEAR_LOG_DEBUG => 'black' - ); - - /** - * String buffer that holds line that are pending output. - * @var array - * @access private - */ - var $_buffer = array(); - - /** - * Constructs a new Log_win object. - * - * @param string $name Ignored. - * @param string $ident The identity string. - * @param array $conf The configuration array. - * @param int $level Log messages up to and including this level. - * @access public - */ - function Log_win($name, $ident = '', $conf = array(), - $level = PEAR_LOG_DEBUG) - { - $this->_id = md5(microtime()); - $this->_name = $name; - $this->_ident = $ident; - $this->_mask = Log::UPTO($level); - - if (isset($conf['title'])) { - $this->_title = $conf['title']; - } - if (isset($conf['colors']) && is_array($conf['colors'])) { - $this->_colors = $conf['colors']; - } - - register_shutdown_function(array(&$this, '_Log_win')); - } - - /** - * Destructor - */ - function _Log_win() - { - if ($this->_opened || (count($this->_buffer) > 0)) { - $this->close(); - } - } - - /** - * The first time open() is called, it will open a new browser window and - * prepare it for output. - * - * This is implicitly called by log(), if necessary. - * - * @access public - */ - function open() - { - if (!$this->_opened) { - $win = $this->_name; - - if (!empty($this->_ident)) { - $identHeader = "$win.document.writeln('Ident')"; - } else { - $identHeader = ''; - } - - echo <<< END_OF_SCRIPT - -END_OF_SCRIPT; - $this->_opened = true; - } - - return $this->_opened; - } - - /** - * Closes the output stream if it is open. If there are still pending - * lines in the output buffer, the output window will be opened so that - * the buffer can be drained. - * - * @access public - */ - function close() - { - /* - * If there are still lines waiting to be written, open the output - * window so that we can drain the buffer. - */ - if (!$this->_opened && (count($this->_buffer) > 0)) { - $this->open(); - } - - if ($this->_opened) { - $this->_writeln(''); - $this->_writeln(''); - $this->_opened = false; - } - - return ($this->_opened === false); - } - - /** - * Writes a single line of text to the output window. - * - * @param string $line The line of text to write. - * - * @access private - */ - function _writeln($line) - { - /* Add this line to our output buffer. */ - $this->_buffer[] = $line; - - /* Buffer the output until this page's headers have been sent. */ - if (!headers_sent()) { - return; - } - - /* If we haven't already opened the output window, do so now. */ - if (!$this->_opened && !$this->open()) { - return false; - } - - /* Drain the buffer to the output window. */ - $win = $this->_name; - foreach ($this->_buffer as $line) { - echo "\n"; - } - - /* Now that the buffer has been drained, clear it. */ - $this->_buffer = array(); - } - - /** - * Logs $message to the output window. The message is also passed along - * to any Log_observer instances that are observing this Log. - * - * @param mixed $message String or object containing the message to log. - * @param string $priority The priority of the message. Valid - * values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, - * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, - * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. - * @return boolean True on success or false on failure. - * @access public - */ - function log($message, $priority = null) - { - /* If a priority hasn't been specified, use the default value. */ - if ($priority === null) { - $priority = $this->_priority; - } - - /* Abort early if the priority is above the maximum logging level. */ - if (!$this->_isMasked($priority)) { - return false; - } - - /* Extract the string representation of the message. */ - $message = $this->_extractMessage($message); - - list($usec, $sec) = explode(' ', microtime()); - - /* Build the output line that contains the log entry row. */ - $line = ''; - $line .= sprintf('%s.%s', - strftime('%T', $sec), substr($usec, 2, 2)); - if (!empty($this->_ident)) { - $line .= '' . $this->_ident . ''; - } - $line .= '' . ucfirst($this->priorityToString($priority)) . ''; - $line .= sprintf('%s', - $this->_colors[$priority], - preg_replace('/\r\n|\n|\r/', '
', $message)); - $line .= ''; - - $this->_writeln($line); - - $this->_announce(array('priority' => $priority, 'message' => $message)); - - return true; - } -} - -?> diff --git a/3dparty/Mail.php b/3dparty/Mail.php deleted file mode 100644 index c9f480fd488..00000000000 --- a/3dparty/Mail.php +++ /dev/null @@ -1,212 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Mail.php,v 1.11 2005/06/26 23:37:18 jon Exp $ - -require_once 'PEAR.php'; - -/** - * PEAR's Mail:: interface. Defines the interface for implementing - * mailers under the PEAR hierarchy, and provides supporting functions - * useful in multiple mailer backends. - * - * @access public - * @version $Revision: 1.11 $ - * @package Mail - */ -class Mail -{ - /** - * Line terminator used for separating header lines. - * @var string - */ - var $sep = "\r\n"; - - /** - * Provides an interface for generating Mail:: objects of various - * types - * - * @param string $driver The kind of Mail:: object to instantiate. - * @param array $params The parameters to pass to the Mail:: object. - * @return object Mail a instance of the driver class or if fails a PEAR Error - * @access public - */ - function &factory($driver, $params = array()) - { - $driver = strtolower($driver); - @include_once 'Mail/' . $driver . '.php'; - $class = 'Mail_' . $driver; - if (class_exists($class)) { - $mailer = &new $class($params); - } else { - $mailer = PEAR::raiseError('Unable to find class for driver ' . $driver); - } - - return $mailer; - } - - /** - * Implements Mail::send() function using php's built-in mail() - * command. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - * @deprecated use Mail_mail::send instead - */ - function send($recipients, $headers, $body) - { - // if we're passed an array of recipients, implode it. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // get the Subject out of the headers array so that we can - // pass it as a seperate argument to mail(). - $subject = ''; - if (isset($headers['Subject'])) { - $subject = $headers['Subject']; - unset($headers['Subject']); - } - - // flatten the headers out. - list(,$text_headers) = Mail::prepareHeaders($headers); - - return mail($recipients, $subject, $body, $text_headers); - - } - - /** - * Take an array of mail headers and return a string containing - * text usable in sending a message. - * - * @param array $headers The array of headers to prepare, in an associative - * array, where the array key is the header name (ie, - * 'Subject'), and the array value is the header - * value (ie, 'test'). The header produced from those - * values would be 'Subject: test'. - * - * @return mixed Returns false if it encounters a bad address, - * otherwise returns an array containing two - * elements: Any From: address found in the headers, - * and the plain text version of the headers. - * @access private - */ - function prepareHeaders($headers) - { - $lines = array(); - $from = null; - - foreach ($headers as $key => $value) { - if (strcasecmp($key, 'From') === 0) { - include_once 'Mail/RFC822.php'; - $parser = &new Mail_RFC822(); - $addresses = $parser->parseAddressList($value, 'localhost', false); - if (PEAR::isError($addresses)) { - return $addresses; - } - - $from = $addresses[0]->mailbox . '@' . $addresses[0]->host; - - // Reject envelope From: addresses with spaces. - if (strstr($from, ' ')) { - return false; - } - - $lines[] = $key . ': ' . $value; - } elseif (strcasecmp($key, 'Received') === 0) { - $received = array(); - if (is_array($value)) { - foreach ($value as $line) { - $received[] = $key . ': ' . $line; - } - } - else { - $received[] = $key . ': ' . $value; - } - // Put Received: headers at the top. Spam detectors often - // flag messages with Received: headers after the Subject: - // as spam. - $lines = array_merge($received, $lines); - } else { - // If $value is an array (i.e., a list of addresses), convert - // it to a comma-delimited string of its elements (addresses). - if (is_array($value)) { - $value = implode(', ', $value); - } - $lines[] = $key . ': ' . $value; - } - } - - return array($from, join($this->sep, $lines) . $this->sep); - } - - /** - * Take a set of recipients and parse them, returning an array of - * bare addresses (forward paths) that can be passed to sendmail - * or an smtp server with the rcpt to: command. - * - * @param mixed Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. - * - * @return array An array of forward paths (bare addresses). - * @access private - */ - function parseRecipients($recipients) - { - include_once 'Mail/RFC822.php'; - - // if we're passed an array, assume addresses are valid and - // implode them before parsing. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // Parse recipients, leaving out all personal info. This is - // for smtp recipients, etc. All relevant personal information - // should already be in the headers. - $addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false); - $recipients = array(); - if (is_array($addresses)) { - foreach ($addresses as $ob) { - $recipients[] = $ob->mailbox . '@' . $ob->host; - } - } - - return $recipients; - } - -} diff --git a/3dparty/Mail/RFC822.php b/3dparty/Mail/RFC822.php deleted file mode 100644 index 47e84f83b26..00000000000 --- a/3dparty/Mail/RFC822.php +++ /dev/null @@ -1,923 +0,0 @@ - | -// | Chuck Hagenbuch | -// +-----------------------------------------------------------------------+ - -/** - * RFC 822 Email address list validation Utility - * - * What is it? - * - * This class will take an address string, and parse it into it's consituent - * parts, be that either addresses, groups, or combinations. Nested groups - * are not supported. The structure it returns is pretty straight forward, - * and is similar to that provided by the imap_rfc822_parse_adrlist(). Use - * print_r() to view the structure. - * - * How do I use it? - * - * $address_string = 'My Group: "Richard" (A comment), ted@example.com (Ted Bloggs), Barney;'; - * $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', true) - * print_r($structure); - * - * @author Richard Heyes - * @author Chuck Hagenbuch - * @version $Revision: 1.21 $ - * @license BSD - * @package Mail - */ -class Mail_RFC822 { - - /** - * The address being parsed by the RFC822 object. - * @var string $address - */ - var $address = ''; - - /** - * The default domain to use for unqualified addresses. - * @var string $default_domain - */ - var $default_domain = 'localhost'; - - /** - * Should we return a nested array showing groups, or flatten everything? - * @var boolean $nestGroups - */ - var $nestGroups = true; - - /** - * Whether or not to validate atoms for non-ascii characters. - * @var boolean $validate - */ - var $validate = true; - - /** - * The array of raw addresses built up as we parse. - * @var array $addresses - */ - var $addresses = array(); - - /** - * The final array of parsed address information that we build up. - * @var array $structure - */ - var $structure = array(); - - /** - * The current error message, if any. - * @var string $error - */ - var $error = null; - - /** - * An internal counter/pointer. - * @var integer $index - */ - var $index = null; - - /** - * The number of groups that have been found in the address list. - * @var integer $num_groups - * @access public - */ - var $num_groups = 0; - - /** - * A variable so that we can tell whether or not we're inside a - * Mail_RFC822 object. - * @var boolean $mailRFC822 - */ - var $mailRFC822 = true; - - /** - * A limit after which processing stops - * @var int $limit - */ - var $limit = null; - - /** - * Sets up the object. The address must either be set here or when - * calling parseAddressList(). One or the other. - * - * @access public - * @param string $address The address(es) to validate. - * @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost. - * @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing. - * @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. - * - * @return object Mail_RFC822 A new Mail_RFC822 object. - */ - function Mail_RFC822($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null) - { - if (isset($address)) $this->address = $address; - if (isset($default_domain)) $this->default_domain = $default_domain; - if (isset($nest_groups)) $this->nestGroups = $nest_groups; - if (isset($validate)) $this->validate = $validate; - if (isset($limit)) $this->limit = $limit; - } - - /** - * Starts the whole process. The address must either be set here - * or when creating the object. One or the other. - * - * @access public - * @param string $address The address(es) to validate. - * @param string $default_domain Default domain/host etc. - * @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing. - * @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance. - * - * @return array A structured array of addresses. - */ - function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null) - { - if (!isset($this) || !isset($this->mailRFC822)) { - $obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit); - return $obj->parseAddressList(); - } - - if (isset($address)) $this->address = $address; - if (isset($default_domain)) $this->default_domain = $default_domain; - if (isset($nest_groups)) $this->nestGroups = $nest_groups; - if (isset($validate)) $this->validate = $validate; - if (isset($limit)) $this->limit = $limit; - - $this->structure = array(); - $this->addresses = array(); - $this->error = null; - $this->index = null; - - // Unfold any long lines in $this->address. - $this->address = preg_replace('/\r?\n/', "\r\n", $this->address); - $this->address = preg_replace('/\r\n(\t| )+/', ' ', $this->address); - - while ($this->address = $this->_splitAddresses($this->address)); - - if ($this->address === false || isset($this->error)) { - require_once 'PEAR.php'; - return PEAR::raiseError($this->error); - } - - // Validate each address individually. If we encounter an invalid - // address, stop iterating and return an error immediately. - foreach ($this->addresses as $address) { - $valid = $this->_validateAddress($address); - - if ($valid === false || isset($this->error)) { - require_once 'PEAR.php'; - return PEAR::raiseError($this->error); - } - - if (!$this->nestGroups) { - $this->structure = array_merge($this->structure, $valid); - } else { - $this->structure[] = $valid; - } - } - - return $this->structure; - } - - /** - * Splits an address into separate addresses. - * - * @access private - * @param string $address The addresses to split. - * @return boolean Success or failure. - */ - function _splitAddresses($address) - { - if (!empty($this->limit) && count($this->addresses) == $this->limit) { - return ''; - } - - if ($this->_isGroup($address) && !isset($this->error)) { - $split_char = ';'; - $is_group = true; - } elseif (!isset($this->error)) { - $split_char = ','; - $is_group = false; - } elseif (isset($this->error)) { - return false; - } - - // Split the string based on the above ten or so lines. - $parts = explode($split_char, $address); - $string = $this->_splitCheck($parts, $split_char); - - // If a group... - if ($is_group) { - // If $string does not contain a colon outside of - // brackets/quotes etc then something's fubar. - - // First check there's a colon at all: - if (strpos($string, ':') === false) { - $this->error = 'Invalid address: ' . $string; - return false; - } - - // Now check it's outside of brackets/quotes: - if (!$this->_splitCheck(explode(':', $string), ':')) { - return false; - } - - // We must have a group at this point, so increase the counter: - $this->num_groups++; - } - - // $string now contains the first full address/group. - // Add to the addresses array. - $this->addresses[] = array( - 'address' => trim($string), - 'group' => $is_group - ); - - // Remove the now stored address from the initial line, the +1 - // is to account for the explode character. - $address = trim(substr($address, strlen($string) + 1)); - - // If the next char is a comma and this was a group, then - // there are more addresses, otherwise, if there are any more - // chars, then there is another address. - if ($is_group && substr($address, 0, 1) == ','){ - $address = trim(substr($address, 1)); - return $address; - - } elseif (strlen($address) > 0) { - return $address; - - } else { - return ''; - } - - // If you got here then something's off - return false; - } - - /** - * Checks for a group at the start of the string. - * - * @access private - * @param string $address The address to check. - * @return boolean Whether or not there is a group at the start of the string. - */ - function _isGroup($address) - { - // First comma not in quotes, angles or escaped: - $parts = explode(',', $address); - $string = $this->_splitCheck($parts, ','); - - // Now we have the first address, we can reliably check for a - // group by searching for a colon that's not escaped or in - // quotes or angle brackets. - if (count($parts = explode(':', $string)) > 1) { - $string2 = $this->_splitCheck($parts, ':'); - return ($string2 !== $string); - } else { - return false; - } - } - - /** - * A common function that will check an exploded string. - * - * @access private - * @param array $parts The exloded string. - * @param string $char The char that was exploded on. - * @return mixed False if the string contains unclosed quotes/brackets, or the string on success. - */ - function _splitCheck($parts, $char) - { - $string = $parts[0]; - - for ($i = 0; $i < count($parts); $i++) { - if ($this->_hasUnclosedQuotes($string) - || $this->_hasUnclosedBrackets($string, '<>') - || $this->_hasUnclosedBrackets($string, '[]') - || $this->_hasUnclosedBrackets($string, '()') - || substr($string, -1) == '\\') { - if (isset($parts[$i + 1])) { - $string = $string . $char . $parts[$i + 1]; - } else { - $this->error = 'Invalid address spec. Unclosed bracket or quotes'; - return false; - } - } else { - $this->index = $i; - break; - } - } - - return $string; - } - - /** - * Checks if a string has an unclosed quotes or not. - * - * @access private - * @param string $string The string to check. - * @return boolean True if there are unclosed quotes inside the string, false otherwise. - */ - function _hasUnclosedQuotes($string) - { - $string = explode('"', $string); - $string_cnt = count($string); - - for ($i = 0; $i < (count($string) - 1); $i++) - if (substr($string[$i], -1) == '\\') - $string_cnt--; - - return ($string_cnt % 2 === 0); - } - - /** - * Checks if a string has an unclosed brackets or not. IMPORTANT: - * This function handles both angle brackets and square brackets; - * - * @access private - * @param string $string The string to check. - * @param string $chars The characters to check for. - * @return boolean True if there are unclosed brackets inside the string, false otherwise. - */ - function _hasUnclosedBrackets($string, $chars) - { - $num_angle_start = substr_count($string, $chars[0]); - $num_angle_end = substr_count($string, $chars[1]); - - $this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]); - $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]); - - if ($num_angle_start < $num_angle_end) { - $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')'; - return false; - } else { - return ($num_angle_start > $num_angle_end); - } - } - - /** - * Sub function that is used only by hasUnclosedBrackets(). - * - * @access private - * @param string $string The string to check. - * @param integer &$num The number of occurences. - * @param string $char The character to count. - * @return integer The number of occurences of $char in $string, adjusted for backslashes. - */ - function _hasUnclosedBracketsSub($string, &$num, $char) - { - $parts = explode($char, $string); - for ($i = 0; $i < count($parts); $i++){ - if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i])) - $num--; - if (isset($parts[$i + 1])) - $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1]; - } - - return $num; - } - - /** - * Function to begin checking the address. - * - * @access private - * @param string $address The address to validate. - * @return mixed False on failure, or a structured array of address information on success. - */ - function _validateAddress($address) - { - $is_group = false; - $addresses = array(); - - if ($address['group']) { - $is_group = true; - - // Get the group part of the name - $parts = explode(':', $address['address']); - $groupname = $this->_splitCheck($parts, ':'); - $structure = array(); - - // And validate the group part of the name. - if (!$this->_validatePhrase($groupname)){ - $this->error = 'Group name did not validate.'; - return false; - } else { - // Don't include groups if we are not nesting - // them. This avoids returning invalid addresses. - if ($this->nestGroups) { - $structure = new stdClass; - $structure->groupname = $groupname; - } - } - - $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':'))); - } - - // If a group then split on comma and put into an array. - // Otherwise, Just put the whole address in an array. - if ($is_group) { - while (strlen($address['address']) > 0) { - $parts = explode(',', $address['address']); - $addresses[] = $this->_splitCheck($parts, ','); - $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ','))); - } - } else { - $addresses[] = $address['address']; - } - - // Check that $addresses is set, if address like this: - // Groupname:; - // Then errors were appearing. - if (!count($addresses)){ - $this->error = 'Empty group.'; - return false; - } - - // Trim the whitespace from all of the address strings. - array_map('trim', $addresses); - - // Validate each mailbox. - // Format could be one of: name - // geezer@domain.com - // geezer - // ... or any other format valid by RFC 822. - for ($i = 0; $i < count($addresses); $i++) { - if (!$this->validateMailbox($addresses[$i])) { - if (empty($this->error)) { - $this->error = 'Validation failed for: ' . $addresses[$i]; - } - return false; - } - } - - // Nested format - if ($this->nestGroups) { - if ($is_group) { - $structure->addresses = $addresses; - } else { - $structure = $addresses[0]; - } - - // Flat format - } else { - if ($is_group) { - $structure = array_merge($structure, $addresses); - } else { - $structure = $addresses; - } - } - - return $structure; - } - - /** - * Function to validate a phrase. - * - * @access private - * @param string $phrase The phrase to check. - * @return boolean Success or failure. - */ - function _validatePhrase($phrase) - { - // Splits on one or more Tab or space. - $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY); - - $phrase_parts = array(); - while (count($parts) > 0){ - $phrase_parts[] = $this->_splitCheck($parts, ' '); - for ($i = 0; $i < $this->index + 1; $i++) - array_shift($parts); - } - - foreach ($phrase_parts as $part) { - // If quoted string: - if (substr($part, 0, 1) == '"') { - if (!$this->_validateQuotedString($part)) { - return false; - } - continue; - } - - // Otherwise it's an atom: - if (!$this->_validateAtom($part)) return false; - } - - return true; - } - - /** - * Function to validate an atom which from rfc822 is: - * atom = 1* - * - * If validation ($this->validate) has been turned off, then - * validateAtom() doesn't actually check anything. This is so that you - * can split a list of addresses up before encoding personal names - * (umlauts, etc.), for example. - * - * @access private - * @param string $atom The string to check. - * @return boolean Success or failure. - */ - function _validateAtom($atom) - { - if (!$this->validate) { - // Validation has been turned off; assume the atom is okay. - return true; - } - - // Check for any char from ASCII 0 - ASCII 127 - if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) { - return false; - } - - // Check for specials: - if (preg_match('/[][()<>@,;\\:". ]/', $atom)) { - return false; - } - - // Check for control characters (ASCII 0-31): - if (preg_match('/[\\x00-\\x1F]+/', $atom)) { - return false; - } - - return true; - } - - /** - * Function to validate quoted string, which is: - * quoted-string = <"> *(qtext/quoted-pair) <"> - * - * @access private - * @param string $qstring The string to check - * @return boolean Success or failure. - */ - function _validateQuotedString($qstring) - { - // Leading and trailing " - $qstring = substr($qstring, 1, -1); - - // Perform check, removing quoted characters first. - return !preg_match('/[\x0D\\\\"]/', preg_replace('/\\\\./', '', $qstring)); - } - - /** - * Function to validate a mailbox, which is: - * mailbox = addr-spec ; simple address - * / phrase route-addr ; name and route-addr - * - * @access public - * @param string &$mailbox The string to check. - * @return boolean Success or failure. - */ - function validateMailbox(&$mailbox) - { - // A couple of defaults. - $phrase = ''; - $comment = ''; - $comments = array(); - - // Catch any RFC822 comments and store them separately. - $_mailbox = $mailbox; - while (strlen(trim($_mailbox)) > 0) { - $parts = explode('(', $_mailbox); - $before_comment = $this->_splitCheck($parts, '('); - if ($before_comment != $_mailbox) { - // First char should be a (. - $comment = substr(str_replace($before_comment, '', $_mailbox), 1); - $parts = explode(')', $comment); - $comment = $this->_splitCheck($parts, ')'); - $comments[] = $comment; - - // +1 is for the trailing ) - $_mailbox = substr($_mailbox, strpos($_mailbox, $comment)+strlen($comment)+1); - } else { - break; - } - } - - foreach ($comments as $comment) { - $mailbox = str_replace("($comment)", '', $mailbox); - } - - $mailbox = trim($mailbox); - - // Check for name + route-addr - if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') { - $parts = explode('<', $mailbox); - $name = $this->_splitCheck($parts, '<'); - - $phrase = trim($name); - $route_addr = trim(substr($mailbox, strlen($name.'<'), -1)); - - if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false) { - return false; - } - - // Only got addr-spec - } else { - // First snip angle brackets if present. - if (substr($mailbox, 0, 1) == '<' && substr($mailbox, -1) == '>') { - $addr_spec = substr($mailbox, 1, -1); - } else { - $addr_spec = $mailbox; - } - - if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { - return false; - } - } - - // Construct the object that will be returned. - $mbox = new stdClass(); - - // Add the phrase (even if empty) and comments - $mbox->personal = $phrase; - $mbox->comment = isset($comments) ? $comments : array(); - - if (isset($route_addr)) { - $mbox->mailbox = $route_addr['local_part']; - $mbox->host = $route_addr['domain']; - $route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : ''; - } else { - $mbox->mailbox = $addr_spec['local_part']; - $mbox->host = $addr_spec['domain']; - } - - $mailbox = $mbox; - return true; - } - - /** - * This function validates a route-addr which is: - * route-addr = "<" [route] addr-spec ">" - * - * Angle brackets have already been removed at the point of - * getting to this function. - * - * @access private - * @param string $route_addr The string to check. - * @return mixed False on failure, or an array containing validated address/route information on success. - */ - function _validateRouteAddr($route_addr) - { - // Check for colon. - if (strpos($route_addr, ':') !== false) { - $parts = explode(':', $route_addr); - $route = $this->_splitCheck($parts, ':'); - } else { - $route = $route_addr; - } - - // If $route is same as $route_addr then the colon was in - // quotes or brackets or, of course, non existent. - if ($route === $route_addr){ - unset($route); - $addr_spec = $route_addr; - if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { - return false; - } - } else { - // Validate route part. - if (($route = $this->_validateRoute($route)) === false) { - return false; - } - - $addr_spec = substr($route_addr, strlen($route . ':')); - - // Validate addr-spec part. - if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) { - return false; - } - } - - if (isset($route)) { - $return['adl'] = $route; - } else { - $return['adl'] = ''; - } - - $return = array_merge($return, $addr_spec); - return $return; - } - - /** - * Function to validate a route, which is: - * route = 1#("@" domain) ":" - * - * @access private - * @param string $route The string to check. - * @return mixed False on failure, or the validated $route on success. - */ - function _validateRoute($route) - { - // Split on comma. - $domains = explode(',', trim($route)); - - foreach ($domains as $domain) { - $domain = str_replace('@', '', trim($domain)); - if (!$this->_validateDomain($domain)) return false; - } - - return $route; - } - - /** - * Function to validate a domain, though this is not quite what - * you expect of a strict internet domain. - * - * domain = sub-domain *("." sub-domain) - * - * @access private - * @param string $domain The string to check. - * @return mixed False on failure, or the validated domain on success. - */ - function _validateDomain($domain) - { - // Note the different use of $subdomains and $sub_domains - $subdomains = explode('.', $domain); - - while (count($subdomains) > 0) { - $sub_domains[] = $this->_splitCheck($subdomains, '.'); - for ($i = 0; $i < $this->index + 1; $i++) - array_shift($subdomains); - } - - foreach ($sub_domains as $sub_domain) { - if (!$this->_validateSubdomain(trim($sub_domain))) - return false; - } - - // Managed to get here, so return input. - return $domain; - } - - /** - * Function to validate a subdomain: - * subdomain = domain-ref / domain-literal - * - * @access private - * @param string $subdomain The string to check. - * @return boolean Success or failure. - */ - function _validateSubdomain($subdomain) - { - if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){ - if (!$this->_validateDliteral($arr[1])) return false; - } else { - if (!$this->_validateAtom($subdomain)) return false; - } - - // Got here, so return successful. - return true; - } - - /** - * Function to validate a domain literal: - * domain-literal = "[" *(dtext / quoted-pair) "]" - * - * @access private - * @param string $dliteral The string to check. - * @return boolean Success or failure. - */ - function _validateDliteral($dliteral) - { - return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\'; - } - - /** - * Function to validate an addr-spec. - * - * addr-spec = local-part "@" domain - * - * @access private - * @param string $addr_spec The string to check. - * @return mixed False on failure, or the validated addr-spec on success. - */ - function _validateAddrSpec($addr_spec) - { - $addr_spec = trim($addr_spec); - - // Split on @ sign if there is one. - if (strpos($addr_spec, '@') !== false) { - $parts = explode('@', $addr_spec); - $local_part = $this->_splitCheck($parts, '@'); - $domain = substr($addr_spec, strlen($local_part . '@')); - - // No @ sign so assume the default domain. - } else { - $local_part = $addr_spec; - $domain = $this->default_domain; - } - - if (($local_part = $this->_validateLocalPart($local_part)) === false) return false; - if (($domain = $this->_validateDomain($domain)) === false) return false; - - // Got here so return successful. - return array('local_part' => $local_part, 'domain' => $domain); - } - - /** - * Function to validate the local part of an address: - * local-part = word *("." word) - * - * @access private - * @param string $local_part - * @return mixed False on failure, or the validated local part on success. - */ - function _validateLocalPart($local_part) - { - $parts = explode('.', $local_part); - $words = array(); - - // Split the local_part into words. - while (count($parts) > 0){ - $words[] = $this->_splitCheck($parts, '.'); - for ($i = 0; $i < $this->index + 1; $i++) { - array_shift($parts); - } - } - - // Validate each word. - foreach ($words as $word) { - // If this word contains an unquoted space, it is invalid. (6.2.4) - if (strpos($word, ' ') && $word[0] !== '"') - { - return false; - } - - if ($this->_validatePhrase(trim($word)) === false) return false; - } - - // Managed to get here, so return the input. - return $local_part; - } - - /** - * Returns an approximate count of how many addresses are in the - * given string. This is APPROXIMATE as it only splits based on a - * comma which has no preceding backslash. Could be useful as - * large amounts of addresses will end up producing *large* - * structures when used with parseAddressList(). - * - * @param string $data Addresses to count - * @return int Approximate count - */ - function approximateCount($data) - { - return count(preg_split('/(?@. This can be sufficient for most - * people. Optional stricter mode can be utilised which restricts - * mailbox characters allowed to alphanumeric, full stop, hyphen - * and underscore. - * - * @param string $data Address to check - * @param boolean $strict Optional stricter mode - * @return mixed False if it fails, an indexed array - * username/domain if it matches - */ - function isValidInetAddress($data, $strict = false) - { - $regex = $strict ? '/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i'; - if (preg_match($regex, trim($data), $matches)) { - return array($matches[1], $matches[2]); - } else { - return false; - } - } - -} diff --git a/3dparty/Mail/mail.php b/3dparty/Mail/mail.php deleted file mode 100644 index 9135fa2363b..00000000000 --- a/3dparty/Mail/mail.php +++ /dev/null @@ -1,130 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mail.php,v 1.13 2004/09/09 02:08:55 jon Exp $ - -/** - * internal PHP-mail() implementation of the PEAR Mail:: interface. - * @package Mail - * @version $Revision: 1.13 $ - */ -class Mail_mail extends Mail { - - /** - * Any arguments to pass to the mail() function. - * @var string - */ - var $_params = ''; - - /** - * Constructor. - * - * Instantiates a new Mail_mail:: object based on the parameters - * passed in. - * - * @param array $params Extra arguments for the mail() function. - */ - function Mail_mail($params = null) - { - /* The other mail implementations accept parameters as arrays. - * In the interest of being consistent, explode an array into - * a string of parameter arguments. */ - if (is_array($params)) { - $this->_params = join(' ', $params); - } else { - $this->_params = $params; - } - - /* Because the mail() function may pass headers as command - * line arguments, we can't guarantee the use of the standard - * "\r\n" separator. Instead, we use the system's native line - * separator. */ - $this->sep = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n"; - } - - /** - * Implements Mail_mail::send() function using php's built-in mail() - * command. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * - * @access public - */ - function send($recipients, $headers, $body) - { - // If we're passed an array of recipients, implode it. - if (is_array($recipients)) { - $recipients = implode(', ', $recipients); - } - - // Get the Subject out of the headers array so that we can - // pass it as a seperate argument to mail(). - $subject = ''; - if (isset($headers['Subject'])) { - $subject = $headers['Subject']; - unset($headers['Subject']); - } - - // Flatten the headers out. - $headerElements = $this->prepareHeaders($headers); - if (PEAR::isError($headerElements)) { - return $headerElements; - } - list(, $text_headers) = $headerElements; - - /* - * We only use mail()'s optional fifth parameter if the additional - * parameters have been provided and we're not running in safe mode. - */ - if (empty($this->_params) || ini_get('safe_mode')) { - $result = mail($recipients, $subject, $body, $text_headers); - } else { - $result = mail($recipients, $subject, $body, $text_headers, - $this->_params); - } - - /* - * If the mail() function returned failure, we need to create a - * PEAR_Error object and return it instead of the boolean result. - */ - if ($result === false) { - $result = PEAR::raiseError('mail() returned failure'); - } - - return $result; - } - -} diff --git a/3dparty/Mail/mime.php b/3dparty/Mail/mime.php deleted file mode 100644 index 302a2120d78..00000000000 --- a/3dparty/Mail/mime.php +++ /dev/null @@ -1,713 +0,0 @@ - | -// | Tomas V.V.Cox (port to PEAR) | -// +-----------------------------------------------------------------------+ -// -// $Id: mime.php,v 1.39 2005/06/13 21:24:16 cipri Exp $ - -require_once('PEAR.php'); -require_once('Mail/mimePart.php'); - -/** - * Mime mail composer class. Can handle: text and html bodies, embedded html - * images and attachments. - * Documentation and examples of this class are avaible here: - * http://pear.php.net/manual/ - * - * @notes This class is based on HTML Mime Mail class from - * Richard Heyes which was based also - * in the mime_mail.class by Tobias Ratschiller and - * Sascha Schumann - * - * @author Richard Heyes - * @author Tomas V.V.Cox - * @package Mail - * @access public - */ -class Mail_mime -{ - /** - * Contains the plain text part of the email - * @var string - */ - var $_txtbody; - /** - * Contains the html part of the email - * @var string - */ - var $_htmlbody; - /** - * contains the mime encoded text - * @var string - */ - var $_mime; - /** - * contains the multipart content - * @var string - */ - var $_multipart; - /** - * list of the attached images - * @var array - */ - var $_html_images = array(); - /** - * list of the attachements - * @var array - */ - var $_parts = array(); - /** - * Build parameters - * @var array - */ - var $_build_params = array(); - /** - * Headers for the mail - * @var array - */ - var $_headers = array(); - /** - * End Of Line sequence (for serialize) - * @var string - */ - var $_eol; - - - /** - * Constructor function - * - * @access public - */ - function Mail_mime($crlf = "\r\n") - { - $this->_setEOL($crlf); - $this->_build_params = array( - 'text_encoding' => '7bit', - 'html_encoding' => 'quoted-printable', - '7bit_wrap' => 998, - 'html_charset' => 'ISO-8859-1', - 'text_charset' => 'ISO-8859-1', - 'head_charset' => 'ISO-8859-1' - ); - } - - /** - * Wakeup (unserialize) - re-sets EOL constant - * - * @access private - */ - function __wakeup() - { - $this->_setEOL($this->_eol); - } - - /** - * Accessor function to set the body text. Body text is used if - * it's not an html mail being sent or else is used to fill the - * text/plain part that emails clients who don't support - * html should show. - * - * @param string $data Either a string or - * the file name with the contents - * @param bool $isfile If true the first param should be treated - * as a file name, else as a string (default) - * @param bool $append If true the text or file is appended to - * the existing body, else the old body is - * overwritten - * @return mixed true on success or PEAR_Error object - * @access public - */ - function setTXTBody($data, $isfile = false, $append = false) - { - if (!$isfile) { - if (!$append) { - $this->_txtbody = $data; - } else { - $this->_txtbody .= $data; - } - } else { - $cont = $this->_file2str($data); - if (PEAR::isError($cont)) { - return $cont; - } - if (!$append) { - $this->_txtbody = $cont; - } else { - $this->_txtbody .= $cont; - } - } - return true; - } - - /** - * Adds a html part to the mail - * - * @param string $data Either a string or the file name with the - * contents - * @param bool $isfile If true the first param should be treated - * as a file name, else as a string (default) - * @return mixed true on success or PEAR_Error object - * @access public - */ - function setHTMLBody($data, $isfile = false) - { - if (!$isfile) { - $this->_htmlbody = $data; - } else { - $cont = $this->_file2str($data); - if (PEAR::isError($cont)) { - return $cont; - } - $this->_htmlbody = $cont; - } - - return true; - } - - /** - * Adds an image to the list of embedded images. - * - * @param string $file The image file name OR image data itself - * @param string $c_type The content type - * @param string $name The filename of the image. - * Only use if $file is the image data - * @param bool $isfilename Whether $file is a filename or not - * Defaults to true - * @return mixed true on success or PEAR_Error object - * @access public - */ - function addHTMLImage($file, $c_type='application/octet-stream', - $name = '', $isfilename = true) - { - $filedata = ($isfilename === true) ? $this->_file2str($file) - : $file; - if ($isfilename === true) { - $filename = ($name == '' ? basename($file) : basename($name)); - } else { - $filename = basename($name); - } - if (PEAR::isError($filedata)) { - return $filedata; - } - $this->_html_images[] = array( - 'body' => $filedata, - 'name' => $filename, - 'c_type' => $c_type, - 'cid' => md5(uniqid(time())) - ); - return true; - } - - /** - * Adds a file to the list of attachments. - * - * @param string $file The file name of the file to attach - * OR the file data itself - * @param string $c_type The content type - * @param string $name The filename of the attachment - * Only use if $file is the file data - * @param bool $isFilename Whether $file is a filename or not - * Defaults to true - * @return mixed true on success or PEAR_Error object - * @access public - */ - function addAttachment($file, $c_type = 'application/octet-stream', - $name = '', $isfilename = true, - $encoding = 'base64') - { - $filedata = ($isfilename === true) ? $this->_file2str($file) - : $file; - if ($isfilename === true) { - // Force the name the user supplied, otherwise use $file - $filename = (!empty($name)) ? $name : $file; - } else { - $filename = $name; - } - if (empty($filename)) { - return PEAR::raiseError( - 'The supplied filename for the attachment can\'t be empty' - ); - } - $filename = basename($filename); - if (PEAR::isError($filedata)) { - return $filedata; - } - - $this->_parts[] = array( - 'body' => $filedata, - 'name' => $filename, - 'c_type' => $c_type, - 'encoding' => $encoding - ); - return true; - } - - /** - * Get the contents of the given file name as string - * - * @param string $file_name path of file to process - * @return string contents of $file_name - * @access private - */ - function &_file2str($file_name) - { - if (!is_readable($file_name)) { - return PEAR::raiseError('File is not readable ' . $file_name); - } - if (!$fd = fopen($file_name, 'rb')) { - return PEAR::raiseError('Could not open ' . $file_name); - } - $filesize = filesize($file_name); - if ($filesize == 0){ - $cont = ""; - }else{ - $cont = fread($fd, $filesize); - } - fclose($fd); - return $cont; - } - - /** - * Adds a text subpart to the mimePart object and - * returns it during the build process. - * - * @param mixed The object to add the part to, or - * null if a new object is to be created. - * @param string The text to add. - * @return object The text mimePart object - * @access private - */ - function &_addTextPart(&$obj, $text) - { - $params['content_type'] = 'text/plain'; - $params['encoding'] = $this->_build_params['text_encoding']; - $params['charset'] = $this->_build_params['text_charset']; - if (is_object($obj)) { - return $obj->addSubpart($text, $params); - } else { - return new Mail_mimePart($text, $params); - } - } - - /** - * Adds a html subpart to the mimePart object and - * returns it during the build process. - * - * @param mixed The object to add the part to, or - * null if a new object is to be created. - * @return object The html mimePart object - * @access private - */ - function &_addHtmlPart(&$obj) - { - $params['content_type'] = 'text/html'; - $params['encoding'] = $this->_build_params['html_encoding']; - $params['charset'] = $this->_build_params['html_charset']; - if (is_object($obj)) { - return $obj->addSubpart($this->_htmlbody, $params); - } else { - return new Mail_mimePart($this->_htmlbody, $params); - } - } - - /** - * Creates a new mimePart object, using multipart/mixed as - * the initial content-type and returns it during the - * build process. - * - * @return object The multipart/mixed mimePart object - * @access private - */ - function &_addMixedPart() - { - $params['content_type'] = 'multipart/mixed'; - return new Mail_mimePart('', $params); - } - - /** - * Adds a multipart/alternative part to a mimePart - * object (or creates one), and returns it during - * the build process. - * - * @param mixed The object to add the part to, or - * null if a new object is to be created. - * @return object The multipart/mixed mimePart object - * @access private - */ - function &_addAlternativePart(&$obj) - { - $params['content_type'] = 'multipart/alternative'; - if (is_object($obj)) { - return $obj->addSubpart('', $params); - } else { - return new Mail_mimePart('', $params); - } - } - - /** - * Adds a multipart/related part to a mimePart - * object (or creates one), and returns it during - * the build process. - * - * @param mixed The object to add the part to, or - * null if a new object is to be created - * @return object The multipart/mixed mimePart object - * @access private - */ - function &_addRelatedPart(&$obj) - { - $params['content_type'] = 'multipart/related'; - if (is_object($obj)) { - return $obj->addSubpart('', $params); - } else { - return new Mail_mimePart('', $params); - } - } - - /** - * Adds an html image subpart to a mimePart object - * and returns it during the build process. - * - * @param object The mimePart to add the image to - * @param array The image information - * @return object The image mimePart object - * @access private - */ - function &_addHtmlImagePart(&$obj, $value) - { - $params['content_type'] = $value['c_type']; - $params['encoding'] = 'base64'; - $params['disposition'] = 'inline'; - $params['dfilename'] = $value['name']; - $params['cid'] = $value['cid']; - $obj->addSubpart($value['body'], $params); - } - - /** - * Adds an attachment subpart to a mimePart object - * and returns it during the build process. - * - * @param object The mimePart to add the image to - * @param array The attachment information - * @return object The image mimePart object - * @access private - */ - function &_addAttachmentPart(&$obj, $value) - { - $params['content_type'] = $value['c_type']; - $params['encoding'] = $value['encoding']; - $params['disposition'] = 'attachment'; - $params['dfilename'] = $value['name']; - $obj->addSubpart($value['body'], $params); - } - - /** - * Builds the multipart message from the list ($this->_parts) and - * returns the mime content. - * - * @param array Build parameters that change the way the email - * is built. Should be associative. Can contain: - * text_encoding - What encoding to use for plain text - * Default is 7bit - * html_encoding - What encoding to use for html - * Default is quoted-printable - * 7bit_wrap - Number of characters before text is - * wrapped in 7bit encoding - * Default is 998 - * html_charset - The character set to use for html. - * Default is iso-8859-1 - * text_charset - The character set to use for text. - * Default is iso-8859-1 - * head_charset - The character set to use for headers. - * Default is iso-8859-1 - * @return string The mime content - * @access public - */ - function &get($build_params = null) - { - if (isset($build_params)) { - while (list($key, $value) = each($build_params)) { - $this->_build_params[$key] = $value; - } - } - - if (!empty($this->_html_images) AND isset($this->_htmlbody)) { - foreach ($this->_html_images as $value) { - $regex = '#(\s)((?i)src|background|href(?-i))\s*=\s*(["\']?)' . preg_quote($value['name'], '#') . - '\3#'; - $rep = '\1\2=\3cid:' . $value['cid'] .'\3'; - $this->_htmlbody = preg_replace($regex, $rep, - $this->_htmlbody - ); - } - } - - $null = null; - $attachments = !empty($this->_parts) ? true : false; - $html_images = !empty($this->_html_images) ? true : false; - $html = !empty($this->_htmlbody) ? true : false; - $text = (!$html AND !empty($this->_txtbody)) ? true : false; - - switch (true) { - case $text AND !$attachments: - $message =& $this->_addTextPart($null, $this->_txtbody); - break; - - case !$text AND !$html AND $attachments: - $message =& $this->_addMixedPart(); - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - case $text AND $attachments: - $message =& $this->_addMixedPart(); - $this->_addTextPart($message, $this->_txtbody); - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - case $html AND !$attachments AND !$html_images: - if (isset($this->_txtbody)) { - $message =& $this->_addAlternativePart($null); - $this->_addTextPart($message, $this->_txtbody); - $this->_addHtmlPart($message); - } else { - $message =& $this->_addHtmlPart($null); - } - break; - - case $html AND !$attachments AND $html_images: - if (isset($this->_txtbody)) { - $message =& $this->_addAlternativePart($null); - $this->_addTextPart($message, $this->_txtbody); - $related =& $this->_addRelatedPart($message); - } else { - $message =& $this->_addRelatedPart($null); - $related =& $message; - } - $this->_addHtmlPart($related); - for ($i = 0; $i < count($this->_html_images); $i++) { - $this->_addHtmlImagePart($related, $this->_html_images[$i]); - } - break; - - case $html AND $attachments AND !$html_images: - $message =& $this->_addMixedPart(); - if (isset($this->_txtbody)) { - $alt =& $this->_addAlternativePart($message); - $this->_addTextPart($alt, $this->_txtbody); - $this->_addHtmlPart($alt); - } else { - $this->_addHtmlPart($message); - } - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - case $html AND $attachments AND $html_images: - $message =& $this->_addMixedPart(); - if (isset($this->_txtbody)) { - $alt =& $this->_addAlternativePart($message); - $this->_addTextPart($alt, $this->_txtbody); - $rel =& $this->_addRelatedPart($alt); - } else { - $rel =& $this->_addRelatedPart($message); - } - $this->_addHtmlPart($rel); - for ($i = 0; $i < count($this->_html_images); $i++) { - $this->_addHtmlImagePart($rel, $this->_html_images[$i]); - } - for ($i = 0; $i < count($this->_parts); $i++) { - $this->_addAttachmentPart($message, $this->_parts[$i]); - } - break; - - } - - if (isset($message)) { - $output = $message->encode(); - $this->_headers = array_merge($this->_headers, - $output['headers']); - return $output['body']; - - } else { - return false; - } - } - - /** - * Returns an array with the headers needed to prepend to the email - * (MIME-Version and Content-Type). Format of argument is: - * $array['header-name'] = 'header-value'; - * - * @param array $xtra_headers Assoc array with any extra headers. - * Optional. - * @return array Assoc array with the mime headers - * @access public - */ - function &headers($xtra_headers = null) - { - // Content-Type header should already be present, - // So just add mime version header - $headers['MIME-Version'] = '1.0'; - if (isset($xtra_headers)) { - $headers = array_merge($headers, $xtra_headers); - } - $this->_headers = array_merge($headers, $this->_headers); - - return $this->_encodeHeaders($this->_headers); - } - - /** - * Get the text version of the headers - * (usefull if you want to use the PHP mail() function) - * - * @param array $xtra_headers Assoc array with any extra headers. - * Optional. - * @return string Plain text headers - * @access public - */ - function txtHeaders($xtra_headers = null) - { - $headers = $this->headers($xtra_headers); - $ret = ''; - foreach ($headers as $key => $val) { - $ret .= "$key: $val" . MAIL_MIME_CRLF; - } - return $ret; - } - - /** - * Sets the Subject header - * - * @param string $subject String to set the subject to - * access public - */ - function setSubject($subject) - { - $this->_headers['Subject'] = $subject; - } - - /** - * Set an email to the From (the sender) header - * - * @param string $email The email direction to add - * @access public - */ - function setFrom($email) - { - $this->_headers['From'] = $email; - } - - /** - * Add an email to the Cc (carbon copy) header - * (multiple calls to this method are allowed) - * - * @param string $email The email direction to add - * @access public - */ - function addCc($email) - { - if (isset($this->_headers['Cc'])) { - $this->_headers['Cc'] .= ", $email"; - } else { - $this->_headers['Cc'] = $email; - } - } - - /** - * Add an email to the Bcc (blank carbon copy) header - * (multiple calls to this method are allowed) - * - * @param string $email The email direction to add - * @access public - */ - function addBcc($email) - { - if (isset($this->_headers['Bcc'])) { - $this->_headers['Bcc'] .= ", $email"; - } else { - $this->_headers['Bcc'] = $email; - } - } - - /** - * Encodes a header as per RFC2047 - * - * @param string $input The header data to encode - * @return string Encoded data - * @access private - */ - function _encodeHeaders($input) - { - foreach ($input as $hdr_name => $hdr_value) { - preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $hdr_value, $matches); - foreach ($matches[1] as $value) { - $replacement = preg_replace('/([\x80-\xFF])/e', - '"=" . - strtoupper(dechex(ord("\1")))', - $value); - $hdr_value = str_replace($value, '=?' . - $this->_build_params['head_charset'] . - '?Q?' . $replacement . '?=', - $hdr_value); - } - $input[$hdr_name] = $hdr_value; - } - - return $input; - } - - /** - * Set the object's end-of-line and define the constant if applicable - * - * @param string $eol End Of Line sequence - * @access private - */ - function _setEOL($eol) - { - $this->_eol = $eol; - if (!defined('MAIL_MIME_CRLF')) { - define('MAIL_MIME_CRLF', $this->_eol, true); - } - } - - - -} // End of class -?> diff --git a/3dparty/Mail/mimeDecode.php b/3dparty/Mail/mimeDecode.php deleted file mode 100644 index d5187d9b7aa..00000000000 --- a/3dparty/Mail/mimeDecode.php +++ /dev/null @@ -1,837 +0,0 @@ - | -// +-----------------------------------------------------------------------+ - -require_once 'PEAR.php'; - -/** -* +----------------------------- IMPORTANT ------------------------------+ -* | Usage of this class compared to native php extensions such as | -* | mailparse or imap, is slow and may be feature deficient. If available| -* | you are STRONGLY recommended to use the php extensions. | -* +----------------------------------------------------------------------+ -* -* Mime Decoding class -* -* This class will parse a raw mime email and return -* the structure. Returned structure is similar to -* that returned by imap_fetchstructure(). -* -* USAGE: (assume $input is your raw email) -* -* $decode = new Mail_mimeDecode($input, "\r\n"); -* $structure = $decode->decode(); -* print_r($structure); -* -* Or statically: -* -* $params['input'] = $input; -* $structure = Mail_mimeDecode::decode($params); -* print_r($structure); -* -* TODO: -* o Implement multipart/appledouble -* o UTF8: ??? - - > 4. We have also found a solution for decoding the UTF-8 - > headers. Therefore I made the following function: - > - > function decode_utf8($txt) { - > $trans=array("ő"=>"õ","ű"=>"û","Ő"=>"Õ","Ű" - =>"Û"); - > $txt=strtr($txt,$trans); - > return(utf8_decode($txt)); - > } - > - > And I have inserted the following line to the class: - > - > if (strtolower($charset)=="utf-8") $text=decode_utf8($text); - > - > ... before the following one in the "_decodeHeader" function: - > - > $input = str_replace($encoded, $text, $input); - > - > This way from now on it can easily decode the UTF-8 headers too. - -* -* @author Richard Heyes -* @version $Revision: 1.46 $ -* @package Mail -*/ -class Mail_mimeDecode extends PEAR -{ - /** - * The raw email to decode - * @var string - */ - var $_input; - - /** - * The header part of the input - * @var string - */ - var $_header; - - /** - * The body part of the input - * @var string - */ - var $_body; - - /** - * If an error occurs, this is used to store the message - * @var string - */ - var $_error; - - /** - * Flag to determine whether to include bodies in the - * returned object. - * @var boolean - */ - var $_include_bodies; - - /** - * Flag to determine whether to decode bodies - * @var boolean - */ - var $_decode_bodies; - - /** - * Flag to determine whether to decode headers - * @var boolean - */ - var $_decode_headers; - - /** - * Constructor. - * - * Sets up the object, initialise the variables, and splits and - * stores the header and body of the input. - * - * @param string The input to decode - * @access public - */ - function Mail_mimeDecode($input) - { - list($header, $body) = $this->_splitBodyHeader($input); - - $this->_input = $input; - $this->_header = $header; - $this->_body = $body; - $this->_decode_bodies = false; - $this->_include_bodies = true; - } - - /** - * Begins the decoding process. If called statically - * it will create an object and call the decode() method - * of it. - * - * @param array An array of various parameters that determine - * various things: - * include_bodies - Whether to include the body in the returned - * object. - * decode_bodies - Whether to decode the bodies - * of the parts. (Transfer encoding) - * decode_headers - Whether to decode headers - * input - If called statically, this will be treated - * as the input - * @return object Decoded results - * @access public - */ - function decode($params = null) - { - // determine if this method has been called statically - $isStatic = !(isset($this) && get_class($this) == __CLASS__); - - // Have we been called statically? - // If so, create an object and pass details to that. - if ($isStatic AND isset($params['input'])) { - - $obj = new Mail_mimeDecode($params['input']); - $structure = $obj->decode($params); - - // Called statically but no input - } elseif ($isStatic) { - return PEAR::raiseError('Called statically and no input given'); - - // Called via an object - } else { - $this->_include_bodies = isset($params['include_bodies']) ? - $params['include_bodies'] : false; - $this->_decode_bodies = isset($params['decode_bodies']) ? - $params['decode_bodies'] : false; - $this->_decode_headers = isset($params['decode_headers']) ? - $params['decode_headers'] : false; - - $structure = $this->_decode($this->_header, $this->_body); - if ($structure === false) { - $structure = $this->raiseError($this->_error); - } - } - - return $structure; - } - - /** - * Performs the decoding. Decodes the body string passed to it - * If it finds certain content-types it will call itself in a - * recursive fashion - * - * @param string Header section - * @param string Body section - * @return object Results of decoding process - * @access private - */ - function _decode($headers, $body, $default_ctype = 'text/plain') - { - $return = new stdClass; - $return->headers = array(); - $headers = $this->_parseHeaders($headers); - - foreach ($headers as $value) { - if (isset($return->headers[strtolower($value['name'])]) AND !is_array($return->headers[strtolower($value['name'])])) { - $return->headers[strtolower($value['name'])] = array($return->headers[strtolower($value['name'])]); - $return->headers[strtolower($value['name'])][] = $value['value']; - - } elseif (isset($return->headers[strtolower($value['name'])])) { - $return->headers[strtolower($value['name'])][] = $value['value']; - - } else { - $return->headers[strtolower($value['name'])] = $value['value']; - } - } - - reset($headers); - while (list($key, $value) = each($headers)) { - $headers[$key]['name'] = strtolower($headers[$key]['name']); - switch ($headers[$key]['name']) { - - case 'content-type': - $content_type = $this->_parseHeaderValue($headers[$key]['value']); - - if (preg_match('/([0-9a-z+.-]+)\/([0-9a-z+.-]+)/i', $content_type['value'], $regs)) { - $return->ctype_primary = $regs[1]; - $return->ctype_secondary = $regs[2]; - } - - if (isset($content_type['other'])) { - while (list($p_name, $p_value) = each($content_type['other'])) { - $return->ctype_parameters[$p_name] = $p_value; - } - } - break; - - case 'content-disposition': - $content_disposition = $this->_parseHeaderValue($headers[$key]['value']); - $return->disposition = $content_disposition['value']; - if (isset($content_disposition['other'])) { - while (list($p_name, $p_value) = each($content_disposition['other'])) { - $return->d_parameters[$p_name] = $p_value; - } - } - break; - - case 'content-transfer-encoding': - $content_transfer_encoding = $this->_parseHeaderValue($headers[$key]['value']); - break; - } - } - - if (isset($content_type)) { - switch (strtolower($content_type['value'])) { - case 'text/plain': - $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null; - break; - - case 'text/html': - $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit'; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body) : null; - break; - - case 'multipart/parallel': - case 'multipart/report': // RFC1892 - case 'multipart/signed': // PGP - case 'multipart/digest': - case 'multipart/alternative': - case 'multipart/related': - case 'multipart/mixed': - if(!isset($content_type['other']['boundary'])){ - $this->_error = 'No boundary found for ' . $content_type['value'] . ' part'; - return false; - } - - $default_ctype = (strtolower($content_type['value']) === 'multipart/digest') ? 'message/rfc822' : 'text/plain'; - - $parts = $this->_boundarySplit($body, $content_type['other']['boundary']); - for ($i = 0; $i < count($parts); $i++) { - list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]); - $part = $this->_decode($part_header, $part_body, $default_ctype); - if($part === false) - $part = $this->raiseError($this->_error); - $return->parts[] = $part; - } - break; - - case 'message/rfc822': - $obj = &new Mail_mimeDecode($body); - $return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies, - 'decode_bodies' => $this->_decode_bodies, - 'decode_headers' => $this->_decode_headers)); - unset($obj); - break; - - default: - if(!isset($content_transfer_encoding['value'])) - $content_transfer_encoding['value'] = '7bit'; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $content_transfer_encoding['value']) : $body) : null; - break; - } - - } else { - $ctype = explode('/', $default_ctype); - $return->ctype_primary = $ctype[0]; - $return->ctype_secondary = $ctype[1]; - $this->_include_bodies ? $return->body = ($this->_decode_bodies ? $this->_decodeBody($body) : $body) : null; - } - - return $return; - } - - /** - * Given the output of the above function, this will return an - * array of references to the parts, indexed by mime number. - * - * @param object $structure The structure to go through - * @param string $mime_number Internal use only. - * @return array Mime numbers - */ - function &getMimeNumbers(&$structure, $no_refs = false, $mime_number = '', $prepend = '') - { - $return = array(); - if (!empty($structure->parts)) { - if ($mime_number != '') { - $structure->mime_id = $prepend . $mime_number; - $return[$prepend . $mime_number] = &$structure; - } - for ($i = 0; $i < count($structure->parts); $i++) { - - - if (!empty($structure->headers['content-type']) AND substr(strtolower($structure->headers['content-type']), 0, 8) == 'message/') { - $prepend = $prepend . $mime_number . '.'; - $_mime_number = ''; - } else { - $_mime_number = ($mime_number == '' ? $i + 1 : sprintf('%s.%s', $mime_number, $i + 1)); - } - - $arr = &Mail_mimeDecode::getMimeNumbers($structure->parts[$i], $no_refs, $_mime_number, $prepend); - foreach ($arr as $key => $val) { - $no_refs ? $return[$key] = '' : $return[$key] = &$arr[$key]; - } - } - } else { - if ($mime_number == '') { - $mime_number = '1'; - } - $structure->mime_id = $prepend . $mime_number; - $no_refs ? $return[$prepend . $mime_number] = '' : $return[$prepend . $mime_number] = &$structure; - } - - return $return; - } - - /** - * Given a string containing a header and body - * section, this function will split them (at the first - * blank line) and return them. - * - * @param string Input to split apart - * @return array Contains header and body section - * @access private - */ - function _splitBodyHeader($input) - { - if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $match)) { - return array($match[1], $match[2]); - } - $this->_error = 'Could not split header and body'; - return false; - } - - /** - * Parse headers given in $input and return - * as assoc array. - * - * @param string Headers to parse - * @return array Contains parsed headers - * @access private - */ - function _parseHeaders($input) - { - - if ($input !== '') { - // Unfold the input - $input = preg_replace("/\r?\n/", "\r\n", $input); - $input = preg_replace("/\r\n(\t| )+/", ' ', $input); - $headers = explode("\r\n", trim($input)); - - foreach ($headers as $value) { - $hdr_name = substr($value, 0, $pos = strpos($value, ':')); - $hdr_value = substr($value, $pos+1); - if($hdr_value[0] == ' ') - $hdr_value = substr($hdr_value, 1); - - $return[] = array( - 'name' => $hdr_name, - 'value' => $this->_decode_headers ? $this->_decodeHeader($hdr_value) : $hdr_value - ); - } - } else { - $return = array(); - } - - return $return; - } - - /** - * Function to parse a header value, - * extract first part, and any secondary - * parts (after ;) This function is not as - * robust as it could be. Eg. header comments - * in the wrong place will probably break it. - * - * @param string Header value to parse - * @return array Contains parsed result - * @access private - */ - function _parseHeaderValue($input) - { - - if (($pos = strpos($input, ';')) !== false) { - - $return['value'] = trim(substr($input, 0, $pos)); - $input = trim(substr($input, $pos+1)); - - if (strlen($input) > 0) { - - // This splits on a semi-colon, if there's no preceeding backslash - // Now works with quoted values; had to glue the \; breaks in PHP - // the regex is already bordering on incomprehensible - $splitRegex = '/([^;\'"]*[\'"]([^\'"]*([^\'"]*)*)[\'"][^;\'"]*|([^;]+))(;|$)/'; - preg_match_all($splitRegex, $input, $matches); - $parameters = array(); - for ($i=0; $i_quotedPrintableDecode($input); - break; - - case 'base64': - return base64_decode($input); - break; - - default: - return $input; - } - } - - /** - * Given a quoted-printable string, this - * function will decode and return it. - * - * @param string Input body to decode - * @return string Decoded body - * @access private - */ - function _quotedPrintableDecode($input) - { - // Remove soft line breaks - $input = preg_replace("/=\r?\n/", '', $input); - - // Replace encoded characters - $input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\\1'))", $input); - - return $input; - } - - /** - * Checks the input for uuencoded files and returns - * an array of them. Can be called statically, eg: - * - * $files =& Mail_mimeDecode::uudecode($some_text); - * - * It will check for the begin 666 ... end syntax - * however and won't just blindly decode whatever you - * pass it. - * - * @param string Input body to look for attahcments in - * @return array Decoded bodies, filenames and permissions - * @access public - * @author Unknown - */ - function &uudecode($input) - { - // Find all uuencoded sections - preg_match_all("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", $input, $matches); - - for ($j = 0; $j < count($matches[3]); $j++) { - - $str = $matches[3][$j]; - $filename = $matches[2][$j]; - $fileperm = $matches[1][$j]; - - $file = ''; - $str = preg_split("/\r?\n/", trim($str)); - $strlen = count($str); - - for ($i = 0; $i < $strlen; $i++) { - $pos = 1; - $d = 0; - $len=(int)(((ord(substr($str[$i],0,1)) -32) - ' ') & 077); - - while (($d + 3 <= $len) AND ($pos + 4 <= strlen($str[$i]))) { - $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); - $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); - $c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20); - $c3 = (ord(substr($str[$i],$pos+3,1)) ^ 0x20); - $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); - - $file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2)); - - $file .= chr(((($c2 - ' ') & 077) << 6) | (($c3 - ' ') & 077)); - - $pos += 4; - $d += 3; - } - - if (($d + 2 <= $len) && ($pos + 3 <= strlen($str[$i]))) { - $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); - $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); - $c2 = (ord(substr($str[$i],$pos+2,1)) ^ 0x20); - $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); - - $file .= chr(((($c1 - ' ') & 077) << 4) | ((($c2 - ' ') & 077) >> 2)); - - $pos += 3; - $d += 2; - } - - if (($d + 1 <= $len) && ($pos + 2 <= strlen($str[$i]))) { - $c0 = (ord(substr($str[$i],$pos,1)) ^ 0x20); - $c1 = (ord(substr($str[$i],$pos+1,1)) ^ 0x20); - $file .= chr(((($c0 - ' ') & 077) << 2) | ((($c1 - ' ') & 077) >> 4)); - - } - } - $files[] = array('filename' => $filename, 'fileperm' => $fileperm, 'filedata' => $file); - } - - return $files; - } - - /** - * getSendArray() returns the arguments required for Mail::send() - * used to build the arguments for a mail::send() call - * - * Usage: - * $mailtext = Full email (for example generated by a template) - * $decoder = new Mail_mimeDecode($mailtext); - * $parts = $decoder->getSendArray(); - * if (!PEAR::isError($parts) { - * list($recipents,$headers,$body) = $parts; - * $mail = Mail::factory('smtp'); - * $mail->send($recipents,$headers,$body); - * } else { - * echo $parts->message; - * } - * @return mixed array of recipeint, headers,body or Pear_Error - * @access public - * @author Alan Knowles - */ - function getSendArray() - { - // prevent warning if this is not set - $this->_decode_headers = FALSE; - $headerlist =$this->_parseHeaders($this->_header); - $to = ""; - if (!$headerlist) { - return $this->raiseError("Message did not contain headers"); - } - foreach($headerlist as $item) { - $header[$item['name']] = $item['value']; - switch (strtolower($item['name'])) { - case "to": - case "cc": - case "bcc": - $to = ",".$item['value']; - default: - break; - } - } - if ($to == "") { - return $this->raiseError("Message did not contain any recipents"); - } - $to = substr($to,1); - return array($to,$header,$this->_body); - } - - /** - * Returns a xml copy of the output of - * Mail_mimeDecode::decode. Pass the output in as the - * argument. This function can be called statically. Eg: - * - * $output = $obj->decode(); - * $xml = Mail_mimeDecode::getXML($output); - * - * The DTD used for this should have been in the package. Or - * alternatively you can get it from cvs, or here: - * http://www.phpguru.org/xmail/xmail.dtd. - * - * @param object Input to convert to xml. This should be the - * output of the Mail_mimeDecode::decode function - * @return string XML version of input - * @access public - */ - function getXML($input) - { - $crlf = "\r\n"; - $output = '' . $crlf . - '' . $crlf . - '' . $crlf . - Mail_mimeDecode::_getXML($input) . - ''; - - return $output; - } - - /** - * Function that does the actual conversion to xml. Does a single - * mimepart at a time. - * - * @param object Input to convert to xml. This is a mimepart object. - * It may or may not contain subparts. - * @param integer Number of tabs to indent - * @return string XML version of input - * @access private - */ - function _getXML($input, $indent = 1) - { - $htab = "\t"; - $crlf = "\r\n"; - $output = ''; - $headers = @(array)$input->headers; - - foreach ($headers as $hdr_name => $hdr_value) { - - // Multiple headers with this name - if (is_array($headers[$hdr_name])) { - for ($i = 0; $i < count($hdr_value); $i++) { - $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value[$i], $indent); - } - - // Only one header of this sort - } else { - $output .= Mail_mimeDecode::_getXML_helper($hdr_name, $hdr_value, $indent); - } - } - - if (!empty($input->parts)) { - for ($i = 0; $i < count($input->parts); $i++) { - $output .= $crlf . str_repeat($htab, $indent) . '' . $crlf . - Mail_mimeDecode::_getXML($input->parts[$i], $indent+1) . - str_repeat($htab, $indent) . '' . $crlf; - } - } elseif (isset($input->body)) { - $output .= $crlf . str_repeat($htab, $indent) . 'body . ']]>' . $crlf; - } - - return $output; - } - - /** - * Helper function to _getXML(). Returns xml of a header. - * - * @param string Name of header - * @param string Value of header - * @param integer Number of tabs to indent - * @return string XML version of input - * @access private - */ - function _getXML_helper($hdr_name, $hdr_value, $indent) - { - $htab = "\t"; - $crlf = "\r\n"; - $return = ''; - - $new_hdr_value = ($hdr_name != 'received') ? Mail_mimeDecode::_parseHeaderValue($hdr_value) : array('value' => $hdr_value); - $new_hdr_name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $hdr_name))); - - // Sort out any parameters - if (!empty($new_hdr_value['other'])) { - foreach ($new_hdr_value['other'] as $paramname => $paramvalue) { - $params[] = str_repeat($htab, $indent) . $htab . '' . $crlf . - str_repeat($htab, $indent) . $htab . $htab . '' . htmlspecialchars($paramname) . '' . $crlf . - str_repeat($htab, $indent) . $htab . $htab . '' . htmlspecialchars($paramvalue) . '' . $crlf . - str_repeat($htab, $indent) . $htab . '' . $crlf; - } - - $params = implode('', $params); - } else { - $params = ''; - } - - $return = str_repeat($htab, $indent) . '
' . $crlf . - str_repeat($htab, $indent) . $htab . '' . htmlspecialchars($new_hdr_name) . '' . $crlf . - str_repeat($htab, $indent) . $htab . '' . htmlspecialchars($new_hdr_value['value']) . '' . $crlf . - $params . - str_repeat($htab, $indent) . '
' . $crlf; - - return $return; - } - -} // End of class -?> diff --git a/3dparty/Mail/mimePart.php b/3dparty/Mail/mimePart.php deleted file mode 100644 index c0050d41127..00000000000 --- a/3dparty/Mail/mimePart.php +++ /dev/null @@ -1,351 +0,0 @@ - | -// +-----------------------------------------------------------------------+ - -/** -* -* Raw mime encoding class -* -* What is it? -* This class enables you to manipulate and build -* a mime email from the ground up. -* -* Why use this instead of mime.php? -* mime.php is a userfriendly api to this class for -* people who aren't interested in the internals of -* mime mail. This class however allows full control -* over the email. -* -* Eg. -* -* // Since multipart/mixed has no real body, (the body is -* // the subpart), we set the body argument to blank. -* -* $params['content_type'] = 'multipart/mixed'; -* $email = new Mail_mimePart('', $params); -* -* // Here we add a text part to the multipart we have -* // already. Assume $body contains plain text. -* -* $params['content_type'] = 'text/plain'; -* $params['encoding'] = '7bit'; -* $text = $email->addSubPart($body, $params); -* -* // Now add an attachment. Assume $attach is -* the contents of the attachment -* -* $params['content_type'] = 'application/zip'; -* $params['encoding'] = 'base64'; -* $params['disposition'] = 'attachment'; -* $params['dfilename'] = 'example.zip'; -* $attach =& $email->addSubPart($body, $params); -* -* // Now build the email. Note that the encode -* // function returns an associative array containing two -* // elements, body and headers. You will need to add extra -* // headers, (eg. Mime-Version) before sending. -* -* $email = $message->encode(); -* $email['headers'][] = 'Mime-Version: 1.0'; -* -* -* Further examples are available at http://www.phpguru.org -* -* TODO: -* - Set encode() to return the $obj->encoded if encode() -* has already been run. Unless a flag is passed to specifically -* re-build the message. -* -* @author Richard Heyes -* @version $Revision: 1.13 $ -* @package Mail -*/ - -class Mail_mimePart { - - /** - * The encoding type of this part - * @var string - */ - var $_encoding; - - /** - * An array of subparts - * @var array - */ - var $_subparts; - - /** - * The output of this part after being built - * @var string - */ - var $_encoded; - - /** - * Headers for this part - * @var array - */ - var $_headers; - - /** - * The body of this part (not encoded) - * @var string - */ - var $_body; - - /** - * Constructor. - * - * Sets up the object. - * - * @param $body - The body of the mime part if any. - * @param $params - An associative array of parameters: - * content_type - The content type for this part eg multipart/mixed - * encoding - The encoding to use, 7bit, 8bit, base64, or quoted-printable - * cid - Content ID to apply - * disposition - Content disposition, inline or attachment - * dfilename - Optional filename parameter for content disposition - * description - Content description - * charset - Character set to use - * @access public - */ - function Mail_mimePart($body = '', $params = array()) - { - if (!defined('MAIL_MIMEPART_CRLF')) { - define('MAIL_MIMEPART_CRLF', defined('MAIL_MIME_CRLF') ? MAIL_MIME_CRLF : "\r\n", TRUE); - } - - foreach ($params as $key => $value) { - switch ($key) { - case 'content_type': - $headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : ''); - break; - - case 'encoding': - $this->_encoding = $value; - $headers['Content-Transfer-Encoding'] = $value; - break; - - case 'cid': - $headers['Content-ID'] = '<' . $value . '>'; - break; - - case 'disposition': - $headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : ''); - break; - - case 'dfilename': - if (isset($headers['Content-Disposition'])) { - $headers['Content-Disposition'] .= '; filename="' . $value . '"'; - } else { - $dfilename = $value; - } - break; - - case 'description': - $headers['Content-Description'] = $value; - break; - - case 'charset': - if (isset($headers['Content-Type'])) { - $headers['Content-Type'] .= '; charset="' . $value . '"'; - } else { - $charset = $value; - } - break; - } - } - - // Default content-type - if (!isset($headers['Content-Type'])) { - $headers['Content-Type'] = 'text/plain'; - } - - //Default encoding - if (!isset($this->_encoding)) { - $this->_encoding = '7bit'; - } - - // Assign stuff to member variables - $this->_encoded = array(); - $this->_headers = $headers; - $this->_body = $body; - } - - /** - * encode() - * - * Encodes and returns the email. Also stores - * it in the encoded member variable - * - * @return An associative array containing two elements, - * body and headers. The headers element is itself - * an indexed array. - * @access public - */ - function encode() - { - $encoded =& $this->_encoded; - - if (!empty($this->_subparts)) { - srand((double)microtime()*1000000); - $boundary = '=_' . md5(rand() . microtime()); - $this->_headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF . "\t" . 'boundary="' . $boundary . '"'; - - // Add body parts to $subparts - for ($i = 0; $i < count($this->_subparts); $i++) { - $headers = array(); - $tmp = $this->_subparts[$i]->encode(); - foreach ($tmp['headers'] as $key => $value) { - $headers[] = $key . ': ' . $value; - } - $subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body']; - } - - $encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF . - implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) . - '--' . $boundary.'--' . MAIL_MIMEPART_CRLF; - - } else { - $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding) . MAIL_MIMEPART_CRLF; - } - - // Add headers to $encoded - $encoded['headers'] =& $this->_headers; - - return $encoded; - } - - /** - * &addSubPart() - * - * Adds a subpart to current mime part and returns - * a reference to it - * - * @param $body The body of the subpart, if any. - * @param $params The parameters for the subpart, same - * as the $params argument for constructor. - * @return A reference to the part you just added. It is - * crucial if using multipart/* in your subparts that - * you use =& in your script when calling this function, - * otherwise you will not be able to add further subparts. - * @access public - */ - function &addSubPart($body, $params) - { - $this->_subparts[] = new Mail_mimePart($body, $params); - return $this->_subparts[count($this->_subparts) - 1]; - } - - /** - * _getEncodedData() - * - * Returns encoded data based upon encoding passed to it - * - * @param $data The data to encode. - * @param $encoding The encoding type to use, 7bit, base64, - * or quoted-printable. - * @access private - */ - function _getEncodedData($data, $encoding) - { - switch ($encoding) { - case '8bit': - case '7bit': - return $data; - break; - - case 'quoted-printable': - return $this->_quotedPrintableEncode($data); - break; - - case 'base64': - return rtrim(chunk_split(base64_encode($data), 76, MAIL_MIMEPART_CRLF)); - break; - - default: - return $data; - } - } - - /** - * quoteadPrintableEncode() - * - * Encodes data to quoted-printable standard. - * - * @param $input The data to encode - * @param $line_max Optional max line length. Should - * not be more than 76 chars - * - * @access private - */ - function _quotedPrintableEncode($input , $line_max = 76) - { - $lines = preg_split("/\r?\n/", $input); - $eol = MAIL_MIMEPART_CRLF; - $escape = '='; - $output = ''; - - while(list(, $line) = each($lines)){ - - $linlen = strlen($line); - $newline = ''; - - for ($i = 0; $i < $linlen; $i++) { - $char = substr($line, $i, 1); - $dec = ord($char); - - if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only - $char = '=20'; - - } elseif(($dec == 9) AND ($i == ($linlen - 1))) { // convert tab at eol only - $char = '=09'; - } elseif($dec == 9) { - ; // Do nothing if a tab. - } elseif(($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) { - $char = $escape . strtoupper(sprintf('%02s', dechex($dec))); - } - - if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted - $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay - $newline = ''; - } - $newline .= $char; - } // end of for - $output .= $newline . $eol; - } - $output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf - return $output; - } -} // End of class -?> diff --git a/3dparty/Mail/null.php b/3dparty/Mail/null.php deleted file mode 100644 index 982bfa45b6d..00000000000 --- a/3dparty/Mail/null.php +++ /dev/null @@ -1,60 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: null.php,v 1.2 2004/04/06 05:19:03 jon Exp $ -// - -/** - * Null implementation of the PEAR Mail:: interface. - * @access public - * @package Mail - * @version $Revision: 1.2 $ - */ -class Mail_null extends Mail { - - /** - * Implements Mail_null::send() function. Silently discards all - * mail. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - */ - function send($recipients, $headers, $body) - { - return true; - } - -} diff --git a/3dparty/Mail/sendmail.php b/3dparty/Mail/sendmail.php deleted file mode 100644 index 39a43c25062..00000000000 --- a/3dparty/Mail/sendmail.php +++ /dev/null @@ -1,145 +0,0 @@ - | -// +----------------------------------------------------------------------+ - -/** - * Sendmail implementation of the PEAR Mail:: interface. - * @access public - * @package Mail - * @version $Revision: 1.10 $ - */ -class Mail_sendmail extends Mail { - - /** - * The location of the sendmail or sendmail wrapper binary on the - * filesystem. - * @var string - */ - var $sendmail_path = '/usr/sbin/sendmail'; - - /** - * Any extra command-line parameters to pass to the sendmail or - * sendmail wrapper binary. - * @var string - */ - var $sendmail_args = ''; - - /** - * Constructor. - * - * Instantiates a new Mail_sendmail:: object based on the parameters - * passed in. It looks for the following parameters: - * sendmail_path The location of the sendmail binary on the - * filesystem. Defaults to '/usr/sbin/sendmail'. - * - * sendmail_args Any extra parameters to pass to the sendmail - * or sendmail wrapper binary. - * - * If a parameter is present in the $params array, it replaces the - * default. - * - * @param array $params Hash containing any parameters different from the - * defaults. - * @access public - */ - function Mail_sendmail($params) - { - if (isset($params['sendmail_path'])) $this->sendmail_path = $params['sendmail_path']; - if (isset($params['sendmail_args'])) $this->sendmail_args = $params['sendmail_args']; - - /* - * Because we need to pass message headers to the sendmail program on - * the commandline, we can't guarantee the use of the standard "\r\n" - * separator. Instead, we use the system's native line separator. - */ - $this->sep = (strstr(PHP_OS, 'WIN')) ? "\r\n" : "\n"; - } - - /** - * Implements Mail::send() function using the sendmail - * command-line binary. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (ie, 'Subject'), and the array value - * is the header value (ie, 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - */ - function send($recipients, $headers, $body) - { - $recipients = $this->parseRecipients($recipients); - if (PEAR::isError($recipients)) { - return $recipients; - } - $recipients = escapeShellCmd(implode(' ', $recipients)); - - $headerElements = $this->prepareHeaders($headers); - if (PEAR::isError($headerElements)) { - return $headerElements; - } - list($from, $text_headers) = $headerElements; - - if (!isset($from)) { - return PEAR::raiseError('No from address given.'); - } elseif (strstr($from, ' ') || - strstr($from, ';') || - strstr($from, '&') || - strstr($from, '`')) { - return PEAR::raiseError('From address specified with dangerous characters.'); - } - - $result = 0; - if (@is_file($this->sendmail_path)) { - $from = escapeShellCmd($from); - $mail = popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f$from -- $recipients", 'w'); - fputs($mail, $text_headers); - fputs($mail, $this->sep); // newline to end the headers section - fputs($mail, $body); - $result = pclose($mail); - if (version_compare(phpversion(), '4.2.3') == -1) { - // With older php versions, we need to shift the - // pclose result to get the exit code. - $result = $result >> 8 & 0xFF; - } - } else { - return PEAR::raiseError('sendmail [' . $this->sendmail_path . '] is not a valid file'); - } - - if ($result != 0) { - return PEAR::raiseError('sendmail returned error code ' . $result, - $result); - } - - return true; - } - -} diff --git a/3dparty/Mail/smtp.php b/3dparty/Mail/smtp.php deleted file mode 100644 index 40686a61689..00000000000 --- a/3dparty/Mail/smtp.php +++ /dev/null @@ -1,223 +0,0 @@ - | -// | Jon Parise | -// +----------------------------------------------------------------------+ - -/** - * SMTP implementation of the PEAR Mail:: interface. Requires the PEAR - * Net_SMTP:: class. - * @access public - * @package Mail - * @version $Revision: 1.20 $ - */ -class Mail_smtp extends Mail { - - /** - * The SMTP host to connect to. - * @var string - */ - var $host = 'localhost'; - - /** - * The port the SMTP server is on. - * @var integer - */ - var $port = 25; - - /** - * Should SMTP authentication be used? - * - * This value may be set to true, false or the name of a specific - * authentication method. - * - * If the value is set to true, the Net_SMTP package will attempt to use - * the best authentication method advertised by the remote SMTP server. - * - * @var mixed - */ - var $auth = false; - - /** - * The username to use if the SMTP server requires authentication. - * @var string - */ - var $username = ''; - - /** - * The password to use if the SMTP server requires authentication. - * @var string - */ - var $password = ''; - - /** - * Hostname or domain that will be sent to the remote SMTP server in the - * HELO / EHLO message. - * - * @var string - */ - var $localhost = 'localhost'; - - /** - * SMTP connection timeout value. NULL indicates no timeout. - * - * @var integer - */ - var $timeout = null; - - /** - * Whether to use VERP or not. If not a boolean, the string value - * will be used as the VERP separators. - * - * @var mixed boolean or string - */ - var $verp = false; - - /** - * Turn on Net_SMTP debugging? - * - * @var boolean $debug - */ - var $debug = false; - - /** - * Constructor. - * - * Instantiates a new Mail_smtp:: object based on the parameters - * passed in. It looks for the following parameters: - * host The server to connect to. Defaults to localhost. - * port The port to connect to. Defaults to 25. - * auth SMTP authentication. Defaults to none. - * username The username to use for SMTP auth. No default. - * password The password to use for SMTP auth. No default. - * localhost The local hostname / domain. Defaults to localhost. - * timeout The SMTP connection timeout. Defaults to none. - * verp Whether to use VERP or not. Defaults to false. - * debug Activate SMTP debug mode? Defaults to false. - * - * If a parameter is present in the $params array, it replaces the - * default. - * - * @param array Hash containing any parameters different from the - * defaults. - * @access public - */ - function Mail_smtp($params) - { - if (isset($params['host'])) $this->host = $params['host']; - if (isset($params['port'])) $this->port = $params['port']; - if (isset($params['auth'])) $this->auth = $params['auth']; - if (isset($params['username'])) $this->username = $params['username']; - if (isset($params['password'])) $this->password = $params['password']; - if (isset($params['localhost'])) $this->localhost = $params['localhost']; - if (isset($params['timeout'])) $this->timeout = $params['timeout']; - if (isset($params['verp'])) $this->verp = $params['verp']; - if (isset($params['debug'])) $this->debug = (boolean)$params['debug']; - } - - /** - * Implements Mail::send() function using SMTP. - * - * @param mixed $recipients Either a comma-seperated list of recipients - * (RFC822 compliant), or an array of recipients, - * each RFC822 valid. This may contain recipients not - * specified in the headers, for Bcc:, resending - * messages, etc. - * - * @param array $headers The array of headers to send with the mail, in an - * associative array, where the array key is the - * header name (e.g., 'Subject'), and the array value - * is the header value (e.g., 'test'). The header - * produced from those values would be 'Subject: - * test'. - * - * @param string $body The full text of the message body, including any - * Mime parts, etc. - * - * @return mixed Returns true on success, or a PEAR_Error - * containing a descriptive error message on - * failure. - * @access public - */ - function send($recipients, $headers, $body) - { - include_once 'Net/SMTP.php'; - - if (!($smtp = &new Net_SMTP($this->host, $this->port, $this->localhost))) { - return PEAR::raiseError('unable to instantiate Net_SMTP object'); - } - - if ($this->debug) { - $smtp->setDebug(true); - } - - if (PEAR::isError($smtp->connect($this->timeout))) { - return PEAR::raiseError('unable to connect to smtp server ' . - $this->host . ':' . $this->port); - } - - if ($this->auth) { - $method = is_string($this->auth) ? $this->auth : ''; - - if (PEAR::isError($smtp->auth($this->username, $this->password, - $method))) { - return PEAR::raiseError('unable to authenticate to smtp server'); - } - } - - $headerElements = $this->prepareHeaders($headers); - if (PEAR::isError($headerElements)) { - return $headerElements; - } - list($from, $text_headers) = $headerElements; - - /* Since few MTAs are going to allow this header to be forged - * unless it's in the MAIL FROM: exchange, we'll use - * Return-Path instead of From: if it's set. */ - if (!empty($headers['Return-Path'])) { - $from = $headers['Return-Path']; - } - - if (!isset($from)) { - return PEAR::raiseError('No from address given'); - } - - $args['verp'] = $this->verp; - if (PEAR::isError($smtp->mailFrom($from, $args))) { - return PEAR::raiseError('unable to set sender to [' . $from . ']'); - } - - $recipients = $this->parseRecipients($recipients); - if (PEAR::isError($recipients)) { - return $recipients; - } - - foreach ($recipients as $recipient) { - if (PEAR::isError($res = $smtp->rcptTo($recipient))) { - return PEAR::raiseError('unable to add recipient [' . - $recipient . ']: ' . $res->getMessage()); - } - } - - if (PEAR::isError($smtp->data($text_headers . "\r\n" . $body))) { - return PEAR::raiseError('unable to send data'); - } - - $smtp->disconnect(); - return true; - } - -} diff --git a/3dparty/Mail/xmail.dtd b/3dparty/Mail/xmail.dtd deleted file mode 100644 index 9f42ca8b331..00000000000 --- a/3dparty/Mail/xmail.dtd +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/3dparty/Mail/xmail.xsl b/3dparty/Mail/xmail.xsl deleted file mode 100644 index 0b948913f84..00000000000 --- a/3dparty/Mail/xmail.xsl +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - : - - - - - - - - ; - - =" - - " - - - - - - - - - - - - - - - - - - - - -- - - - - ---- - - - - - - - - - - - \ No newline at end of file diff --git a/3dparty/Net/SMTP.php b/3dparty/Net/SMTP.php deleted file mode 100644 index 71dcb5e9bef..00000000000 --- a/3dparty/Net/SMTP.php +++ /dev/null @@ -1,970 +0,0 @@ - | -// | Jon Parise | -// | Damian Alejandro Fernandez Sosa | -// +----------------------------------------------------------------------+ - -require_once 'PEAR.php'; -require_once 'Net/Socket.php'; - -/** - * Provides an implementation of the SMTP protocol using PEAR's - * Net_Socket:: class. - * - * @package Net_SMTP - * @author Chuck Hagenbuch - * @author Jon Parise - * @author Damian Alejandro Fernandez Sosa - * - * @example basic.php A basic implementation of the Net_SMTP package. - */ -class Net_SMTP -{ - /** - * The server to connect to. - * @var string - * @access public - */ - var $host = 'localhost'; - - /** - * The port to connect to. - * @var int - * @access public - */ - var $port = 25; - - /** - * The value to give when sending EHLO or HELO. - * @var string - * @access public - */ - var $localhost = 'localhost'; - - /** - * List of supported authentication methods, in preferential order. - * @var array - * @access public - */ - var $auth_methods = array('DIGEST-MD5', 'CRAM-MD5', 'LOGIN', 'PLAIN'); - - /** - * Should debugging output be enabled? - * @var boolean - * @access private - */ - var $_debug = false; - - /** - * The socket resource being used to connect to the SMTP server. - * @var resource - * @access private - */ - var $_socket = null; - - /** - * The most recent server response code. - * @var int - * @access private - */ - var $_code = -1; - - /** - * The most recent server response arguments. - * @var array - * @access private - */ - var $_arguments = array(); - - /** - * Stores detected features of the SMTP server. - * @var array - * @access private - */ - var $_esmtp = array(); - - /** - * Instantiates a new Net_SMTP object, overriding any defaults - * with parameters that are passed in. - * - * @param string The server to connect to. - * @param int The port to connect to. - * @param string The value to give when sending EHLO or HELO. - * - * @access public - * @since 1.0 - */ - function Net_SMTP($host = null, $port = null, $localhost = null) - { - if (isset($host)) $this->host = $host; - if (isset($port)) $this->port = $port; - if (isset($localhost)) $this->localhost = $localhost; - - $this->_socket = new Net_Socket(); - - /* - * Include the Auth_SASL package. If the package is not available, - * we disable the authentication methods that depend upon it. - */ - if ((@include_once 'Auth/SASL.php') === false) { - $pos = array_search('DIGEST-MD5', $this->auth_methods); - unset($this->auth_methods[$pos]); - $pos = array_search('CRAM-MD5', $this->auth_methods); - unset($this->auth_methods[$pos]); - } - } - - /** - * Set the value of the debugging flag. - * - * @param boolean $debug New value for the debugging flag. - * - * @access public - * @since 1.1.0 - */ - function setDebug($debug) - { - $this->_debug = $debug; - } - - /** - * Send the given string of data to the server. - * - * @param string $data The string of data to send. - * - * @return mixed True on success or a PEAR_Error object on failure. - * - * @access private - * @since 1.1.0 - */ - function _send($data) - { - if ($this->_debug) { - echo "DEBUG: Send: $data\n"; - } - - if (PEAR::isError($error = $this->_socket->write($data))) { - return new PEAR_Error('Failed to write to socket: ' . - $error->getMessage()); - } - - return true; - } - - /** - * Send a command to the server with an optional string of arguments. - * A carriage return / linefeed (CRLF) sequence will be appended to each - * command string before it is sent to the SMTP server. - * - * @param string $command The SMTP command to send to the server. - * @param string $args A string of optional arguments to append - * to the command. - * - * @return mixed The result of the _send() call. - * - * @access private - * @since 1.1.0 - */ - function _put($command, $args = '') - { - if (!empty($args)) { - return $this->_send($command . ' ' . $args . "\r\n"); - } - - return $this->_send($command . "\r\n"); - } - - /** - * Read a reply from the SMTP server. The reply consists of a response - * code and a response message. - * - * @param mixed $valid The set of valid response codes. These - * may be specified as an array of integer - * values or as a single integer value. - * - * @return mixed True if the server returned a valid response code or - * a PEAR_Error object is an error condition is reached. - * - * @access private - * @since 1.1.0 - * - * @see getResponse - */ - function _parseResponse($valid) - { - $this->_code = -1; - $this->_arguments = array(); - - while ($line = $this->_socket->readLine()) { - if ($this->_debug) { - echo "DEBUG: Recv: $line\n"; - } - - /* If we receive an empty line, the connection has been closed. */ - if (empty($line)) { - $this->disconnect(); - return new PEAR_Error("Connection was unexpectedly closed"); - } - - /* Read the code and store the rest in the arguments array. */ - $code = substr($line, 0, 3); - $this->_arguments[] = trim(substr($line, 4)); - - /* Check the syntax of the response code. */ - if (is_numeric($code)) { - $this->_code = (int)$code; - } else { - $this->_code = -1; - break; - } - - /* If this is not a multiline response, we're done. */ - if (substr($line, 3, 1) != '-') { - break; - } - } - - /* Compare the server's response code with the valid code. */ - if (is_int($valid) && ($this->_code === $valid)) { - return true; - } - - /* If we were given an array of valid response codes, check each one. */ - if (is_array($valid)) { - foreach ($valid as $valid_code) { - if ($this->_code === $valid_code) { - return true; - } - } - } - - return new PEAR_Error("Invalid response code received from server"); - } - - /** - * Return a 2-tuple containing the last response from the SMTP server. - * - * @return array A two-element array: the first element contains the - * response code as an integer and the second element - * contains the response's arguments as a string. - * - * @access public - * @since 1.1.0 - */ - function getResponse() - { - return array($this->_code, join("\n", $this->_arguments)); - } - - /** - * Attempt to connect to the SMTP server. - * - * @param int $timeout The timeout value (in seconds) for the - * socket connection. - * @param bool $persistent Should a persistent socket connection - * be used? - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function connect($timeout = null, $persistent = false) - { - $result = $this->_socket->connect($this->host, $this->port, - $persistent, $timeout); - if (PEAR::isError($result)) { - return new PEAR_Error('Failed to connect socket: ' . - $result->getMessage()); - } - - if (PEAR::isError($error = $this->_parseResponse(220))) { - return $error; - } - if (PEAR::isError($error = $this->_negotiate())) { - return $error; - } - - return true; - } - - /** - * Attempt to disconnect from the SMTP server. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function disconnect() - { - if (PEAR::isError($error = $this->_put('QUIT'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(221))) { - return $error; - } - if (PEAR::isError($error = $this->_socket->disconnect())) { - return new PEAR_Error('Failed to disconnect socket: ' . - $error->getMessage()); - } - - return true; - } - - /** - * Attempt to send the EHLO command and obtain a list of ESMTP - * extensions available, and failing that just send HELO. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access private - * @since 1.1.0 - */ - function _negotiate() - { - if (PEAR::isError($error = $this->_put('EHLO', $this->localhost))) { - return $error; - } - - if (PEAR::isError($this->_parseResponse(250))) { - /* If we receive a 503 response, we're already authenticated. */ - if ($this->_code === 503) { - return true; - } - - /* If the EHLO failed, try the simpler HELO command. */ - if (PEAR::isError($error = $this->_put('HELO', $this->localhost))) { - return $error; - } - if (PEAR::isError($this->_parseResponse(250))) { - return new PEAR_Error('HELO was not accepted: ', $this->_code); - } - - return true; - } - - foreach ($this->_arguments as $argument) { - $verb = strtok($argument, ' '); - $arguments = substr($argument, strlen($verb) + 1, - strlen($argument) - strlen($verb) - 1); - $this->_esmtp[$verb] = $arguments; - } - - return true; - } - - /** - * Returns the name of the best authentication method that the server - * has advertised. - * - * @return mixed Returns a string containing the name of the best - * supported authentication method or a PEAR_Error object - * if a failure condition is encountered. - * @access private - * @since 1.1.0 - */ - function _getBestAuthMethod() - { - $available_methods = explode(' ', $this->_esmtp['AUTH']); - - foreach ($this->auth_methods as $method) { - if (in_array($method, $available_methods)) { - return $method; - } - } - - return new PEAR_Error('No supported authentication methods'); - } - - /** - * Attempt to do SMTP authentication. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * @param string The requested authentication method. If none is - * specified, the best supported method will be used. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function auth($uid, $pwd , $method = '') - { - if (empty($this->_esmtp['AUTH'])) { - return new PEAR_Error('SMTP server does no support authentication'); - } - - /* - * If no method has been specified, get the name of the best supported - * method advertised by the SMTP server. - */ - if (empty($method)) { - if (PEAR::isError($method = $this->_getBestAuthMethod())) { - /* Return the PEAR_Error object from _getBestAuthMethod(). */ - return $method; - } - } else { - $method = strtoupper($method); - if (!in_array($method, $this->auth_methods)) { - return new PEAR_Error("$method is not a supported authentication method"); - } - } - - switch ($method) { - case 'DIGEST-MD5': - $result = $this->_authDigest_MD5($uid, $pwd); - break; - case 'CRAM-MD5': - $result = $this->_authCRAM_MD5($uid, $pwd); - break; - case 'LOGIN': - $result = $this->_authLogin($uid, $pwd); - break; - case 'PLAIN': - $result = $this->_authPlain($uid, $pwd); - break; - default: - $result = new PEAR_Error("$method is not a supported authentication method"); - break; - } - - /* If an error was encountered, return the PEAR_Error object. */ - if (PEAR::isError($result)) { - return $result; - } - - /* RFC-2554 requires us to re-negotiate ESMTP after an AUTH. */ - if (PEAR::isError($error = $this->_negotiate())) { - return $error; - } - - return true; - } - - /** - * Authenticates the user using the DIGEST-MD5 method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authDigest_MD5($uid, $pwd) - { - if (PEAR::isError($error = $this->_put('AUTH', 'DIGEST-MD5'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - $challenge = base64_decode($this->_arguments[0]); - $digest = &Auth_SASL::factory('digestmd5'); - $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, - $this->host, "smtp")); - - if (PEAR::isError($error = $this->_put($auth_str))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - return $error; - } - - /* - * We don't use the protocol's third step because SMTP doesn't allow - * subsequent authentication, so we just silently ignore it. - */ - if (PEAR::isError($error = $this->_put(' '))) { - return $error; - } - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - } - - /** - * Authenticates the user using the CRAM-MD5 method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authCRAM_MD5($uid, $pwd) - { - if (PEAR::isError($error = $this->_put('AUTH', 'CRAM-MD5'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - $challenge = base64_decode($this->_arguments[0]); - $cram = &Auth_SASL::factory('crammd5'); - $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge)); - - if (PEAR::isError($error = $this->_put($auth_str))) { - return $error; - } - - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - } - - /** - * Authenticates the user using the LOGIN method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authLogin($uid, $pwd) - { - if (PEAR::isError($error = $this->_put('AUTH', 'LOGIN'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - if (PEAR::isError($error = $this->_put(base64_encode($uid)))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - return $error; - } - - if (PEAR::isError($error = $this->_put(base64_encode($pwd)))) { - return $error; - } - - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - - return true; - } - - /** - * Authenticates the user using the PLAIN method. - * - * @param string The userid to authenticate as. - * @param string The password to authenticate with. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access private - * @since 1.1.0 - */ - function _authPlain($uid, $pwd) - { - if (PEAR::isError($error = $this->_put('AUTH', 'PLAIN'))) { - return $error; - } - /* 334: Continue authentication request */ - if (PEAR::isError($error = $this->_parseResponse(334))) { - /* 503: Error: already authenticated */ - if ($this->_code === 503) { - return true; - } - return $error; - } - - $auth_str = base64_encode(chr(0) . $uid . chr(0) . $pwd); - - if (PEAR::isError($error = $this->_put($auth_str))) { - return $error; - } - - /* 235: Authentication successful */ - if (PEAR::isError($error = $this->_parseResponse(235))) { - return $error; - } - - return true; - } - - /** - * Send the HELO command. - * - * @param string The domain name to say we are. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function helo($domain) - { - if (PEAR::isError($error = $this->_put('HELO', $domain))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Send the MAIL FROM: command. - * - * @param string The sender (reverse path) to set. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function mailFrom($sender) - { - if (PEAR::isError($error = $this->_put('MAIL', "FROM:<$sender>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Send the RCPT TO: command. - * - * @param string The recipient (forward path) to add. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function rcptTo($recipient) - { - if (PEAR::isError($error = $this->_put('RCPT', "TO:<$recipient>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(array(250, 251)))) { - return $error; - } - - return true; - } - - /** - * Quote the data so that it meets SMTP standards. - * - * This is provided as a separate public function to facilitate easier - * overloading for the cases where it is desirable to customize the - * quoting behavior. - * - * @param string The message text to quote. The string must be passed - * by reference, and the text will be modified in place. - * - * @access public - * @since 1.2 - */ - function quotedata(&$data) - { - /* - * Change Unix (\n) and Mac (\r) linefeeds into Internet-standard CRLF - * (\r\n) linefeeds. - */ - $data = preg_replace("/([^\r]{1})\n/", "\\1\r\n", $data); - $data = preg_replace("/\n\n/", "\n\r\n", $data); - - /* - * Because a single leading period (.) signifies an end to the data, - * legitimate leading periods need to be "doubled" (e.g. '..'). - */ - $data = preg_replace("/\n\./", "\n..", $data); - } - - /** - * Send the DATA command. - * - * @param string The message body to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function data($data) - { - /* - * RFC 1870, section 3, subsection 3 states "a value of zero indicates - * that no fixed maximum message size is in force". Furthermore, it - * says that if "the parameter is omitted no information is conveyed - * about the server's fixed maximum message size". - */ - if (isset($this->_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) { - if (strlen($data) >= $this->_esmtp['SIZE']) { - $this->disconnect(); - return new PEAR_Error('Message size excedes the server limit'); - } - } - - /* Quote the data based on the SMTP standards. */ - $this->quotedata($data); - - if (PEAR::isError($error = $this->_put('DATA'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(354))) { - return $error; - } - - if (PEAR::isError($this->_send($data . "\r\n.\r\n"))) { - return new PEAR_Error('write to socket failed'); - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Send the SEND FROM: command. - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.2.6 - */ - function sendFrom($path) - { - if (PEAR::isError($error = $this->_put('SEND', "FROM:<$path>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility wrapper for sendFrom(). - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access public - * @since 1.0 - * @deprecated 1.2.6 - */ - function send_from($path) - { - return sendFrom($path); - } - - /** - * Send the SOML FROM: command. - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.2.6 - */ - function somlFrom($path) - { - if (PEAR::isError($error = $this->_put('SOML', "FROM:<$path>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility wrapper for somlFrom(). - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access public - * @since 1.0 - * @deprecated 1.2.6 - */ - function soml_from($path) - { - return somlFrom($path); - } - - /** - * Send the SAML FROM: command. - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.2.6 - */ - function samlFrom($path) - { - if (PEAR::isError($error = $this->_put('SAML', "FROM:<$path>"))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility wrapper for samlFrom(). - * - * @param string The reverse path to send. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * - * @access public - * @since 1.0 - * @deprecated 1.2.6 - */ - function saml_from($path) - { - return samlFrom($path); - } - - /** - * Send the RSET command. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function rset() - { - if (PEAR::isError($error = $this->_put('RSET'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Send the VRFY command. - * - * @param string The string to verify - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function vrfy($string) - { - /* Note: 251 is also a valid response code */ - if (PEAR::isError($error = $this->_put('VRFY', $string))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Send the NOOP command. - * - * @return mixed Returns a PEAR_Error with an error message on any - * kind of failure, or true on success. - * @access public - * @since 1.0 - */ - function noop() - { - if (PEAR::isError($error = $this->_put('NOOP'))) { - return $error; - } - if (PEAR::isError($error = $this->_parseResponse(250))) { - return $error; - } - - return true; - } - - /** - * Backwards-compatibility method. identifySender()'s functionality is - * now handled internally. - * - * @return boolean This method always return true. - * - * @access public - * @since 1.0 - */ - function identifySender() - { - return true; - } -} - -?> diff --git a/3dparty/Net/Socket.php b/3dparty/Net/Socket.php deleted file mode 100644 index 7c4ff1d4e21..00000000000 --- a/3dparty/Net/Socket.php +++ /dev/null @@ -1,528 +0,0 @@ - | -// | Chuck Hagenbuch | -// +----------------------------------------------------------------------+ -// -// $Id: Socket.php,v 1.24 2005/02/03 20:40:16 chagenbu Exp $ - -require_once 'PEAR.php'; - -define('NET_SOCKET_READ', 1); -define('NET_SOCKET_WRITE', 2); -define('NET_SOCKET_ERROR', 3); - -/** - * Generalized Socket class. - * - * @version 1.1 - * @author Stig Bakken - * @author Chuck Hagenbuch - */ -class Net_Socket extends PEAR { - - /** - * Socket file pointer. - * @var resource $fp - */ - var $fp = null; - - /** - * Whether the socket is blocking. Defaults to true. - * @var boolean $blocking - */ - var $blocking = true; - - /** - * Whether the socket is persistent. Defaults to false. - * @var boolean $persistent - */ - var $persistent = false; - - /** - * The IP address to connect to. - * @var string $addr - */ - var $addr = ''; - - /** - * The port number to connect to. - * @var integer $port - */ - var $port = 0; - - /** - * Number of seconds to wait on socket connections before assuming - * there's no more data. Defaults to no timeout. - * @var integer $timeout - */ - var $timeout = false; - - /** - * Number of bytes to read at a time in readLine() and - * readAll(). Defaults to 2048. - * @var integer $lineLength - */ - var $lineLength = 2048; - - /** - * Connect to the specified port. If called when the socket is - * already connected, it disconnects and connects again. - * - * @param string $addr IP address or host name. - * @param integer $port TCP port number. - * @param boolean $persistent (optional) Whether the connection is - * persistent (kept open between requests - * by the web server). - * @param integer $timeout (optional) How long to wait for data. - * @param array $options See options for stream_context_create. - * - * @access public - * - * @return boolean | PEAR_Error True on success or a PEAR_Error on failure. - */ - function connect($addr, $port = 0, $persistent = null, $timeout = null, $options = null) - { - if (is_resource($this->fp)) { - @fclose($this->fp); - $this->fp = null; - } - - if (!$addr) { - return $this->raiseError('$addr cannot be empty'); - } elseif (strspn($addr, '.0123456789') == strlen($addr) || - strstr($addr, '/') !== false) { - $this->addr = $addr; - } else { - $this->addr = @gethostbyname($addr); - } - - $this->port = $port % 65536; - - if ($persistent !== null) { - $this->persistent = $persistent; - } - - if ($timeout !== null) { - $this->timeout = $timeout; - } - - $openfunc = $this->persistent ? 'pfsockopen' : 'fsockopen'; - $errno = 0; - $errstr = ''; - if ($options && function_exists('stream_context_create')) { - if ($this->timeout) { - $timeout = $this->timeout; - } else { - $timeout = 0; - } - $context = stream_context_create($options); - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $timeout, $context); - } else { - if ($this->timeout) { - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr, $this->timeout); - } else { - $fp = @$openfunc($this->addr, $this->port, $errno, $errstr); - } - } - - if (!$fp) { - return $this->raiseError($errstr, $errno); - } - - $this->fp = $fp; - - return $this->setBlocking($this->blocking); - } - - /** - * Disconnects from the peer, closes the socket. - * - * @access public - * @return mixed true on success or an error object otherwise - */ - function disconnect() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - @fclose($this->fp); - $this->fp = null; - return true; - } - - /** - * Find out if the socket is in blocking mode. - * - * @access public - * @return boolean The current blocking mode. - */ - function isBlocking() - { - return $this->blocking; - } - - /** - * Sets whether the socket connection should be blocking or - * not. A read call to a non-blocking socket will return immediately - * if there is no data available, whereas it will block until there - * is data for blocking sockets. - * - * @param boolean $mode True for blocking sockets, false for nonblocking. - * @access public - * @return mixed true on success or an error object otherwise - */ - function setBlocking($mode) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $this->blocking = $mode; - socket_set_blocking($this->fp, $this->blocking); - return true; - } - - /** - * Sets the timeout value on socket descriptor, - * expressed in the sum of seconds and microseconds - * - * @param integer $seconds Seconds. - * @param integer $microseconds Microseconds. - * @access public - * @return mixed true on success or an error object otherwise - */ - function setTimeout($seconds, $microseconds) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_set_timeout($this->fp, $seconds, $microseconds); - } - - /** - * Returns information about an existing socket resource. - * Currently returns four entries in the result array: - * - *

- * timed_out (bool) - The socket timed out waiting for data
- * blocked (bool) - The socket was blocked
- * eof (bool) - Indicates EOF event
- * unread_bytes (int) - Number of bytes left in the socket buffer
- *

- * - * @access public - * @return mixed Array containing information about existing socket resource or an error object otherwise - */ - function getStatus() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return socket_get_status($this->fp); - } - - /** - * Get a specified line of data - * - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function gets($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return @fgets($this->fp, $size); - } - - /** - * Read a specified amount of data. This is guaranteed to return, - * and has the added benefit of getting everything in one fread() - * chunk; if you know the size of the data you're getting - * beforehand, this is definitely the way to go. - * - * @param integer $size The number of bytes to read from the socket. - * @access public - * @return $size bytes of data from the socket, or a PEAR_Error if - * not connected. - */ - function read($size) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return @fread($this->fp, $size); - } - - /** - * Write a specified amount of data. - * - * @param string $data Data to write. - * @param integer $blocksize Amount of data to write at once. - * NULL means all at once. - * - * @access public - * @return mixed true on success or an error object otherwise - */ - function write($data, $blocksize = null) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - if (is_null($blocksize) && !OS_WINDOWS) { - return fwrite($this->fp, $data); - } else { - if (is_null($blocksize)) { - $blocksize = 1024; - } - - $pos = 0; - $size = strlen($data); - while ($pos < $size) { - $written = @fwrite($this->fp, substr($data, $pos, $blocksize)); - if ($written === false) { - return false; - } - $pos += $written; - } - - return $pos; - } - } - - /** - * Write a line of data to the socket, followed by a trailing "\r\n". - * - * @access public - * @return mixed fputs result, or an error - */ - function writeLine($data) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return fwrite($this->fp, $data . "\r\n"); - } - - /** - * Tests for end-of-file on a socket descriptor. - * - * @access public - * @return bool - */ - function eof() - { - return (is_resource($this->fp) && feof($this->fp)); - } - - /** - * Reads a byte of data - * - * @access public - * @return 1 byte of data from the socket, or a PEAR_Error if - * not connected. - */ - function readByte() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - return ord(@fread($this->fp, 1)); - } - - /** - * Reads a word of data - * - * @access public - * @return 1 word of data from the socket, or a PEAR_Error if - * not connected. - */ - function readWord() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 2); - return (ord($buf[0]) + (ord($buf[1]) << 8)); - } - - /** - * Reads an int of data - * - * @access public - * @return integer 1 int of data from the socket, or a PEAR_Error if - * not connected. - */ - function readInt() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return (ord($buf[0]) + (ord($buf[1]) << 8) + - (ord($buf[2]) << 16) + (ord($buf[3]) << 24)); - } - - /** - * Reads a zero-terminated string of data - * - * @access public - * @return string, or a PEAR_Error if - * not connected. - */ - function readString() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $string = ''; - while (($char = @fread($this->fp, 1)) != "\x00") { - $string .= $char; - } - return $string; - } - - /** - * Reads an IP Address and returns it in a dot formated string - * - * @access public - * @return Dot formated string, or a PEAR_Error if - * not connected. - */ - function readIPAddress() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $buf = @fread($this->fp, 4); - return sprintf("%s.%s.%s.%s", ord($buf[0]), ord($buf[1]), - ord($buf[2]), ord($buf[3])); - } - - /** - * Read until either the end of the socket or a newline, whichever - * comes first. Strips the trailing newline from the returned data. - * - * @access public - * @return All available data up to a newline, without that - * newline, or until the end of the socket, or a PEAR_Error if - * not connected. - */ - function readLine() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $line = ''; - $timeout = time() + $this->timeout; - while (!feof($this->fp) && (!$this->timeout || time() < $timeout)) { - $line .= @fgets($this->fp, $this->lineLength); - if (substr($line, -1) == "\n") { - return rtrim($line, "\r\n"); - } - } - return $line; - } - - /** - * Read until the socket closes, or until there is no more data in - * the inner PHP buffer. If the inner buffer is empty, in blocking - * mode we wait for at least 1 byte of data. Therefore, in - * blocking mode, if there is no data at all to be read, this - * function will never exit (unless the socket is closed on the - * remote end). - * - * @access public - * - * @return string All data until the socket closes, or a PEAR_Error if - * not connected. - */ - function readAll() - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $data = ''; - while (!feof($this->fp)) { - $data .= @fread($this->fp, $this->lineLength); - } - return $data; - } - - /** - * Runs the equivalent of the select() system call on the socket - * with a timeout specified by tv_sec and tv_usec. - * - * @param integer $state Which of read/write/error to check for. - * @param integer $tv_sec Number of seconds for timeout. - * @param integer $tv_usec Number of microseconds for timeout. - * - * @access public - * @return False if select fails, integer describing which of read/write/error - * are ready, or PEAR_Error if not connected. - */ - function select($state, $tv_sec, $tv_usec = 0) - { - if (!is_resource($this->fp)) { - return $this->raiseError('not connected'); - } - - $read = null; - $write = null; - $except = null; - if ($state & NET_SOCKET_READ) { - $read[] = $this->fp; - } - if ($state & NET_SOCKET_WRITE) { - $write[] = $this->fp; - } - if ($state & NET_SOCKET_ERROR) { - $except[] = $this->fp; - } - if (false === ($sr = stream_select($read, $write, $except, $tv_sec, $tv_usec))) { - return false; - } - - $result = 0; - if (count($read)) { - $result |= NET_SOCKET_READ; - } - if (count($write)) { - $result |= NET_SOCKET_WRITE; - } - if (count($except)) { - $result |= NET_SOCKET_ERROR; - } - return $result; - } - -} diff --git a/3dparty/OS/Guess.php b/3dparty/OS/Guess.php deleted file mode 100644 index a85bf360ebc..00000000000 --- a/3dparty/OS/Guess.php +++ /dev/null @@ -1,287 +0,0 @@ - | -// | | -// +----------------------------------------------------------------------+ -// -// $Id: Guess.php,v 1.13.4.1 2004/10/19 04:15:56 cellog Exp $ - -// {{{ uname examples - -// php_uname() without args returns the same as 'uname -a', or a PHP-custom -// string for Windows. -// PHP versions prior to 4.3 return the uname of the host where PHP was built, -// as of 4.3 it returns the uname of the host running the PHP code. -// -// PC RedHat Linux 7.1: -// Linux host.example.com 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown -// -// PC Debian Potato: -// Linux host 2.4.17 #2 SMP Tue Feb 12 15:10:04 CET 2002 i686 unknown -// -// PC FreeBSD 3.3: -// FreeBSD host.example.com 3.3-STABLE FreeBSD 3.3-STABLE #0: Mon Feb 21 00:42:31 CET 2000 root@example.com:/usr/src/sys/compile/CONFIG i386 -// -// PC FreeBSD 4.3: -// FreeBSD host.example.com 4.3-RELEASE FreeBSD 4.3-RELEASE #1: Mon Jun 25 11:19:43 EDT 2001 root@example.com:/usr/src/sys/compile/CONFIG i386 -// -// PC FreeBSD 4.5: -// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb 6 23:59:23 CET 2002 root@example.com:/usr/src/sys/compile/CONFIG i386 -// -// PC FreeBSD 4.5 w/uname from GNU shellutils: -// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb i386 unknown -// -// HP 9000/712 HP-UX 10: -// HP-UX iq B.10.10 A 9000/712 2008429113 two-user license -// -// HP 9000/712 HP-UX 10 w/uname from GNU shellutils: -// HP-UX host B.10.10 A 9000/712 unknown -// -// IBM RS6000/550 AIX 4.3: -// AIX host 3 4 000003531C00 -// -// AIX 4.3 w/uname from GNU shellutils: -// AIX host 3 4 000003531C00 unknown -// -// SGI Onyx IRIX 6.5 w/uname from GNU shellutils: -// IRIX64 host 6.5 01091820 IP19 mips -// -// SGI Onyx IRIX 6.5: -// IRIX64 host 6.5 01091820 IP19 -// -// SparcStation 20 Solaris 8 w/uname from GNU shellutils: -// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc -// -// SparcStation 20 Solaris 8: -// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc SUNW,SPARCstation-20 -// -// Mac OS X (Darwin) -// Darwin home-eden.local 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug 5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC Power Macintosh -// -// Mac OS X early versions -// - -// }}} - -/* TODO: - * - define endianness, to allow matchSignature("bigend") etc. - */ - -class OS_Guess -{ - var $sysname; - var $nodename; - var $cpu; - var $release; - var $extra; - - function OS_Guess($uname = null) - { - list($this->sysname, - $this->release, - $this->cpu, - $this->extra, - $this->nodename) = $this->parseSignature($uname); - } - - function parseSignature($uname = null) - { - static $sysmap = array( - 'HP-UX' => 'hpux', - 'IRIX64' => 'irix', - ); - static $cpumap = array( - 'i586' => 'i386', - 'i686' => 'i386', - 'ppc' => 'powerpc', - ); - if ($uname === null) { - $uname = php_uname(); - } - $parts = split('[[:space:]]+', trim($uname)); - $n = count($parts); - - $release = $machine = $cpu = ''; - $sysname = $parts[0]; - $nodename = $parts[1]; - $cpu = $parts[$n-1]; - $extra = ''; - if ($cpu == 'unknown') { - $cpu = $parts[$n-2]; - } - - switch ($sysname) { - case 'AIX': - $release = "$parts[3].$parts[2]"; - break; - case 'Windows': - switch ($parts[1]) { - case '95/98': - $release = '9x'; - break; - default: - $release = $parts[1]; - break; - } - $cpu = 'i386'; - break; - case 'Linux': - $extra = $this->_detectGlibcVersion(); - // use only the first two digits from the kernel version - $release = ereg_replace('^([[:digit:]]+\.[[:digit:]]+).*', '\1', $parts[2]); - break; - case 'Mac' : - $sysname = 'darwin'; - $nodename = $parts[2]; - $release = $parts[3]; - if ($cpu == 'Macintosh') { - if ($parts[$n - 2] == 'Power') { - $cpu = 'powerpc'; - } - } - break; - case 'Darwin' : - if ($cpu == 'Macintosh') { - if ($parts[$n - 2] == 'Power') { - $cpu = 'powerpc'; - } - } - $release = ereg_replace('^([[:digit:]]+\.[[:digit:]]+).*', '\1', $parts[2]); - break; - default: - $release = ereg_replace('-.*', '', $parts[2]); - break; - } - - - if (isset($sysmap[$sysname])) { - $sysname = $sysmap[$sysname]; - } else { - $sysname = strtolower($sysname); - } - if (isset($cpumap[$cpu])) { - $cpu = $cpumap[$cpu]; - } - return array($sysname, $release, $cpu, $extra, $nodename); - } - - function _detectGlibcVersion() - { - // Use glibc's header file to - // get major and minor version number: - include_once "System.php"; - $tmpfile = System::mktemp("glibctest"); - $fp = fopen($tmpfile, "w"); - fwrite($fp, "#include \n__GLIBC__ __GLIBC_MINOR__\n"); - fclose($fp); - $cpp = popen("/usr/bin/cpp $tmpfile", "r"); - $major = $minor = 0; - while ($line = fgets($cpp, 1024)) { - if ($line{0} == '#' || trim($line) == '') { - continue; - } - if (list($major, $minor) = explode(' ', trim($line))) { - break; - } - } - pclose($cpp); - unlink($tmpfile); - if (!($major && $minor) && is_link('/lib/libc.so.6')) { - // Let's try reading the libc.so.6 symlink - if (ereg('^libc-([.*])\.so$', basename(readlink('/lib/libc.so.6')), $matches)) { - list($major, $minor) = explode('.', $matches); - } - } - if (!($major && $minor)) { - return ''; - } - return "glibc{$major}.{$minor}"; - } - - function getSignature() - { - if (empty($this->extra)) { - return "{$this->sysname}-{$this->release}-{$this->cpu}"; - } - return "{$this->sysname}-{$this->release}-{$this->cpu}-{$this->extra}"; - } - - function getSysname() - { - return $this->sysname; - } - - function getNodename() - { - return $this->nodename; - } - - function getCpu() - { - return $this->cpu; - } - - function getRelease() - { - return $this->release; - } - - function getExtra() - { - return $this->extra; - } - - function matchSignature($match) - { - if (is_array($match)) { - $fragments = $match; - } else { - $fragments = explode('-', $match); - } - $n = count($fragments); - $matches = 0; - if ($n > 0) { - $matches += $this->_matchFragment($fragments[0], $this->sysname); - } - if ($n > 1) { - $matches += $this->_matchFragment($fragments[1], $this->release); - } - if ($n > 2) { - $matches += $this->_matchFragment($fragments[2], $this->cpu); - } - if ($n > 3) { - $matches += $this->_matchFragment($fragments[3], $this->extra); - } - return ($matches == $n); - } - - function _matchFragment($fragment, $value) - { - if (strcspn($fragment, '*?') < strlen($fragment)) { - $reg = '^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '$'; - return eregi($reg, $value); - } - return ($fragment == '*' || !strcasecmp($fragment, $value)); - } - -} -/* - * Local Variables: - * indent-tabs-mode: nil - * c-basic-offset: 4 - * End: - */ -?> diff --git a/3dparty/PHPUnit.php b/3dparty/PHPUnit.php deleted file mode 100644 index de4da858eb9..00000000000 --- a/3dparty/PHPUnit.php +++ /dev/null @@ -1,83 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: PHPUnit.php,v 1.14 2004/12/22 08:06:11 sebastian Exp $ -// - -require_once 'PHPUnit/TestCase.php'; -require_once 'PHPUnit/TestResult.php'; -require_once 'PHPUnit/TestSuite.php'; - -/** - * PHPUnit runs a TestSuite and returns a TestResult object. - * - * Here is an example: - * - * - * PHPUnit_TestCase($name); - * } - * - * function setUp() { - * $this->fValue1 = 2; - * $this->fValue2 = 3; - * } - * - * function testAdd() { - * $this->assertTrue($this->fValue1 + $this->fValue2 == 5); - * } - * } - * - * $suite = new PHPUnit_TestSuite(); - * $suite->addTest(new MathTest('testAdd')); - * - * $result = PHPUnit::run($suite); - * print $result->toHTML(); - * ?> - * - * - * Alternatively, you can pass a class name to the PHPUnit_TestSuite() - * constructor and let it automatically add all methods of that class - * that start with 'test' to the suite: - * - * - * toHTML(); - * ?> - * - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit { - function &run(&$suite) { - $result = new PHPUnit_TestResult(); - $suite->run($result); - - return $result; - } -} -?> diff --git a/3dparty/PHPUnit/Assert.php b/3dparty/PHPUnit/Assert.php deleted file mode 100644 index 74806458bd3..00000000000 --- a/3dparty/PHPUnit/Assert.php +++ /dev/null @@ -1,384 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: Assert.php,v 1.25 2005/01/31 04:57:16 sebastian Exp $ -// - -/** - * A set of assert methods. - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_Assert { - /** - * @var boolean - * @access private - */ - var $_looselyTyped = FALSE; - - /** - * Asserts that a haystack contains a needle. - * - * @param mixed - * @param mixed - * @param string - * @access public - * @since 1.1.0 - */ - function assertContains($needle, $haystack, $message = '') { - if (is_string($needle) && is_string($haystack)) { - $this->assertTrue(strpos($haystack, $needle) !== FALSE ? TRUE : FALSE); - } - - else if (is_array($haystack) && !is_object($needle)) { - $this->assertTrue(in_array($needle, $haystack), $message); - } - - else { - $this->fail('Unsupported parameter passed to assertContains().'); - } - } - - /** - * Asserts that a haystack does not contain a needle. - * - * @param mixed - * @param mixed - * @param string - * @access public - * @since 1.1.0 - */ - function assertNotContains($needle, $haystack, $message = '') { - if (is_string($needle) && is_string($haystack)) { - $this->assertFalse(strpos($haystack, $needle) !== FALSE ? TRUE : FALSE); - } - - else if (is_array($haystack) && !is_object($needle)) { - $this->assertFalse(in_array($needle, $haystack), $message); - } - - else { - $this->fail('Unsupported parameter passed to assertNotContains().'); - } - } - - /** - * Asserts that two variables are equal. - * - * @param mixed - * @param mixed - * @param string - * @param mixed - * @access public - */ - function assertEquals($expected, $actual, $message = '', $delta = 0) { - if ((is_array($actual) && is_array($expected)) || - (is_object($actual) && is_object($expected))) { - if (is_array($actual) && is_array($expected)) { - ksort($actual); - ksort($expected); - } - - if ($this->_looselyTyped) { - $actual = $this->_convertToString($actual); - $expected = $this->_convertToString($expected); - } - - $actual = serialize($actual); - $expected = serialize($expected); - - $message = sprintf( - '%sexpected %s, actual %s', - - !empty($message) ? $message . ' ' : '', - $expected, - $actual - ); - - if ($actual !== $expected) { - return $this->fail($message); - } - } - - elseif (is_numeric($actual) && is_numeric($expected)) { - $message = sprintf( - '%sexpected %s%s, actual %s', - - !empty($message) ? $message . ' ' : '', - $expected, - ($delta != 0) ? ('+/- ' . $delta) : '', - $actual - ); - - if (!($actual >= ($expected - $delta) && $actual <= ($expected + $delta))) { - return $this->fail($message); - } - } - - else { - $message = sprintf( - '%sexpected %s, actual %s', - - !empty($message) ? $message . ' ' : '', - $expected, - $actual - ); - - if ($actual !== $expected) { - return $this->fail($message); - } - } - } - - /** - * Asserts that two variables reference the same object. - * This requires the Zend Engine 2 to work. - * - * @param object - * @param object - * @param string - * @access public - * @deprecated - */ - function assertSame($expected, $actual, $message = '') { - if (!version_compare(phpversion(), '5.0.0', '>=')) { - $this->fail('assertSame() only works with PHP >= 5.0.0.'); - } - - if ((is_object($expected) || is_null($expected)) && - (is_object($actual) || is_null($actual))) { - $message = sprintf( - '%sexpected two variables to reference the same object', - - !empty($message) ? $message . ' ' : '' - ); - - if ($expected !== $actual) { - return $this->fail($message); - } - } else { - $this->fail('Unsupported parameter passed to assertSame().'); - } - } - - /** - * Asserts that two variables do not reference the same object. - * This requires the Zend Engine 2 to work. - * - * @param object - * @param object - * @param string - * @access public - * @deprecated - */ - function assertNotSame($expected, $actual, $message = '') { - if (!version_compare(phpversion(), '5.0.0', '>=')) { - $this->fail('assertNotSame() only works with PHP >= 5.0.0.'); - } - - if ((is_object($expected) || is_null($expected)) && - (is_object($actual) || is_null($actual))) { - $message = sprintf( - '%sexpected two variables to reference different objects', - - !empty($message) ? $message . ' ' : '' - ); - - if ($expected === $actual) { - return $this->fail($message); - } - } else { - $this->fail('Unsupported parameter passed to assertNotSame().'); - } - } - - /** - * Asserts that a variable is not NULL. - * - * @param mixed - * @param string - * @access public - */ - function assertNotNull($actual, $message = '') { - $message = sprintf( - '%sexpected NOT NULL, actual NULL', - - !empty($message) ? $message . ' ' : '' - ); - - if (is_null($actual)) { - return $this->fail($message); - } - } - - /** - * Asserts that a variable is NULL. - * - * @param mixed - * @param string - * @access public - */ - function assertNull($actual, $message = '') { - $message = sprintf( - '%sexpected NULL, actual NOT NULL', - - !empty($message) ? $message . ' ' : '' - ); - - if (!is_null($actual)) { - return $this->fail($message); - } - } - - /** - * Asserts that a condition is true. - * - * @param boolean - * @param string - * @access public - */ - function assertTrue($condition, $message = '') { - $message = sprintf( - '%sexpected TRUE, actual FALSE', - - !empty($message) ? $message . ' ' : '' - ); - - if (!$condition) { - return $this->fail($message); - } - } - - /** - * Asserts that a condition is false. - * - * @param boolean - * @param string - * @access public - */ - function assertFalse($condition, $message = '') { - $message = sprintf( - '%sexpected FALSE, actual TRUE', - - !empty($message) ? $message . ' ' : '' - ); - - if ($condition) { - return $this->fail($message); - } - } - - /** - * Asserts that a string matches a given regular expression. - * - * @param string - * @param string - * @param string - * @access public - */ - function assertRegExp($pattern, $string, $message = '') { - $message = sprintf( - '%s"%s" does not match pattern "%s"', - - !empty($message) ? $message . ' ' : '', - $string, - $pattern - ); - - if (!preg_match($pattern, $string)) { - return $this->fail($message); - } - } - - /** - * Asserts that a string does not match a given regular expression. - * - * @param string - * @param string - * @param string - * @access public - * @since 1.1.0 - */ - function assertNotRegExp($pattern, $string, $message = '') { - $message = sprintf( - '%s"%s" matches pattern "%s"', - - !empty($message) ? $message . ' ' : '', - $string, - $pattern - ); - - if (preg_match($pattern, $string)) { - return $this->fail($message); - } - } - - /** - * Asserts that a variable is of a given type. - * - * @param string $expected - * @param mixed $actual - * @param optional string $message - * @access public - */ - function assertType($expected, $actual, $message = '') { - return $this->assertEquals( - $expected, - gettype($actual), - $message - ); - } - - /** - * Converts a value to a string. - * - * @param mixed $value - * @access private - */ - function _convertToString($value) { - foreach ($value as $k => $v) { - if (is_array($v)) { - $value[$k] = $this->_convertToString($value[$k]); - } else { - settype($value[$k], 'string'); - } - } - - return $value; - } - - /** - * @param boolean $looselyTyped - * @access public - */ - function setLooselyTyped($looselyTyped) { - if (is_bool($looselyTyped)) { - $this->_looselyTyped = $looselyTyped; - } - } - - /** - * Fails a test with the given message. - * - * @param string - * @access protected - * @abstract - */ - function fail($message = '') { /* abstract */ } -} -?> diff --git a/3dparty/PHPUnit/GUI/Gtk.php b/3dparty/PHPUnit/GUI/Gtk.php deleted file mode 100644 index fdd3a9931e5..00000000000 --- a/3dparty/PHPUnit/GUI/Gtk.php +++ /dev/null @@ -1,698 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Gtk.php,v 1.2 2004/11/25 09:06:55 sebastian Exp $ -/** - * GTK GUI interface for PHPUnit. - * - * This class is a PHP port of junit.awtui.testrunner. Documentation - * for junit.awtui.testrunner can be found at - * http://junit.sourceforge.net - * - * Due to the limitations of PHP4 and PHP-Gtk, this class can not - * duplicate all of the functionality of the JUnit GUI. Some of the - * things this class cannot do include: - * - Reloading the class for each run - * - Stopping the test in progress - * - * To use simply intantiate the class and call main() - * $gtk =& new PHPUnit_GUI_Gtk; - * $gtk->main(); - * - * Once the window has finished loading, you can enter the name of - * a class that has been loaded (include/require some where in your - * code, or you can pass the name of the file containing the class. - * - * You can also load classes using the SetupDecorator class. - * require_once 'PHPUnit/GUI/SetupDecorator.php'; - * require_once 'PHPUnit/GUI/Gtk.php'; - * $gui = new PHPUnit_GUI_SetupDecorator(new PHPUnit_GUI_Gtk()); - * $gui->getSuitesFromDir('/path/to/test','.*\.php$',array('index.php','sql.php')); - * $gui->show(); - * - * @todo Allow file drop. (Gtk_FileDrop) - * - * @author Scott Mattocks - * @copyright Copyright © 2004 Scott Mattocks - * @license PHP 3.0 - * @version @VER@ - * @category PHP - * @package PHPUnit - * @subpackage GUI - */ -class PHPUnit_GUI_Gtk { - - /** - * The main gtk window - * @var object - */ - var $gui; - /** - * The text entry that contains the name of the - * file that holds the test(s)/suite(s). - * @var object - */ - var $suiteField; - /** - * The label that shows the number of tests that - * were run. - * @var object - */ - var $numberOfRuns; - /** - * The label that shows the number of errors that - * were encountered. - * @var object - */ - var $numberOfErrors; - /** - * The label that shows the number of failures - * that were encountered. - * @var object - */ - var $numberOfFailures; - /** - * The label for reporting user messages. - * @var object - */ - var $statusLine; - /** - * The text area for reporting messages from successful - * test runs. (not necessarily successful tests) - * @var object - */ - var $reportArea; - /** - * The text area for reporting errors encountered when - * running tests. - * @var object - */ - var $dumpArea; - /** - * The progress bar indicator. Shows the percentage of - * passed tests. - * @var object - */ - var $progress; - /** - * A checkbox for the user to indicate whether or not they - * would like to see results from all tests or just failures. - * @object - */ - var $showPassed; - - /** - * Constructor. - * - * The constructor checks for the gtk extension and loads it - * if needed. Then it creates the GUI. The GUI is not shown - * nor is the main gtk loop started until main() is called. - * - * @access public - * @param none - * @return void - */ - function PHPUnit_GUI_Gtk() - { - // Check for php-gtk extension. - if (!extension_loaded('gtk')) { - dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); - } - - // Create the interface but don't start the loop - $this->_createUI(); - } - /** - * Start the main gtk loop. - * - * main() first sets the default state of the showPassed - * check box. Next all widgets that are part of the GUI - * are shown. Finally the main gtk loop is started. - * - * @access public - * @param boolean $showPassed - * @return void - */ - function main($showPassed = true) - { - $this->showPassed->set_active($showPassed); - $this->gui->show_all(); - - gtk::main(); - } - /** - * Create the user interface. - * - * The user interface is pretty simple. It consists of a - * menu, text entry, run button, some labels, a progress - * indicator, and a couple of areas for notification of - * any messages. - * - * @access private - * @param none - * @return void - */ - function _createUI() - { - // Create a window. - $window =& new GtkWindow; - $window->set_title('PHPUnit Gtk'); - $window->set_usize(400, -1); - - // Create the main box. - $mainBox =& new GtkVBox; - $window->add($mainBox); - - // Start with the menu. - $mainBox->pack_start($this->_createMenu()); - - // Then add the suite field entry. - $mainBox->pack_start($this->_createSuiteEntry()); - - // Then add the report labels. - $mainBox->pack_start($this->_createReportLabels()); - - // Next add the progress bar. - $mainBox->pack_start($this->_createProgressBar()); - - // Then add the report area and the dump area. - $mainBox->pack_start($this->_createReportAreas()); - - // Finish off with the status line. - $mainBox->pack_start($this->_createStatusLine()); - - // Connect the destroy signal. - $window->connect_object('destroy', array('gtk', 'main_quit')); - - // Assign the member. - $this->gui =& $window; - } - /** - * Create the menu. - * - * The menu is very simple. It an exit menu item, which exits - * the application, and an about menu item, which shows some - * basic information about the application itself. - * - * @access private - * @param none - * @return &object The GtkMenuBar - */ - function &_createMenu() - { - // Create the menu bar. - $menuBar =& new GtkMenuBar; - - // Create the main (only) menu item. - $phpHeader =& new GtkMenuItem('PHPUnit'); - - // Add the menu item to the menu bar. - $menuBar->append($phpHeader); - - // Create the PHPUnit menu. - $phpMenu =& new GtkMenu; - - // Add the menu items - $about =& new GtkMenuItem('About...'); - $about->connect('activate', array(&$this, 'about')); - $phpMenu->append($about); - - $exit =& new GtkMenuItem('Exit'); - $exit->connect_object('activate', array('gtk', 'main_quit')); - $phpMenu->append($exit); - - // Complete the menu. - $phpHeader->set_submenu($phpMenu); - - return $menuBar; - } - /** - * Create the suite entry and related widgets. - * - * The suite entry has some supporting components such as a - * label, the show passed check box and the run button. All - * of these items are packed into two nested boxes. - * - * @access private - * @param none - * @return &object A box that contains all of the suite entry pieces. - */ - function &_createSuiteEntry() - { - // Create the outermost box. - $outerBox =& new GtkVBox; - - // Create the suite label, box, and field. - $suiteLabel =& new GtkLabel('Test class name:'); - $suiteBox =& new GtkHBox; - $this->suiteField =& new GtkEntry; - $this->suiteField->set_text($suiteName != NULL ? $suiteName : ''); - - // Create the button the user will use to start the test. - $runButton =& new GtkButton('Run'); - $runButton->connect_object('clicked', array(&$this, 'run')); - - // Create the check box that lets the user show only failures. - $this->showPassed =& new GtkCheckButton('Show passed tests'); - - // Add the components to their respective boxes. - $suiteLabel->set_alignment(0, 0); - $outerBox->pack_start($suiteLabel); - $outerBox->pack_start($suiteBox); - $outerBox->pack_start($this->showPassed); - - $suiteBox->pack_start($this->suiteField); - $suiteBox->pack_start($runButton); - - return $outerBox; - } - - /** - * Create the labels that tell the user what has happened. - * - * There are three labels, one each for total runs, errors and - * failures. There is also one label for each of these that - * describes what the label is. It could be done with one label - * instead of two but that would make updates much harder. - * - * @access private - * @param none - * @return &object A box containing the labels. - */ - function &_createReportLabels() - { - // Create a box to hold everything. - $labelBox =& new GtkHBox; - - // Create the non-updated labels. - $numberOfRuns =& new GtkLabel('Runs:'); - $numberOfErrors =& new GtkLabel('Errors:'); - $numberOfFailures =& new GtkLabel('Failures:'); - - // Create the labels that will be updated. - // These are asssigned to members to make it easier to - // set their values later. - $this->numberOfRuns =& new GtkLabel(0); - $this->numberOfErrors =& new GtkLabel(0); - $this->numberOfFailures =& new GtkLabel(0); - - // Pack everything in. - $labelBox->pack_start($numberOfRuns); - $labelBox->pack_start($this->numberOfRuns); - $labelBox->pack_start($numberOfErrors); - $labelBox->pack_start($this->numberOfErrors); - $labelBox->pack_start($numberOfFailures); - $labelBox->pack_start($this->numberOfFailures); - - return $labelBox; - } - - /** - * Create the success/failure indicator. - * - * A GtkProgressBar is used to visually indicate how many - * tests were successful compared to how many were not. The - * progress bar shows the percentage of success and will - * change from green to red if there are any failures. - * - * @access private - * @param none - * @return &object The progress bar - */ - function &_createProgressBar() - { - // Create the progress bar. - $this->progress =& new GtkProgressBar(new GtkAdjustment(0, 0, 1, .1, 1, 0)); - - // Set the progress bar to print the percentage. - $this->progress->set_show_text(true); - - return $this->progress; - } - - /** - * Create the report text areas. - * - * The report area consists of one text area for failures, one - * text area for errors and one label for identification purposes. - * All three widgets are packed into a box. - * - * @access private - * @param none - * @return &object The box containing the report areas. - */ - function &_createReportAreas() - { - // Create the containing box. - $reportBox =& new GtkVBox; - - // Create the identification label - $reportLabel =& new GtkLabel('Errors and Failures:'); - $reportLabel->set_alignment(0, 0); - - // Create the scrolled windows for the text areas. - $reportScroll =& new GtkScrolledWindow; - $dumpScroll =& new GtkScrolledWindow; - - // Make the scroll areas big enough. - $reportScroll->set_usize(-1, 150); - $dumpScroll->set_usize(-1, 150); - - // Only show the vertical scroll bar when needed. - // Never show the horizontal scroll bar. - $reportScroll->set_policy(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - $dumpScroll->set_policy(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - - // Create the text areas. - $this->reportArea =& new GtkText; - $this->dumpArea =& new GtkText; - - // Don't let words get broken. - $this->reportArea->set_word_wrap(true); - $this->dumpArea->set_word_wrap(true); - - // Pack everything in. - $reportBox->pack_start($reportLabel); - $reportScroll->add($this->reportArea); - $reportBox->pack_start($reportScroll); - $dumpScroll->add($this->dumpArea); - $reportBox->pack_start($dumpScroll); - - return $reportBox; - } - - /** - * Create a status label. - * - * A status line at the bottom of the application is used - * to notify the user of non-test related messages such as - * failures loading a test suite. - * - * @access private - * @param none - * @return &object The status label. - */ - function &_createStatusLine() - { - // Create the status label. - $this->statusLine =& new GtkLabel(''); - $this->statusLine->set_alignment(0, 0); - - return $this->statusLine; - } - - /** - * Show a popup with information about the application. - * - * The popup should show information about the version, - * the author, the license, where to get the latest - * version and a short description. - * - * @access public - * @param none - * @return void - */ - function about() - { - // Create the new window. - $about =& new GtkWindow; - $about->set_title('About PHPUnit GUI Gtk'); - $about->set_usize(250, -1); - - // Put two vboxes in the hbox. - $vBox =& new GtkVBox; - $about->add($vBox); - - // Create the labels. - $version =& new GtkLabel(" Version: 1.0"); - $license =& new GtkLabel(" License: PHP License v3.0"); - $where =& new GtkLabel(" Download from: http://pear.php.net/PHPUnit/"); - $unitAuth =& new GtkLabel(" PHPUnit Author: Sebastian Bergman"); - $gtkAuth =& new GtkLabel(" Gtk GUI Author: Scott Mattocks"); - - // Align everything to the left - $where->set_alignment(0, .5); - $version->set_alignment(0, .5); - $license->set_alignment(0, .5); - $gtkAuth->set_alignment(0, .5); - $unitAuth->set_alignment(0, .5); - - // Pack everything into the vBox; - $vBox->pack_start($version); - $vBox->pack_start($license); - $vBox->pack_start($where); - $vBox->pack_start($unitAuth); - $vBox->pack_start($gtkAuth); - - // Connect the destroy signal. - $about->connect('destroy', array('gtk', 'true')); - - // Show the goods. - $about->show_all(); - } - - /** - * Load the test suite. - * - * This method tries to load test suite based on the user - * info. If the user passes the name of a tests suite, it - * is instantiated and a new object is returned. If the - * user passes a file that contains a test suite, the class - * is instantiated and a new object is returned. If the user - * passes a file that contains a test case, the test case is - * passed to a new test suite and the new suite object is - * returned. - * - * @access public - * @param string The file that contains a test case/suite or the classname. - * @return &object The new test suite. - */ - function &loadTest(&$file) - { - // Check to see if a class name was given. - if (is_a($file, 'PHPUnit_TestSuite')) { - return $file; - } elseif (class_exists($file)) { - require_once 'PHPUnit/TestSuite.php'; - return new PHPUnit_TestSuite($file); - } - - // Check that the file exists. - if (!@is_readable($file)) { - $this->_showStatus('Cannot find file: ' . $file); - return false; - } - - $this->_showStatus('Loading test suite...'); - - // Instantiate the class. - // If the path is /path/to/test/TestClass.php - // the class name should be test_TestClass - require_once $file; - $className = str_replace(DIRECTORY_SEPARATOR, '_', $file); - $className = substr($className, 0, strpos($className, '.')); - - require_once 'PHPUnit/TestSuite.php'; - return new PHPUnit_TestSuite($className); - } - - /** - * Run the test suite. - * - * This method runs the test suite and updates the messages - * for the user. When finished it changes the status line - * to 'Test Complete' - * - * @access public - * @param none - * @return void - */ - function runTest() - { - // Notify the user that the test is running. - $this->_showStatus('Running Test...'); - - // Run the test. - $result = PHPUnit::run($this->suite); - - // Update the labels. - $this->_setLabelValue($this->numberOfRuns, $result->runCount()); - $this->_setLabelValue($this->numberOfErrors, $result->errorCount()); - $this->_setLabelValue($this->numberOfFailures, $result->failureCount()); - - // Update the progress bar. - $this->_updateProgress($result->runCount(), - $result->errorCount(), - $result->failureCount() - ); - - // Show the errors. - $this->_showFailures($result->errors(), $this->dumpArea); - - // Show the messages from the tests. - if ($this->showPassed->get_active()) { - // Show failures and success. - $this->_showAll($result, $this->reportArea); - } else { - // Show only failures. - $this->_showFailures($result->failures(), $this->reportArea); - } - - // Update the status message. - $this->_showStatus('Test complete'); - } - - /** - * Set the text of a label. - * - * Change the text of a given label. - * - * @access private - * @param widget &$label The label whose value is to be changed. - * @param string $value The new text of the label. - * @return void - */ - function _setLabelValue(&$label, $value) - { - $label->set_text($value); - } - - /** - * The main work of the application. - * - * Load the test suite and then execute the tests. - * - * @access public - * @param none - * @return void - */ - function run() - { - // Load the test suite. - $this->suite =& $this->loadTest($this->suiteField->get_text()); - - // Check to make sure the suite was loaded properly. - if (!is_object($this->suite)) { - // Raise an error. - $this->_showStatus('Could not load test suite.'); - return false; - } - - // Run the tests. - $this->runTest(); - } - - /** - * Update the status message. - * - * @access private - * @param string $status The new message. - * @return void - */ - function _showStatus($status) - { - $this->statusLine->set_text($status); - } - - /** - * Alias for main() - * - * @see main - */ - function show($showPassed = true) - { - $this->main($showPassed); - } - - /** - * Add a suite to the tests. - * - * This method is require by SetupDecorator. It adds a - * suite to the the current set of suites. - * - * @access public - * @param object $testSuite The suite to add. - * @return void - */ - function addSuites($testSuite) - { - if (!is_array($testSuite)) { - settype($testSuite, 'array'); - } - - foreach ($testSuite as $suite) { - - if (is_a($this->suite, 'PHPUnit_TestSuite')) { - $this->suite->addTestSuite($suite->getName()); - } else { - $this->suite =& $this->loadTest($suite); - } - - // Set the suite field. - $text = $this->suiteField->get_text(); - if (empty($text)) { - $this->suiteField->set_text($this->suite->getName()); - } - } - } - - /** - * Show all test messages. - * - * @access private - * @param object The TestResult from the test suite. - * @return void - */ - function _showAll(&$result) - { - // Clear the area first. - $this->reportArea->delete_text(0, -1); - $this->reportArea->insert_text($result->toString(), 0); - } - - /** - * Show failure/error messages in the given text area. - * - * @access private - * @param object &$results The results of the test. - * @param widget &$area The area to show the results in. - */ - function _showFailures(&$results, &$area) - { - $area->delete_text(0, -1); - foreach (array_reverse($results, true) as $result) { - $area->insert_text($result->toString(), 0); - } - } - - /** - * Update the progress indicator. - * - * @access private - * @param integer $runs - * @param integer $errors - * @param integer $failures - * @return void - */ - function _updateProgress($runs, $errors, $failures) - { - $percentage = 1 - (($errors + $failures) / $runs); - $this->progress->set_percentage($percentage); - } -} -?> \ No newline at end of file diff --git a/3dparty/PHPUnit/GUI/HTML.php b/3dparty/PHPUnit/GUI/HTML.php deleted file mode 100644 index 773ab9af9f3..00000000000 --- a/3dparty/PHPUnit/GUI/HTML.php +++ /dev/null @@ -1,210 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: HTML.php,v 1.17 2005/01/07 07:34:05 sebastian Exp $ -// - -/** - * This class provides a HTML GUI. - * - * @author Wolfram Kriesing - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - * @subpackage GUI - */ -class PHPUnit_GUI_HTML -{ - var $_suites = array(); - - /** - * the current implementation of PHPUnit is designed - * this way that adding a suite to another suite only - * grabs all the tests and adds them to the suite, so you - * have no chance to find out which test goes with which suite - * therefore you can simply pass an array of suites to this constructor here - * - * @param array The suites to be tested. If not given, then you might - * be using the SetupDecorator, which detects them automatically - * when calling getSuitesFromDir() - */ - function PHPUnit_GUI_HTML($suites = array()) - { - if (!is_array($suites)) { - $this->_suites = array($suites); - } else { - $this->_suites = $suites; - } - } - - /** - * Add suites to the GUI - * - * @param object this should be an instance of PHPUnit_TestSuite - */ - function addSuites($suites) - { - $this->_suites = array_merge($this->_suites,$suites); - } - - /** - * this prints the HTML code straight out - * - */ - function show() - { - $request = $_REQUEST; - $showPassed = FALSE; - $submitted = @$request['submitted']; - - if ($submitted) { - $showPassed = @$request['showOK'] ? TRUE : FALSE; - } - - $suiteResults = array(); - - foreach ($this->_suites as $aSuite) { - $aSuiteResult = array(); - - // remove the first directory's name from the test-suite name, since it - // mostly is something like 'tests' or alike - $removablePrefix = explode('_',$aSuite->getName()); - $aSuiteResult['name'] = str_replace($removablePrefix[0].'_', '', $aSuite->getName()); - - if ($submitted && isset($request[$aSuiteResult['name']])) { - $result = PHPUnit::run($aSuite); - - $aSuiteResult['counts']['run'] = $result->runCount(); - $aSuiteResult['counts']['error'] = $result->errorCount(); - $aSuiteResult['counts']['failure'] = $result->failureCount(); - - $aSuiteResult['results'] = $this->_prepareResult($result,$showPassed); - - $per = 100/$result->runCount(); - $failed = ($per*$result->errorCount())+($per*$result->failureCount()); - $aSuiteResult['percent'] = round(100-$failed,2); - } else { - $aSuiteResult['addInfo'] = 'NOT EXECUTED'; - } - - $suiteResults[] = $aSuiteResult; - } - - $final['name'] = 'OVERALL RESULT'; - $final['counts'] = array(); - $final['percent'] = 0; - $numExecutedTests = 0; - - foreach ($suiteResults as $aSuiteResult) { - if (sizeof(@$aSuiteResult['counts'])) { - foreach ($aSuiteResult['counts'] as $key=>$aCount) { - if (!isset($final['counts'][$key])) { - $final['counts'][$key] = 0; - } - - $final['counts'][$key] += $aCount; - } - } - } - - if (isset($final['counts']['run'])) { - $per = 100/$final['counts']['run']; - $failed = ($per*$final['counts']['error'])+($per*$final['counts']['failure']); - $final['percent'] = round(100-$failed,2); - } else { - $final['percent'] = 0; - } - - array_unshift($suiteResults,$final); - - include 'PHPUnit/GUI/HTML.tpl'; - } - - function _prepareResult($result,$showPassed) - { - $ret = array(); - $failures = $result->failures(); - - foreach($failures as $aFailure) { - $ret['failures'][] = $this->_prepareFailure($aFailure); - } - - $errors = $result->errors(); - - foreach($errors as $aError) { - $ret['errors'][] = $this->_prepareErrors($aError); - } - - if ($showPassed) { - $passed = $result->passedTests(); - - foreach($passed as $aPassed) { - $ret['passed'][] = $this->_preparePassedTests($aPassed); - } - } - - return $ret; - } - - function _prepareFailure($failure) - { - $test = $failure->failedTest(); - $ret['testName'] = $test->getName(); - $exception = $failure->thrownException(); - - // a serialized string starts with a 'character:decimal:{' - // if so we try to unserialize it - // this piece of the regular expression is for detecting a serialized - // type like 'a:3:' for an array with three element or an object i.e. 'O:12:"class":3' - $serialized = '(\w:\d+:(?:"[^"]+":\d+:)?\{.*\})'; - - // Spaces might make a diff, so we shall show them properly (since a - // user agent ignores them). - if (preg_match('/^(.*)expected ' . $serialized . ', actual ' . $serialized . '$/sU', $exception, $matches)) { - ob_start(); - print_r(unserialize($matches[2])); - $ret['expected'] = htmlspecialchars($matches[1]) . "
" . htmlspecialchars(rtrim(ob_get_contents())) . "
"; - // Improved compatibility, ob_clean() would be PHP >= 4.2.0 only. - ob_end_clean(); - - ob_start(); - print_r(unserialize($matches[3])); - $ret['actual'] = htmlspecialchars($matches[1]) . "
" . htmlspecialchars(rtrim(ob_get_contents())) . "
"; - ob_end_clean(); - } - - else if (preg_match('/^(.*)expected (.*), actual (.*)$/sU', $exception, $matches)) { - $ret['expected'] = nl2br(str_replace(" ", " ", htmlspecialchars($matches[1] . $matches[2]))); - $ret['actual'] = nl2br(str_replace(" ", " ", htmlspecialchars($matches[1] . $matches[3]))); - } else { - $ret['message'] = nl2br(str_replace(" ", " ", htmlspecialchars($exception))); - } - - return $ret; - } - - function _preparePassedTests($passed) - { - $ret['testName'] = $passed->getName(); - return $ret; - } - - function _prepareError($error) - { - $ret['testName'] = $error->getName(); - $ret['message'] = $error->toString(); - return $ret; - } -} -?> diff --git a/3dparty/PHPUnit/GUI/SetupDecorator.php b/3dparty/PHPUnit/GUI/SetupDecorator.php deleted file mode 100644 index 73c3d8298e2..00000000000 --- a/3dparty/PHPUnit/GUI/SetupDecorator.php +++ /dev/null @@ -1,167 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: SetupDecorator.php,v 1.12 2005/05/14 05:58:38 sebastian Exp $ -// - -/** - * This decorator actually just adds the functionality to read the - * test-suite classes from a given directory and instanciate them - * automatically, use it as given in the example below. - * - * - * getSuitesFromDir('/path/to/dir/tests','.*\.php$',array('index.php','sql.php')); - * $gui->show(); - * ?> - * - * - * The example calls this class and tells it to: - * - * - find all file under the directory /path/to/dir/tests - * - for files, which end with '.php' (this is a piece of a regexp, that's why the . is escaped) - * - and to exclude the files 'index.php' and 'sql.php' - * - and include all the files that are left in the tests. - * - * Given that the path (the first parameter) ends with 'tests' it will be assumed - * that the classes are named tests_* where * is the directory plus the filename, - * according to PEAR standards. - * - * So that: - * - * - 'testMe.php' in the dir 'tests' bill be assumed to contain a class tests_testMe - * - '/moretests/aTest.php' should contain a class 'tests_moretests_aTest' - * - * @author Wolfram Kriesing - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - * @subpackage GUI - */ -class PHPUnit_GUI_SetupDecorator -{ - /** - * - * - */ - function PHPUnit_GUI_SetupDecorator(&$gui) - { - $this->_gui = &$gui; - } - - /** - * just forwarding the action to the decorated class. - * - */ - function show($showPassed=TRUE) - { - $this->_gui->show($showPassed); - } - - /** - * Setup test suites that can be found in the given directory - * Using the second parameter you can also choose a subsets of the files found - * in the given directory. I.e. only all the files that contain '_UnitTest_', - * in order to do this simply call it like this: - * getSuitesFromDir($dir,'.*_UnitTest_.*'). - * There you can already see that the pattern is built for the use within a regular expression. - * - * @param string the directory where to search for test-suite files - * @param string the pattern (a regexp) by which to find the files - * @param array an array of file names that shall be excluded - */ - function getSuitesFromDir($dir, $filenamePattern = '', $exclude = array()) - { - if ($dir{strlen($dir)-1} == DIRECTORY_SEPARATOR) { - $dir = substr($dir, 0, -1); - } - - $files = $this->_getFiles($dir, $filenamePattern, $exclude, realpath($dir . '/..')); - asort($files); - - foreach ($files as $className => $aFile) { - include_once($aFile); - - if (class_exists($className)) { - $suites[] =& new PHPUnit_TestSuite($className); - } else { - trigger_error("$className could not be found in $dir$aFile!"); - } - } - - $this->_gui->addSuites($suites); - } - - /** - * This method searches recursively through the directories - * to find all the files that shall be added to the be visible. - * - * @param string the path where find the files - * @param srting the string pattern by which to find the files - * @param string the file names to be excluded - * @param string the root directory, which serves as the prefix to the fully qualified filename - * @access private - */ - function _getFiles($dir, $filenamePattern, $exclude, $rootDir) - { - $files = array(); - - if ($dp = opendir($dir)) { - while (FALSE !== ($file = readdir($dp))) { - $filename = $dir . DIRECTORY_SEPARATOR . $file; - $match = TRUE; - - if ($filenamePattern && !preg_match("~$filenamePattern~", $file)) { - $match = FALSE; - } - - if (sizeof($exclude)) { - foreach ($exclude as $aExclude) { - if (strpos($file, $aExclude) !== FALSE) { - $match = FALSE; - break; - } - } - } - - if (is_file($filename) && $match) { - $tmp = str_replace($rootDir, '', $filename); - - if (strpos($tmp, DIRECTORY_SEPARATOR) === 0) { - $tmp = substr($tmp, 1); - } - - if (strpos($tmp, '/') === 0) { - $tmp = substr($tmp, 1); - } - - $className = str_replace(DIRECTORY_SEPARATOR, '_', $tmp); - $className = basename($className, '.php'); - - $files[$className] = $filename; - } - - if ($file != '.' && $file != '..' && is_dir($filename)) { - $files = array_merge($files, $this->_getFiles($filename, $filenamePattern, $exclude, $rootDir)); - } - } - - closedir($dp); - } - - return $files; - } -} -?> diff --git a/3dparty/PHPUnit/RepeatedTest.php b/3dparty/PHPUnit/RepeatedTest.php deleted file mode 100644 index f8cbbc640f6..00000000000 --- a/3dparty/PHPUnit/RepeatedTest.php +++ /dev/null @@ -1,112 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: RepeatedTest.php,v 1.10 2004/12/22 08:06:11 sebastian Exp $ -// - -require_once 'PHPUnit/TestDecorator.php'; - -/** - * A Decorator that runs a test repeatedly. - * - * Here is an example: - * - * - * PHPUnit_TestCase($name); - * } - * - * function setUp() { - * $this->fValue1 = 2; - * $this->fValue2 = 3; - * } - * - * function testAdd() { - * $this->assertTrue($this->fValue1 + $this->fValue2 == 5); - * } - * } - * - * $suite = new PHPUnit_TestSuite; - * - * $suite->addTest( - * new PHPUnit_RepeatedTest( - * new MathTest('testAdd'), - * 10 - * ) - * ); - * - * $result = PHPUnit::run($suite); - * print $result->toString(); - * ?> - * - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_RepeatedTest extends PHPUnit_TestDecorator { - /** - * @var integer - * @access private - */ - var $_timesRepeat = 1; - - /** - * Constructor. - * - * @param object - * @param integer - * @access public - */ - function PHPUnit_RepeatedTest(&$test, $timesRepeat = 1) { - $this->PHPUnit_TestDecorator($test); - $this->_timesRepeat = $timesRepeat; - } - - /** - * Counts the number of test cases that - * will be run by this test. - * - * @return integer - * @access public - */ - function countTestCases() { - return $this->_timesRepeat * $this->_test->countTestCases(); - } - - /** - * Runs the decorated test and collects the - * result in a TestResult. - * - * @param object - * @access public - * @abstract - */ - function run(&$result) { - for ($i = 0; $i < $this->_timesRepeat; $i++) { - $this->_test->run($result); - } - } -} -?> diff --git a/3dparty/PHPUnit/Skeleton.php b/3dparty/PHPUnit/Skeleton.php deleted file mode 100644 index 81fe3149066..00000000000 --- a/3dparty/PHPUnit/Skeleton.php +++ /dev/null @@ -1,406 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: Skeleton.php,v 1.6 2004/12/22 08:06:11 sebastian Exp $ -// - -/** - * Class for creating a PHPUnit_TestCase skeleton file. - * - * This class will take a classname as a parameter on construction and will - * create a PHP file that contains the skeleton of a PHPUnit_TestCase - * subclass. The test case will contain a test foreach method of the class. - * Methods of the parent class will, by default, be excluded from the test - * class. Passing and optional construction parameter will include them. - * - * Example - * - * createTestClass(); - * - * // Write the new test class to file. - * // By default, code to run the test will be included. - * $ps->writeTestClass(); - * ?> - * - * Now open the skeleton class and fill in the details. - * If you run the test as is, all tests will fail and - * you will see plenty of undefined constant errors. - * - * @author Scott Mattocks - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_Skeleton { - /** - * Path to the class file to create a skeleton for. - * @var string - */ - var $classPath; - - /** - * The name of the class - * @var string - */ - var $className; - - /** - * Path to the configuration file needed by class to test. - * @var string - */ - var $configFile; - - /** - * Whether or not to include the methods of the parent class when testing. - * @var boolean - */ - var $includeParents; - - /** - * Whether or not to test private methods. - * @var boolean - */ - var $includePrivate; - - /** - * The test class that will be created. - * @var string - */ - var $testClass; - - /** - * Constructor. Sets the class members and check that the class - * to test is accessible. - * - * @access public - * @param string $className - * @param string $classPath - * @param boolean $includeParents Wheter to include the parent's methods in the test. - * @return void - */ - function PHPUnit_Skeleton($className, $classPath, $includeParents = FALSE, $includePrivate = TRUE) { - // Set up the members. - if (@is_readable($classPath)) { - $this->className = $className; - $this->classPath = $classPath; - } else { - $this->_handleErrors($classPath . ' is not readable. Cannot create test class.'); - } - - // Do we want to include parent methods? - $this->includeParents = $includeParents; - - // Do we want to allow private methods? - $this->includePrivate = $includePrivate; - } - - /** - * The class to test may require a special config file before it can be - * instantiated. This method lets you set that file. - * - * @access public - * @param string $configPath - * @return void - */ - function setConfigFile($configFile) { - // Check that the file is readable - if (@is_readable($configFile)) { - $this->configFile = $configFile; - } else { - $this->_handleErrors($configFile . ' is not readable. Cannot create test class.'); - } - } - - /** - * Create the code that will be the skeleton of the test case. - * - * The test case must have a clss definition, one var, a constructor - * setUp, tearDown, and methods. Optionally and by default the code - * to run the test is added when the class is written to file. - * - * @access public - * @param none - * @return void - */ - function createTestClass() { - // Instantiate the object. - if (isset($this->configFile)) { - require_once $this->configFile; - } - - require_once $this->classPath; - - // Get the methods. - $classMethods = get_class_methods($this->className); - - // Remove the parent methods if needed. - if (!$this->includeParents) { - $parentMethods = get_class_methods(get_parent_class($this->className)); - - if (count($parentMethods)) { - $classMethods = array_diff($classMethods, $parentMethods); - } - } - - // Create the class definition, constructor, setUp and tearDown. - $this->_createDefinition(); - $this->_createConstructor(); - $this->_createSetUpTearDown(); - - if (count($classMethods)) { - // Foreach method create a test case. - foreach ($classMethods as $method) { - // Unless it is the constructor. - if (strcasecmp($this->className, $method) !== 0) { - // Check for private methods. - if (!$this->includePrivate && strpos($method, '_') === 0) { - continue; - } else { - $this->_createMethod($method); - } - } - } - } - - // Finis off the class. - $this->_finishClass(); - } - - /** - * Create the class definition. - * - * The definition consist of a header comment, require statment - * for getting the PHPUnit file, the actual class definition, - * and the definition of the class member variable. - * - * All of the code needed for the new class is stored in the - * testClass member. - * - * @access private - * @param none - * @return void - */ - function _createDefinition() { - // Create header comment. - $this->testClass = - "/**\n" . - " * PHPUnit test case for " . $this->className . "\n" . - " * \n" . - " * The method skeletons below need to be filled in with \n" . - " * real data so that the tests will run correctly. Replace \n" . - " * all EXPECTED_VAL and PARAM strings with real data. \n" . - " * \n" . - " * Created with PHPUnit_Skeleton on " . date('Y-m-d') . "\n" . - " */\n"; - - // Add the require statements. - $this->testClass .= "require_once 'PHPUnit.php';\n"; - - // Add the class definition and variable definition. - $this->testClass .= - "class " . $this->className . "Test extends PHPUnit_TestCase {\n\n" . - " var \$" . $this->className . ";\n\n"; - } - - /** - * Create the class constructor. (PHP4 style) - * - * The constructor simply calls the PHPUnit_TestCase method. - * This code is taken from the PHPUnit documentation. - * - * All of the code needed for the new class is stored in the - * testClass member. - * - * @access private - * @param none - * @return void - */ - function _createConstructor() { - // Create the test class constructor. - $this->testClass.= - " function " . $this->className . "Test(\$name)\n" . - " {\n" . - " \$this->PHPUnit_TestCase(\$name);\n" . - " }\n\n"; - } - - /** - * Create setUp and tearDown methods. - * - * The setUp method creates the instance of the object to test. - * The tearDown method releases the instance. - * This code is taken from the PHPUnit documentation. - * - * All of the code needed for the new class is stored in the - * testClass member. - * - * @access private - * @param none - * @return void - */ - function _createSetUpTearDown() { - // Create the setUp method. - $this->testClass .= - " function setUp()\n" . - " {\n"; - - if (isset($this->configFile)) { - $this->testClass .= - " require_once '" . $this->configFile . "';\n"; - } - - $this->testClass .= - " require_once '" . $this->classPath . "';\n" . - " \$this->" . $this->className . " =& new " . $this->className . "(PARAM);\n" . - " }\n\n"; - - // Create the tearDown method. - $this->testClass .= - " function tearDown()\n" . - " {\n" . - " unset(\$this->" . $this->className . ");\n" . - " }\n\n"; - } - - /** - * Create a basic skeleton for test methods. - * - * This code is taken from the PHPUnit documentation. - * - * All of the code needed for the new class is stored in the - * testClass member. - * - * @access private - * @param none - * @return void - */ - function _createMethod($methodName) { - // Create a test method. - $this->testClass .= - " function test" . $methodName . "()\n" . - " {\n" . - " \$result = \$this->" . $this->className . "->" . $methodName . "(PARAM);\n" . - " \$expected = EXPECTED_VAL;\n" . - " \$this->assertEquals(\$expected, \$result);\n" . - " }\n\n"; - } - - /** - * Add the closing brace needed for a proper class definition. - * - * All of the code needed for the new class is stored in the - * testClass member. - * - * @access private - * @param none - * @return void - */ - function _finishClass() { - // Close off the class. - $this->testClass.= "}\n"; - } - - /** - * Create the code that will actually run the test. - * - * This code is added by default so that the test can be run - * just by running the file. To have it not added pass false - * as the second parameter to the writeTestClass method. - * This code is taken from the PHPUnit documentation. - * - * All of the code needed for the new class is stored in the - * testClass member. - * - * @access private - * @param none - * @return void - */ - function _createTest() { - // Create a call to the test. - $test = - "// Running the test.\n" . - "\$suite = new PHPUnit_TestSuite('" . $this->className . "Test');\n" . - "\$result = PHPUnit::run(\$suite);\n" . - "echo \$result->toString();\n"; - - return $test; - } - - /** - * Write the test class to file. - * - * This will write the test class created using the createTestClass - * method to a file called Test.php. By default the file - * is written to the current directory and will have code to run - * the test appended to the bottom of the file. - * - * @access public - * @param string $destination The directory to write the file to. - * @param boolean $addTest Wheter to add the test running code. - * @return void - */ - function writeTestClass($destination = './', $addTest = TRUE) { - // Check for something to write to file. - if (!isset($this->testClass)) { - $this->_handleErrors('Noting to write.', PHPUS_WARNING); - return; - } - - // Open the destination file. - $fp = fopen($destination . $this->className . 'Test.php', 'w'); - fwrite($fp, "testClass); - - // Add the call to test the class in the file if we were asked to. - if ($addTest) { - fwrite($fp, $this->_createTest()); - } - - // Close the file. - fwrite($fp, "?>\n"); - fclose($fp); - } - - /** - * Error handler. - * - * This method should be rewritten to use the prefered error - * handling method. (PEAR_ErrorStack) - * - * @access private - * @param string $message The error message. - * @param integer $type An indication of the severity of the error. - * @return void Code may cause PHP to exit. - */ - function _handleErrors($message, $type = E_USER_ERROR) { - // For now just echo the message. - echo $message; - - // Check to see if we should quit. - if ($type == E_USER_ERROR) { - exit; - } - } -} -?> diff --git a/3dparty/PHPUnit/TestCase.php b/3dparty/PHPUnit/TestCase.php deleted file mode 100644 index 69594ed2f8e..00000000000 --- a/3dparty/PHPUnit/TestCase.php +++ /dev/null @@ -1,237 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: TestCase.php,v 1.16 2004/12/22 08:06:11 sebastian Exp $ -// - -require_once 'PHPUnit/Assert.php'; -require_once 'PHPUnit/TestResult.php'; - -/** - * A TestCase defines the fixture to run multiple tests. - * - * To define a TestCase - * - * 1) Implement a subclass of PHPUnit_TestCase. - * 2) Define instance variables that store the state of the fixture. - * 3) Initialize the fixture state by overriding setUp(). - * 4) Clean-up after a test by overriding tearDown(). - * - * Each test runs in its own fixture so there can be no side effects - * among test runs. - * - * Here is an example: - * - * - * PHPUnit_TestCase($name); - * } - * - * function setUp() { - * $this->fValue1 = 2; - * $this->fValue2 = 3; - * } - * } - * ?> - * - * - * For each test implement a method which interacts with the fixture. - * Verify the expected results with assertions specified by calling - * assert with a boolean. - * - * - * assertTrue($this->fValue1 + $this->fValue2 == 5); - * } - * ?> - * - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_TestCase extends PHPUnit_Assert { - /** - * @var boolean - * @access private - */ - var $_failed = FALSE; - - /** - * The name of the test case. - * - * @var string - * @access private - */ - var $_name = ''; - - /** - * PHPUnit_TestResult object - * - * @var object - * @access private - */ - var $_result; - - /** - * Constructs a test case with the given name. - * - * @param string - * @access public - */ - function PHPUnit_TestCase($name = FALSE) { - if ($name !== FALSE) { - $this->setName($name); - } - } - - /** - * Counts the number of test cases executed by run(TestResult result). - * - * @return integer - * @access public - */ - function countTestCases() { - return 1; - } - - /** - * Gets the name of a TestCase. - * - * @return string - * @access public - */ - function getName() { - return $this->_name; - } - - /** - * Runs the test case and collects the results in a given TestResult object. - * - * @param object - * @return object - * @access public - */ - function run(&$result) { - $this->_result = &$result; - $this->_result->run($this); - - return $this->_result; - } - - /** - * Runs the bare test sequence. - * - * @access public - */ - function runBare() { - $this->setUp(); - $this->runTest(); - $this->tearDown(); - $this->pass(); - } - - /** - * Override to run the test and assert its state. - * - * @access protected - */ - function runTest() { - call_user_func( - array( - &$this, - $this->_name - ) - ); - } - - /** - * Sets the name of a TestCase. - * - * @param string - * @access public - */ - function setName($name) { - $this->_name = $name; - } - - /** - * Returns a string representation of the test case. - * - * @return string - * @access public - */ - function toString() { - return ''; - } - - /** - * Creates a default TestResult object. - * - * @return object - * @access protected - */ - function &createResult() { - return new PHPUnit_TestResult; - } - - /** - * Fails a test with the given message. - * - * @param string - * @access protected - */ - function fail($message = '') { - $this->_result->addFailure($this, $message); - $this->_failed = TRUE; - } - - /** - * Passes a test. - * - * @access protected - */ - function pass() { - if (!$this->_failed) { - $this->_result->addPassedTest($this); - } - } - - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - * - * @access protected - * @abstract - */ - function setUp() { /* abstract */ } - - /** - * Tears down the fixture, for example, close a network connection. - * This method is called after a test is executed. - * - * @access protected - * @abstract - */ - function tearDown() { /* abstract */ } -} -?> diff --git a/3dparty/PHPUnit/TestDecorator.php b/3dparty/PHPUnit/TestDecorator.php deleted file mode 100644 index 6486309a70b..00000000000 --- a/3dparty/PHPUnit/TestDecorator.php +++ /dev/null @@ -1,110 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: TestDecorator.php,v 1.12 2005/05/14 05:58:38 sebastian Exp $ -// - -require_once 'PHPUnit/TestCase.php'; -require_once 'PHPUnit/TestSuite.php'; - -/** - * A Decorator for Tests. - * - * Use TestDecorator as the base class for defining new - * test decorators. Test decorator subclasses can be introduced - * to add behaviour before or after a test is run. - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_TestDecorator { - /** - * The Test to be decorated. - * - * @var object - * @access protected - */ - var $_test = NULL; - - /** - * Constructor. - * - * @param object - * @access public - */ - function PHPUnit_TestDecorator(&$test) { - if (is_object($test) && - (is_a($test, 'PHPUnit_TestCase') || - is_a($test, 'PHPUnit_TestSuite'))) { - - $this->_test = &$test; - } - } - - /** - * Runs the test and collects the - * result in a TestResult. - * - * @param object - * @access public - */ - function basicRun(&$result) { - $this->_test->run($result); - } - - /** - * Counts the number of test cases that - * will be run by this test. - * - * @return integer - * @access public - */ - function countTestCases() { - return $this->_test->countTestCases(); - } - - /** - * Returns the test to be run. - * - * @return object - * @access public - */ - function &getTest() { - return $this->_test; - } - - /** - * Runs the decorated test and collects the - * result in a TestResult. - * - * @param object - * @access public - * @abstract - */ - function run(&$result) { /* abstract */ } - - /** - * Returns a string representation of the test. - * - * @return string - * @access public - */ - function toString() { - return $this->_test->toString(); - } -} -?> diff --git a/3dparty/PHPUnit/TestFailure.php b/3dparty/PHPUnit/TestFailure.php deleted file mode 100644 index 69c8b80bcbb..00000000000 --- a/3dparty/PHPUnit/TestFailure.php +++ /dev/null @@ -1,88 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: TestFailure.php,v 1.10 2005/05/14 05:58:38 sebastian Exp $ -// - -/** - * A TestFailure collects a failed test together with the caught exception. - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_TestFailure { - /** - * @var object - * @access private - */ - var $_failedTest; - - /** - * @var string - * @access private - */ - var $_thrownException; - - /** - * Constructs a TestFailure with the given test and exception. - * - * @param object - * @param string - * @access public - */ - function PHPUnit_TestFailure(&$failedTest, &$thrownException) { - $this->_failedTest = &$failedTest; - $this->_thrownException = &$thrownException; - } - - /** - * Gets the failed test. - * - * @return object - * @access public - */ - function &failedTest() { - return $this->_failedTest; - } - - /** - * Gets the thrown exception. - * - * @return object - * @access public - */ - function &thrownException() { - return $this->_thrownException; - } - - /** - * Returns a short description of the failure. - * - * @return string - * @access public - */ - function toString() { - return sprintf( - "TestCase %s->%s() failed: %s\n", - - get_class($this->_failedTest), - $this->_failedTest->getName(), - $this->_thrownException - ); - } -} -?> diff --git a/3dparty/PHPUnit/TestListener.php b/3dparty/PHPUnit/TestListener.php deleted file mode 100644 index 7685df46792..00000000000 --- a/3dparty/PHPUnit/TestListener.php +++ /dev/null @@ -1,120 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: TestListener.php,v 1.9 2004/12/22 08:06:11 sebastian Exp $ -// - -/** - * A Listener for test progress. - * - * Here is an example: - * - * - * PHPUnit_TestCase($name); - * } - * - * function setUp() { - * $this->fValue1 = 2; - * $this->fValue2 = 3; - * } - * - * function testAdd() { - * $this->assertTrue($this->fValue1 + $this->fValue2 == 4); - * } - * } - * - * class MyListener extends PHPUnit_TestListener { - * function addError(&$test, &$t) { - * print "MyListener::addError() called.\n"; - * } - * - * function addFailure(&$test, &$t) { - * print "MyListener::addFailure() called.\n"; - * } - * - * function endTest(&$test) { - * print "MyListener::endTest() called.\n"; - * } - * - * function startTest(&$test) { - * print "MyListener::startTest() called.\n"; - * } - * } - * - * $suite = new PHPUnit_TestSuite; - * $suite->addTest(new MathTest('testAdd')); - * - * $result = new PHPUnit_TestResult; - * $result->addListener(new MyListener); - * - * $suite->run($result); - * print $result->toString(); - * ?> - * - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_TestListener { - /** - * An error occurred. - * - * @param object - * @param object - * @access public - * @abstract - */ - function addError(&$test, &$t) { /*abstract */ } - - /** - * A failure occurred. - * - * @param object - * @param object - * @access public - * @abstract - */ - function addFailure(&$test, &$t) { /*abstract */ } - - /** - * A test ended. - * - * @param object - * @access public - * @abstract - */ - function endTest(&$test) { /*abstract */ } - - /** - * A test started. - * - * @param object - * @access public - * @abstract - */ - function startTest(&$test) { /*abstract */ } -} -?> diff --git a/3dparty/PHPUnit/TestResult.php b/3dparty/PHPUnit/TestResult.php deleted file mode 100644 index ee60b2c5b50..00000000000 --- a/3dparty/PHPUnit/TestResult.php +++ /dev/null @@ -1,300 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: TestResult.php,v 1.13 2005/05/14 05:58:38 sebastian Exp $ -// - -require_once 'PHPUnit/TestFailure.php'; -require_once 'PHPUnit/TestListener.php'; - -/** - * A TestResult collects the results of executing a test case. - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_TestResult { - /** - * @var array - * @access protected - */ - var $_errors = array(); - - /** - * @var array - * @access protected - */ - var $_failures = array(); - - /** - * @var array - * @access protected - */ - var $_listeners = array(); - - /** - * @var array - * @access protected - */ - var $_passedTests = array(); - - /** - * @var integer - * @access protected - */ - var $_runTests = 0; - - /** - * @var boolean - * @access private - */ - var $_stop = FALSE; - - /** - * Adds an error to the list of errors. - * The passed in exception caused the error. - * - * @param object - * @param object - * @access public - */ - function addError(&$test, &$t) { - $this->_errors[] = new PHPUnit_TestFailure($test, $t); - - for ($i = 0; $i < sizeof($this->_listeners); $i++) { - $this->_listeners[$i]->addError($test, $t); - } - } - - /** - * Adds a failure to the list of failures. - * The passed in exception caused the failure. - * - * @param object - * @param object - * @access public - */ - function addFailure(&$test, &$t) { - $this->_failures[] = new PHPUnit_TestFailure($test, $t); - - for ($i = 0; $i < sizeof($this->_listeners); $i++) { - $this->_listeners[$i]->addFailure($test, $t); - } - } - - /** - * Registers a TestListener. - * - * @param object - * @access public - */ - function addListener(&$listener) { - if (is_object($listener) && - is_a($listener, 'PHPUnit_TestListener')) { - $this->_listeners[] = &$listener; - } - } - - /** - * Adds a passed test to the list of passed tests. - * - * @param object - * @access public - */ - function addPassedTest(&$test) { - $this->_passedTests[] = &$test; - } - - /** - * Informs the result that a test was completed. - * - * @param object - * @access public - */ - function endTest(&$test) { - for ($i = 0; $i < sizeof($this->_listeners); $i++) { - $this->_listeners[$i]->endTest($test); - } - } - - /** - * Gets the number of detected errors. - * - * @return integer - * @access public - */ - function errorCount() { - return sizeof($this->_errors); - } - - /** - * Returns an Enumeration for the errors. - * - * @return array - * @access public - */ - function &errors() { - return $this->_errors; - } - - /** - * Gets the number of detected failures. - * - * @return integer - * @access public - */ - function failureCount() { - return sizeof($this->_failures); - } - - /** - * Returns an Enumeration for the failures. - * - * @return array - * @access public - */ - function &failures() { - return $this->_failures; - } - - /** - * Returns an Enumeration for the passed tests. - * - * @return array - * @access public - */ - function &passedTests() { - return $this->_passedTests; - } - - /** - * Unregisters a TestListener. - * This requires the Zend Engine 2 (to work properly). - * - * @param object - * @access public - */ - function removeListener(&$listener) { - for ($i = 0; $i < sizeof($this->_listeners); $i++) { - if ($this->_listeners[$i] === $listener) { - unset($this->_listeners[$i]); - } - } - } - - /** - * Runs a TestCase. - * - * @param object - * @access public - */ - function run(&$test) { - $this->startTest($test); - $this->_runTests++; - $test->runBare(); - $this->endTest($test); - } - - /** - * Gets the number of run tests. - * - * @return integer - * @access public - */ - function runCount() { - return $this->_runTests; - } - - /** - * Checks whether the test run should stop. - * - * @access public - */ - function shouldStop() { - return $this->_stop; - } - - /** - * Informs the result that a test will be started. - * - * @param object - * @access public - */ - function startTest(&$test) { - for ($i = 0; $i < sizeof($this->_listeners); $i++) { - $this->_listeners[$i]->startTest($test); - } - } - - /** - * Marks that the test run should stop. - * - * @access public - */ - function stop() { - $this->_stop = TRUE; - } - - /** - * Returns a HTML representation of the test result. - * - * @return string - * @access public - */ - function toHTML() { - return '
' . htmlspecialchars($this->toString()) . '
'; - } - - /** - * Returns a text representation of the test result. - * - * @return string - * @access public - */ - function toString() { - $result = ''; - - foreach ($this->_passedTests as $passedTest) { - $result .= sprintf( - "TestCase %s->%s() passed\n", - - get_class($passedTest), - $passedTest->getName() - ); - } - - foreach ($this->_failures as $failedTest) { - $result .= $failedTest->toString(); - } - - return $result; - } - /** - * Returns whether the entire test was successful or not. - * - * @return boolean - * @access public - */ - function wasSuccessful() { - if (empty($this->_errors) && empty($this->_failures)) { - return TRUE; - } else { - return FALSE; - } - } -} -?> diff --git a/3dparty/PHPUnit/TestSuite.php b/3dparty/PHPUnit/TestSuite.php deleted file mode 100644 index f2396748ba3..00000000000 --- a/3dparty/PHPUnit/TestSuite.php +++ /dev/null @@ -1,220 +0,0 @@ -. | -// +------------------------------------------------------------------------+ -// | This source file is subject to version 3.00 of the PHP License, | -// | that is available at http://www.php.net/license/3_0.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. | -// +------------------------------------------------------------------------+ -// -// $Id: TestSuite.php,v 1.14 2005/05/14 05:58:38 sebastian Exp $ -// - -require_once 'PHPUnit/TestCase.php'; - -/** - * A TestSuite is a Composite of Tests. It runs a collection of test cases. - * - * Here is an example using the dynamic test definition. - * - * - * addTest(new MathTest('testPass')); - * ?> - * - * - * Alternatively, a TestSuite can extract the tests to be run automatically. - * To do so you pass the classname of your TestCase class to the TestSuite - * constructor. - * - * - * - * - * - * This constructor creates a suite with all the methods starting with - * "test" that take no arguments. - * - * @author Sebastian Bergmann - * @copyright Copyright © 2002-2005 Sebastian Bergmann - * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0 - * @category Testing - * @package PHPUnit - */ -class PHPUnit_TestSuite { - /** - * The name of the test suite. - * - * @var string - * @access private - */ - var $_name = ''; - - /** - * The tests in the test suite. - * - * @var array - * @access private - */ - var $_tests = array(); - - /** - * Constructs a TestSuite. - * - * @param mixed - * @access public - */ - function PHPUnit_TestSuite($test = FALSE) { - if ($test !== FALSE) { - $this->setName($test); - $this->addTestSuite($test); - } - } - - /** - * Adds a test to the suite. - * - * @param object - * @access public - */ - function addTest(&$test) { - $this->_tests[] = &$test; - } - - /** - * Adds the tests from the given class to the suite. - * - * @param string - * @access public - */ - function addTestSuite($testClass) { - if (class_exists($testClass)) { - $methods = get_class_methods($testClass); - $parentClasses = array(strtolower($testClass)); - $parentClass = $testClass; - - while(is_string($parentClass = get_parent_class($parentClass))) { - $parentClasses[] = $parentClass; - } - - foreach ($methods as $method) { - if (substr($method, 0, 4) == 'test' && - !in_array($method, $parentClasses)) { - $this->addTest(new $testClass($method)); - } - } - } - } - - /** - * Counts the number of test cases that will be run by this test. - * - * @return integer - * @access public - */ - function countTestCases() { - $count = 0; - - foreach ($this->_tests as $test) { - $count += $test->countTestCases(); - } - - return $count; - } - - /** - * Returns the name of the suite. - * - * @return string - * @access public - */ - function getName() { - return $this->_name; - } - - /** - * Runs the tests and collects their result in a TestResult. - * - * @param object - * @access public - */ - function run(&$result) { - for ($i = 0; $i < sizeof($this->_tests) && !$result->shouldStop(); $i++) { - $this->_tests[$i]->run($result); - } - } - - /** - * Runs a test. - * - * @param object - * @param object - * @access public - */ - function runTest(&$test, &$result) { - $test->run($result); - } - - /** - * Sets the name of the suite. - * - * @param string - * @access public - */ - function setName($name) { - $this->_name = $name; - } - - /** - * Returns the test at the given index. - * - * @param integer - * @return object - * @access public - */ - function &testAt($index) { - if (isset($this->_tests[$index])) { - return $this->_tests[$index]; - } else { - return FALSE; - } - } - - /** - * Returns the number of tests in this suite. - * - * @return integer - * @access public - */ - function testCount() { - return sizeof($this->_tests); - } - - /** - * Returns the tests as an enumeration. - * - * @return array - * @access public - */ - function &tests() { - return $this->_tests; - } - - /** - * Returns a string representation of the test suite. - * - * @return string - * @access public - */ - function toString() { - return ''; - } -} -?> diff --git a/3dparty/System.php b/3dparty/System.php deleted file mode 100644 index 97de96b14ca..00000000000 --- a/3dparty/System.php +++ /dev/null @@ -1,540 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: System.php,v 1.36 2004/06/15 16:33:46 pajoye Exp $ -// - -require_once( 'PEAR.php'); -require_once( 'Console/Getopt.php'); - -$GLOBALS['_System_temp_files'] = array(); - -/** -* System offers cross plattform compatible system functions -* -* Static functions for different operations. Should work under -* Unix and Windows. The names and usage has been taken from its respectively -* GNU commands. The functions will return (bool) false on error and will -* trigger the error with the PHP trigger_error() function (you can silence -* the error by prefixing a '@' sign after the function call). -* -* Documentation on this class you can find in: -* http://pear.php.net/manual/ -* -* Example usage: -* if (!@System::rm('-r file1 dir1')) { -* print "could not delete file1 or dir1"; -* } -* -* In case you need to to pass file names with spaces, -* pass the params as an array: -* -* System::rm(array('-r', $file1, $dir1)); -* -* @package System -* @author Tomas V.V.Cox -* @version $Revision: 1.36 $ -* @access public -* @see http://pear.php.net/manual/ -*/ -class System -{ - /** - * returns the commandline arguments of a function - * - * @param string $argv the commandline - * @param string $short_options the allowed option short-tags - * @param string $long_options the allowed option long-tags - * @return array the given options and there values - * @access private - */ - function _parseArgs($argv, $short_options, $long_options = null) - { - if (!is_array($argv) && $argv !== null) { - $argv = preg_split('/\s+/', $argv); - } - return Console_Getopt::getopt2($argv, $short_options); - } - - /** - * Output errors with PHP trigger_error(). You can silence the errors - * with prefixing a "@" sign to the function call: @System::mkdir(..); - * - * @param mixed $error a PEAR error or a string with the error message - * @return bool false - * @access private - */ - function raiseError($error) - { - if (PEAR::isError($error)) { - $error = $error->getMessage(); - } - trigger_error($error, E_USER_WARNING); - return false; - } - - /** - * Creates a nested array representing the structure of a directory - * - * System::_dirToStruct('dir1', 0) => - * Array - * ( - * [dirs] => Array - * ( - * [0] => dir1 - * ) - * - * [files] => Array - * ( - * [0] => dir1/file2 - * [1] => dir1/file3 - * ) - * ) - * @param string $sPath Name of the directory - * @param integer $maxinst max. deep of the lookup - * @param integer $aktinst starting deep of the lookup - * @return array the structure of the dir - * @access private - */ - - function _dirToStruct($sPath, $maxinst, $aktinst = 0) - { - $struct = array('dirs' => array(), 'files' => array()); - if (($dir = @opendir($sPath)) === false) { - System::raiseError("Could not open dir $sPath"); - return $struct; // XXX could not open error - } - $struct['dirs'][] = $sPath; // XXX don't add if '.' or '..' ? - $list = array(); - while ($file = readdir($dir)) { - if ($file != '.' && $file != '..') { - $list[] = $file; - } - } - closedir($dir); - sort($list); - if ($aktinst < $maxinst || $maxinst == 0) { - foreach($list as $val) { - $path = $sPath . DIRECTORY_SEPARATOR . $val; - if (is_dir($path)) { - $tmp = System::_dirToStruct($path, $maxinst, $aktinst+1); - $struct = array_merge_recursive($tmp, $struct); - } else { - $struct['files'][] = $path; - } - } - } - return $struct; - } - - /** - * Creates a nested array representing the structure of a directory and files - * - * @param array $files Array listing files and dirs - * @return array - * @see System::_dirToStruct() - */ - function _multipleToStruct($files) - { - $struct = array('dirs' => array(), 'files' => array()); - settype($files, 'array'); - foreach ($files as $file) { - if (is_dir($file)) { - $tmp = System::_dirToStruct($file, 0); - $struct = array_merge_recursive($tmp, $struct); - } else { - $struct['files'][] = $file; - } - } - return $struct; - } - - /** - * The rm command for removing files. - * Supports multiple files and dirs and also recursive deletes - * - * @param string $args the arguments for rm - * @return mixed PEAR_Error or true for success - * @access public - */ - function rm($args) - { - $opts = System::_parseArgs($args, 'rf'); // "f" do nothing but like it :-) - if (PEAR::isError($opts)) { - return System::raiseError($opts); - } - foreach($opts[0] as $opt) { - if ($opt[0] == 'r') { - $do_recursive = true; - } - } - $ret = true; - if (isset($do_recursive)) { - $struct = System::_multipleToStruct($opts[1]); - foreach($struct['files'] as $file) { - if (!@unlink($file)) { - $ret = false; - } - } - foreach($struct['dirs'] as $dir) { - if (!@rmdir($dir)) { - $ret = false; - } - } - } else { - foreach ($opts[1] as $file) { - $delete = (is_dir($file)) ? 'rmdir' : 'unlink'; - if (!@$delete($file)) { - $ret = false; - } - } - } - return $ret; - } - - /** - * Make directories. Note that we use call_user_func('mkdir') to avoid - * a problem with ZE2 calling System::mkDir instead of the native PHP func. - * - * @param string $args the name of the director(y|ies) to create - * @return bool True for success - * @access public - */ - function mkDir($args) - { - $opts = System::_parseArgs($args, 'pm:'); - if (PEAR::isError($opts)) { - return System::raiseError($opts); - } - $mode = 0777; // default mode - foreach($opts[0] as $opt) { - if ($opt[0] == 'p') { - $create_parents = true; - } elseif($opt[0] == 'm') { - // if the mode is clearly an octal number (starts with 0) - // convert it to decimal - if (strlen($opt[1]) && $opt[1]{0} == '0') { - $opt[1] = octdec($opt[1]); - } else { - // convert to int - $opt[1] += 0; - } - $mode = $opt[1]; - } - } - $ret = true; - if (isset($create_parents)) { - foreach($opts[1] as $dir) { - $dirstack = array(); - while (!@is_dir($dir) && $dir != DIRECTORY_SEPARATOR) { - array_unshift($dirstack, $dir); - $dir = dirname($dir); - } - while ($newdir = array_shift($dirstack)) { - if (!call_user_func('mkdir', $newdir, $mode)) { - $ret = false; - } - } - } - } else { - foreach($opts[1] as $dir) { - if (!@is_dir($dir) && !call_user_func('mkdir', $dir, $mode)) { - $ret = false; - } - } - } - return $ret; - } - - /** - * Concatenate files - * - * Usage: - * 1) $var = System::cat('sample.txt test.txt'); - * 2) System::cat('sample.txt test.txt > final.txt'); - * 3) System::cat('sample.txt test.txt >> final.txt'); - * - * Note: as the class use fopen, urls should work also (test that) - * - * @param string $args the arguments - * @return boolean true on success - * @access public - */ - function &cat($args) - { - $ret = null; - $files = array(); - if (!is_array($args)) { - $args = preg_split('/\s+/', $args); - } - for($i=0; $i < count($args); $i++) { - if ($args[$i] == '>') { - $mode = 'wb'; - $outputfile = $args[$i+1]; - break; - } elseif ($args[$i] == '>>') { - $mode = 'ab+'; - $outputfile = $args[$i+1]; - break; - } else { - $files[] = $args[$i]; - } - } - if (isset($mode)) { - if (!$outputfd = fopen($outputfile, $mode)) { - $err = System::raiseError("Could not open $outputfile"); - return $err; - } - $ret = true; - } - foreach ($files as $file) { - if (!$fd = fopen($file, 'r')) { - System::raiseError("Could not open $file"); - continue; - } - while ($cont = fread($fd, 2048)) { - if (isset($outputfd)) { - fwrite($outputfd, $cont); - } else { - $ret .= $cont; - } - } - fclose($fd); - } - if (@is_resource($outputfd)) { - fclose($outputfd); - } - return $ret; - } - - /** - * Creates temporary files or directories. This function will remove - * the created files when the scripts finish its execution. - * - * Usage: - * 1) $tempfile = System::mktemp("prefix"); - * 2) $tempdir = System::mktemp("-d prefix"); - * 3) $tempfile = System::mktemp(); - * 4) $tempfile = System::mktemp("-t /var/tmp prefix"); - * - * prefix -> The string that will be prepended to the temp name - * (defaults to "tmp"). - * -d -> A temporary dir will be created instead of a file. - * -t -> The target dir where the temporary (file|dir) will be created. If - * this param is missing by default the env vars TMP on Windows or - * TMPDIR in Unix will be used. If these vars are also missing - * c:\windows\temp or /tmp will be used. - * - * @param string $args The arguments - * @return mixed the full path of the created (file|dir) or false - * @see System::tmpdir() - * @access public - */ - function mktemp($args = null) - { - static $first_time = true; - $opts = System::_parseArgs($args, 't:d'); - if (PEAR::isError($opts)) { - return System::raiseError($opts); - } - foreach($opts[0] as $opt) { - if($opt[0] == 'd') { - $tmp_is_dir = true; - } elseif($opt[0] == 't') { - $tmpdir = $opt[1]; - } - } - $prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp'; - if (!isset($tmpdir)) { - $tmpdir = System::tmpdir(); - } - if (!System::mkDir("-p $tmpdir")) { - return false; - } - $tmp = tempnam($tmpdir, $prefix); - if (isset($tmp_is_dir)) { - unlink($tmp); // be careful possible race condition here - if (!call_user_func('mkdir', $tmp, 0700)) { - return System::raiseError("Unable to create temporary directory $tmpdir"); - } - } - $GLOBALS['_System_temp_files'][] = $tmp; - if ($first_time) { - PEAR::registerShutdownFunc(array('System', '_removeTmpFiles')); - $first_time = false; - } - return $tmp; - } - - /** - * Remove temporary files created my mkTemp. This function is executed - * at script shutdown time - * - * @access private - */ - function _removeTmpFiles() - { - if (count($GLOBALS['_System_temp_files'])) { - $delete = $GLOBALS['_System_temp_files']; - array_unshift($delete, '-r'); - System::rm($delete); - } - } - - /** - * Get the path of the temporal directory set in the system - * by looking in its environments variables. - * Note: php.ini-recommended removes the "E" from the variables_order setting, - * making unavaible the $_ENV array, that s why we do tests with _ENV - * - * @return string The temporal directory on the system - */ - function tmpdir() - { - if (OS_WINDOWS) { - if ($var = isset($_ENV['TEMP']) ? $_ENV['TEMP'] : getenv('TEMP')) { - return $var; - } - if ($var = isset($_ENV['TMP']) ? $_ENV['TMP'] : getenv('TMP')) { - return $var; - } - if ($var = isset($_ENV['windir']) ? $_ENV['windir'] : getenv('windir')) { - return $var; - } - return getenv('SystemRoot') . '\temp'; - } - if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) { - return $var; - } - return '/tmp'; - } - - /** - * The "which" command (show the full path of a command) - * - * @param string $program The command to search for - * @return mixed A string with the full path or false if not found - * @author Stig Bakken - */ - function which($program, $fallback = false) - { - // is_executable() is not available on windows - if (OS_WINDOWS) { - $pear_is_executable = 'is_file'; - } else { - $pear_is_executable = 'is_executable'; - } - - // full path given - if (basename($program) != $program) { - return (@$pear_is_executable($program)) ? $program : $fallback; - } - - // XXX FIXME honor safe mode - $path_delim = OS_WINDOWS ? ';' : ':'; - $exe_suffixes = OS_WINDOWS ? array('.exe','.bat','.cmd','.com') : array(''); - $path_elements = explode($path_delim, getenv('PATH')); - foreach ($exe_suffixes as $suff) { - foreach ($path_elements as $dir) { - $file = $dir . DIRECTORY_SEPARATOR . $program . $suff; - if (@is_file($file) && @$pear_is_executable($file)) { - return $file; - } - } - } - return $fallback; - } - - /** - * The "find" command - * - * Usage: - * - * System::find($dir); - * System::find("$dir -type d"); - * System::find("$dir -type f"); - * System::find("$dir -name *.php"); - * System::find("$dir -name *.php -name *.htm*"); - * System::find("$dir -maxdepth 1"); - * - * Params implmented: - * $dir -> Start the search at this directory - * -type d -> return only directories - * -type f -> return only files - * -maxdepth -> max depth of recursion - * -name -> search pattern (bash style). Multiple -name param allowed - * - * @param mixed Either array or string with the command line - * @return array Array of found files - * - */ - function find($args) - { - if (!is_array($args)) { - $args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY); - } - $dir = array_shift($args); - $patterns = array(); - $depth = 0; - $do_files = $do_dirs = true; - for ($i = 0; $i < count($args); $i++) { - switch ($args[$i]) { - case '-type': - if (in_array($args[$i+1], array('d', 'f'))) { - if ($args[$i+1] == 'd') { - $do_files = false; - } else { - $do_dirs = false; - } - } - $i++; - break; - case '-name': - $patterns[] = "(" . preg_replace(array('/\./', '/\*/'), - array('\.', '.*'), - $args[$i+1]) - . ")"; - $i++; - break; - case '-maxdepth': - $depth = $args[$i+1]; - break; - } - } - $path = System::_dirToStruct($dir, $depth); - if ($do_files && $do_dirs) { - $files = array_merge($path['files'], $path['dirs']); - } elseif ($do_dirs) { - $files = $path['dirs']; - } else { - $files = $path['files']; - } - if (count($patterns)) { - $patterns = implode('|', $patterns); - $ret = array(); - for ($i = 0; $i < count($files); $i++) { - if (preg_match("#^$patterns\$#", $files[$i])) { - $ret[] = $files[$i]; - } - } - return $ret; - } - return $files; - } -} -?> diff --git a/3dparty/docs/HTTP_WebDAV_Server/README b/3dparty/docs/HTTP_WebDAV_Server/README deleted file mode 100644 index 9847b261684..00000000000 --- a/3dparty/docs/HTTP_WebDAV_Server/README +++ /dev/null @@ -1,10 +0,0 @@ -This code depends on code introduced into the developement branch for -PHP 4.3, so it will not run with PHP releases before 4.3.0 - -preliminary documentation is available in the dav.txt file, -although it is currently a little outdated ... - -Server/Filesystem.php contains a sample implementation for a simple -file server (including property and lock info storage in a mySQL -database, see db/Fileserver.sql). This sample should give you a good -clue about how to use this class for your own purpose. diff --git a/3dparty/docs/HTTP_WebDAV_Server/dav.txt b/3dparty/docs/HTTP_WebDAV_Server/dav.txt deleted file mode 100644 index 9e0b8299229..00000000000 --- a/3dparty/docs/HTTP_WebDAV_Server/dav.txt +++ /dev/null @@ -1,229 +0,0 @@ -The HTTP_WebDAV_Server class provides a framwork for the -implementation of customized WebDAV servers that can provide -filesystem like access to almost any kind of hierachically stored -data. - -The (abstract) server base class tries to encapsulate as much of -the protocol details as possible. It takes care of the needed WebDAV -header and XML payload parsing and generation (and knows about some -of the problems with common clients and tries hard to work around -them). - -WebDAV itself is an extension to the HTTP protocol. The HTTP -specific parts of it are already taken care of by the web server. Any -data needed by the server class is provided by the PHP SAPI interface -of the server used. - -To create a working server from the base class you have to extend and -add methods for the actual access, modification and access control of -your own data. - -You may use the included HTTP_WebDAV_Server_Filesystem class as an -example of how to create a working server. This sample implementation -is used for testing the implementation of this package against the -litmus WebDAV compliance test suite. -(litmus is available on http://www.webdav.org/neon/litmus) - -The methods you can add in your extended class are mostly named after -the WebDAV specific request methods (using upper case names). Methods -you may implement are: - -* GET() get a resource from the server -* HEAD() get resource headers only from the server -* PUT() create or modify a resource on the server -* COPY() copy a resource on the server -* MOVE() move a resource on the server -* DELETE() delete a resource on the server -* MKCOL() create a new collection -* PROPFIND() get property data for a resource -* PROPPATCH() modify property data for a resource -* LOCK() lock a resource -* UNLOCK() unlock a locked resource -* checklock() check whether a resource is locked -* check_auth() check authentication - -You can think of WebDAV resources as files, collections as directories -and properties as filesystem meta data (like size, creation date, ...). - -The base class is able identify which of the methods you have -implemented and will create appropriate answers to OPTIONS requests -that ask for the WebDAV standards compliance level and the allowed -HTTP methods for you. - -For a minimal working test server you need to implement GET(), PUT() -and PROPFIND() only. - -For a minimal (level 1) standards compliant server you also need to -implement MKCOL(), DELETE(), and PROPPATCH(). The COPY(), MOVE() and -HEAD() methods are emulated using GET(), PUT() and DELETE() if not -implemented, but for performance reasons you should better implement -them yourself. - -For a complete (level 2) RFC2518 compliand server you also have to -provide locking support by implementing LOCK(), UNLOCK() and -checklock(). - -Authentication is not really part of the WebDAV specification and -should be handled on the HTTP level. You can do so by means of, for -example, .htaccess files or similar services provided by your web -server. But you can also make use of the authentication features -offered by PHP by implementing the check_auth() method. -Using the check_auth() method you can create a dynamic interface -to any authentication system protecting the data you want to serve. - - - - the following reference information may be outdated and/or - incomplete ... - - -bool PROPINFO($options, &$files) - - options[path] - Resource-Path - options[depth] - Depth of search requested: "0", "1", or "infinity" - options[props] - "all", "names", or an arry of requested properties - each property array element is either a string - (which implies the default "DAV:" namespace) or - an array with the two elements "name" and "xmlns" - for the properties name and XML namespace - - &$files - storage array for property results with the following elements: - - "files" -> array of found properties forresources. elements are: - - "path" -> path of the resource - "props" -> properties array - each property array element is either a string - (which implies the default "DAV:" namespace) or - an array with the two elements "name" and "xmlns" - for the properties name and XML namespace - - you should at least support the following - list of properties from the "DAV:" namespave: - - - resourcetype: "collection" oder "" - - creationdate: unix-timestamp - - getcontentlength: integer - - getlastmodified: unix-timestamp - - You may want to add support for these "DAV:" - properties, too: - - - getcontenttype: mime-type - - displayname: string - - for a compliant server you also have to be - able to return any property from other - namespaces that has been stored using - PROPPATCH - - - return-value: true / false - - - - -string MKCOL($option) - - options[path] - path of the new collection to be created - - return-value: string - HTTP status and status message, possible values are - * 201 Success - * 403 Forbidden - * 405 Method not allowed - * 409 Conflict - * 415 Unsupported media type - * 507 Insufficient Storage - (see also RFC2518 8.3.2) - - - - -string GET(&$options) - - $options['path'] - path to the requested resource - $options['ranges'] - optional array of range specifications for - partial access. range specs are arrays that - consist of either a 'start' and 'end' element - (where 'end' can be empty to indicate a request - up to the actual end of the resource) or a - 'last' element to access the last n bytes of - a resource without knowing its actual size in - advance - - Return-value: true bei Erfolg, false wenn not found - - (TODO: andere stati berücksichtigen) - - Content-Type, Content-Length header müssen von der Methode selbst - erzeugt werden (TODO: outdated) - - - - -string PUT($options) - - options[path] - path to the requested resource - options[content_length] - size of request data in bytes - options[stream] - a PHP stream providing the input data - - return-value: string - HTTP status, possible values are: - * 201 Created -> the resource did not exist before - and has been successfully created - * 204 No Content -> a previously existing resource has - successfully been modified - * 409 Conflict - ... - - - - -string COPY($options) - - options[path] - path to the resource to be copied - options[depth] - "0" or "infinity" (applies only to directories) - options[overwrite] - true / false - options[dest] - path to the destination resource if local - options[dest_url] - non-local destination path - - return-value: string - HTTP status, see RFC2518 8.8.5 - - - - - -string MOVE($options) - - options[path] - path to the resource to be moved - options[overwrite] - true / false - options[dest] - path to the destination resource if local - options[dest_url] - non-local destination path - - return-value: string - HTTP status, see RFC2518 8.9.4 - - - - -string DELETE($options) - - options[path] - path to the resource to be removed - - return-value: string - HTTP status, see RFC2518 8.6.2 - - - - - -bool check_auth($type, $user, $passwd) - - $type: HTTP-Auth type, i.A. "Basic" - $user: HTTP Username - $passwd: HTTP Passwort - - return-value: true bei success, sonst false - (ToDo: array mit Auth-Type und Realm String zulassen bei fehler) \ No newline at end of file diff --git a/3dparty/docs/HTTP_WebDAV_Server/db/Fileserver.sql b/3dparty/docs/HTTP_WebDAV_Server/db/Fileserver.sql deleted file mode 100644 index 8047d12f5e4..00000000000 --- a/3dparty/docs/HTTP_WebDAV_Server/db/Fileserver.sql +++ /dev/null @@ -1,49 +0,0 @@ --- MySQL dump 9.06 --- --- Host: localhost Database: webdav ---------------------------------------------------------- --- Server version 4.0.3-beta - --- --- Table structure for table 'locks' --- - -CREATE TABLE locks ( - token varchar(255) NOT NULL default '', - path varchar(200) NOT NULL default '', - expires int(11) NOT NULL default '0', - owner varchar(200) default NULL, - recursive int(11) default '0', - writelock int(11) default '0', - exclusivelock int(11) NOT NULL default 0, - PRIMARY KEY (token), - UNIQUE KEY token (token), - KEY path (path), - KEY path_2 (path), - KEY path_3 (path,token), - KEY expires (expires) -) TYPE=MyISAM; - --- --- Dumping data for table 'locks' --- - - --- --- Table structure for table 'properties' --- - -CREATE TABLE properties ( - path varchar(255) NOT NULL default '', - name varchar(120) NOT NULL default '', - ns varchar(120) NOT NULL default 'DAV:', - value text, - PRIMARY KEY (path,name,ns), - KEY path (path) -) TYPE=MyISAM; - --- --- Dumping data for table 'properties' --- - - diff --git a/3dparty/package.dtd b/3dparty/package.dtd deleted file mode 100644 index 6092e8f4ce3..00000000000 --- a/3dparty/package.dtd +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/3dparty/packages/Archive_Tar.xml b/3dparty/packages/Archive_Tar.xml deleted file mode 100644 index ba748a18afd..00000000000 --- a/3dparty/packages/Archive_Tar.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - Archive_Tar - Tar file management class - 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. Bz2 compression is also supported with the bz2 extension loaded. - - - vblavet - Vincent Blavet - vincent@phpconcept.net - lead - - - ssb - Stig Bakken - stig@php.net - helper - - - - 1.3.1 - 2005-03-17 - PHP License - stable - Correct Bug #3855 - - - - - - - - - - - - - - - - - - - - 1.3.0 - 2005-03-06 - stable - Bugs correction (2475, 2488, 2135, 2176) - - - - - 1.2 - 2004-05-08 - stable - Add support for other separator than the space char and bug - correction - - - - - 1.1 - 2003-05-28 - stable - * Add support for BZ2 compression -* Add support for add and extract without using temporary files : methods addString() and extractInString() - - - - 1.0 - 2003-01-24 - stable - Change status to stable - - - - - 0.10-b1 - 2003-01-08 - beta - Add support for long filenames (greater than 99 characters) - - - - - 0.9 - 2002-05-27 - stable - Auto-detect gzip'ed files - - - - - 0.4 - 2002-05-20 - stable - Windows bugfix: use forward slashes inside archives - - - - - 0.2 - 2002-02-18 - stable - From initial commit to stable - - - - - 0.3 - 2002-04-13 - stable - Windows bugfix: used wrong directory separators - - - - - diff --git a/3dparty/packages/Console_Getopt.xml b/3dparty/packages/Console_Getopt.xml deleted file mode 100644 index 221919d9767..00000000000 --- a/3dparty/packages/Console_Getopt.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - Console_Getopt - Command-line option parser - This is a PHP implementation of "getopt" supporting both -short and long options. - - - andrei - Andrei Zmievski - andrei@php.net - lead - - - ssb - Stig Bakken - stig@php.net - developer - - - - 1.2 - 2003-12-11 - PHP License - stable - Fix to preserve BC with 1.0 and allow correct behaviour for new users - - - - - - - - - - - - 1.0 - 2002-09-13 - stable - Stable release - - - - 0.11 - 2002-05-26 - beta - POSIX getopt compatibility fix: treat first element of args - array as command name - - - - - 0.10 - 2002-05-12 - beta - Packaging fix - - - - 0.9 - 2002-05-12 - beta - Initial release - - - - diff --git a/3dparty/packages/DB.xml b/3dparty/packages/DB.xml deleted file mode 100644 index d8aaec82c27..00000000000 --- a/3dparty/packages/DB.xml +++ /dev/null @@ -1,348 +0,0 @@ - - - - DB - Database Abstraction Layer - DB is a database abstraction layer providing: -* an OO-style query API -* portability features that make programs written for one DBMS work with other DBMS's -* a DSN (data source name) format for specifying database servers -* prepare/execute (bind) emulation for databases that don't support it natively -* a result object for each query response -* portable error codes -* sequence emulation -* sequential and non-sequential row fetching as well as bulk fetching -* formats fetched rows as associative arrays, ordered arrays or objects -* row limit support -* transactions support -* table information interface -* DocBook and phpDocumentor API documentation - -DB layers itself on top of PHP's existing -database extensions. - -Drivers for the following extensions pass -the complete test suite and provide -interchangeability when all of DB's -portability options are enabled: - - fbsql, ibase, informix, msql, mssql, - mysql, mysqli, oci8, odbc, pgsql, - sqlite and sybase. - -There is also a driver for the dbase -extension, but it can't be used -interchangeably because dbase doesn't -support many standard DBMS features. - -DB is compatible with both PHP 4 and PHP 5. - - - - ssb - Stig Bakken - stig@php.net - developer - - - cox - Tomas V.V.Cox - cox@idecnet.com - developer - - - danielc - Daniel Convissor - danielc@php.net - lead - - - lsmith - Lukas Kahwe Smith - smith@backendmedia.com - helper - - - - 1.7.6 - 2005-04-11 - PHP License - stable - common: -* Fix the docblocks regarding DB_FETCHMODE_FLIPPED. Bug 4027. - -oic8: -* Provide BC hack for those connecting to oci8 using 'hostspec' instead of 'database'. Bug 4104. - - - - PEAR - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/3dparty/packages/Log.xml b/3dparty/packages/Log.xml deleted file mode 100644 index de16370c8bf..00000000000 --- a/3dparty/packages/Log.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - - Log - Logging utilities - The Log framework provides an abstracted logging system. It supports logging to console, file, syslog, SQL, Sqlite, mail and mcal targets. It also provides a subject - observer mechanism. - - - jon - Jon Parise - jon@php.net - lead - - - - 1.8.7 - 2004-12-20 - PHP License - stable - The Log package now supports logging arrays with a 'message' key. -The 'display' handler now preserves line breaks in its output. -An experimental new handler ('daemon') has been added. - - DB - sqlite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.8.7 - 2004-12-20 - PHP License - stable - The Log::_extractMessage() routine will now extract and use the value of an array's 'message' key if it exists. (Laurent Laville) -The 'display' handler now preserves line breaks in its output. (Bug 2606) -An experimental new syslog daemon log handler ('daemon') has been added to the Log distribution. (Bart van der Schans) - - - - 1.8.6 - 2004-09-08 - PHP License - stable - The maximum length of the 'sql' handler's 'ident' string is now configurable via the 'identLimit' configuration parameter. (Bug 2137) - -Different instances of the 'win' handler can now address their own output windows. (Bug 2212) - - - - 1.8.5 - 2004-08-09 - PHP License - stable - The 'sql' handler now enforces a maximum 'ident' length of 16 characters. - -The 'sql' handler can now use a user-defined sequence (via the 'sequence' configuration parameter). This allows each log table to use its own sequence. You will need to take appropriate steps to preserve your sequence numbering if that is important to your site; the ID sequence will be reinitialized to 0 the first time this updated handler is used. You may also need to explicitly drop the 'log_id_seq' sequence before using this new code. - -The 'composite' handler now properly closes all of its children when its close() method is called. It also guards against multiple calls to open(). (Bug 1947) - - - - 1.8.4 - 2004-02-16 - PHP License - stable - The Log package now requires PHP 4.3.0 or later. - -The _extractMessage() method no longer uses the serialize()'ed version of an event object if no string conversion method is available. Instead, the human-readable (via print_r()) representation of the object will be used. - -_extractMessage() can now handle arrays. Their human-readable representation will be used. - -Each Log instance now has a default priority level. This priority will be used by the log() method when no specific priority parameter is provided. It can be accessed using the new getPriority() and setPriority() methods. - - - - 1.8.3 - 2004-01-11 - PHP License - stable - The open() and close() methods now consistently return success or failure. Previously, some handlers' open() and close() methods did not return any result. Also, the log() methods will return failure when the handler cannot be opened. - -Bertrand Mansion contributed a new handler that logs using the Sqlite extension. - - - - 1.8.2 - 2004-01-01 - PHP License - stable - A new 'null' log handler that simply consumes log events has been added. The 'null' handler will still respect log masks and attached observers. - -The public Log API has grown a flush() method. This allows buffered log output to be explicitly flushed. At this time, the flush() method is only implemented by the console, file and mail handlers. - -New unit tests for the Factory and Singleton construction methods have been added. - - - - 1.8.1 - 2003-12-14 - PHP License - stable - The 'win' handler now handles newline sequences correctly (Bug 282). - -The Log_observer::factory() method has been updated to accept an optional associative array of configuration values, return the newly-created object by reference, and look for files named 'Log/observer_.php'. Backwards compatibility for the old-style conventions has been preserved. - - - - 1.8.0 - 2003-11-18 - PHP License - stable - The Log package now includes a users guide, example scripts and unit tests. - -A number of small improvements have been made to the 'win' log handler (based on suggestions from Paul Yanchenko). - -A new 'display' log handler has been added to the distribution. Contributed by Paul Yanchenko, this handler simply prints the error message back to the browser. It respects the 'error_prepend_string' and 'error_append_string' PHP INI values and is useful when using PEAR::setErrorHandling()'s PEAR_ERROR_CALLBACK mechanism. - - - - 1.7.1 - 2003-09-21 - stable - The mail handler now uses "\n" to terminate lines instead of "\r\n". - -The file handler's path creation routines now guard against potentially infinite recursion. - -It is now possible to pass an object to the logging methods. If the object offers a PEAR_Error-style getMessage() or PHP5 exception-style toString() method, it will be used to extract the message text. - - - - 1.7.0 - 2003-08-02 - stable - It is now possible to specific a specific mask that dictates exactly which levels will be logged. - -A number of convenient "shortcut" functions have been added for logging messages at specific log messages. - -Two new log handers have been added: the 'error_log' handler wraps PHP's native error_log() function; and the 'win' handler outputs log messages to a separate browser window. - -The file log handler has been completely rewritten based on suggestions from Roman Neuhauser. It no longer buffers log output in memory before writing to the log file. - -Greg Beaver submitted a change that allows callers to provide their own Log classes (that existing outside of the PEAR file hierarchy) by including them before invoking a factory() method. - - - - 1.6.7 - 2003-06-16 - stable - It is now possible to set the identification string for all of a composite's child instances. - -The preamble of the mail handler's message is now configurable. - - - - 1.6.5 - 2003-04-26 - stable - The mail log handler needs to register its own destructer now that the Log class no longer inherits from the PEAR base class. - - - - 1.6.4 - 2003-04-08 - stable - The Log classes no longer inherits from the PEAR base class. Not including the PEAR base class gives us smaller, faster Log objects. - -The Log_file class now registers its own destructor to ensure that the logfile is correctly closed upon shutdown. - -A ZendEngine 1 incompatibility was introduced in the previous release. This has been corrrected. - - - - 1.6.3 - 2003-04-07 - stable - A unique identifier is now stored inside each Log instance. Both the composite and subject-observer mechanisms use this identifier to index their object lists. - -The internals of the Log_observer system have been rewritten for general cleanliness. The external interface remains unchanged. - -The Log class now offers public setIdent() and getIdent() members for setting and getting the Log instance's identification string during the object's lifetime. - - - - 1.6.2 - 2003-04-06 - stable - In the Log_observer class, operate directly on the reference to the Log instance (instead of on a copy of the object). - - - - 1.6.1 - 2003-04-02 - stable - - Fix a typo that broke the Log_Observer class. - - - - 1.6.0 - 2003-02-17 - stable - - The SQL handler now uses sequences instead of timestamps as unique identifiers. -- The time format used by the file handler is now configurable. - - - - 1.5.3 - 2003-01-01 - stable - - Improved singleton()'s signature generation. -- The SQL handler no longer closes existing database connections. -- The log() method now returns a boolean result indicating success or failure. - - - - 1.5.2 - 2002-11-28 - stable - - Altered the singleton's "signature" construction to be shorter and more array-friendly. - - - - 1.5.1 - 2002-11-17 - stable - - The mail handler now implements a destructor to ensure close() is called. -- The syslog handler now requires $name to be a valid syslog facility. - - - - 1.5 - 2002-10-24 - stable - - Adding the ability to set the mode of the logfile in the Log_file. -- mail() failures in Log_mail are logged via error_log(). -- Replaced all remaining LOG_* constants with the PEAR_LOG_* versions. - - - - 1.4 - 2002-09-28 - stable - - Altered the format of the SQL logging table to use a TIMESTAMP field. -- The Log class now extends the PEAR base class. -- New file logger that keeps the log file open for the life of the request. - - - - 1.3 - 2002-09-15 - stable - Adding a mail logging target. - - - - 1.2 - 2002-07-24 - stable - Introduce the PEAR_LOG_* constants. - - - - 1.1 - 2002-04-12 - stable - Adding a new console logging target. - - - - diff --git a/3dparty/packages/Mail.xml b/3dparty/packages/Mail.xml deleted file mode 100644 index 0fbd10ac951..00000000000 --- a/3dparty/packages/Mail.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - Mail - Class that provides multiple interfaces for sending emails - PEAR's Mail:: package defines the interface for implementing mailers under the PEAR hierarchy, and provides supporting functions useful in multiple mailer backends. Currently supported are native PHP mail() function, sendmail and SMTP. This package also provides a RFC 822 Email address list validation utility class. - - - chagenbu - Chuck Hagenbuch - chuck@horde.org - lead - - - richard - Richard Heyes - richard@phpguru.org - developer - - - jon - Jon Parise - jon@php.net - lead - - - - 1.1.6 - 2005-07-12 - PHP/BSD - stable - - Don't emit warnings with PHP 4.4/5.1. - - Net_SMTP - - - - - - - - - - - - - - 1.1.5 - 2005-06-26 - stable - - Unfold long lines before parsing addresses in Mail_RFC822. -- The SMTP driver now supports a 'timeout' value. (Request #3776) -- An array of Received: headers can now be provided. (Bug #4636) - - - - - 1.1.4 - 2004-09-08 - stable - - Header key comparisons are now case-insensitive. (Colin Viebrock) -- Header fields (e.g., 'Cc', 'Bcc') may now be specified as arrays of addresses. (Colin Viebrock) -- PHP5 compatibility fix (Bug #1563). -- PHP4 / Win32 compatibility fix for the 'sendmail' driver (Bug 1881). -- Stricter "local part" parsing for Mail_RFC822 (in accordance with Section 6.2.4 of RFC 822) (Bug 1869). -- The various send() implementations now properly escalate the PEAR_Error object returned by Mail::prepareHeaders() in the event of an invalid header. - - - - - 1.1.3 - 2004-04-08 - stable - - The 'mail' driver now returns a PEAR_Error object on failure. -- The individual drivers no longer include the 'Mail.php' file. If you want to instantiate a driver directly, you'll need to explicitly include the 'Mail.php' file yourself. - - - - - 1.1.2 - 2003-09-04 - stable - The 'localhost' value can now be set in the SMTP driver. - - - - 1.1.1 - 2003-06-26 - stable - Minor fixes with newlines in headers. - - - - 1.1.0 - 2003-06-21 - stable - The Mail package now depends on Net_SMTP 1.1.0 or greater for its SMTP authentication capabilities. - - - - 1.0.2 - 2002-07-27 - stable - Minor additions and changes to RFC822.php. Fixed line terminator issue for smtp.php and set smtp.php to use Return-Path header in place of From header for MAIL FROM: (if supplied) - - - - 1.0.1 - 2002-07-27 - stable - License change for RFC822.php - - - - 1.0 - 2002-06-06 - stable - Initial release as PEAR package - - - - diff --git a/3dparty/packages/Mail_Mime.xml b/3dparty/packages/Mail_Mime.xml deleted file mode 100644 index ddf734f0c28..00000000000 --- a/3dparty/packages/Mail_Mime.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - Mail_Mime - Provides classes to create and decode mime messages. - Provides classes to deal with creation and manipulation of mime messages. - - - cipri - Cipriano Groenendal - cipri@php.net - lead - - - gschlossnagle - George Schlossnagle - gschlossnagle@php.net - lead - - - sean - Sean Coates - sean@php.net - lead - - - richard - Richard Heyes - richard@php.net - contributor - - - cox - Tomas V.V.Cox - cox@idecnet.com - contributor - - - - 1.3.1 - 2005-07-13 - PHP - stable - A bugfix release: - - - - - - - - - - - 1.3.0 - 2005-04-01 - PHP - stable - o First (stable) release in over 2.5 years (!) -o MANY bugfixes (see the bugtracker) -o added a few tests -o one small fix after RC1 (bug #3940) - - - - - 1.3.0RC1 - 2005-03-20 - beta - o First release in over 2.5 years (!) -o MANY bugfixes (see the bugtracker) -o added a few tests - - - - - 1.2.1 - 2002-07-27 - PHP - stable - o License change -o Applied a few changes From Ilia Alshanetsky - - - - - 1.2 - 2002-07-14 - stable - o Added header encoding -o Altered mimePart to put boundary parameter on newline -o Changed addFrom() to setFrom() -o Added setSubject() -o Made mimePart inherit crlf setting from mime - - - - - 1.1 - 2002-04-03 - stable - This is a maintenance release with various bugfixes and minor enhancements. - - - - 1.0 - 2001-12-28 - stable - This is the initial release of the Mime_Mail package. - - - - diff --git a/3dparty/packages/Net_SMTP.xml b/3dparty/packages/Net_SMTP.xml deleted file mode 100644 index d1e8c56332e..00000000000 --- a/3dparty/packages/Net_SMTP.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - Net_SMTP - Provides an implementation of the SMTP protocol - Provides an implementation of the SMTP protocol using PEAR's Net_Socket class. - - - chagenbu - Chuck Hagenbuch - chuck@horde.org - lead - - - jon - Jon Parise - jon@php.net - lead - - - - 1.2.6 - 2004-04-12 - PHP License - stable - Renaming some methods to be compatible with the PEAR coding standards. Backwards-compatible wrappers have been provided. - - Net_Socket - Auth_SASL - - - - - - - - - - - - - 1.2.6 - 2004-04-12 - PHP License - stable - The following methods have been renamed for compliance with the PEAR coding standards: send_from() -> sendFrom(), soml_from() -> somlFrom(), saml_from() -> samlFrom(). Backwards-compatible wrappers have been provided. - - - - 1.2.5 - 2004-03-11 - PHP License - stable - The connect() method has grown an optional 'persistent' parameter that will be passed to the Net_Socket::connect() method. Previously, persistent connections will always disabled. 'persistent' defaults to false. - -Release 1.2.4 was incorrectly packaged. Release 1.2.5 corrects that error. The code itself remains the same. - - - - 1.2.4 - 2004-03-11 - PHP License - stable - The connect() method has grown an optional 'persistent' parameter that will be passed to the Net_Socket::connect() method. Previously, persistent connections will always disabled. 'persistent' defaults to false. - - - - 1.2.3 - 2003-05-11 - stable - Both 235 (Authentication successful) and 503 (Error: already authenticated) are now accepted as valid AUTH responses. - -503 (Error: already authenticated) is now considered a valid EHLO response. - - - - 1.2.2 - 2003-05-02 - stable - Fix a call-time pass-by-reference problem that was raising a warning if call-time pass-by-reference was disabled. - - - - 1.2.1 - 2003-04-26 - stable - The Auth_SASL package is no longer absolutely required, but it will be used if it is available. Otherwise, the authentication methods that depend upon it will be disabled. - - - - 1.2.0 - 2003-04-06 - stable - - Perform data quoting in its own routine: quotedata() - - - - 1.1.2 - 2003-02-17 - stable - - Correctly handle the case where the server's ESMTP response includes a SIZE keyword with no specific value. - - - - 1.1.1 - 2003-01-30 - stable - - Don't enforce a maximum message size if the SIZE parameter is zero. - - - - 1.1.0 - 2003-01-18 - stable - - The SMTP server's SIZE capability is now honored. -- Improved support for SMTP authentication (LOGIN, PLAIN, CRAM-MD5, DIGEST-MD5). -- Overhauled the server response parsing system. -- Added optional debugging output (enabled via setDebug()). -- A timeout value can now be specified for the socket connection. - - - - 1.0.1 - 2003-01-02 - stable - Corrected an off-by-one bug that corrupted the list of ESMTP capabilities. - - - - 1.0 - 2002-06-11 - stable - Initial release as PEAR package - - - - diff --git a/3dparty/packages/Net_Socket.xml b/3dparty/packages/Net_Socket.xml deleted file mode 100644 index 9c7eae00940..00000000000 --- a/3dparty/packages/Net_Socket.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - Net_Socket - Network Socket Interface - Net_Socket is a class interface to TCP sockets. It provides blocking -and non-blocking operation, with different reading and writing modes -(byte-wise, block-wise, line-wise and special formats like network -byte-order ip addresses). - - - ssb - Stig Bakken - stig@php.net - lead - - - chagenbu - Chuck Hagenbuch - chuck@horde.org - lead - - - - 1.0.6 - 2005-02-26 - PHP License - stable - - Make package.xml safe for PEAR 1.4.0. -- Chunk socket writes on Windows by default, or if explicitly specified (Bug #980) -- Don't run any $addr with a '/' in it through gethostbyname() (Bug #3372) - - - - - - - 1.0.0 - 2002-04-01 - stable - First independent release of Net_Socket. - - - - 1.0.1 - 2002-04-04 - stable - Touch up error handling. - - - - 1.0.2 - 2004-04-26 - stable - Fixes for several longstanding bugs. Allow setting of stream -context. Correctly read lines that only end in \n. Suppress -PHP warnings. - - - - 1.0.3 - 2004-12-08 - stable - Optimize away some duplicate is_resource() calls. -Better solution for eof() on blocking sockets [#1427]. -Add select() implementation [#1428]. - - - - 1.0.4 - 2004-12-13 - stable - Restore support for unix sockets (Bug #2961). - - - - 1.0.5 - 2005-01-11 - stable - Don't rely on gethostbyname() for error checking (Bug #3100). - - - - diff --git a/3dparty/packages/PEAR.xml b/3dparty/packages/PEAR.xml deleted file mode 100644 index 83800a16a0d..00000000000 --- a/3dparty/packages/PEAR.xml +++ /dev/null @@ -1,282 +0,0 @@ - - - - PEAR - PEAR Base System - The PEAR package contains: - * the PEAR installer, for creating, distributing - and installing packages - * the alpha-quality PEAR_Exception php5-only exception class - * the beta-quality PEAR_ErrorStack advanced error handling mechanism - * the PEAR_Error error handling mechanism - * the OS_Guess class for retrieving info about the OS - where PHP is running on - * the System class for quick handling common operations - with files and directories - * the PEAR base class - - - - ssb - Stig Bakken - stig@php.net - lead - - - cox - Tomas V.V.Cox - cox@idecnet.com - lead - - - cellog - Greg Beaver - cellog@php.net - lead - - - pajoye - Pierre-Alain Joye - pajoye@pearfr.org - lead - - - mj - Martin Jansen - mj@php.net - developer - - - - 1.3.5 - 2005-02-18 - PHP License - stable - * fix Bug #3505: pecl can't install PDO -* enhance pear run-tests dramatically -* fix Bug #3506: pear install should export the pear version into the environment - - - - Archive_Tar - Console_Getopt - XML_RPC - xml - pcre - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.3.1 - 2004-04-06 - stable - PEAR Installer: - - * Bug #534 pear search doesn't list unstable releases - * Bug #933 CMD Usability Patch - * Bug #937 throwError() treats every call as static - * Bug #964 PEAR_ERROR_EXCEPTION causes fatal error - * Bug #1008 safe mode raises warning - -PEAR_ErrorStack: - - * Added experimental error handling, designed to eventually replace - PEAR_Error. It should be considered experimental until explicitly marked - stable. require_once 'PEAR/ErrorStack.php' to use. - - - - 1.3.3 - 2004-10-28 - stable - Installer: - * fix Bug #1186 raise a notice error on PEAR::Common $_packageName - * fix Bug #1249 display the right state when using --force option - * fix Bug #2189 upgrade-all stops if dependancy fails - * fix Bug #1637 The use of interface causes warnings when packaging with PEAR - * fix Bug #1420 Parser bug for T_DOUBLE_COLON - * fix Request #2220 pear5 build fails on dual php4/php5 system - * fix Bug #1163 pear makerpm fails with packages that supply role="doc" - -Other: - * add PEAR_Exception class for PHP5 users - * fix critical problem in package.xml for linux in 1.3.2 - * fix staticPopCallback() in PEAR_ErrorStack - * fix warning in PEAR_Registry for windows 98 users - - - - 1.3.3.1 - 2004-11-08 - stable - add RunTest.php to package.xml, make run-tests display failed tests, and use ui - - - - 1.3.4 - 2005-01-01 - stable - * fix a serious problem caused by a bug in all versions of PHP that caused multiple registration - of the shutdown function of PEAR.php -* fix Bug #2861: package.dtd does not define NUMBER -* fix Bug #2946: ini_set warning errors -* fix Bug #3026: Dependency type "ne" is needed, "not" is not handled - properly -* fix Bug #3061: potential warnings in PEAR_Exception -* implement Request #2848: PEAR_ErrorStack logger extends, PEAR_ERRORSTACK_DIE -* implement Request #2914: Dynamic Include Path for run-tests command -* make pear help listing more useful (put how-to-use info at the bottom of the listing) - - - - diff --git a/3dparty/packages/PHPUnit.xml b/3dparty/packages/PHPUnit.xml deleted file mode 100644 index 71e736764db..00000000000 --- a/3dparty/packages/PHPUnit.xml +++ /dev/null @@ -1,224 +0,0 @@ - - - - PHPUnit - Regression testing framework for unit tests. - PHPUnit is a regression testing framework used by the developer who implements unit tests in PHP. This is the version to be used with PHP 4. - - - sebastian - Sebastian Bergmann - sb@sebastian-bergmann.de - lead - - - - 1.2.3 - 2005-05-14 - PHP License - stable - Fixed bug #4342. - - - - - - - - - - - - - - - - - - - - 1.2.2 - 2005-01-31 - stable - * Fixed bug #3332. - - - - - - 1.2.1 - 2005-01-28 - stable - * Relaxed PHPUnit_Assert::assertNotNull() and PHPUnit_Assert::assertNull() to work on non-objects. - -* Fixed an issue in PHPUnit_GUI_SetupDecorator related to Windows' directory separators. (Patch by Lorenzo Alberton <l.alberton@quipo.it>) - - - - - - 1.2.0 - 2005-01-19 - stable - + Added Gtk-based frontend. (Patch by Scott Mattocks <scott@crisscott.com>) - -+ Re-Added PHPUnit_Assert::assertSame() and PHPUnit_Assert::assertNotSame() to make the PEAR QA team happy. These methods only work with PHP >= 5.0.0. - -* PHPUnit_Assert::assertSame(), PHPUnit_Assert::assertNotSame(), PHPUnit_Assert::assertNotNull(), and PHPUnit_Assert::assertNull() are now stricter than before and only work on objects. This was always the documented behaviour. - -* Fixed a bug in the PHPUnit_GUI_SetupDecorator::_getFiles() method. (Patch by Michael Schmidt <michael.schmidt@object-it.de>) - -* Fixed bug #3127: PHPUnit_GUI_HTML and $_REQUEST. (Patch by cricket@djcricket.com) - - - - - - 1.1.1 - 2004-11-05 - stable - * Fixed bug #2701. - - - - - - 1.1.0 - 2004-09-29 - stable - + Added PHPUnit_Skeleton class for creating a PHPUnit_TestCase skeleton file. (Patch by Scott Mattocks <scott@crisscott.com>) - -+ Added PHPUnit_Assert::assertContains() and PHPUnit_Assert::assertNotContains() methods to assert that an array contains (or not contains) a given value or that a string contains (or not contains) a given substring. - -+ Added PHPUnit_Assert::assertNotRegexp() to assert that a string does not match a given regular expression. - -- Removed PHPUnit_Assert::assertSame() and PHPUnit_Assert::assertNotSame() since these assertion methods do not work with PHP 4. - - - - - - 1.0.2 - 2004-09-21 - stable - * Added/fixed phpDocumentor code documentation. - - - - - - 1.0.1 - 2004-04-17 - stable - * Fixed a bug that let the HTML GUI fail for expected and/or actual results with newline characters. (Patch by Thiemo Maettig <thiemo.maettig@gmx.de>) - -* Fixed bug #1169. - - - - - - 1.0.0 - 2004-03-15 - stable - * No functional changes since PHPUnit-0.6.2. - - - - - - 0.6.2 - 2003-06-21 - * Fixed PHPUnit_Assert::assertType(). - - - - - - 0.6.1 - 2003-05-15 - + Added assertType() assertion method. - -* Fixed parse error in GUI/HTML.php that occured with PHP 5. - -* Fixed a layout issue in the HTML GUI. - - - - - - 0.6 - 2003-04-25 - * Fixed bug that caused the constructor detection in PHPUnit_TestSuite to fail with upper-case class names. - -* Fixed bug with multiple assertions per Test Case. - -* call_user_func() was called with a copy instead of a reference in PHPUnit_TestCase::runTest(). - -* Assertion methods append the generated actual/expected message to a user-defined message, rather than overwriting it. - -* Constructors are now excluded from automatic TestCase creation in TestSuite::addTestSuite(). (Patch by Wolfram Kriesing <wolfram@kriesing.de>.) - -* serialize() was called twice in PHPUnit_Assert::assertEquals(). - - - - - - 0.5 - 2003-03-26 - + Added new HTML GUI. (Patch by Wolfram Kriesing <wolfram@kriesing.de>.) - -+ Added "loosely typed" mode to assertEquals() that can be turned on/off using setLooselyTyped(). When activated, array elements are cast to strings before comparison. - -* Allow multiple assertions per Test Case. - -* Use call_user_func() instead of $object->$method(). - - - - - - 0.4 - 2002-09-25 - + Added PHPUnit_Assert::assertFalse() and PHPUnit_Assert::assertNotSame(). JUnit introduced those two convenience methods in the JUnit 3.8 release. - -* Fixed directory structure. - - - - - - 0.3 - 2002-07-12 - * Added PHPUnit_TestDecorator and PHPUnit_RepeatedTest. - -* Implemented PHPUnit_TestResult::addListener() and PHPUnit_TestResult::removeListener(). - -* Added object support to PHPUnit_Assert::assertEquals(). - -* Implemented PHPUnit_Assert::assertSame() using Zend Engine 2 object handles. - - - - - - 0.2 - 2002-07-11 - * Added Array support to PHPUnit_Assert::equals(). (Patch by Wolfram Kriesing <wolfram@kriesing.de>) - -* Added PHPUnit_Assert::assertRegExp(). (Patch by M@rms <marms@marms.com>) - - - - - - 0.1 - 2002-04-06 - First release. - - - - - - diff --git a/3dparty/packages/XML_Parser.xml b/3dparty/packages/XML_Parser.xml deleted file mode 100644 index 9b4b0269faf..00000000000 --- a/3dparty/packages/XML_Parser.xml +++ /dev/null @@ -1,254 +0,0 @@ - - - - XML_Parser - XML parsing class based on PHP's bundled expat - This is an XML parser based on PHPs built-in xml extension. -It supports two basic modes of operation: "func" and "event". In "func" mode, it will look for a function named after each element (xmltag_ELEMENT for start tags and xmltag_ELEMENT_ for end tags), and in "event" mode it uses a set of generic callbacks. - -Since version 1.2.0 there's a new XML_Parser_Simple class that makes parsing of most XML documents easier, by automatically providing a stack for the elements. -Furthermore its now possible to split the parser from the handler object, so you do not have to extend XML_Parser anymore in order to parse a document with it. - - - - schst - Stephan Schmidt - schst@php-tools.net - lead - - - ssb - Stig S&#230;ther Bakken - stig@php.net - developer - - - cox - Tomas V.V.Cox - cox@php.net - developer - - - - 1.2.6 - 2005-03-25 - PHP License - stable - - fixed Bug #3949: reset does not return true on success as the documentation states -- implement Request #3905: replace "." with "_" in tagnames when using func mode -- added package2.xml file for PEAR 1.4.0 - - - - PEAR - - - - - - - - - - - - - - - - - - - - - - - - 1.1.0beta1 - 2004-04-16 - PHP License - beta - - Fixed memory leaks parsing many documents or big files (mroch) -- Fixed setInput() url detection regex (mroch) -- Added setInputString() method, allowing strings to be passed as input (schst) -- Error handling rewritten (cox) -- Increased the overall parsing speed (cox) -- Added free() method (schst -- Added reset() method, that is called when parsing a document so it is possible to parse more than one document per instance (schst) -- Added error codes (schst) -- revamped documentation (cox, schst) -- Fixed bug #516 (url fopen and safe mode) (schst) -- Fixed bug #637 (dependency on PEAR) (schst) -- improved parse() and parseString() to be able to parse more than one document (schst) -- added PHP5 constructor (schst) -- moved xml_parser_create() to _create() for PHP5 compatibility (schst) -- added dependency on PHP 4.2 - -Thanks to Marshall Roch for commments and contributions and Tomas V.V. Cox -for applying a lot of fixes and improvements. - - - - 1.1.0beta2 - 2004-04-18 - PHP License - beta - beta2: -- Fixed calling of __construct - -beta1: -- Fixed memory leaks parsing many documents or big files (mroch) -- Fixed setInput() url detection regex (mroch) -- Added setInputString() method, allowing strings to be passed as input (schst) -- Error handling rewritten (cox) -- Increased the overall parsing speed (cox) -- Added free() method (schst -- Added reset() method, that is called when parsing a document so it is possible to parse more than one document per instance (schst) -- Added error codes (schst) -- revamped documentation (cox, schst) -- Fixed bug #516 (url fopen and safe mode) (schst) -- Fixed bug #637 (dependency on PEAR) (schst) -- improved parse() and parseString() to be able to parse more than one document (schst) -- added PHP5 constructor (schst) -- moved xml_parser_create() to _create() for PHP5 compatibility (schst) -- added dependency on PHP 4.2 - -Thanks to Marshall Roch for commments and contributions and Tomas V.V. Cox -for applying a lot of fixes and improvements. - - - - 1.1.0 - 2004-04-23 - PHP License - stable - - Fixed memory leaks parsing many documents or big files (mroch) -- Fixed setInput() url detection regex (mroch) -- Added setInputString() method, allowing strings to be passed as input (schst) -- Error handling rewritten (cox) -- Increased the overall parsing speed (cox) -- Added free() method (schst -- Added reset() method, that is called when parsing a document so it is possible to parse more than one document per instance (schst) -- Added error codes (schst) -- revamped documentation (cox, schst) -- Fixed bug #516 (url fopen and safe mode) (schst) -- Fixed bug #637 (dependency on PEAR) (schst) -- improved parse() and parseString() to be able to parse more than one document (schst) -- added PHP5 constructor (schst) -- moved xml_parser_create() to _create() for PHP5 compatibility (schst) -- added dependency on PHP 4.2 - -Thanks to Marshall Roch for commments and contributions and Tomas V.V. Cox -for applying a lot of fixes and improvements. - - - - 1.2.0beta1 - 2004-05-17 - PHP License - beta - added new class XML_Parser_Simple that provides a stack for the elements so the user only needs to implement one method to handle the tag and cdata. - - - - 1.2.0beta2 - 2004-05-24 - PHP License - beta - XML_Parser: -- fixed bug with setMode() -- moved the init routines for the handlers in _initHandlers() -XML_Parser_Simple: -- fixed bug with character data (did not get parsed) -- fixed bug with setMode() -- some refactoring -- added getCurrentDepth() to retrieve the tag depth -- added addToData() -- added new example - - - - 1.2.0beta3 - 2004-05-25 - PHP License - beta - - added setHandlerObj() which allows you to have the parser separate from the handler methods - - - - 1.2.0 - 2004-05-28 - PHP License - stable - - added setHandlerObj() which allows you to have the parser separate from the handler methods -- fixed bug with setMode() -- moved the init routines for the handlers in _initHandlers() -- added new examples -- fixed test files so they do not fail because of different resource ids -XML_Parser_Simple: -- added new class XML_Parser_Simple that provides a stack for the elements so the user only needs to implement one method to handle the tag and cdata. - - - - 1.2.1 - 2004-10-04 - PHP License - stable - fixed bug #2442: Call to "xmltag_ELEMENT_" not correctly managed in function funcEndHandler - - - - 1.2.2beta1 - 2004-12-22 - PHP License - beta - - fixed small notice in XML_Parser::free(), -- fixed Bug #2939: bug in error routine leads to segmentation fault (raiseError does not free the internal resources anymore) - - - - 1.2.2 - 2004-12-22 - PHP License - stable - - fixed small notice in XML_Parser::free(), -- fixed Bug #2939: bug in error routine leads to segmentation fault (raiseError does not free the internal resources anymore) - - - - 1.2.3 - 2005-01-17 - PHP License - stable - - fixed a bug that occured when using 'func' mode and setHandlerObj() (schst) -- added default handlers for 'func' mode (schst) - - - - 1.2.4 - 2005-01-18 - PHP License - stable - - fixed a bug in XML_Parser_Simple when trying to register more than the default handlers and a separate callback object (schst) - - - - 1.2.5 - 2005-02-26 - PHP License - stable - - fixed Bug #3557 (removed $attribs parameter, which caused a notice) -- fixed Bug #3277 (remove obsolete ini_set('allow_url_fopen')) - - - - 1.2.6 - 2005-03-25 - PHP License - stable - - fixed Bug #3949: reset does not return true on success as the documentation states -- implement Request #3905: replace "." with "_" in tagnames when using func mode - - - - diff --git a/3dparty/packages/XML_RPC.xml b/3dparty/packages/XML_RPC.xml deleted file mode 100644 index 44e94882647..00000000000 --- a/3dparty/packages/XML_RPC.xml +++ /dev/null @@ -1,266 +0,0 @@ - - - - XML_RPC - PHP implementation of the XML-RPC protocol - A PEAR-ified version of Useful Inc's XML-RPC for PHP. - -It has support for HTTP/HTTPS transport, proxies and authentication. - - - - ssb - Stig Bakken - stig@php.net - lead - - - danielc - Daniel Convissor - danielc@php.net - lead - - - - 1.4.0 - 2005-08-14 - PHP License - stable - * MAJOR SECURITY FIX: eliminate use of eval(). -* Using socket_get_status() because stream_get_meta_data() was introduced in 4.3.0, but we need to support 4.2.0. Bug 4805. - - - - - - - - - - - - - - - - - - - - - - 1.3.3 - 2005-07-15 - stable - * Eliminate memory leak by resetting $XML_RPC_xh each time parseResponse() is called. Bug 4780. -* Using socket_set_timeout() because stream_set_timeout() was introduced in 4.3.0, but we need to support 4.2.0. Bug 4805. - - - - 1.3.2 - 2005-07-07 - stable - * Eliminate path disclosure vulnerabilities by suppressing error messages when eval()'ing. -* Eliminate path disclosure vulnerability by catching bogus parameters submitted to XML_RPC_Value::serializeval(). -* In XML_RPC_Server::service(), only call createServerPayload() and createServerHeaders() if necessary. Fixes compatibility issue introduced in Release 1.3.0RC1 for users who set the $serviceNow parameter of XML_RPC_Server() to 0. Bug 4757. -* Change "var $errstring" to "var $errstr". Bug 4582. Was put into CVS version 1.75 of RPC.php but didn't make it into RELEASE_1_3_1. - - - - 1.3.1 - 2005-06-29 - stable - * Security fix. Update highly recommended! - - - - 1.3.0 - 2005-06-13 - stable - * Stable release. See earlier releases for changes since 1.2.2. - - - - 1.3.0RC3 - 2005-05-10 - beta - * When verifying requests against function signatures, if the number of parameters don't match, provide an appropriate message. NOTE: this resolves a path disclosure vulnerability. (Refines the changes made in the last commit.) Bug 4231. -* XML_RPC_Message::getParam() now returns an XML_RPC_Response object upon error. Changed from Release 1.3.0RC2. -* Add the XML_RPC_Value::isValue() method. For testing if an item is an XML_RPC_Value object. -* If XML_RPC_Client::send() is given an incorrect $msg parameter, raise an error with the new XML_RPC_ERROR_PROGRAMMING code and return 0. -* Improve cross-platform operation by using PEAR::loadExtension() instead of dl(). -* Use <br /> instead of <br> in XML_RPC_Value::dump(). - - - - 1.3.0RC2 - 2005-05-05 - beta - * If XML_RPC_Message::getParam() is given an incorrect parameter, raise an error with the new XML_RPC_ERROR_INCORRECT_PARAMS code and return FALSE. -* Handle improper requests to XML_RPC_Server::verifySignature(). Bug 4231. -* Try to allow HTTP 100 responses if followed by a 200 response. Bug 4116. -* Help Delphi users by making RPCMETHODNAME an alias for METHODNAME. Request 4205. - - - - 1.3.0RC1 - 2005-04-07 - beta - * Improve timeout handling for situations where connection to server is made but no response is not received in time. Accomplished via stream_set_timeout(). Request 3963. -* Add Fault Code 6: "The requested method didn't return an XML_RPC_Response object." Request 4032. -* Add the createServerPayload() and createServerHeaders() methods and the $server_payload and $server_headers properties. Request 3121. -* As in earlier versions, if the $serviceNow parameter to XML_RPC_Server() is 0, no data will be returned, but now the new $server_payload and $server_headers properties will be set. -* Convert the parser handle to an integer before using it as an index for $XML_RPC_xh[$parser]. Reduces E_STRICT notices. Bug 3782. -* Add createHeaders() method and $headers property to XML_RPC_Client to make testing easier. - - - - 1.2.2 - 2005-03-07 - stable - * When using a proxy, add the protocol to the Request-URI, making it an "absoluteURI" as per the HTTP 1.0 spec. Bug 3679. - - - - 1.2.1 - 2005-03-01 - stable - * Add isset() check before examining the dispatch map. Bug 3658. - - - - 1.2.0 - 2005-02-27 - stable - * Provide the "stable" release. -* Add package2.xml for compatibility with PEAR 1.4.0. -* For changes since 1.1.0, see the changelogs for the various RC releases. - - - - 1.2.0RC7 - 2005-02-22 - beta - * Add the setSendEncoding() method and $send_encoding - property to XML_RPC_Message. Request 3537. -* Allow class methods to be mapped using either syntax: - 'function' => 'hello::sayHello', - or - 'function' => array('hello', 'sayhello'), - Bug 3363. -* Use 8192 instead of 32768 for bytes in fread() - in parseResponseFile(). Bug 3340. - - - - 1.2.0RC6 - 2005-01-25 - beta - * Don't put the protocol in the Host field of the POST data. (danielc) - - - - 1.2.0RC5 - 2005-01-24 - beta - * If $port is 443 but a protocol isn't specified in $server, assume ssl:// is the protocol. - - - - 1.2.0RC4 - 2005-01-24 - beta - * When a connection attempt fails, have the method return 0. (danielc) -* Move the protocol/port checking/switching and the property settings from sendPayloadHTTP10() to the XML_RPC_Client constructor. (danielc) -* Add tests for setting the client properties. (danielc) -* Remove $GLOBALS['XML_RPC_twoslash'] since it's not used. (danielc) -* Bundle the tests with the package. (danielc) - - - - 1.2.0RC3 - 2005-01-19 - beta - * ssl uses port 443, not 445. - - - - 1.2.0RC2 - 2005-01-11 - beta - * Handle ssl:// in the $server string. (danielc) -* Also default to port 445 for ssl:// requests as well. (danielc) -* Enhance debugging in the server. (danielc) - - - - 1.2.0RC1 - 2004-12-30 - beta - * Make things work with SSL. Bug 2489. (nkukard lbsd net) -* Allow array function callbacks (Matt Kane) -* Some minor speed-ups (Matt Kane) -* Add Dump.php to the package (Christian Weiske) -* Replace all line endings with \r\n. Had only done replacements on \n. Bug 2521. (danielc) -* Silence fsockopen() errors. Bug 1714. (danielc) -* Encode empty arrays as an array. Bug 1493. (danielc) -* Eliminate undefined index notice when submitting empty arrays to XML_RPC_Encode(). Bug 1819. (danielc) -* Speed up check for enumerated arrays in XML_RPC_Encode(). (danielc) -* Prepend "XML_RPC_" to ERROR_NON_NUMERIC_FOUND, eliminating problem when eval()'ing error messages. (danielc) -* Use XML_RPC_Base::raiseError() instead of PEAR::raiseError() in XML_RPC_ee() because PEAR.php is lazy loaded. (danielc) -* Allow raiseError() to be called statically. (danielc) -* Stop double escaping of character entities. Bug 987. (danielc) - NOTICE: the following have been removed: - * XML_RPC_dh() - * $GLOBALS['XML_RPC_entities'] - * XML_RPC_entity_decode() - * XML_RPC_lookup_entity() -* Determine the XML's encoding via the encoding attribute in the XML declaration. Bug 52. (danielc) - - - - 1.1.0 - 2004-03-15 - stable - * Added support for sequential arrays to XML_RPC_encode() (mroch) -* Cleaned up new XML_RPC_encode() changes a bit (mroch, pierre) -* Remove "require_once 'PEAR.php'", include only when needed to raise an error -* Replace echo and error_log() with raiseError() (mroch) -* Make all classes extend XML_RPC_Base, which will handle common functions (mroch) -* be tolerant of junk after methodResponse (Luca Mariano, mroch) -* Silent notice even in the error log (pierre) -* fix include of shared xml extension on win32 (pierre) - - - - 1.0.4 - 2002-10-02 - stable - * added HTTP proxy authorization support (thanks to Arnaud Limbourg) - - - - 1.0.3 - 2002-05-19 - stable - * fix bug when parsing responses with boolean types - - - - 1.0.2 - 2002-04-16 - stable - * E_ALL fixes -* fix HTTP response header parsing - - - - 1.0.1 - 2001-09-25 - stable - This is a PEAR-ified version of Useful Inc's 1.0.1 release. -Includes an urgent security fix identified by Dan Libby <dan@libby.com>. - - - - diff --git a/3dparty/pearcmd.php b/3dparty/pearcmd.php deleted file mode 100644 index 28a81dcf67f..00000000000 --- a/3dparty/pearcmd.php +++ /dev/null @@ -1,318 +0,0 @@ - | -// | Tomas V.V.Cox | -// | | -// +----------------------------------------------------------------------+ -// -// $Id: pearcmd.php,v 1.13.2.2 2004/12/30 05:43:18 cellog Exp $ - -ob_end_clean(); -/** - * @nodep Gtk - */ -if ('@include_path@' != '@'.'include_path'.'@') { - ini_set('include_path', '@include_path@'); -} -ini_set('allow_url_fopen', true); -if (!ini_get('safe_mode')) { - @set_time_limit(0); -} -ob_implicit_flush(true); -ini_set('track_errors', true); -ini_set('html_errors', false); -ini_set('magic_quotes_runtime', false); -set_error_handler('error_handler'); - -$pear_package_version = "5.0.4"; - -require_once 'PEAR.php'; -require_once 'PEAR/Config.php'; -require_once 'PEAR/Command.php'; -require_once 'Console/Getopt.php'; - -PEAR_Command::setFrontendType('CLI'); -$all_commands = PEAR_Command::getCommands(); - -$argv = Console_Getopt::readPHPArgv(); -/* $progname = basename($argv[0]); */ -$progname = 'pear'; -if (in_array('getopt2', get_class_methods('Console_Getopt'))) { - array_shift($argv); - $options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV"); -} else { - $options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV"); -} -if (PEAR::isError($options)) { - usage($options); -} - -$opts = $options[0]; - -$fetype = 'CLI'; -if ($progname == 'gpear' || $progname == 'pear-gtk') { - $fetype = 'Gtk'; -} else { - foreach ($opts as $opt) { - if ($opt[0] == 'G') { - $fetype = 'Gtk'; - } - } -} -PEAR_Command::setFrontendType($fetype); -$ui = &PEAR_Command::getFrontendObject(); -PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); -if (ini_get('safe_mode')) { - $ui->outputData('WARNING: running in safe mode requires that all files created ' . - 'be the same uid as the current script. PHP reports this script is uid: ' . - @getmyuid() . ', and current user is: ' . @get_current_user()); -} - -$pear_user_config = ''; -$pear_system_config = ''; -$store_user_config = false; -$store_system_config = false; -$verbose = 1; - -foreach ($opts as $opt) { - switch ($opt[0]) { - case 'c': - $pear_user_config = $opt[1]; - break; - case 'C': - $pear_system_config = $opt[1]; - break; - } -} - -$config = &PEAR_Config::singleton($pear_user_config, $pear_system_config); -$verbose = $config->get("verbose"); -$cmdopts = array(); - -foreach ($opts as $opt) { - $param = !empty($opt[1]) ? $opt[1] : true; - switch ($opt[0]) { - case 'd': - list($key, $value) = explode('=', $param); - $config->set($key, $value, 'user'); - break; - case 'D': - list($key, $value) = explode('=', $param); - $config->set($key, $value, 'system'); - break; - case 's': - $store_user_config = true; - break; - case 'S': - $store_system_config = true; - break; - case 'u': - $config->remove($param, 'user'); - break; - case 'v': - $config->set('verbose', $config->get('verbose') + 1); - break; - case 'q': - $config->set('verbose', $config->get('verbose') - 1); - break; - case 'V': - usage(null, 'version'); - default: - // all non pear params goes to the command - $cmdopts[$opt[0]] = $param; - break; - } -} - -if ($store_system_config) { - $config->store('system'); -} - -if ($store_user_config) { - $config->store('user'); -} - -$command = (isset($options[1][0])) ? $options[1][0] : null; - -if (empty($command) && ($store_user_config || $store_system_config)) { - exit; -} - -if ($fetype == 'Gtk') { - Gtk::main(); -} else do { - if ($command == 'help') { - usage(null, @$options[1][1]); - } - - PEAR::pushErrorHandling(PEAR_ERROR_RETURN); - $cmd = PEAR_Command::factory($command, $config); - PEAR::popErrorHandling(); - if (PEAR::isError($cmd)) { - usage(null, @$options[1][1]); - } - - $short_args = $long_args = null; - PEAR_Command::getGetoptArgs($command, $short_args, $long_args); - if (in_array('getopt2', get_class_methods('Console_Getopt'))) { - array_shift($options[1]); - $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args); - } else { - $tmp = Console_Getopt::getopt($options[1], $short_args, $long_args); - } - if (PEAR::isError($tmp)) { - break; - } - list($tmpopt, $params) = $tmp; - $opts = array(); - foreach ($tmpopt as $foo => $tmp2) { - list($opt, $value) = $tmp2; - if ($value === null) { - $value = true; // options without args - } - if (strlen($opt) == 1) { - $cmdoptions = $cmd->getOptions($command); - foreach ($cmdoptions as $o => $d) { - if (@$d['shortopt'] == $opt) { - $opts[$o] = $value; - } - } - } else { - if (substr($opt, 0, 2) == '--') { - $opts[substr($opt, 2)] = $value; - } - } - } - $ok = $cmd->run($command, $opts, $params); - if ($ok === false) { - PEAR::raiseError("unknown command `$command'"); - } -} while (false); - -// {{{ usage() - -function usage($error = null, $helpsubject = null) -{ - global $progname, $all_commands; - $stderr = fopen('php://stderr', 'w'); - if (PEAR::isError($error)) { - fputs($stderr, $error->getMessage() . "\n"); - } elseif ($error !== null) { - fputs($stderr, "$error\n"); - } - if ($helpsubject != null) { - $put = cmdHelp($helpsubject); - } else { - $put = - "Commands:\n"; - $maxlen = max(array_map("strlen", $all_commands)); - $formatstr = "%-{$maxlen}s %s\n"; - ksort($all_commands); - foreach ($all_commands as $cmd => $class) { - $put .= sprintf($formatstr, $cmd, PEAR_Command::getDescription($cmd)); - } - $put .= - "Usage: $progname [options] command [command-options] \n". - "Type \"$progname help options\" to list all options.\n". - "Type \"$progname help shortcuts\" to list all command shortcuts.\n". - "Type \"$progname help \" to get the help for the specified command."; - } - fputs($stderr, "$put\n"); - fclose($stderr); - exit; -} - -function cmdHelp($command) -{ - global $progname, $all_commands, $config; - if ($command == "options") { - return - "Options:\n". - " -v increase verbosity level (default 1)\n". - " -q be quiet, decrease verbosity level\n". - " -c file find user configuration in `file'\n". - " -C file find system configuration in `file'\n". - " -d foo=bar set user config variable `foo' to `bar'\n". - " -D foo=bar set system config variable `foo' to `bar'\n". - " -G start in graphical (Gtk) mode\n". - " -s store user configuration\n". - " -S store system configuration\n". - " -u foo unset `foo' in the user configuration\n". - " -h, -? display help/usage (this message)\n". - " -V version information\n"; - } elseif ($command == "shortcuts") { - $sc = PEAR_Command::getShortcuts(); - $ret = "Shortcuts:\n"; - foreach ($sc as $s => $c) { - $ret .= sprintf(" %-8s %s\n", $s, $c); - } - return $ret; - - } elseif ($command == "version") { - return "PEAR Version: ".$GLOBALS['pear_package_version']. - "\nPHP Version: ".phpversion(). - "\nZend Engine Version: ".zend_version(). - "\nRunning on: ".php_uname(); - - } elseif ($help = PEAR_Command::getHelp($command)) { - if (is_string($help)) { - return "$progname $command [options] $help\n"; - } - if ($help[1] === null) { - return "$progname $command $help[0]"; - } else { - return "$progname $command [options] $help[0]\n$help[1]"; - } - } - return "Command '$command' is not valid, try 'pear help'"; -} - -// }}} - -function error_handler($errno, $errmsg, $file, $line, $vars) { - if ((defined('E_STRICT') && $errno & E_STRICT) || !error_reporting()) { - return; // @silenced error - } - $errortype = array ( - E_ERROR => "Error", - E_WARNING => "Warning", - E_PARSE => "Parsing Error", - E_NOTICE => "Notice", - E_CORE_ERROR => "Core Error", - E_CORE_WARNING => "Core Warning", - E_COMPILE_ERROR => "Compile Error", - E_COMPILE_WARNING => "Compile Warning", - E_USER_ERROR => "User Error", - E_USER_WARNING => "User Warning", - E_USER_NOTICE => "User Notice" - ); - $prefix = $errortype[$errno]; - $file = basename($file); - print "\n$prefix: $errmsg in $file on line $line\n"; -} - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: nil - * mode: php - * End: - */ -// vim600:syn=php - -?> -- 2.39.5