From e5c6be809efcf65d1d16e5fe856db2e371d06d3a Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Wed, 9 Jan 2008 14:23:10 +0000 Subject: [PATCH] Continuation of merge from DEV trunk. --- error_01.gif | Bin 2137 -> 0 bytes errors.css | 43 ------------------------------------------- thirdparty/pear/File/Archive/Predicate.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ thirdparty/pear/File/Archive/Reader.php | 416 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ thirdparty/pear/File/Archive/Writer.php | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ thirdparty/pear/MIME/Type.php | 395 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 987 insertions(+), 43 deletions(-) delete mode 100644 error_01.gif delete mode 100644 errors.css create mode 100644 thirdparty/pear/File/Archive/Predicate.php create mode 100644 thirdparty/pear/File/Archive/Reader.php create mode 100644 thirdparty/pear/File/Archive/Writer.php create mode 100644 thirdparty/pear/MIME/Type.php diff --git a/error_01.gif b/error_01.gif deleted file mode 100644 index 3f7dfbf..0000000 Binary files a/error_01.gif and /dev/null differ diff --git a/errors.css b/errors.css deleted file mode 100644 index f5da2d6..0000000 --- a/errors.css +++ /dev/null @@ -1,43 +0,0 @@ -div#error-container { - width: 500px; - color: #555; - font-size: 11px; - font-family: Verdana, Arial, sans-serif; -} -div#error-container div { - height: 140px; -} -div#error-container h1 { - font-weight: lighter; - font-size: 22px; - margin-left: 100px; -} -div#error-container p { - margin-left: 100px; -} - - div#acc-error { - background: transparent url(error_01.gif) no-repeat top left; - } - div#acc-suspend { - background: transparent url(error_02.gif) no-repeat top left; - } - div#acc-maint { - background: transparent url(error_03.gif) no-repeat top left; - } - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/thirdparty/pear/File/Archive/Predicate.php b/thirdparty/pear/File/Archive/Predicate.php new file mode 100644 index 0000000..437e7c5 --- /dev/null +++ b/thirdparty/pear/File/Archive/Predicate.php @@ -0,0 +1,57 @@ + + * @copyright 1997-2005 The PHP Group + * @license http://www.gnu.org/copyleft/lesser.html LGPL + * @version CVS: $Id: Predicate.php,v 1.7 2005/05/26 21:30:18 vincentlascaux Exp $ + * @link http://pear.php.net/package/File_Archive + */ + +require_once "File/Archive/Reader.php"; + +/** + * A predicate is an object that can evaluate to true or false depending on the + * file currently read by a File_Archive_Reader + * + * @see File_Archive_Reader_Filter + */ +class File_Archive_Predicate +{ + /** + * Indicates whether the current file from the reader should be kept + * + * @param File_Archive_Reader $source Reader which will be filtered + * @return bool False iif the current file must be filtered out + */ + function isTrue(&$source) + { + return PEAR::raiseError("Predicat abstract function call"); + } +} + +?> \ No newline at end of file diff --git a/thirdparty/pear/File/Archive/Reader.php b/thirdparty/pear/File/Archive/Reader.php new file mode 100644 index 0000000..0149965 --- /dev/null +++ b/thirdparty/pear/File/Archive/Reader.php @@ -0,0 +1,416 @@ + + * @copyright 1997-2005 The PHP Group + * @license http://www.gnu.org/copyleft/lesser.html LGPL + * @version CVS: $Id: Reader.php,v 1.33 2005/07/07 12:24:57 vincentlascaux Exp $ + * @link http://pear.php.net/package/File_Archive + */ + +require_once "PEAR.php"; + +/** + * Abstract base class for all the readers + * + * A reader is a compilation of serveral files that can be read + */ +class File_Archive_Reader +{ + /** + * Move to the next file in the reader + * + * @return bool false iif no more files are available + */ + function next() + { + return false; + } + + /** + * Move to the next file whose name is in directory $filename + * or is exactly $filename + * + * @param string $filename Name of the file to find in the archive + * @param bool $close If true, close the reader and search from the first file + * @return bool whether the file was found in the archive or not + */ + function select($filename, $close = true) + { + $std = $this->getStandardURL($filename); + + if ($close) { + $error = $this->close(); + if (PEAR::isError($error)) { + return $error; + } + } + while (($error = $this->next()) === true) { + $sourceName = $this->getFilename(); + if ( + empty($std) || + + //$std is a file + $std == $sourceName || + + //$std is a directory + strncmp($std.'/', $sourceName, strlen($std)+1) == 0 + ) { + return true; + } + } + return $error; + } + + /** + * Returns the standard path + * Changes \ to / + * Removes the .. and . from the URL + * @param string $path a valid URL that may contain . or .. and \ + * @static + */ + function getStandardURL($path) + { + if ($path == '.') { + return ''; + } + $std = str_replace("\\", "/", $path); + while ($std != ($std = preg_replace("/[^\/:?]+\/\.\.\//", "", $std))) ; + $std = str_replace("/./", "", $std); + if (strncmp($std, "./", 2) == 0) { + return substr($std, 2); + } else { + return $std; + } + } + + /** + * Returns the name of the file currently read by the reader + * + * Warning: undefined behaviour if no call to next have been + * done or if last call to next has returned false + * + * @return string Name of the current file + */ + function getFilename() + { + return PEAR::raiseError("Reader abstract function call (getFilename)"); + } + + /** + * Returns the list of filenames from the current pos to the end of the source + * The source will be closed after having called this function + * This function goes through the whole archive (which may be slow). + * If you intend to work on the reader, doing it in one pass would be faster + * + * @return array filenames from the current pos to the end of the source + */ + function getFileList() + { + $result = array(); + while ( ($error = $this->next()) === true) { + $result[] = $this->getFilename(); + } + $this->close(); + if (PEAR::isError($error)) { + return $error; + } else { + return $result; + } + } + + /** + * Returns an array of statistics about the file + * (see the PHP stat function for more information) + * + * The returned array may be empty, even if readers should try + * their best to return as many data as possible + */ + function getStat() { return array(); } + + /** + * Returns the MIME associated with the current file + * The default function does that by looking at the extension of the file + */ + function getMime() + { + require_once "File/Archive/Reader/MimeList.php"; + return File_Archive_Reader_GetMime($this->getFilename()); + } + + /** + * If the current file of the archive is a physical file, + * + * @return the name of the physical file containing the data + * or null if no such file exists + * + * The data filename may not be the same as the filename. + */ + function getDataFilename() { return null; } + + /** + * Reads some data from the current file + * If the end of the file is reached, returns null + * If $length is not specified, reads up to the end of the file + * If $length is specified reads up to $length + */ + function getData($length = -1) + { + return PEAR::raiseError("Reader abstract function call (getData)"); + } + + /** + * Skip some data and returns how many bytes have been skipped + * This is strictly equivalent to + * return strlen(getData($length)) + * But could be far more efficient + */ + function skip($length = -1) + { + $data = $this->getData($length); + if (PEAR::isError($data)) { + return $data; + } else { + return strlen($data); + } + } + + /** + * Move the current position back of a given amount of bytes. + * Not all readers may implement this function (a PEAR error will + * be returned if the reader can't rewind) + * + * @param int $length number of bytes to seek before the current pos + * or -1 to move back to the begining of the current file + * @return the number of bytes really rewinded (which may be less than + * $length if the current pos is less than $length + */ + function rewind($length = -1) + { + return PEAR::raiseError('Rewind function is not implemented on this reader'); + } + + /** + * Returns the current offset in the current file + */ + function tell() + { + $offset = $this->rewind(); + $this->skip($offset); + return $offset; + } + + /** + * Put back the reader in the state it was before the first call + * to next() + */ + function close() + { + } + + /** + * Sends the current file to the Writer $writer + * The data will be sent by chunks of at most $bufferSize bytes + * If $bufferSize <= 0 (default), the blockSize option is used + */ + function sendData(&$writer, $bufferSize = 0) + { + if (PEAR::isError($writer)) { + return $writer; + } + if ($bufferSize <= 0) { + $bufferSize = File_Archive::getOption('blockSize'); + } + + $filename = $this->getDataFilename(); + if ($filename !== null) { + $error = $writer->writeFile($filename); + if (PEAR::isError($error)) { + return $error; + } + } else { + while (($data = $this->getData($bufferSize)) !== null) { + if (PEAR::isError($data)) { + return $data; + } + $error = $writer->writeData($data); + if (PEAR::isError($error)) { + return $error; + } + } + } + } + + /** + * Sends the whole reader to $writer and close the reader + * + * @param File_Archive_Writer $writer Where to write the files of the reader + * @param bool $autoClose If true, close $writer at the end of the function. + * Default value is true + * @param int $bufferSize Size of the chunks that will be sent to the writer + * If $bufferSize <= 0 (default value), the blockSize option is used + */ + function extract(&$writer, $autoClose = true, $bufferSize = 0) + { + if (PEAR::isError($writer)) { + $this->close(); + return $writer; + } + + while (($error = $this->next()) === true) { + if ($writer->newFileNeedsMIME()) { + $mime = $this->getMime(); + } else { + $mime = null; + } + $error = $writer->newFile( + $this->getFilename(), + $this->getStat(), + $mime + ); + if (PEAR::isError($error)) { + break; + } + $error = $this->sendData($writer, $bufferSize); + if (PEAR::isError($error)) { + break; + } + } + $this->close(); + if ($autoClose) { + $writer->close(); + } + if (PEAR::isError($error)) { + return $error; + } + } + + /** + * Extract only one file (given by the URL) + * + * @param string $filename URL of the file to extract from this + * @param File_Archive_Writer $writer Where to write the file + * @param bool $autoClose If true, close $writer at the end of the function + * Default value is true + * @param int $bufferSize Size of the chunks that will be sent to the writer + * If $bufferSize <= 0 (default value), the blockSize option is used + */ + function extractFile($filename, &$writer, + $autoClose = true, $bufferSize = 0) + { + if (PEAR::isError($writer)) { + return $writer; + } + + if (($error = $this->select($filename)) === true) { + $result = $this->sendData($writer, $bufferSize); + if (!PEAR::isError($result)) { + $result = true; + } + } else if ($error === false) { + $result = PEAR::raiseError("File $filename not found"); + } else { + $result = $error; + } + if ($autoClose) { + $error = $writer->close(); + if (PEAR::isError($error)) { + return $error; + } + } + return $result; + } + + /** + * Return a writer that allows appending files to the archive + * After having called makeAppendWriter, $this is closed and should not be + * used until the returned writer is closed. + * + * @return a writer that will allow to append files to an existing archive + * @see makeWriter + */ + function makeAppendWriter() + { + require_once "File/Archive/Predicate/False.php"; + return $this->makeWriterRemoveFiles(new File_Archive_Predicate_False()); + } + + /** + * Return a writer that has the same properties as the one returned by + * makeAppendWriter, but after having removed all the files that follow a + * given predicate. + * After a call to makeWriterRemoveFiles, $this is closed and should not + * be used until the returned writer is closed + * + * @param File_Archive_Predicate $pred the predicate verified by removed files + * @return File_Archive_Writer that allows to append files to the archive + */ + function makeWriterRemoveFiles($pred) + { + return PEAR::raiseError("Reader abstract function call (makeWriterRemoveFiles)"); + } + + /** + * Returns a writer that removes the current file + * This is a syntaxic sugar for makeWriterRemoveFiles(new File_Archive_Predicate_Current()); + */ + function makeWriterRemove() + { + require_once "File/Archive/Predicate/Current.php"; + return $this->makeWriterRemoveFiles(new File_Archive_Predicate_Current()); + } + + /** + * Removes the current file from the reader + */ + function remove() + { + $writer = $this->makeWriterRemove(); + if (PEAR::isError($writer)) { + return $writer; + } + $writer->close(); + } + + /** + * Return a writer that has the same properties as the one returned by makeWriter, but after + * having removed a block of data from the current file. The writer will append data to the current file + * no data (other than the block) will be removed + * + * @param array Lengths of the blocks. The first one will be discarded, the second one kept, the third + * one discarded... If the sum of the blocks is less than the size of the file, the comportment is the + * same as if a last block was set in the array to reach the size of the file + * if $length is -1, the file is truncated from the specified pos + * It is possible to specify blocks of size 0 + * @param int $seek relative pos of the block + */ + function makeWriterRemoveBlocks($blocks, $seek = 0) + { + return PEAR::raiseError("Reader abstract function call (makeWriterRemoveBlocks)"); + } +} + +?> \ No newline at end of file diff --git a/thirdparty/pear/File/Archive/Writer.php b/thirdparty/pear/File/Archive/Writer.php new file mode 100644 index 0000000..3785f07 --- /dev/null +++ b/thirdparty/pear/File/Archive/Writer.php @@ -0,0 +1,119 @@ + + * @copyright 1997-2005 The PHP Group + * @license http://www.gnu.org/copyleft/lesser.html LGPL + * @version CVS: $Id: Writer.php,v 1.12 2005/05/31 21:22:02 vincentlascaux Exp $ + * @link http://pear.php.net/package/File_Archive + */ + +require_once "PEAR.php"; + +/** + * Base class for any writer + */ +class File_Archive_Writer +{ + /** + * Create a new file in the writer + * + * @param string $filename Name of the file, eventually including a path + * @param array $stat Its Statistics. None of the indexes are required + * @param string $mime MIME type of the file + */ + function newFile($filename, $stat = array(), $mime = "application/octet-stream") + { + } + + /** + * Create a new file in the writer with the content of the physical file $filename + * and then unlink $filename. + * newFromTempFile($tmpfile, $filename, $stat, $mime) is equivalent to + * newFile($filename, $stat, $mime); writeFile($tmpfile); unlink($tmpfile); + * but can be more efficient. + * A typical use is for File_Archive_Writer_Files: it renames the temporary + * file instead of copy/delete + * + * @param string $tmpfile Name of the physical file that contains data and will be unlinked + * @param string $filename Name of the file, eventually including a path + * @param array $stat Its Statistics. None of the indexes are required + * @param string $mime MIME type of the file + */ + function newFromTempFile($tmpfile, $filename, $stat = array(), $mime = "application/octet-stream") + { + $this->newFile($filename, $stat, $mime); + $this->writeFile($tmpfile); + unlink($tmpfile); + } + + /** + * Returns whether the writer newFile function needs the $mime parameter + * Default is false + */ + function newFileNeedsMIME() + { + return false; + } + + /** + * Append the specified data to the writer + * + * @param String $data the data to append to the writer + */ + function writeData($data) + { + } + + /** + * Append the content of the physical file $filename to the writer + * writeFile($filename) must be equivalent to + * writeData(file_get_contents($filename)) but can be more efficient + * + * @param string $filename Name of the file which content must be appended + * to the writer + */ + function writeFile($filename) + { + $handle = fopen($filename, "r"); + if (!is_resource($handle)) { + return PEAR::raiseError("Unable to write to $filename"); + } + while (!feof($handle)) { + $error = $this->writeData(fread($handle, 102400)); + if (PEAR::isError($error)) { + return $error; + } + } + fclose($handle); + } + + /** + * Close the writer, eventually flush the data, write the footer... + * This function must be called before the end of the script + */ + function close() { } +} + +?> \ No newline at end of file diff --git a/thirdparty/pear/MIME/Type.php b/thirdparty/pear/MIME/Type.php new file mode 100644 index 0000000..6acc15e --- /dev/null +++ b/thirdparty/pear/MIME/Type.php @@ -0,0 +1,395 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id: Type.php,v 1.2 2004/08/07 22:19:04 ieure Exp $ + +require_once 'PEAR.php'; + +$_fileCmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd'); +$_fileCmd = 'file'; + +/** + * Class for working with MIME types + * + * @version @version@ + * @package @package@ + * @author Ian Eure + */ +class MIME_Type { + /** + * The MIME media type + * + * @var string + */ + var $media = ''; + + /** + * The MIME media sub-type + * + * @var string + */ + var $subType = ''; + + /** + * Optional MIME parameters + * + * @var array + */ + var $parameters = array(); + + /** + * List of valid media types + * + * @var array + */ + var $validMediaTypes = array( + 'text', + 'image', + 'audio', + 'video', + 'application', + 'multipart', + 'message' + ); + + + /** + * Constructor. + * + * If $type is set, if will be parsed and the appropriate class vars set. If not, + * you get an empty class. This is useful, but not quite as useful as parsing a + * type. + * + * @param string $type MIME type + * @return void + */ + function MIME_Type($type = false) + { + if ($type) { + $this->parse($type); + } + } + + + /** + * Parse a mime-type + * + * @param $type string MIME type to parse + * @return void + */ + function parse($type) + { + $this->media = $this->getMedia($type); + $this->subType = $this->getSubType($type); + if (MIME_Type::hasParameters($type)) { + require_once 'MIME/Type/Parameter.php'; + foreach (MIME_Type::getParameters($type) as $param) { + $param = &new MIME_Type_Parameter($param); + $this->parameters[$param->name] = $param; + } + } + } + + + /** + * Does this type have any parameters? + * + * @param $type string MIME type to check + * @return boolean true if $type has parameters, false otherwise + * @static + */ + function hasParameters($type) + { + if (strstr($type, ';')) { + return true; + } + return false; + } + + + /** + * Get a MIME type's parameters + * + * @param $type string MIME type to get parameters of + * @return array $type's parameters + * @static + */ + function getParameters($type) + { + $params = array(); + $tmp = explode(';', $type); + for ($i = 1; $i < count($tmp); $i++) { + $params[] = trim($tmp[$i]); + } + return $params; + } + + + /** + * Strip paramaters from a MIME type string + * + * @param string $type MIME type string + * @return string MIME type with parameters removed + * @static + */ + function stripParameters($type) + { + if (strstr($type, ';')) { + return substr($type, 0, strpos($type, ';')); + } + return $type; + } + + + /** + * Get a MIME type's media + * + * @note 'media' refers to the portion before the first slash + * @param $type string MIME type to get media of + * @return string $type's media + * @static + */ + function getMedia($type) + { + $tmp = explode('/', $type); + return strtolower($tmp[0]); + } + + + /** + * Get a MIME type's subtype + * + * @param $type string MIME type to get subtype of + * @return string $type's subtype + * @static + */ + function getSubType($type) + { + $tmp = explode('/', $type); + $tmp = explode(';', $tmp[1]); + return strtolower(trim($tmp[0])); + } + + + /** + * Create a textual MIME type from object values + * + * This function performs the opposite function of parse(). + * + * @return string MIME type string + */ + function get() + { + $type = strtolower($this->media.'/'.$this->subType); + if (count($this->parameters)) { + foreach ($this->parameters as $key => $null) { + $type .= '; '.$this->parameters[$key]->get(); + } + } + return $type; + } + + + /** + * Is this type experimental? + * + * @note Experimental types are denoted by a leading 'x-' in the media or + * subtype, e.g. text/x-vcard or x-world/x-vrml. + * @param string $type MIME type to check + * @return boolean true if $type is experimental, false otherwise + * @static + */ + function isExperimental($type) + { + if (substr(MIME_Type::getMedia($type), 0, 2) == 'x-' || + substr(MIME_Type::getSubType($type), 0, 2) == 'x-') { + return true; + } + return false; + } + + + /** + * Is this a vendor MIME type? + * + * @note Vendor types are denoted with a leading 'vnd. in the subtype. + * @param string $type MIME type to check + * @return boolean true if $type is a vendor type, false otherwise + * @static + */ + function isVendor($type) + { + if (substr(MIME_Type::getSubType($type), 0, 4) == 'vnd.') { + return true; + } + return false; + } + + + /** + * Is this a wildcard type? + * + * @param string $type MIME type to check + * @return boolean true if $type is a wildcard, false otherwise + * @static + */ + function isWildcard($type) + { + if ($type == '*/*' || MIME_Type::getSubtype($type) == '*') { + return true; + } + return false; + } + + + /** + * Perform a wildcard match on a MIME type + * + * Example: + * MIME_Type::wildcardMatch('image/*', 'image/png') + * + * @param string $card Wildcard to check against + * @param string $type MIME type to check + * @return boolean true if there was a match, false otherwise + */ + function wildcardMatch($card, $type) + { + if (!MIME_Type::isWildcard($card)) { + return false; + } + + if ($card == '*/*') { + return true; + } + + if (MIME_Type::getMedia($card) == + MIME_Type::getMedia($type)) { + return true; + } + return false; + } + + + /** + * Add a parameter to this type + * + * @param string $name Attribute name + * @param string $value Attribute value + * @param string $comment Comment for this parameter + * @return void + */ + function addParameter($name, $value, $comment = false) + { + $tmp = &new MIME_Type_Parameter; + $tmp->name = $name; + $tmp->value = $value; + $tmp->comment = $comment; + $this->parameters[$name] = $tmp; + } + + + /** + * Remove a parameter from this type + * + * @param string $name Parameter name + * @return void + */ + function removeParameter($name) + { + unset ($this->parameters[$name]); + } + + + /** + * Autodetect a file's MIME-type + * + * This function may be called staticly. + * + * @param string $file Path to the file to get the type of + * @param bool $params Append MIME parameters if true + * @return string $file's MIME-type on success, PEAR_Error otherwise + * @since 1.0.0beta1 + * @static + */ + function autoDetect($file, $params = false) + { + @include_once 'System/Command.php'; + if (function_exists('mime_content_type')) { + $type = mime_content_type($file); + } else if (class_exists('System_Command')) { + $type = MIME_Type::_fileAutoDetect($file); + } else { + return PEAR::raiseError("Sorry, can't autodetect; you need the mime_magic extension or System_Command and 'file' installed to use this function."); + } + + // _fileAutoDetect() may have returned an error. + if (PEAR::isError($type)) { + return $type; + } + + // Don't return an empty string + if (!$type || !strlen($type)) { + return PEAR::raiseError("Sorry, couldn't determine file type."); + } + + // Strip parameters if present & requested + if (MIME_Type::hasParameters($type) && !$params) { + $type = MIME_Type::stripParameters($type); + } + + return $type; + } + + /** + * Autodetect a file's MIME-type with 'file' and System_Command + * + * This function may be called staticly. + * + * @param string $file Path to the file to get the type of + * @return string $file's MIME-type + * @since 1.0.0beta1 + * @static + */ + function _fileAutoDetect($file) + { + // Sanity checks + if (!file_exists($file)) { + return PEAR::raiseError("File \"$file\" doesn't exist"); + } + + if (!is_readable($file)) { + return PEAR::raiseError("File \"$file\" is not readable"); + } + + $cmd = new System_Command; + + + // Make sure we have the 'file' command. + $fileCmd = PEAR::getStaticProperty('MIME_Type', 'fileCmd'); + if (!$cmd->which($fileCmd)) { + unset($cmd); + return PEAR::raiseError("Can't find file command \"{$fileCmd}\""); + } + + $cmd->pushCommand($fileCmd, "-bi '{$file}'"); + $res = $cmd->execute(); + unset($cmd); + + return $res; + } +} \ No newline at end of file -- libgit2 0.21.4