";
-
- closedir($handle);
-
- echo "\n";
-
- exit;
- }
-
- /**
- * PUT method handler
- *
- * @param array parameter passing array
- * @return bool true on success
- */
- function PUT(&$options)
- {
- $fspath = $this->base . $options["path"];
-
- if (!@is_dir(dirname($fspath))) {
- return "409 Conflict";
- }
-
- $options["new"] = ! file_exists($fspath);
-
- $fp = fopen($fspath, "w");
-
- return $fp;
- }
-
-
- /**
- * MKCOL method handler
- *
- * @param array general parameter passing array
- * @return bool true on success
- */
- function MKCOL($options)
- {
- $path = $this->base .$options["path"];
- $parent = dirname($path);
- $name = basename($path);
-
- if (!file_exists($parent)) {
- return "409 Conflict";
- }
-
- if (!is_dir($parent)) {
- return "403 Forbidden";
- }
-
- if ( file_exists($parent."/".$name) ) {
- return "405 Method not allowed";
- }
-
- if (!empty($_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
- return "415 Unsupported media type";
- }
-
- $stat = mkdir ($parent."/".$name,0777);
- if (!$stat) {
- return "403 Forbidden";
- }
-
- return ("201 Created");
- }
-
-
- /**
- * DELETE method handler
- *
- * @param array general parameter passing array
- * @return bool true on success
- */
- function DELETE($options)
- {
- $path = $this->base . "/" .$options["path"];
-
- if (!file_exists($path)) {
- return "404 Not found";
- }
-
- if (is_dir($path)) {
- $query = "DELETE FROM properties WHERE path LIKE '".$this->_slashify($options["path"])."%'";
- mysql_query($query);
- PearSystem::rm("-rf $path");
- } else {
- unlink ($path);
- }
- $query = "DELETE FROM properties WHERE path = '$options[path]'";
- mysql_query($query);
-
- return "204 No Content";
- }
-
-
- /**
- * MOVE method handler
- *
- * @param array general parameter passing array
- * @return bool true on success
- */
- function MOVE($options)
- {
- return $this->COPY($options, true);
- }
-
- /**
- * COPY method handler
- *
- * @param array general parameter passing array
- * @return bool true on success
- */
- function COPY($options, $del=false)
- {
- // TODO Property updates still broken (Litmus should detect this?)
-
- if (!empty($_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
- return "415 Unsupported media type";
- }
-
- // no copying to different WebDAV Servers yet
- if (isset($options["dest_url"])) {
- return "502 bad gateway";
- }
-
- $source = $this->base .$options["path"];
- if (!file_exists($source)) return "404 Not found";
-
- $dest = $this->base . $options["dest"];
-
- $new = !file_exists($dest);
- $existing_col = false;
-
- if (!$new) {
- if ($del && is_dir($dest)) {
- if (!$options["overwrite"]) {
- return "412 precondition failed";
- }
- $dest .= basename($source);
- if (file_exists($dest)) {
- $options["dest"] .= basename($source);
- } else {
- $new = true;
- $existing_col = true;
- }
- }
- }
-
- if (!$new) {
- if ($options["overwrite"]) {
- $stat = $this->DELETE(array("path" => $options["dest"]));
- if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
- return $stat;
- }
- } else {
- return "412 precondition failed";
- }
- }
-
- if (is_dir($source) && ($options["depth"] != "infinity")) {
- // RFC 2518 Section 9.2, last paragraph
- return "400 Bad request";
- }
-
- if ($del) {
- if (!rename($source, $dest)) {
- return "500 Internal server error";
- }
- $destpath = $this->_unslashify($options["dest"]);
- if (is_dir($source)) {
- $query = "UPDATE properties
- SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
- WHERE path LIKE '".$this->_slashify($options["path"])."%'";
- mysql_query($query);
- }
-
- $query = "UPDATE properties
- SET path = '".$destpath."'
- WHERE path = '".$options["path"]."'";
- mysql_query($query);
- } else {
- if (is_dir($source)) {
- $files = PearSystem::find($source);
- $files = array_reverse($files);
- } else {
- $files = array($source);
- }
-
- if (!is_array($files) || empty($files)) {
- return "500 Internal server error";
- }
-
-
- foreach ($files as $file) {
- if (is_dir($file)) {
- $file = $this->_slashify($file);
- }
-
- $destfile = str_replace($source, $dest, $file);
-
- if (is_dir($file)) {
- if (!is_dir($destfile)) {
- // TODO "mkdir -p" here? (only natively supported by PHP 5)
- if (!mkdir($destfile)) {
- return "409 Conflict";
- }
- } else {
- error_log("existing dir '$destfile'");
- }
- } else {
- if (!copy($file, $destfile)) {
- return "409 Conflict";
- }
- }
- }
-
- $query = "INSERT INTO properties SELECT ... FROM properties WHERE path = '".$options['path']."'";
- }
-
- return ($new && !$existing_col) ? "201 Created" : "204 No Content";
- }
-
-
- /**
- * LOCK method handler
- *
- * @param array general parameter passing array
- * @return bool true on success
- */
- function LOCK(&$options)
- {
- if (isset($options["update"])) { // Lock Update
- $query = "UPDATE locks SET expires = ".(time()+300);
- mysql_query($query);
-
- if (mysql_affected_rows()) {
- $options["timeout"] = 300; // 5min hardcoded
- return true;
- } else {
- return false;
- }
- }
-
- $options["timeout"] = time()+300; // 5min. hardcoded
-
- $query = "INSERT INTO locks
- SET token = '$options[locktoken]'
- , path = '$options[path]'
- , owner = '$options[owner]'
- , expires = '$options[timeout]'
- , exclusivelock = " .($options['scope'] === "exclusive" ? "1" : "0")
- ;
- mysql_query($query);
-
- return mysql_affected_rows() ? "200 OK" : "409 Conflict";
- }
-
- /**
- * UNLOCK method handler
- *
- * @param array general parameter passing array
- * @return bool true on success
- */
- function UNLOCK(&$options)
- {
- $query = "DELETE FROM locks
- WHERE path = '$options[path]'
- AND token = '$options[token]'";
- mysql_query($query);
-
- return mysql_affected_rows() ? "204 No Content" : "409 Conflict";
- }
-
- /**
- * checkLock() helper
- *
- * @param string resource path to check for locks
- * @return bool true on success
- */
- function checkLock($path)
- {
- $result = false;
-
- $query = "SELECT owner, token, expires, exclusivelock
- FROM locks
- WHERE path = '$path'
- ";
- $res = mysql_query($query);
-
- if ($res) {
- $row = mysql_fetch_array($res);
- mysql_free_result($res);
-
- if ($row) {
- $result = array( "type" => "write",
- "scope" => $row["exclusivelock"] ? "exclusive" : "shared",
- "depth" => 0,
- "owner" => $row['owner'],
- "token" => $row['token'],
- "expires" => $row['expires']
- );
- }
- }
-
- return $result;
- }
-
-
- /**
- * create database tables for property and lock storage
- *
- * @param void
- * @return bool true on success
- */
- function create_database()
- {
- // TODO
- return false;
- }
-
- }
-
-
-?>
diff --git a/thirdparty/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php b/thirdparty/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php
deleted file mode 100644
index 3b32e2ff6..000000000
--- a/thirdparty/pear/HTTP/WebDAV/Tools/_parse_lockinfo.php
+++ /dev/null
@@ -1,237 +0,0 @@
- |
-// | Christian Stocker |
-// +----------------------------------------------------------------------+
-//
-// $Id: _parse_lockinfo.php,v 1.2 2004/01/05 12:32:40 hholzgra Exp $
-//
-
-/**
- * helper class for parsing LOCK request bodies
- *
- * @package HTTP_WebDAV_Server
- * @author Hartmut Holzgraefe
- * @version 0.99.1dev
- */
-class _parse_lockinfo
-{
- /**
- * success state flag
- *
- * @var bool
- * @access public
- */
- var $success = false;
-
- /**
- * lock type, currently only "write"
- *
- * @var string
- * @access public
- */
- var $locktype = "";
-
- /**
- * lock scope, "shared" or "exclusive"
- *
- * @var string
- * @access public
- */
- var $lockscope = "";
-
- /**
- * lock owner information
- *
- * @var string
- * @access public
- */
- var $owner = "";
-
- /**
- * flag that is set during lock owner read
- *
- * @var bool
- * @access private
- */
- var $collect_owner = false;
-
- /**
- * constructor
- *
- * @param string path of stream to read
- * @access public
- */
- function _parse_lockinfo($path)
- {
- // we assume success unless problems occur
- $this->success = true;
-
- // remember if any input was parsed
- $had_input = false;
-
- // open stream
- $f_in = fopen($path, "r");
- if (!$f_in) {
- $this->success = false;
- return;
- }
-
- // create namespace aware parser
- $xml_parser = xml_parser_create_ns("UTF-8", " ");
-
- // set tag and data handlers
- xml_set_element_handler($xml_parser,
- array(&$this, "_startElement"),
- array(&$this, "_endElement"));
- xml_set_character_data_handler($xml_parser,
- array(&$this, "_data"));
-
- // we want a case sensitive parser
- xml_parser_set_option($xml_parser,
- XML_OPTION_CASE_FOLDING, false);
-
- // parse input
- while($this->success && !feof($f_in)) {
- $line = fgets($f_in);
- if (is_string($line)) {
- $had_input = true;
- $this->success &= xml_parse($xml_parser, $line, false);
- }
- }
-
- // finish parsing
- if($had_input) {
- $this->success &= xml_parse($xml_parser, "", true);
- }
-
- // check if required tags where found
- $this->success &= !empty($this->locktype);
- $this->success &= !empty($this->lockscope);
-
- // free parser resource
- xml_parser_free($xml_parser);
-
- // close input stream
- fclose($f_in);
- }
-
-
- /**
- * tag start handler
- *
- * @param resource parser
- * @param string tag name
- * @param array tag attributes
- * @return void
- * @access private
- */
- function _startElement($parser, $name, $attrs)
- {
- // namespace handling
- if (strstr($name, " ")) {
- list($ns, $tag) = explode(" ", $name);
- } else {
- $ns = "";
- $tag = $name;
- }
-
-
- if ($this->collect_owner) {
- // everything within the tag needs to be collected
- $ns_short = "";
- $ns_attr = "";
- if ($ns) {
- if ($ns == "DAV:") {
- $ns_short = "D:";
- } else {
- $ns_attr = " xmlns='$ns'";
- }
- }
- $this->owner .= "<$ns_short$tag$ns_attr>";
- } else if ($ns == "DAV:") {
- // parse only the essential tags
- switch ($tag) {
- case "write":
- $this->locktype = $tag;
- break;
- case "exclusive":
- case "shared":
- $this->lockscope = $tag;
- break;
- case "owner":
- $this->collect_owner = true;
- break;
- }
- }
- }
-
- /**
- * data handler
- *
- * @param resource parser
- * @param string data
- * @return void
- * @access private
- */
- function _data($parser, $data)
- {
- // only the tag has data content
- if ($this->collect_owner) {
- $this->owner .= $data;
- }
- }
-
- /**
- * tag end handler
- *
- * @param resource parser
- * @param string tag name
- * @return void
- * @access private
- */
- function _endElement($parser, $name)
- {
- // namespace handling
- if (strstr($name, " ")) {
- list($ns, $tag) = explode(" ", $name);
- } else {
- $ns = "";
- $tag = $name;
- }
-
- // finished?
- if (($ns == "DAV:") && ($tag == "owner")) {
- $this->collect_owner = false;
- }
-
- // within we have to collect everything
- if ($this->collect_owner) {
- $ns_short = "";
- $ns_attr = "";
- if ($ns) {
- if ($ns == "DAV:") {
- $ns_short = "D:";
- } else {
- $ns_attr = " xmlns='$ns'";
- }
- }
- $this->owner .= "$ns_short$tag$ns_attr>";
- }
- }
-}
-
-?>
\ No newline at end of file
diff --git a/thirdparty/pear/HTTP/WebDAV/Tools/_parse_propfind.php b/thirdparty/pear/HTTP/WebDAV/Tools/_parse_propfind.php
deleted file mode 100644
index 15234cb15..000000000
--- a/thirdparty/pear/HTTP/WebDAV/Tools/_parse_propfind.php
+++ /dev/null
@@ -1,178 +0,0 @@
- |
-// | Christian Stocker |
-// +----------------------------------------------------------------------+
-//
-// $Id: _parse_propfind.php,v 1.2 2004/01/05 12:33:22 hholzgra Exp $
-//
-
-/**
- * helper class for parsing PROPFIND request bodies
- *
- * @package HTTP_WebDAV_Server
- * @author Hartmut Holzgraefe
- * @version 0.99.1dev
- */
-class _parse_propfind
-{
- /**
- * success state flag
- *
- * @var bool
- * @access public
- */
- var $success = false;
-
- /**
- * found properties are collected here
- *
- * @var array
- * @access public
- */
- var $props = false;
-
- /**
- * internal tag nesting depth counter
- *
- * @var int
- * @access private
- */
- var $depth = 0;
-
-
- /**
- * constructor
- *
- * @access public
- */
- function _parse_propfind($path)
- {
- // success state flag
- $this->success = true;
-
- // property storage array
- $this->props = array();
-
- // internal tag depth counter
- $this->depth = 0;
-
- // remember if any input was parsed
- $had_input = false;
-
- // open input stream
- $f_in = fopen($path, "r");
- if (!$f_in) {
- $this->success = false;
- return;
- }
-
- // create XML parser
- $xml_parser = xml_parser_create_ns("UTF-8", " ");
-
- // set tag and data handlers
- xml_set_element_handler($xml_parser,
- array(&$this, "_startElement"),
- array(&$this, "_endElement"));
-
- // we want a case sensitive parser
- xml_parser_set_option($xml_parser,
- XML_OPTION_CASE_FOLDING, false);
-
-
- // parse input
- while($this->success && !feof($f_in)) {
- $line = fgets($f_in);
- if (is_string($line)) {
- $had_input = true;
- $this->success &= xml_parse($xml_parser, $line, false);
- }
- }
-
- // finish parsing
- if($had_input) {
- $this->success &= xml_parse($xml_parser, "", true);
- }
-
- // free parser
- xml_parser_free($xml_parser);
-
- // close input stream
- fclose($f_in);
-
- // if no input was parsed it was a request
- if(!count($this->props)) $this->props = "all"; // default
- }
-
-
- /**
- * start tag handler
- *
- * @access private
- * @param resource parser
- * @param string tag name
- * @param array tag attributes
- */
- function _startElement($parser, $name, $attrs)
- {
- // name space handling
- if (strstr($name, " ")) {
- list($ns, $tag) = explode(" ", $name);
- if ($ns == "")
- $this->success = false;
- } else {
- $ns = "";
- $tag = $name;
- }
-
- // special tags at level 1: and
- if ($this->depth == 1) {
- if ($tag == "allprop")
- $this->props = "all";
-
- if ($tag == "propname")
- $this->props = "names";
- }
-
- // requested properties are found at level 2
- if ($this->depth == 2) {
- $prop = array("name" => $tag);
- if ($ns)
- $prop["xmlns"] = $ns;
- $this->props[] = $prop;
- }
-
- // increment depth count
- $this->depth++;
- }
-
-
- /**
- * end tag handler
- *
- * @access private
- * @param resource parser
- * @param string tag name
- */
- function _endElement($parser, $name)
- {
- // here we only need to decrement the depth count
- $this->depth--;
- }
-}
-
-
-?>
\ No newline at end of file
diff --git a/thirdparty/pear/HTTP/WebDAV/Tools/_parse_proppatch.php b/thirdparty/pear/HTTP/WebDAV/Tools/_parse_proppatch.php
deleted file mode 100644
index 9836ab228..000000000
--- a/thirdparty/pear/HTTP/WebDAV/Tools/_parse_proppatch.php
+++ /dev/null
@@ -1,214 +0,0 @@
- |
-// | Christian Stocker |
-// +----------------------------------------------------------------------+
-//
-// $Id: _parse_proppatch.php,v 1.3 2004/01/05 12:41:34 hholzgra Exp $
-//
-
-/**
- * helper class for parsing PROPPATCH request bodies
- *
- * @package HTTP_WebDAV_Server
- * @author Hartmut Holzgraefe
- * @version 0.99.1dev
- */
-class _parse_proppatch
-{
- /**
- *
- *
- * @var
- * @access
- */
- var $success;
-
- /**
- *
- *
- * @var
- * @access
- */
- var $props;
-
- /**
- *
- *
- * @var
- * @access
- */
- var $depth;
-
- /**
- *
- *
- * @var
- * @access
- */
- var $mode;
-
- /**
- *
- *
- * @var
- * @access
- */
- var $current;
-
- /**
- * constructor
- *
- * @param string path of input stream
- * @access public
- */
- function _parse_proppatch($path)
- {
- $this->success = true;
-
- $this->depth = 0;
- $this->props = array();
- $had_input = false;
-
- $f_in = fopen($path, "r");
- if (!$f_in) {
- $this->success = false;
- return;
- }
-
- $xml_parser = xml_parser_create_ns("UTF-8", " ");
-
- xml_set_element_handler($xml_parser,
- array(&$this, "_startElement"),
- array(&$this, "_endElement"));
-
- xml_set_character_data_handler($xml_parser,
- array(&$this, "_data"));
-
- xml_parser_set_option($xml_parser,
- XML_OPTION_CASE_FOLDING, false);
-
- while($this->success && !feof($f_in)) {
- $line = fgets($f_in);
- if (is_string($line)) {
- $had_input = true;
- $this->success &= xml_parse($xml_parser, $line, false);
- }
- }
-
- if($had_input) {
- $this->success &= xml_parse($xml_parser, "", true);
- }
-
- xml_parser_free($xml_parser);
-
- fclose($f_in);
- }
-
- /**
- * tag start handler
- *
- * @param resource parser
- * @param string tag name
- * @param array tag attributes
- * @return void
- * @access private
- */
- function _startElement($parser, $name, $attrs)
- {
- if (strstr($name, " ")) {
- list($ns, $tag) = explode(" ", $name);
- if ($ns == "")
- $this->success = false;
- } else {
- $ns = "";
- $tag = $name;
- }
-
- if ($this->depth == 1) {
- $this->mode = $tag;
- }
-
- if ($this->depth == 3) {
- $prop = array("name" => $tag);
- $this->current = array("name" => $tag, "ns" => $ns, "status"=> 200);
- if ($this->mode == "set") {
- $this->current["val"] = ""; // default set val
- }
- }
-
- if ($this->depth >= 4) {
- $this->current["val"] .= "<$tag";
- foreach ($attr as $key => $val) {
- $this->current["val"] .= ' '.$key.'="'.str_replace('"','"', $val).'"';
- }
- $this->current["val"] .= ">";
- }
-
-
-
- $this->depth++;
- }
-
- /**
- * tag end handler
- *
- * @param resource parser
- * @param string tag name
- * @return void
- * @access private
- */
- function _endElement($parser, $name)
- {
- if (strstr($name, " ")) {
- list($ns, $tag) = explode(" ", $name);
- if ($ns == "")
- $this->success = false;
- } else {
- $ns = "";
- $tag = $name;
- }
-
- $this->depth--;
-
- if ($this->depth >= 4) {
- $this->current["val"] .= "$tag>";
- }
-
- if ($this->depth == 3) {
- if (isset($this->current)) {
- $this->props[] = $this->current;
- unset($this->current);
- }
- }
- }
-
- /**
- * input data handler
- *
- * @param resource parser
- * @param string data
- * @return void
- * @access private
- */
- function _data($parser, $data) {
- if (isset($this->current)) {
- $this->current["val"] .= $data;
- }
- }
-}
-
-?>
\ No newline at end of file
diff --git a/thirdparty/pear/Log/sqlite.php b/thirdparty/pear/Log/sqlite.php
deleted file mode 100644
index 0473e069f..000000000
--- a/thirdparty/pear/Log/sqlite.php
+++ /dev/null
@@ -1,239 +0,0 @@
-
- * @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 = $this->encryptOld(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;
- }
-
- public function encryptOld($string)
- {
- if (!class_exists('G')) {
- $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
- $docuroot = explode( '/', $realdocuroot );
- array_pop( $docuroot );
- $pathhome = implode( '/', $docuroot ) . '/';
- array_pop( $docuroot );
- $pathTrunk = implode( '/', $docuroot ) . '/';
- require_once($pathTrunk.'gulliver/system/class.g.php');
- }
- return G::encryptOld($string);
- }
-
-}
diff --git a/thirdparty/pear/Net/CheckIP.php b/thirdparty/pear/Net/CheckIP.php
deleted file mode 100644
index e7309db67..000000000
--- a/thirdparty/pear/Net/CheckIP.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
-*
-* @author Martin Jansen
-* @author Guido Haeger
-* @package Net_CheckIP
-* @version 1.1
-* @access public
-*/
-class Net_CheckIP
-{
-
- /**
- * Validate the syntax of the given IP adress
- *
- * This function splits the IP address in 4 pieces
- * (separated by ".") and checks for each piece
- * if it's an integer value between 0 and 255.
- * If all 4 parameters pass this test, the function
- * returns true.
- *
- * @param string $ip IP adress
- * @return bool true if syntax is valid, otherwise false
- */
- function check_ip($ip)
- {
- $oct = explode('.', $ip);
- if (count($oct) != 4) {
- return false;
- }
-
- for ($i = 0; $i < 4; $i++) {
- if (!preg_match("/^[0-9]+$/", $oct[$i])) {
- return false;
- }
-
- if ($oct[$i] < 0 || $oct[$i] > 255) {
- return false;
- }
- }
-
- return true;
- }
-}
-?>
diff --git a/thirdparty/pear/Net/Curl.php b/thirdparty/pear/Net/Curl.php
deleted file mode 100644
index ef9ceb5e2..000000000
--- a/thirdparty/pear/Net/Curl.php
+++ /dev/null
@@ -1,876 +0,0 @@
-
- * @author Sterling Hughes
- * @author Joe Stump
- * @author Philippe Jausions
- * @copyright 1997-2008 The PHP Group
- * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Revision: 1.15 $
- * @link http://pear.php.net/package/Net_Curl
- */
-
-/**
- * Include PEAR package for error handling
- */
-require_once 'PEAR.php';
-
-/**
- * Object-oriented implementation of the Curl extension
- *
- * @category Net
- * @package Net_Curl
- * @author David Costa
- * @author Sterling Hughes
- * @author Joe Stump
- * @author Philippe Jausions
- * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
- * @link http://pear.php.net/package/Net_Curl
- */
-class Net_Curl
-{
- // {{{ Public Properties
- /**
- * The URL for cURL to work with
- *
- * @var string $url
- * @access public
- */
- var $url;
-
- /**
- * The Username for standard HTTP Authentication
- *
- * @var string $username
- * @access public
- */
- var $username = '';
-
- /**
- * The Password for standard HTTP Authentication
- *
- * @var string $password
- * @access public
- */
- var $password = '';
-
- /**
- * The SSL version for the transfer
- *
- * @var integer $sslVersion
- * @access public
- */
- var $sslVersion;
-
- /**
- * The filename of the SSL certificate
- *
- * @var string $sslCert
- * @access public
- */
- var $sslCert;
-
- /**
- * The password corresponding to the certificate
- * in the $sslCert property
- *
- * @var string $sslCertPasswd
- * @access public
- */
- var $sslCertPasswd;
-
- /**
- * User Agent string when making an HTTP request
- *
- * @var string $userAgent
- * @access public
- */
- var $userAgent;
-
- /**
- * Whether or not to include the header in the results
- * of the CURL transfer
- *
- * @var boolean $header
- */
- var $header = false;
-
- /**
- * Whether or not to output debug information while executing a
- * curl transfer
- *
- * @var boolean $verbose
- * @access public
- */
- var $verbose = false;
-
- /**
- * Whether or not to display a progress meter for the current transfer
- *
- * @var boolean $progress
- * @access public
- */
- var $progress = false;
-
- /**
- * Whether or not to suppress error messages
- *
- * @var boolean $mute
- * @access public
- */
- var $mute = false;
-
- /**
- * Whether or not to follow HTTP Location headers.
- *
- * @var boolean $followLocation
- * @access public
- */
- var $followLocation = true;
-
- /**
- * Whether or not to follow HTTP Location headers.
- *
- * @var boolean $follow_location
- * @access public
- * @deprecated
- */
- var $follow_location = false;
-
- /**
- * Time allowed for current transfer, in seconds. 0 means no limit
- *
- * @var int $timeout
- * @access public
- */
- var $timeout = 0;
-
- /**
- * Whether or not to return the results of the
- * current transfer
- *
- * @var boolean $returnTransfer
- * @access public
- */
- var $returnTransfer = true;
-
- /**
- * Whether or not to return the results of the
- * current transfer
- *
- * @var boolean $return_transfer
- * @access public
- * @deprecated
- */
- var $return_transfer = false;
-
- /**
- * The type of transfer to perform (ie. 'POST', 'GET', 'PUT', etc)
- *
- * @var string $type
- * @access public
- */
- var $type;
-
- /**
- * The file to upload (PUT, or FTP methods)
- *
- * @var string $file
- * @access public
- */
- var $file;
-
- /**
- * The file size of the file pointed to by the $file
- * property
- *
- * @var integer $fileSize
- * @access public
- */
- var $fileSize;
-
- /**
- * The file size of the file pointed to by the $file
- * property
- *
- * @var integer $file_size
- * @access public
- * @deprecated
- */
- var $file_size = false;
-
-
- /**
- * The cookies to send to the remote site
- *
- * @var array $cookies
- * @access public
- */
- var $cookies = array();
-
- /**
- * Additional HTTP headers to send to the remote site
- *
- * @var array $httpHeaders
- * @access public
- */
- var $httpHeaders = null;
-
- /**
- * Additional HTTP headers to send to the remote site
- *
- * @var array $http_headers
- * @access public
- * @deprecated
- */
- var $http_headers = false;
-
- /**
- * The fields to send in a 'POST' request
- *
- * @var array $fields
- * @access public
- */
- var $fields;
-
- /**
- * The proxy server to go through
- *
- * @var string $proxy
- * @access public
- */
- var $proxy;
-
- /**
- * The username for the Proxy server
- *
- * @var string $proxyUser
- * @access public
- */
- var $proxyUser;
-
- /**
- * The password for the Proxy server
- *
- * @var string $proxyPassword
- * @access public
- */
- var $proxyPassword;
-
- /**
- * $verifyPeer
- *
- * FALSE to stop CURL from verifying the peer's certificate.
- * Alternate certificates to verify against can be specified
- * with the CURLOPT_CAINFO option or a certificate directory
- * can be specified with the CURLOPT_CAPATH option.
- * CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE
- * if CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2).
- *
- * @var boolean $verifyPeer
- * @access public
- */
- var $verifyPeer = true;
-
- /**
- * $verifyHost
- *
- * 0 : to stop CURL from verifying the host's certificate.
- * 1 : to check the existence of a common name in the SSL peer certificate.
- * 2 : to check the existence of a common name and also verify that it
- * matches the hostname provided.
- *
- * @var bool $verifyHost
- * @access public
- */
- var $verifyHost = 2;
-
- /**
- * $caInfo
- *
- * Set value for CURLOPT_CAINFO. The name of a file holding one or more
- * certificates to verify the peer with. This only makes sense when used
- * in combination with CURLOPT_SSL_VERIFYPEER. curl-ca-bundle.crt is
- * avaible on the Curl website http://curl.haxx.se/ for download inside
- * the packages.
- *
- * @var string $caInfo
- * @access public
- */
- var $caInfo = '';
-
- /**
- * $caPath
- *
- * Set value for CURLOPT_CAPATH. A directory that holds multiple CA
- * certificates. Use this option alongside CURLOPT_SSL_VERIFYPEER.
- *
- * @var string $caPath
- * @access public
- */
- var $caPath;
- // }}}
- // {{{ Private Properties
- /**
- * The current curl handle
- *
- * @var resource $_ch
- * @access private
- * @see Net_Curl::create()
- */
- var $_ch = null;
-
- /**
- * The file upload resource
- *
- * The CURLOPT_INFILE requires a file resource and not just a file name.
- * This is used by execute to open the file.
- *
- * @var resource $_fp
- * @access private
- * @see Net_Curl::execute()
- */
- var $_fp = null;
- // }}}
-
- // {{{ __construct($url = '', $userAgent = '')
- /**
- * The Net_Curl PHP 5.x constructor, called when a new Net_Curl object
- * is initialized (also called via 4.x constructor)
- *
- * @param string $url The URL to fetch (can be set using the $url
- * property as well)
- * @param string $userAgent The userAgent string (can be set using the
- * $userAgent property as well)
- *
- * @access public
- * @author Joe Stump
- * @return void
- */
- function __construct($url = '', $userAgent = '')
- {
- if (is_string($url) && strlen($url)) {
- $this->url = $url;
- }
-
- if (is_string($userAgent) && strlen($userAgent)) {
- $this->userAgent = $userAgent;
- }
- }
- // }}}
-
- // {{{ Net_Curl($url = '', $userAgent = '')
- /**
- * Net_Curl
- *
- * PHP 4.x constructor.
- *
- * @param string $url The URL to fetch (can be set using the $url
- * property as well)
- * @param string $userAgent The userAgent string (can be set using the
- * $userAgent property as well)
- *
- * @access public
- * @return void
- */
- function Net_Curl($url = '', $userAgent = '')
- {
- $this->__construct($url, $userAgent);
- }
- // }}}
-
- // {{{ execute()
- /**
- * Executes a prepared CURL transfer
- *
- * Run this function to execute your cURL request. If all goes well you
- * should get a string (the output from the remote host regarding your
- * request) or true (if you choose to output directly to the browser). If
- * something fails then PEAR_Error is returned.
- *
- *
- * fields = array('foo' => '1', 'bar' => 'apple');
- * $result = $curl->execute();
- * if (!PEAR::isError($result)) {
- * echo $result;
- * }
- * ?>
- *
- *
- * @access public
- * @author Sterling Hughes
- * @author Joe Stump
- * @return PEAR_Error on failure, true/result on success
- * @since PHP 4.0.5
- */
- function execute()
- {
- // Create cURL handle if it hasn't already been created
- if (!is_resource($this->_ch)) {
- $result = $this->create();
- if (PEAR::isError($result)) {
- return $result;
- }
- }
-
- // Map the deprecated variables and throw a bunch of errors
- $this->_mapDeprecatedVariables();
-
- // Default return value is true.
- $ret = true;
-
- // Basic stuff
- $ret = curl_setopt($this->_ch, CURLOPT_URL, $this->url);
- $ret = curl_setopt($this->_ch, CURLOPT_HEADER, $this->header);
-
- // Whether or not to return the transfer contents
- if ($this->returnTransfer === true || $this->mute === true) {
- $ret = curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, true);
- }
-
- // HTTP Authentication
- if ($this->username != '') {
- $ret = curl_setopt($this->_ch,
- CURLOPT_USERPWD,
- $this->username . ':' . $this->password);
- }
-
- // SSL Checks
- if (isset($this->sslVersion)) {
- $ret = curl_setopt($this->_ch,
- CURLOPT_SSLVERSION,
- $this->sslVersion);
- }
-
- if (isset($this->sslCert)) {
- $ret = curl_setopt($this->_ch, CURLOPT_SSLCERT, $this->sslCert);
- }
-
- if (isset($this->sslCertPasswd)) {
- $ret = curl_setopt($this->_ch,
- CURLOPT_SSLCERTPASSWD,
- $this->sslCertPasswd);
- }
-
- // Proxy Related checks
- if (isset($this->proxy)) {
- $ret = curl_setopt($this->_ch, CURLOPT_PROXY, $this->proxy);
- }
-
- if (isset($this->proxyUser) || isset($this->proxyPassword)) {
- $ret = curl_setopt($this->_ch,
- CURLOPT_PROXYUSERPWD,
- $this->proxyUser . ':' . $this->proxyPassword);
- }
-
- if (is_bool($this->verifyPeer)) {
- if (!$this->setOption(CURLOPT_SSL_VERIFYPEER, $this->verifyPeer)) {
- return PEAR::raiseError('Error setting CURLOPT_SSL_VERIFYPEER');
- }
- }
-
- if (is_numeric($this->verifyHost) && $this->verifyHost >= 0 &&
- $this->verifyHost <= 2) {
- if (!$this->setOption(CURLOPT_SSL_VERIFYHOST, $this->verifyHost)) {
- return PEAR::raiseError('Error setting CURLOPT_SSL_VERIFYPEER');
- }
- }
-
- if (is_bool($this->verifyPeer) && $this->verifyPeer == true) {
- if (isset($this->caInfo) && strlen($this->caInfo)) {
- if (file_exists($this->caInfo)) {
- if (!$this->setOption(CURLOPT_CAINFO, $this->caInfo)) {
- return PEAR::raiseError('Error setting CURLOPT_CAINFO');
- }
- } else {
- return PEAR::raiseError('Could not find CA info: '.
- $this->caInfo);
- }
- }
-
- if (isset($this->caPath) && is_string($this->caPath)) {
- if (!$this->setOption(CURLOPT_CAPATH, $this->caPath)) {
- return PEAR::raiseError('Error setting CURLOPT_CAPATH');
- }
- }
- }
-
- // Transfer type
- if (isset($this->type)) {
- switch (strtolower($this->type)) {
- case 'post':
- $ret = curl_setopt($this->_ch, CURLOPT_POST, true);
- break;
- case 'put':
- $ret = curl_setopt($this->_ch, CURLOPT_PUT, true);
- break;
- }
- }
-
- // Transfer upload, etc. related
- if (isset($this->file)) {
- if (!file_exists($this->file)) {
- return PEAR::raiseError('File does not exist: '.$this->file);
- }
-
- $this->_fp = fopen($this->file, 'r');
- if (!is_resource($this->_fp)) {
- return PEAR::raiseError('Could not open file: '.$this->file);
- }
-
- if (!isset($this->fileSize)) {
- $this->fileSize = filesize($this->file);
- }
-
- $ret = curl_setopt($this->_ch, CURLOPT_INFILE, $this->_fp);
- $ret = curl_setopt($this->_ch, CURLOPT_INFILESIZE, $this->fileSize);
- $ret = curl_setopt($this->_ch, CURLOPT_UPLOAD, true);
- }
-
- if (isset($this->fields)) {
- $sets = null;
- if (!isset($this->type)) {
- $this->type = 'post';
- $ret = curl_setopt($this->_ch, CURLOPT_POST, true);
- }
-
- // If fields is an array then turn it into a string. Sometimes
- // cURL doesn't like fields as an array.
- // Exception: if a value is prefixed with "@" and the rest of the
- // value resolves to an existing file, then pass
- // the values as the original array.
- if (is_array($this->fields)) {
- $sets = array();
- foreach ($this->fields as $key => $val) {
- if (strlen($val) > 1 && $val{0} == '@') {
- $file = substr($val, 1);
- if (is_file($file) && is_readable($file)) {
- $sets = null;
- break;
- }
- }
- $sets[] = urlencode($key) . '=' . urlencode($val);
- }
- }
-
- if (!is_null($sets)) {
- $fields = implode('&', $sets);
- } else {
- $fields = $this->fields;
- }
- $ret = curl_setopt($this->_ch, CURLOPT_POSTFIELDS, $fields);
- }
-
- // Error related
- if ($this->progress === true) {
- $ret = curl_setopt($this->_ch, CURLOPT_PROGRESS, true);
- }
-
- if ($this->verbose === true) {
- $ret = curl_setopt($this->_ch, CURLOPT_VERBOSE, true);
- }
-
- // If a Location: header is passed then follow it
- $ret = curl_setopt($this->_ch,
- CURLOPT_FOLLOWLOCATION,
- $this->followLocation);
-
- // If a timeout is set and is greater then zero then set it
- if (is_numeric($this->timeout) && $this->timeout > 0) {
- $ret = curl_setopt($this->_ch, CURLOPT_TIMEOUT, $this->timeout);
- }
-
- if (isset($this->userAgent)) {
- $ret = curl_setopt($this->_ch, CURLOPT_USERAGENT, $this->userAgent);
- }
-
- // Cookies
- if (is_array($this->cookies) && count($this->cookies)) {
- $cookieData = '';
- foreach ($this->cookies as $name => $value) {
- $cookieData .= $name . '=' . $value . ';';
- }
-
- $ret = curl_setopt($this->_ch, CURLOPT_COOKIE, $cookieData);
- }
-
- // Other HTTP headers
- if ($this->httpHeaders !== null) {
- if (is_array($this->httpHeaders)) {
- $ret = curl_setopt($this->_ch,
- CURLOPT_HTTPHEADER,
- $this->httpHeaders);
- } else {
- return PEAR::raiseError('Net_Curl::$httpHeaders must be an array');
- }
- }
-
- $ret = curl_exec($this->_ch);
-
- // Close the file before we return anything
- if (is_resource($this->_fp)) {
- fclose($this->_fp);
- }
-
- if (curl_errno($this->_ch)) {
- return PEAR::raiseError(curl_error($this->_ch), curl_errno($this->_ch));
- }
-
- // Check to make sure we get a 2XX/3XX code and not a 404 or something.
- $info = $this->getInfo();
- if (!isset($info['http_code'])) {
- return PEAR::raiseError('Unknown or invalid HTTP response');
- } else {
- $type = substr($info['http_code'], 0, 1);
- if ($type != 2 && $type != 3) {
- return PEAR::raiseError('Unexpected HTTP code: ' .
- $info['http_code']);
- }
- }
-
- return $ret;
- }
- // }}}
-
- // {{{ setOption($option, $value)
- /**
- * Sets an option for your cURL session. Please note that the cURL handler
- * is NOT created before execute(). This is for error checking purposes.
- * You should use setOption() in the following manner:
- *
- *
- * create();
- * if (!PEAR::isError($check)) {
- * $curl->setOption(CURLOPT_FOO, 'bar');
- * $result = $curl->execute();
- * if (!PEAR::isError($result)) {
- * echo $result;
- * }
- * }
- *
- * ?>
- *
- *
- * @param int $option cURL constant (ie. CURLOPT_URL)
- * @param mixed $value The option's value
- *
- * @author Joe Stump
- * @access public
- * @return boolean
- */
- function setOption($option, $value)
- {
- if (is_resource($this->_ch)) {
- return curl_setopt($this->_ch, $option, $value);
- }
-
- return false;
- }
- // }}}
-
- // {{{ getInfo()
- /**
- * Returns the info from the cURL session. PEAR_Error if you try and run
- * this before you execute the session.
- *
- * @author Joe Stump
- * @access public
- * @return mixed PEAR_Error if there is no resource, info on success
- */
- function getInfo()
- {
- if (is_resource($this->_ch)) {
- return curl_getinfo($this->_ch);
- }
-
- return PEAR::isError('cURL handler does not exist!');
- }
- // }}}
-
- // {{{ create()
- /**
- * Creates a cURL resource. If curl_init() doesn't exist or we could not
- * create a resource it will error out.
- *
- * @author Joe Stump
- * @return boolean TRUE on success, PEAR_Error on failure
- */
- function create()
- {
- if (!PEAR::loadExtension('curl')) {
- return PEAR::raiseError('CURL extension is not available');
- }
- if (!function_exists('curl_init')) {
- return PEAR::raiseError('Function curl_init() not found');
- }
-
- $this->_ch = curl_init();
- if (!is_resource($this->_ch)) {
- return PEAR::raiseError('Could not initialize cURL handler');
- }
-
- return true;
- }
- // }}}
-
- // {{{ verboseAll()
- /**
- * Sets verbose output
- *
- * Turns on super debugging mode by not suppressing errors, turning on
- * verbose mode, showing headers and displaying progress.
- *
- * @access public
- * @author David Costa
- * @return void
- */
- function verboseAll()
- {
- $this->verbose = true;
- $this->mute = false;
- $this->header = true;
- $this->progress = true;
- }
- // }}}
-
- // {{{ verbose_all()
- /**
- * Sets verbose output
- *
- * @access public
- * @author David Costa
- * @return void
- * @deprecated
- */
- function verbose_all()
- {
- $this->verboseAll();
- PEAR::raiseError('Net_Curl::verbose_all() is deprecated! Please use Net_Curl::verboseAll()'." \n", null, PEAR_ERROR_PRINT);
- }
- // }}}
-
- // {{{ close()
- /**
- * Closes the curl transfer and finishes the object (kinda ;)
- *
- * @access public
- * @author Sterling Hughes
- * @return void
- * @since PHP 4.0.5
- */
- function close()
- {
- if (is_resource($this->_ch)) {
- curl_close($this->_ch);
- }
- }
- // }}}
-
- // {{{ _mapDeprecatedVariables()
- /**
- * Maps deprecated variables into the appropriate places. It also throws
- * the necessary notices.
- *
- * @author Joe Stump
- * @access private
- * @return void
- */
- function _mapDeprecatedVariables()
- {
- $bad = array();
- if ($this->follow_location !== false) {
- if ($this->follow_location > 0) {
- $this->followLocation = true;
- } else {
- $this->followLocation = false;
- }
-
- $bad[] = array('follow_location', 'followLocation');
- }
-
- if ($this->return_transfer !== false) {
- if ($this->return_transfer > 0) {
- $this->returnTransfer = true;
- } else {
- $this->returnTransfer = false;
- }
-
- $bad[] = array('return_transfer', 'returnTransfer');
- }
-
- if ($this->file_size !== false) {
- $this->fileSize = $this->file_size;
- $bad[] = array('file_size', 'fileSize');
- }
-
- if ($this->http_headers !== false) {
- $this->httpHeaders = $this->http_headers;
- $bad[] = array('http_headers', 'httpHeaders');
- }
-
- foreach ($bad as $map) {
- PEAR::raiseError('Net_Curl::$'. $map[0]. ' is deprecated! Please use Net_Curl::$'.$map[1]." instead! \n", null, PEAR_ERROR_PRINT);
- }
- }
- // }}}
-
- // {{{ __destruct()
- /**
- * PHP 5.x destructor.
- *
- * Runs Net_Curl::close() to make sure we close our cURL connection.
- *
- * @author Joe Stump
- * @see Net_Curl::close()
- */
- function __destruct()
- {
- $this->close();
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Net/DIME.php b/thirdparty/pear/Net/DIME.php
deleted file mode 100644
index 1087f2178..000000000
--- a/thirdparty/pear/Net/DIME.php
+++ /dev/null
@@ -1,647 +0,0 @@
- |
-// | Ralf Hofmann |
-// +----------------------------------------------------------------------+
-//
-// $Id: DIME.php,v 1.5 2002/09/29 01:55:16 shane Exp $
-//
-
-require_once 'PEAR.php';
-/**
- *
- * DIME Encoding/Decoding
- *
- * What is it?
- * This class enables you to manipulate and build
- * a DIME encapsulated message.
- *
- * http://www.ietf.org/internet-drafts/draft-nielsen-dime-02.txt
- *
- * 09/18/02 Ralf - A huge number of changes to be compliant
- * with the DIME Specification Release 17 June 2002
- *
- * TODO: lots of stuff needs to be tested.
- * Definitily have to go through DIME spec and
- * make things work right, most importantly, sec 3.3
- * make examples, document
- *
- * see test/dime_mesage_test.php for example of usage
- *
- * @author Shane Caraveo ,
- * Ralf Hofmann
- * @version $Revision: 1.5 $
- * @package Net_DIME
- */
-define('NET_DIME_TYPE_UNCHANGED',0x00);
-define('NET_DIME_TYPE_MEDIA',0x01);
-define('NET_DIME_TYPE_URI',0x02);
-define('NET_DIME_TYPE_UNKNOWN',0x03);
-define('NET_DIME_TYPE_NONE',0x04);
-
-define('NET_DIME_VERSION',0x0001);
-
-define('NET_DIME_RECORD_HEADER',12);
-
-define('NET_DIME_FLAGS', 0);
-define('NET_DIME_OPTS_LEN', 1);
-define('NET_DIME_ID_LEN', 2);
-define('NET_DIME_TYPE_LEN', 3);
-define('NET_DIME_DATA_LEN', 4);
-define('NET_DIME_OPTS', 5);
-define('NET_DIME_ID', 6);
-define('NET_DIME_TYPE', 7);
-define('NET_DIME_DATA', 8);
-
-class Net_DIME_Record extends PEAR
-{
- // these are used to hold the padded length
- var $OPTS_LENGTH = 0;
- var $ID_LENGTH = 0;
- var $TYPE_LENGTH = 0;
- var $DATA_LENGTH = 0;
- var $_haveOpts = FALSE;
- var $_haveID = FALSE;
- var $_haveType = FALSE;
- var $_haveData = FALSE;
- var $debug = FALSE;
- var $padstr = "\0";
- /**
- * Elements
- * [NET_DIME_FLAGS], 16 bits: VERSION:MB:ME:CF:TYPE_T
- * [NET_DIME_OPTS_LEN], 16 bits: OPTIONS_LENGTH
- * [NET_DIME_ID_LEN], 16 bits: ID_LENGTH
- * [NET_DIME_TYPE_LEN], 16 bits: TYPE_LENGTH
- * [NET_DIME_DATA_LEN], 32 bits: DATA_LENGTH
- * [NET_DIME_OPTS] : OPTIONS
- * [NET_DIME_ID] : ID
- * [NET_DIME_TYPE] : TYPE
- * [NET_DIME_DATA] : DATA
- */
- var $Elements = array(NET_DIME_FLAGS => 0, NET_DIME_OPTS_LEN => 0,
- NET_DIME_ID_LEN => 0, NET_DIME_TYPE_LEN => 0,
- NET_DIME_DATA_LEN => 0,
- NET_DIME_OPTS => '',
- NET_DIME_ID => '',
- NET_DIME_TYPE => '',
- NET_DIME_DATA => '');
-
- function Net_DIME_Record($debug = FALSE)
- {
- $this->debug = $debug;
- if ($debug) $this->padstr = '*';
- }
-
- function setMB()
- {
- $this->Elements[NET_DIME_FLAGS] |= 0x0400;
- }
-
- function setME()
- {
- $this->Elements[NET_DIME_FLAGS] |= 0x0200;
- }
-
- function setCF()
- {
- $this->Elements[NET_DIME_FLAGS] |= 0x0100;
- }
-
- function isChunk()
- {
- return $this->Elements[NET_DIME_FLAGS] & 0x0100;
- }
-
- function isEnd()
- {
- return $this->Elements[NET_DIME_FLAGS] & 0x0200;
- }
-
- function isStart()
- {
- return $this->Elements[NET_DIME_FLAGS] & 0x0400;
- }
-
- function getID()
- {
- return $this->Elements[NET_DIME_ID];
- }
-
- function getType()
- {
- return $this->Elements[NET_DIME_TYPE];
- }
-
- function getData()
- {
- return $this->Elements[NET_DIME_DATA];
- }
-
- function getDataLength()
- {
- return $this->Elements[NET_DIME_DATA_LEN];
- }
-
- function setType($typestring, $type=NET_DIME_TYPE_UNKNOWN)
- {
- $typelen = strlen($typestring) & 0xFFFF;
- $type = $type << 4;
- $this->Elements[NET_DIME_FLAGS] = ($this->Elements[NET_DIME_FLAGS] & 0xFF0F) | $type;
- $this->Elements[NET_DIME_TYPE_LEN] = $typelen;
- $this->TYPE_LENGTH = $this->_getPadLength($typelen);
- $this->Elements[NET_DIME_TYPE] = $typestring;
- }
-
- function generateID()
- {
- if(!class_exists('G')){
- $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
- $docuroot = explode( '/', $realdocuroot );
- array_pop( $docuroot );
- $pathhome = implode( '/', $docuroot ) . '/';
- array_pop( $docuroot );
- $pathTrunk = implode( '/', $docuroot ) . '/';
- require_once($pathTrunk.'gulliver/system/class.g.php');
- }
- $id = G::encryptOld(time());
- $this->setID($id);
- return $id;
- }
-
- function setID($id)
- {
- $idlen = strlen($id) & 0xFFFF;
- $this->Elements[NET_DIME_ID_LEN] = $idlen;
- $this->ID_LENGTH = $this->_getPadLength($idlen);
- $this->Elements[NET_DIME_ID] = $id;
- }
-
- function setData($data, $size=0)
- {
- $datalen = $size?$size:strlen($data);
- $this->Elements[NET_DIME_DATA_LEN] = $datalen;
- $this->DATA_LENGTH = $this->_getPadLength($datalen);
- $this->Elements[NET_DIME_DATA] = $data;
- }
-
- function encode()
- {
- // insert version
- $this->Elements[NET_DIME_FLAGS] = ($this->Elements[NET_DIME_FLAGS] & 0x07FF) | (NET_DIME_VERSION << 11);
-
- // the real dime encoding
- $format = '%c%c%c%c%c%c%c%c%c%c%c%c'.
- '%'.$this->OPTS_LENGTH.'s'.
- '%'.$this->ID_LENGTH.'s'.
- '%'.$this->TYPE_LENGTH.'s'.
- '%'.$this->DATA_LENGTH.'s';
- return sprintf($format,
- ($this->Elements[NET_DIME_FLAGS]&0x0000FF00)>>8,
- ($this->Elements[NET_DIME_FLAGS]&0x000000FF),
- ($this->Elements[NET_DIME_OPTS_LEN]&0x0000FF00)>>8,
- ($this->Elements[NET_DIME_OPTS_LEN]&0x000000FF),
- ($this->Elements[NET_DIME_ID_LEN]&0x0000FF00)>>8,
- ($this->Elements[NET_DIME_ID_LEN]&0x000000FF),
- ($this->Elements[NET_DIME_TYPE_LEN]&0x0000FF00)>>8,
- ($this->Elements[NET_DIME_TYPE_LEN]&0x000000FF),
- ($this->Elements[NET_DIME_DATA_LEN]&0xFF000000)>>24,
- ($this->Elements[NET_DIME_DATA_LEN]&0x00FF0000)>>16,
- ($this->Elements[NET_DIME_DATA_LEN]&0x0000FF00)>>8,
- ($this->Elements[NET_DIME_DATA_LEN]&0x000000FF),
- str_pad($this->Elements[NET_DIME_OPTS], $this->OPTS_LENGTH, $this->padstr),
- str_pad($this->Elements[NET_DIME_ID], $this->ID_LENGTH, $this->padstr),
- str_pad($this->Elements[NET_DIME_TYPE], $this->TYPE_LENGTH, $this->padstr),
- str_pad($this->Elements[NET_DIME_DATA], $this->DATA_LENGTH, $this->padstr));
- }
-
- function _getPadLength($len)
- {
- $pad = 0;
- if ($len) {
- $pad = $len % 4;
- if ($pad) $pad = 4 - $pad;
- }
- return $len + $pad;
- }
-
- function decode(&$data)
- {
- // REAL DIME decoding
- $this->Elements[NET_DIME_FLAGS] = (hexdec(bin2hex($data[0]))<<8) + hexdec(bin2hex($data[1]));
- $this->Elements[NET_DIME_OPTS_LEN] = (hexdec(bin2hex($data[2]))<<8) + hexdec(bin2hex($data[3]));
- $this->Elements[NET_DIME_ID_LEN] = (hexdec(bin2hex($data[4]))<<8) + hexdec(bin2hex($data[5]));
- $this->Elements[NET_DIME_TYPE_LEN] = (hexdec(bin2hex($data[6]))<<8) + hexdec(bin2hex($data[7]));
- $this->Elements[NET_DIME_DATA_LEN] = (hexdec(bin2hex($data[8]))<<24) +
- (hexdec(bin2hex($data[9]))<<16) +
- (hexdec(bin2hex($data[10]))<<8) +
- hexdec(bin2hex($data[11]));
- $p = 12;
-
- $version = (($this->Elements[NET_DIME_FLAGS]>>11) & 0x001F);
-
- if ($version == NET_DIME_VERSION)
- {
- $this->OPTS_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_OPTS_LEN]);
- $this->ID_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_ID_LEN]);
- $this->TYPE_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_TYPE_LEN]);
- $this->DATA_LENGTH = $this->_getPadLength($this->Elements[NET_DIME_DATA_LEN]);
-
- $datalen = strlen($data);
- $this->Elements[NET_DIME_OPTS] = substr($data,$p,$this->Elements[NET_DIME_OPTS_LEN]);
- $this->_haveOpts = (strlen($this->Elements[NET_DIME_OPTS]) == $this->Elements[NET_DIME_OPTS_LEN]);
- if ($this->_haveOpts) {
- $p += $this->OPTS_LENGTH;
- $this->Elements[NET_DIME_ID] = substr($data,$p,$this->Elements[NET_DIME_ID_LEN]);
- $this->_haveID = (strlen($this->Elements[NET_DIME_ID]) == $this->Elements[NET_DIME_ID_LEN]);
- if ($this->_haveID) {
- $p += $this->ID_LENGTH;
- $this->Elements[NET_DIME_TYPE] = substr($data,$p,$this->Elements[NET_DIME_TYPE_LEN]);
- $this->_haveType = (strlen($this->Elements[NET_DIME_TYPE]) == $this->Elements[NET_DIME_TYPE_LEN]);
- if ($this->_haveType) {
- $p += $this->TYPE_LENGTH;
- $this->Elements[NET_DIME_DATA] = substr($data,$p,$this->Elements[NET_DIME_DATA_LEN]);
- $this->_haveData = (strlen($this->Elements[NET_DIME_DATA]) == $this->Elements[NET_DIME_DATA_LEN]);
- if ($this->_haveData) {
- $p += $this->DATA_LENGTH;
- } else {
- $p += strlen($this->Elements[NET_DIME_DATA]);
- }
- } else {
- $p += strlen($this->Elements[NET_DIME_TYPE]);
- }
- } else {
- $p += strlen($this->Elements[NET_DIME_ID]);
- }
- } else {
- $p += strlen($this->Elements[NET_DIME_OPTS]);
- }
- }
- return substr($data, $p);
- }
-
- function addData(&$data)
- {
- $datalen = strlen($data);
- $p = 0;
- if (!$this->_haveOpts) {
- $have = strlen($this->Elements[NET_DIME_OPTS]);
- $this->Elements[NET_DIME_OPTS] .= substr($data,$p,$this->Elements[NET_DIME_OPTS_LEN]-$have);
- $this->_haveOpts = (strlen($this->Elements[NET_DIME_OPTS]) == $this->Elements[DIME_OTPS_LEN]);
- if (!$this->_haveOpts) return NULL;
- $p += $this->OPTS_LENGTH-$have;
- }
- if (!$this->_haveID) {
- $have = strlen($this->Elements[NET_DIME_ID]);
- $this->Elements[NET_DIME_ID] .= substr($data,$p,$this->Elements[NET_DIME_ID_LEN]-$have);
- $this->_haveID = (strlen($this->Elements[NET_DIME_ID]) == $this->Elements[NET_DIME_ID_LEN]);
- if (!$this->_haveID) return NULL;
- $p += $this->ID_LENGTH-$have;
- }
- if (!$this->_haveType && $p < $datalen) {
- $have = strlen($this->Elements[NET_DIME_TYPE]);
- $this->Elements[NET_DIME_TYPE] .= substr($data,$p,$this->Elements[NET_DIME_TYPE_LEN]-$have);
- $this->_haveType = (strlen($this->Elements[NET_DIME_TYPE]) == $this->Elements[NET_DIME_TYPE_LEN]);
- if (!$this->_haveType) return NULL;
- $p += $this->TYPE_LENGTH-$have;
- }
- if (!$this->_haveData && $p < $datalen) {
- $have = strlen($this->Elements[NET_DIME_DATA]);
- $this->Elements[NET_DIME_DATA] .= substr($data,$p,$this->Elements[NET_DIME_DATA_LEN]-$have);
- $this->_haveData = (strlen($this->Elements[NET_DIME_DATA]) == $this->Elements[NET_DIME_DATA_LEN]);
- if (!$this->_haveData) return NULL;
- $p += $this->DATA_LENGTH-$have;
- }
- return substr($data,$p);
- }
-}
-
-
-class Net_DIME_Message extends PEAR
-{
-
- var $record_size = 4096;
- #var $records =array();
- var $parts = array();
- var $currentPart = -1;
- var $stream = NULL;
- var $_currentRecord;
- var $_proc = array();
- var $type;
- var $typestr;
- var $mb = 1;
- var $me = 0;
- var $cf = 0;
- var $id = NULL;
- var $debug = FALSE;
- /**
- * constructor
- *
- * this currently takes a file pointer as provided
- * by fopen
- *
- * TODO: integrate with the php streams stuff
- */
- function Net_DIME_Message($stream=NULL, $record_size = 4096, $debug = FALSE)
- {
- $this->stream = $stream;
- $this->record_size = $record_size;
- $this->debug = $debug;
- }
-
- function _makeRecord(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN)
- {
- $record = new Net_DIME_Record($this->debug);
- if ($this->mb) {
- $record->setMB();
- // all subsequent records are not message begin!
- $this->mb = 0;
- }
- if ($this->me) $record->setME();
- if ($this->cf) $record->setCF();
- $record->setData($data);
- $record->setType($typestr,$type);
- if ($id) $record->setID($id);
- #if ($this->debug) {
- # print str_replace('\0','*',$record->encode());
- #}
- return $record->encode();
- }
-
- function startChunk(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN)
- {
- if(!class_exists('G')){
- $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
- $docuroot = explode( '/', $realdocuroot );
- array_pop( $docuroot );
- $pathhome = implode( '/', $docuroot ) . '/';
- array_pop( $docuroot );
- $pathTrunk = implode( '/', $docuroot ) . '/';
- require_once($pathTrunk.'gulliver/system/class.g.php');
- }
- $this->me = 0;
- $this->cf = 1;
- $this->type = $type;
- $this->typestr = $typestr;
- if ($id) {
- $this->id = $id;
- } else {
- $this->id = G::encryptOld(time());
- }
- return $this->_makeRecord($data, $this->typestr, $this->id, $this->type);
- }
-
- function doChunk(&$data)
- {
- $this->me = 0;
- $this->cf = 1;
- return $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_UNCHANGED);
- }
-
- function endChunk()
- {
- $this->cf = 0;
- $data = NULL;
- $rec = $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_UNCHANGED);
- $this->id = 0;
- $this->cf = 0;
- $this->id = 0;
- $this->type = NET_DIME_TYPE_UNKNOWN;
- $this->typestr = NULL;
- return $rec;
- }
-
- function endMessage()
- {
- $this->me = 1;
- $data = NULL;
- $rec = $this->_makeRecord($data, NULL, NULL, NET_DIME_TYPE_NONE);
- $this->me = 0;
- $this->mb = 1;
- $this->id = 0;
- return $rec;
- }
-
- /**
- * sendRecord
- *
- * given a chunk of data, it creates DIME records
- * and writes them to the stream
- *
- */
- function sendData(&$data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN)
- {
- $len = strlen($data);
- if ($len > $this->record_size) {
- $chunk = substr($data, 0, $this->record_size);
- $p = $this->record_size;
- $rec = $this->startChunk($chunk,$typestr,$id,$type);
- fwrite($this->stream, $rec);
- while ($p < $len) {
- $chunk = substr($data, $p, $this->record_size);
- $p += $this->record_size;
- $rec = $this->doChunk($chunk);
- fwrite($this->stream, $rec);
- }
- $rec = $this->endChunk();
- fwrite($this->stream, $rec);
- return;
- }
- $rec = $this->_makeRecord($data, $typestr,$id,$type);
- fwrite($this->stream, $rec);
- }
-
- function sendEndMessage()
- {
- $rec = $this->endMessage();
- fwrite($this->stream, $rec);
- }
-
- /**
- * sendFile
- *
- * given a filename, it reads the file,
- * creates records and writes them to the stream
- *
- */
- function sendFile($filename, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN)
- {
- $f = fopen($filename, "rb");
- if ($f) {
- if ($data = fread($f, $this->record_size)) {
- $this->startChunk($data,$typestr,$id,$type);
- }
- while ($data = fread($f, $this->record_size)) {
- $this->doChunk($data,$typestr,$id,$type);
- }
- $this->endChunk();
- fclose($f);
- }
- }
-
- /**
- * encodeData
- *
- * given data, encode it in DIME
- *
- */
- function encodeData($data, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN)
- {
- $len = strlen($data);
- $resp = '';
- if ($len > $this->record_size) {
- $chunk = substr($data, 0, $this->record_size);
- $p = $this->record_size;
- $resp .= $this->startChunk($chunk,$typestr,$id,$type);
- while ($p < $len) {
- $chunk = substr($data, $p, $this->record_size);
- $p += $this->record_size;
- $resp .= $this->doChunk($chunk);
- }
- $resp .= $this->endChunk();
- } else {
- $resp .= $this->_makeRecord($data, $typestr,$id,$type);
- }
- return $resp;
- }
-
- /**
- * sendFile
- *
- * given a filename, it reads the file,
- * creates records and writes them to the stream
- *
- */
- function encodeFile($filename, $typestr='', $id=NULL, $type=NET_DIME_TYPE_UNKNOWN)
- {
- $f = fopen($filename, "rb");
- if ($f) {
- if ($data = fread($f, $this->record_size)) {
- $resp = $this->startChunk($data,$typestr,$id,$type);
- }
- while ($data = fread($f, $this->record_size)) {
- $resp = $this->doChunk($data,$typestr,$id,$type);
- }
- $resp = $this->endChunk();
- fclose($f);
- }
- return $resp;
- }
-
- /**
- * _processData
- *
- * creates Net_DIME_Records from provided data
- *
- */
- function _processData(&$data)
- {
- $leftover = NULL;
- if (!$this->_currentRecord) {
- $this->_currentRecord = new Net_DIME_Record($this->debug);
- $data = $this->_currentRecord->decode($data);
- } else {
- $data = $this->_currentRecord->addData($data);
- }
-
- if ($this->_currentRecord->_haveData) {
- if (count($this->parts)==0 && !$this->_currentRecord->isStart()) {
- // raise an error!
- return PEAR::raiseError('First Message is not a DIME begin record!');
- }
-
- if ($this->_currentRecord->isEnd() && $this->_currentRecord->getDataLength()==0) {
- return NULL;
- }
-
- if ($this->currentPart < 0 && !$this->_currentRecord->isChunk()) {
- $this->parts[] = array();
- $this->currentPart = count($this->parts)-1;
- $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID();
- $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType();
- $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData();
- $this->currentPart = -1;
- } else {
- if ($this->currentPart < 0) {
- $this->parts[] = array();
- $this->currentPart = count($this->parts)-1;
- $this->parts[$this->currentPart]['id'] = $this->_currentRecord->getID();
- $this->parts[$this->currentPart]['type'] = $this->_currentRecord->getType();
- $this->parts[$this->currentPart]['data'] = $this->_currentRecord->getData();
- } else {
- $this->parts[$this->currentPart]['data'] .= $this->_currentRecord->getData();
- if (!$this->_currentRecord->isChunk()) {
- // we reached the end of the chunk
- $this->currentPart = -1;
- }
- }
- }
- #$this->records[] = $this->_currentRecord;
- if (!$this->_currentRecord->isEnd()) $this->_currentRecord = NULL;
- }
- return NULL;
- }
-
- /**
- * decodeData
- *
- * decodes a DIME encrypted string of data
- *
- */
- function decodeData(&$data) {
- while (strlen($data) >= NET_DIME_RECORD_HEADER) {
- $err = $this->_processData($data);
- if (PEAR::isError($err)) {
- return $err;
- }
- }
- }
-
- /**
- * read
- *
- * reads the stream and creates
- * an array of records
- *
- * it can accept the start of a previously read buffer
- * this is usefull in situations where you need to read
- * headers before discovering that the data is DIME encoded
- * such as in the case of reading an HTTP response.
- */
- function read($buf=NULL)
- {
- while ($data = fread($this->stream, 8192)) {
- if ($buf) {
- $data = $buf.$data;
- $buf = NULL;
- }
- if ($this->debug)
- echo "read: ".strlen($data)." bytes\n";
- $err = $this->decodeData($data);
- if (PEAR::isError($err)) {
- return $err;
- }
-
- // store any leftover data to be used again
- // should be < NET_DIME_RECORD_HEADER bytes
- $buf = $data;
- }
- if (!$this->_currentRecord || !$this->_currentRecord->isEnd()) {
- return PEAR::raiseError('reached stream end without end record');
- }
- return NULL;
- }
-}
-?>
\ No newline at end of file
diff --git a/thirdparty/pear/Net/FTP.php b/thirdparty/pear/Net/FTP.php
deleted file mode 100644
index 9bbfc4d6f..000000000
--- a/thirdparty/pear/Net/FTP.php
+++ /dev/null
@@ -1,2346 +0,0 @@
-
- * @author Jorrit Schippers
- * @copyright 1997-2008 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: FTP.php,v 1.53.2.10 2008/05/19 18:01:08 jschippers Exp $
- * @link http://pear.php.net/package/Net_FTP
- * @since File available since Release 0.0.1
- */
-
-/**
- * Include PEAR.php to obtain the PEAR base class
- */
-require_once 'PEAR.php';
-
-/**
- * Option to let the ls() method return only files.
- *
- * @since 1.3
- * @name NET_FTP_FILES_ONLY
- * @see Net_FTP::ls()
- */
-define('NET_FTP_FILES_ONLY', 0, true);
-
-/**
- * Option to let the ls() method return only directories.
- *
- * @since 1.3
- * @name NET_FTP_DIRS_ONLY
- * @see Net_FTP::ls()
- */
-define('NET_FTP_DIRS_ONLY', 1, true);
-
-/**
- * Option to let the ls() method return directories and files (default).
- *
- * @since 1.3
- * @name NET_FTP_DIRS_FILES
- * @see Net_FTP::ls()
- */
-define('NET_FTP_DIRS_FILES', 2, true);
-
-/**
- * Option to let the ls() method return the raw directory listing from ftp_rawlist()
- *
- * @since 1.3
- * @name NET_FTP_RAWLIST
- * @see Net_FTP::ls()
- */
-define('NET_FTP_RAWLIST', 3, true);
-
-/**
- * Error code to indicate a failed connection
- * This error code indicates, that the connection you tryed to set up
- * could not be established. Check your connection settings (host & port)!
- *
- * @since 1.3
- * @name NET_FTP_ERR_CONNECT_FAILED
- * @see Net_FTP::connect()
- */
-define('NET_FTP_ERR_CONNECT_FAILED', -1);
-
-/**
- * Error code to indicate a failed login
- * This error code indicates, that the login to the FTP server failed. Check
- * your user data (username & password).
- *
- * @since 1.3
- * @name NET_FTP_ERR_LOGIN_FAILED
- * @see Net_FTP::login()
- */
-define('NET_FTP_ERR_LOGIN_FAILED', -2);
-
-/**
- * Error code to indicate a failed directory change
- * The cd() method failed. Ensure that the directory you wanted to access exists.
- *
- * @since 1.3
- * @name NET_FTP_ERR_DIRCHANGE_FAILED
- * @see Net_FTP::cd()
- */
-define('NET_FTP_ERR_DIRCHANGE_FAILED', 2); // Compatibillity reasons!
-
-/**
- * Error code to indicate that Net_FTP could not determine the current path
- * The cwd() method failed and could not determine the path you currently reside
- * in on the FTP server.
- *
- * @since 1.3
- * @name NET_FTP_ERR_DETERMINEPATH_FAILED
- * @see Net_FTP::pwd()
- */
-define('NET_FTP_ERR_DETERMINEPATH_FAILED', 4); // Compatibillity reasons!
-
-/**
- * Error code to indicate that the creation of a directory failed
- * The directory you tryed to create could not be created. Check the
- * access rights on the parent directory!
- *
- * @since 1.3
- * @name NET_FTP_ERR_CREATEDIR_FAILED
- * @see Net_FTP::mkdir()
- */
-define('NET_FTP_ERR_CREATEDIR_FAILED', -4);
-
-/**
- * Error code to indicate that the EXEC execution failed.
- * The execution of a command using EXEC failed. Ensure, that your
- * FTP server supports the EXEC command.
- *
- * @since 1.3
- * @name NET_FTP_ERR_EXEC_FAILED
- * @see Net_FTP::execute()
- */
-define('NET_FTP_ERR_EXEC_FAILED', -5);
-
-/**
- * Error code to indicate that the SITE command failed.
- * The execution of a command using SITE failed. Ensure, that your
- * FTP server supports the SITE command.
- *
- * @since 1.3
- * @name NET_FTP_ERR_SITE_FAILED
- * @see Net_FTP::site()
- */
-define('NET_FTP_ERR_SITE_FAILED', -6);
-
-/**
- * Error code to indicate that the CHMOD command failed.
- * The execution of CHMOD failed. Ensure, that your
- * FTP server supports the CHMOD command and that you have the appropriate
- * access rights to use CHMOD.
- *
- * @since 1.3
- * @name NET_FTP_ERR_CHMOD_FAILED
- * @see Net_FTP::chmod()
- */
-define('NET_FTP_ERR_CHMOD_FAILED', -7);
-
-/**
- * Error code to indicate that a file rename failed
- * The renaming of a file on the server failed. Ensure that you have the
- * appropriate access rights to rename the file.
- *
- * @since 1.3
- * @name NET_FTP_ERR_RENAME_FAILED
- * @see Net_FTP::rename()
- */
-define('NET_FTP_ERR_RENAME_FAILED', -8);
-
-/**
- * Error code to indicate that the MDTM command failed
- * The MDTM command is not supported for directories. Ensure that you gave
- * a file path to the mdtm() method, not a directory path.
- *
- * @since 1.3
- * @name NET_FTP_ERR_MDTMDIR_UNSUPPORTED
- * @see Net_FTP::mdtm()
- */
-define('NET_FTP_ERR_MDTMDIR_UNSUPPORTED', -9);
-
-/**
- * Error code to indicate that the MDTM command failed
- * The MDTM command failed. Ensure that your server supports the MDTM command.
- *
- * @since 1.3
- * @name NET_FTP_ERR_MDTM_FAILED
- * @see Net_FTP::mdtm()
- */
-define('NET_FTP_ERR_MDTM_FAILED', -10);
-
-/**
- * Error code to indicate that a date returned by the server was misformated
- * A date string returned by your server seems to be missformated and could not be
- * parsed. Check that the server is configured correctly. If you're sure, please
- * send an email to the auhtor with a dumped output of
- * $ftp->ls('./', NET_FTP_RAWLIST); to get the date format supported.
- *
- * @since 1.3
- * @name NET_FTP_ERR_DATEFORMAT_FAILED
- * @see Net_FTP::mdtm(), Net_FTP::ls()
- */
-define('NET_FTP_ERR_DATEFORMAT_FAILED', -11);
-
-/**
- * Error code to indicate that the SIZE command failed
- * The determination of the filesize of a file failed. Ensure that your server
- * supports the SIZE command.
- *
- * @since 1.3
- * @name NET_FTP_ERR_SIZE_FAILED
- * @see Net_FTP::size()
- */
-define('NET_FTP_ERR_SIZE_FAILED', -12);
-
-/**
- * Error code to indicate that a local file could not be overwritten
- * You specified not to overwrite files. Therefore the local file has not been
- * overwriten. If you want to get the file overwriten, please set the option to
- * do so.
- *
- * @since 1.3
- * @name NET_FTP_ERR_OVERWRITELOCALFILE_FORBIDDEN
- * @see Net_FTP::get(), Net_FTP::getRecursive()
- */
-define('NET_FTP_ERR_OVERWRITELOCALFILE_FORBIDDEN', -13);
-
-/**
- * Error code to indicate that a local file could not be overwritten
- * Also you specified to overwrite the local file you want to download to,
- * it has not been possible to do so. Check that you have the appropriate access
- * rights on the local file to overwrite it.
- *
- * @since 1.3
- * @name NET_FTP_ERR_OVERWRITELOCALFILE_FAILED
- * @see Net_FTP::get(), Net_FTP::getRecursive()
- */
-define('NET_FTP_ERR_OVERWRITELOCALFILE_FAILED', -14);
-
-/**
- * Error code to indicate that the file you wanted to upload does not exist
- * The file you tried to upload does not exist. Ensure that it exists.
- *
- * @since 1.3
- * @name NET_FTP_ERR_LOCALFILENOTEXIST
- * @see Net_FTP::put(), Net_FTP::putRecursive()
- */
-define('NET_FTP_ERR_LOCALFILENOTEXIST', -15);
-
-/**
- * Error code to indicate that a remote file could not be overwritten
- * You specified not to overwrite files. Therefore the remote file has not been
- * overwriten. If you want to get the file overwriten, please set the option to
- * do so.
- *
- * @since 1.3
- * @name NET_FTP_ERR_OVERWRITEREMOTEFILE_FORBIDDEN
- * @see Net_FTP::put(), Net_FTP::putRecursive()
- */
-define('NET_FTP_ERR_OVERWRITEREMOTEFILE_FORBIDDEN', -16);
-
-/**
- * Error code to indicate that the upload of a file failed
- * The upload you tried failed. Ensure that you have appropriate access rights
- * to upload the desired file.
- *
- * @since 1.3
- * @name NET_FTP_ERR_UPLOADFILE_FAILED
- * @see Net_FTP::put(), Net_FTP::putRecursive()
- */
-define('NET_FTP_ERR_UPLOADFILE_FAILED', -17);
-
-/**
- * Error code to indicate that you specified an incorrect directory path
- * The remote path you specified seems not to be a directory. Ensure that
- * the path you specify is a directory and that the path string ends with
- * a /.
- *
- * @since 1.3
- * @name NET_FTP_ERR_REMOTEPATHNODIR
- * @see Net_FTP::putRecursive(), Net_FTP::getRecursive()
- */
-define('NET_FTP_ERR_REMOTEPATHNODIR', -18);
-
-/**
- * Error code to indicate that you specified an incorrect directory path
- * The local path you specified seems not to be a directory. Ensure that
- * the path you specify is a directory and that the path string ends with
- * a /.
- *
- * @since 1.3
- * @name NET_FTP_ERR_LOCALPATHNODIR
- * @see Net_FTP::putRecursive(), Net_FTP::getRecursive()
- */
-define('NET_FTP_ERR_LOCALPATHNODIR', -19);
-
-/**
- * Error code to indicate that a local directory failed to be created
- * You tried to create a local directory through getRecursive() method,
- * which has failed. Ensure that you have the appropriate access rights
- * to create it.
- *
- * @since 1.3
- * @name NET_FTP_ERR_CREATELOCALDIR_FAILED
- * @see Net_FTP::getRecursive()
- */
-define('NET_FTP_ERR_CREATELOCALDIR_FAILED', -20);
-
-/**
- * Error code to indicate that the provided hostname was incorrect
- * The hostname you provided was invalid. Ensure to provide either a
- * full qualified domain name or an IP address.
- *
- * @since 1.3
- * @name NET_FTP_ERR_HOSTNAMENOSTRING
- * @see Net_FTP::setHostname()
- */
-define('NET_FTP_ERR_HOSTNAMENOSTRING', -21);
-
-/**
- * Error code to indicate that the provided port was incorrect
- * The port number you provided was invalid. Ensure to provide either a
- * a numeric port number greater zero.
- *
- * @since 1.3
- * @name NET_FTP_ERR_PORTLESSZERO
- * @see Net_FTP::setPort()
- */
-define('NET_FTP_ERR_PORTLESSZERO', -22);
-
-/**
- * Error code to indicate that you provided an invalid mode constant
- * The mode constant you provided was invalid. You may only provide
- * FTP_ASCII or FTP_BINARY.
- *
- * @since 1.3
- * @name NET_FTP_ERR_NOMODECONST
- * @see Net_FTP::setMode()
- */
-define('NET_FTP_ERR_NOMODECONST', -23);
-
-/**
- * Error code to indicate that you provided an invalid timeout
- * The timeout you provided was invalid. You have to provide a timeout greater
- * or equal to zero.
- *
- * @since 1.3
- * @name NET_FTP_ERR_TIMEOUTLESSZERO
- * @see Net_FTP::Net_FTP(), Net_FTP::setTimeout()
- */
-define('NET_FTP_ERR_TIMEOUTLESSZERO', -24);
-
-/**
- * Error code to indicate that you provided an invalid timeout
- * An error occured while setting the timeout. Ensure that you provide a
- * valid integer for the timeount and that your PHP installation works
- * correctly.
- *
- * @since 1.3
- * @name NET_FTP_ERR_SETTIMEOUT_FAILED
- * @see Net_FTP::Net_FTP(), Net_FTP::setTimeout()
- */
-define('NET_FTP_ERR_SETTIMEOUT_FAILED', -25);
-
-/**
- * Error code to indicate that the provided extension file doesn't exist
- * The provided extension file does not exist. Ensure to provided an
- * existant extension file.
- *
- * @since 1.3
- * @name NET_FTP_ERR_EXTFILENOTEXIST
- * @see Net_FTP::getExtensionsFile()
- */
-define('NET_FTP_ERR_EXTFILENOTEXIST', -26);
-
-/**
- * Error code to indicate that the provided extension file is not readable
- * The provided extension file is not readable. Ensure to have sufficient
- * access rights for it.
- *
- * @since 1.3
- * @name NET_FTP_ERR_EXTFILEREAD_FAILED
- * @see Net_FTP::getExtensionsFile()
- */
-define('NET_FTP_ERR_EXTFILEREAD_FAILED', -27);
-
-/**
- * Error code to indicate that the deletion of a file failed
- * The specified file could not be deleted. Ensure to have sufficient
- * access rights to delete the file.
- *
- * @since 1.3
- * @name NET_FTP_ERR_EXTFILEREAD_FAILED
- * @see Net_FTP::rm()
- */
-define('NET_FTP_ERR_DELETEFILE_FAILED', -28);
-
-/**
- * Error code to indicate that the deletion of a directory faild
- * The specified file could not be deleted. Ensure to have sufficient
- * access rights to delete the file.
- *
- * @since 1.3
- * @name NET_FTP_ERR_EXTFILEREAD_FAILED
- * @see Net_FTP::rm()
- */
-define('NET_FTP_ERR_DELETEDIR_FAILED', -29);
-
-/**
- * Error code to indicate that the directory listing failed
- * PHP could not list the directory contents on the server. Ensure
- * that your server is configured appropriate.
- *
- * @since 1.3
- * @name NET_FTP_ERR_RAWDIRLIST_FAILED
- * @see Net_FTP::ls()
- */
-define('NET_FTP_ERR_RAWDIRLIST_FAILED', -30);
-
-/**
- * Error code to indicate that the directory listing failed
- * The directory listing format your server uses seems not to
- * be supported by Net_FTP. Please send the output of the
- * call ls('./', NET_FTP_RAWLIST); to the author of this
- * class to get it supported.
- *
- * @since 1.3
- * @name NET_FTP_ERR_DIRLIST_UNSUPPORTED
- * @see Net_FTP::ls()
- */
-define('NET_FTP_ERR_DIRLIST_UNSUPPORTED', -31);
-
-/**
- * Error code to indicate failed disconnecting
- * This error code indicates, that disconnection was not possible.
- *
- * @since 1.3
- * @name NET_FTP_ERR_DISCONNECT_FAILED
- * @see Net_FTP::disconnect()
- */
-define('NET_FTP_ERR_DISCONNECT_FAILED', -32);
-
-/**
- * Error code to indicate that the username you provided was invalid.
- * Check that you provided a non-empty string as the username.
- *
- * @since 1.3
- * @name NET_FTP_ERR_USERNAMENOSTRING
- * @see Net_FTP::setUsername()
- */
-define('NET_FTP_ERR_USERNAMENOSTRING', -33);
-
-/**
- * Error code to indicate that the username you provided was invalid.
- * Check that you provided a non-empty string as the username.
- *
- * @since 1.3
- * @name NET_FTP_ERR_PASSWORDNOSTRING
- * @see Net_FTP::setPassword()
- */
-define('NET_FTP_ERR_PASSWORDNOSTRING', -34);
-
-/**
- * Error code to indicate that the provided extension file is not loadable
- * The provided extension file is not loadable. Ensure to have a correct file
- * syntax.
- *
- * @since 1.3.3
- * @name NET_FTP_ERR_EXTFILELOAD_FAILED
- * @see Net_FTP::getExtensionsFile()
- */
-define('NET_FTP_ERR_EXTFILELOAD_FAILED', -35);
-
-/**
- * Class for comfortable FTP-communication
- *
- * This class provides comfortable communication with FTP-servers. You may do
- * everything enabled by the PHP-FTP-extension and further functionalities, like
- * recursive-deletion, -up- and -download. Another feature is to create directories
- * recursively.
- *
- * @category Networking
- * @package FTP
- * @author Tobias Schlitt
- * @author Jorrit Schippers
- * @copyright 1997-2008 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.3.7
- * @link http://pear.php.net/package/Net_FTP
- * @since 0.0.1
- * @access public
- */
-class Net_FTP extends PEAR
-{
- const mkdir = 'mkdir';
- /**
- * The host to connect to
- *
- * @access private
- * @var string
- */
- var $_hostname;
-
- /**
- * The port for ftp-connection (standard is 21)
- *
- * @access private
- * @var int
- */
- var $_port = 21;
-
- /**
- * The username for login
- *
- * @access private
- * @var string
- */
- var $_username;
-
- /**
- * The password for login
- *
- * @access private
- * @var string
- */
- var $_password;
-
- /**
- * Determine whether to use passive-mode (true) or active-mode (false)
- *
- * @access private
- * @var bool
- */
- var $_passv;
-
- /**
- * The standard mode for ftp-transfer
- *
- * @access private
- * @var int
- */
- var $_mode = FTP_BINARY;
-
- /**
- * This holds the handle for the ftp-connection
- *
- * @access private
- * @var resource
- */
- var $_handle;
-
- /**
- * Contains the timeout for FTP operations
- *
- * @access private
- * @var int
- * @since 1.3
- */
- var $_timeout = 90;
-
- /**
- * Saves file-extensions for ascii- and binary-mode
- *
- * The array contains 2 sub-arrays ("ascii" and "binary"), which both contain
- * file-extensions without the "." (".php" = "php").
- *
- * @access private
- * @var array
- */
- var $_file_extensions;
-
- /**
- * ls match
- * Matches the ls entries against a regex and maps the resulting array to
- * speaking names
- *
- * The values are set in the constructor because of line length constaints.
- *
- * Typical lines for the Windows format:
- * 07-05-07 08:40AM 4701 SomeFile.ext
- * 04-29-07 10:28PM SomeDir
- *
- * @access private
- * @var array
- * @since 1.3
- */
- var $_ls_match = null;
-
- /**
- * matcher
- * Stores the matcher for the current connection
- *
- * @access private
- * @var array
- * @since 1.3
- */
- var $_matcher = null;
-
- /**
- * Holds all Net_FTP_Observer objects
- * that wish to be notified of new messages.
- *
- * @var array
- * @access private
- * @since 1.3
- */
- var $_listeners = array();
-
- /**
- * This generates a new FTP-Object. The FTP-connection will not be established,
- * yet.
- * You can leave $host and $port blank, if you want. The $host will not be set
- * and the $port will be left at 21. You have to set the $host manualy before
- * trying to connect or with the connect() method.
- *
- * @param string $host (optional) The hostname
- * @param int $port (optional) The port
- * @param int $timeout (optional) Sets the standard timeout
- *
- * @access public
- * @return void
- * @see Net_FTP::setHostname(), Net_FTP::setPort(), Net_FTP::connect()
- */
- function Net_FTP($host = null, $port = null, $timeout = 90)
- {
- $this->PEAR();
- if (isset($host)) {
- $this->setHostname($host);
- }
- if (isset($port)) {
- $this->setPort($port);
- }
- $this->_timeout = $timeout;
- $this->_file_extensions[FTP_ASCII] = array();
- $this->_file_extensions[FTP_BINARY] = array();
-
- $this->_ls_match = array(
- 'unix' => array(
- 'pattern' => '/(?:(d)|.)([rwxts-]{9})\s+(\w+)\s+([\w\d-()?.]+)\s+'.
- '([\w\d-()?.]+)\s+(\w+)\s+(\S+\s+\S+\s+\S+)\s+(.+)/',
- 'map' => array(
- 'is_dir' => 1,
- 'rights' => 2,
- 'files_inside' => 3,
- 'user' => 4,
- 'group' => 5,
- 'size' => 6,
- 'date' => 7,
- 'name' => 8,
- )
- ),
- 'windows' => array(
- 'pattern' => '/([0-9\-]+)\s+([0-9:APM]+)\s+(()|\d+)\s+(.+)/',
- 'map' => array(
- 'date' => 1,
- 'time' => 2,
- 'size' => 3,
- 'is_dir' => 4,
- 'name' => 5,
- )
- )
- );
- }
-
- /**
- * This function generates the FTP-connection. You can optionally define a
- * hostname and/or a port. If you do so, this data is stored inside the object.
- *
- * @param string $host (optional) The Hostname
- * @param int $port (optional) The Port
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_CONNECT_FAILED
- */
- function connect($host = null, $port = null)
- {
- $this->_matcher = null;
- if (isset($host)) {
- $this->setHostname($host);
- }
- if (isset($port)) {
- $this->setPort($port);
- }
- $handle = @ftp_connect($this->getHostname(), $this->getPort(),
- $this->_timeout);
- if (!$handle) {
- return $this->raiseError("Connection to host failed",
- NET_FTP_ERR_CONNECT_FAILED);
- } else {
- $this->_handle =& $handle;
- return true;
- }
- }
-
- /**
- * This function close the FTP-connection
- *
- * @access public
- * @return bool|PEAR_Error Returns true on success, PEAR_Error on failure
- */
- function disconnect()
- {
- $res = @ftp_close($this->_handle);
- if (!$res) {
- return PEAR::raiseError('Disconnect failed.',
- NET_FTP_ERR_DISCONNECT_FAILED);
- }
- return true;
- }
-
- /**
- * This logs you into the ftp-server. You are free to specify username and
- * password in this method. If you specify it, the values will be taken into
- * the corresponding attributes, if do not specify, the attributes are taken.
- *
- * @param string $username (optional) The username to use
- * @param string $password (optional) The password to use
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_LOGIN_FAILED
- */
- function login($username = null, $password = null)
- {
- if (!isset($username)) {
- $username = $this->getUsername();
- } else {
- $this->setUsername($username);
- }
-
- if (!isset($password)) {
- $password = $this->getPassword();
- } else {
- $this->setPassword($password);
- }
-
- $res = @ftp_login($this->_handle, $username, $password);
-
- if (!$res) {
- return $this->raiseError("Unable to login", NET_FTP_ERR_LOGIN_FAILED);
- } else {
- return true;
- }
- }
-
- /**
- * This changes the currently used directory. You can use either an absolute
- * directory-path (e.g. "/home/blah") or a relative one (e.g. "../test").
- *
- * @param string $dir The directory to go to.
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_DIRCHANGE_FAILED
- */
- function cd($dir)
- {
- $erg = @ftp_chdir($this->_handle, $dir);
- if (!$erg) {
- return $this->raiseError("Directory change failed",
- NET_FTP_ERR_DIRCHANGE_FAILED);
- } else {
- return true;
- }
- }
-
- /**
- * Show's you the actual path on the server
- * This function questions the ftp-handle for the actual selected path and
- * returns it.
- *
- * @access public
- * @return mixed The actual path or PEAR::Error
- * @see NET_FTP_ERR_DETERMINEPATH_FAILED
- */
- function pwd()
- {
- $res = @ftp_pwd($this->_handle);
- if (!$res) {
- return $this->raiseError("Could not determine the actual path.",
- NET_FTP_ERR_DETERMINEPATH_FAILED);
- } else {
- return $res;
- }
- }
-
- /**
- * This works similar to the mkdir-command on your local machine. You can either
- * give it an absolute or relative path. The relative path will be completed
- * with the actual selected server-path. (see: pwd())
- *
- * @param string $dir Absolute or relative dir-path
- * @param bool $recursive (optional) Create all needed directories
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_CREATEDIR_FAILED
- */
- function mkdir($dir, $recursive = false)
- {
- $dir = $this->_constructPath($dir);
- $savedir = $this->pwd();
- $this->pushErrorHandling(PEAR_ERROR_RETURN);
- $e = $this->cd($dir);
- $this->popErrorHandling();
- if ($e === true) {
- $this->cd($savedir);
- return true;
- }
- $this->cd($savedir);
- if ($recursive === false) {
- $res = @ftp_mkdir($this->_handle, $dir);
- if (!$res) {
- return $this->raiseError("Creation of '$dir' failed",
- NET_FTP_ERR_CREATEDIR_FAILED);
- } else {
- return true;
- }
- } else {
- // do not look at the first character, as $dir is absolute,
- // it will always be a /
- if (strpos(substr($dir, 1), '/') === false) {
- return $this->mkdir($dir, false);
- }
- if (substr($dir, -1) == '/') {
- $dir = substr($dir, 0, -1);
- }
- $parent = substr($dir, 0, strrpos($dir, '/'));
- $res = $this->mkdir($parent, true);
- if ($res === true) {
- $res = $this->mkdir($dir, false);
- }
- if ($res !== true) {
- return $res;
- }
- return true;
- }
- }
-
- /**
- * This method tries executing a command on the ftp, using SITE EXEC.
- *
- * @param string $command The command to execute
- *
- * @access public
- * @return mixed The result of the command (if successfull), otherwise
- * PEAR::Error
- * @see NET_FTP_ERR_EXEC_FAILED
- */
- function execute($command)
- {
- $res = @ftp_exec($this->_handle, $command);
- if (!$res) {
- return $this->raiseError("Execution of command '$command' failed.",
- NET_FTP_ERR_EXEC_FAILED);
- } else {
- return $res;
- }
- }
-
- /**
- * Execute a SITE command on the server
- * This method tries to execute a SITE command on the ftp server.
- *
- * @param string $command The command with parameters to execute
- *
- * @access public
- * @return mixed True if successful, otherwise PEAR::Error
- * @see NET_FTP_ERR_SITE_FAILED
- */
- function site($command)
- {
- $res = @ftp_site($this->_handle, $command);
- if (!$res) {
- return $this->raiseError("Execution of SITE command '$command' failed.",
- NET_FTP_ERR_SITE_FAILED);
- } else {
- return $res;
- }
- }
-
- /**
- * This method will try to chmod the file specified on the server
- * Currently, you must give a number as the the permission argument (777 or
- * similar). The file can be either a relative or absolute path.
- * NOTE: Some servers do not support this feature. In that case, you will
- * get a PEAR error object returned. If successful, the method returns true
- *
- * @param mixed $target The file or array of files to set permissions for
- * @param integer $permissions The mode to set the file permissions to
- *
- * @access public
- * @return mixed True if successful, otherwise PEAR::Error
- * @see NET_FTP_ERR_CHMOD_FAILED
- */
- function chmod($target, $permissions)
- {
- // If $target is an array: Loop through it.
- if (is_array($target)) {
-
- for ($i = 0; $i < count($target); $i++) {
- $res = $this->chmod($target[$i], $permissions);
- if (PEAR::isError($res)) {
- return $res;
- } // end if isError
- } // end for i < count($target)
-
- } else {
-
- $res = $this->site("CHMOD " . $permissions . " " . $target);
- if (!$res) {
- return PEAR::raiseError("CHMOD " . $permissions . " " . $target .
- " failed", NET_FTP_ERR_CHMOD_FAILED);
- } else {
- return $res;
- }
-
- } // end if is_array
-
- } // end method chmod
-
- /**
- * This method will try to chmod a folder and all of its contents
- * on the server. The target argument must be a folder or an array of folders
- * and the permissions argument have to be an integer (i.e. 777).
- * The file can be either a relative or absolute path.
- * NOTE: Some servers do not support this feature. In that case, you
- * will get a PEAR error object returned. If successful, the method
- * returns true
- *
- * @param mixed $target The folder or array of folders to
- * set permissions for
- * @param integer $permissions The mode to set the folder
- * and file permissions to
- *
- * @access public
- * @return mixed True if successful, otherwise PEAR::Error
- * @see NET_FTP_ERR_CHMOD_FAILED, NET_FTP_ERR_DETERMINEPATH_FAILED,
- * NET_FTP_ERR_RAWDIRLIST_FAILED, NET_FTP_ERR_DIRLIST_UNSUPPORTED
- */
- function chmodRecursive($target, $permissions)
- {
- static $dir_permissions;
-
- if (!isset($dir_permissions)) { // Making directory specific permissions
- $dir_permissions = $this->_makeDirPermissions($permissions);
- }
-
- // If $target is an array: Loop through it
- if (is_array($target)) {
-
- for ($i = 0; $i < count($target); $i++) {
- $res = $this->chmodRecursive($target[$i], $permissions);
- if (PEAR::isError($res)) {
- return $res;
- } // end if isError
- } // end for i < count($target)
-
- } else {
-
- $remote_path = $this->_constructPath($target);
-
- // Chmod the directory itself
- $result = $this->chmod($remote_path, $dir_permissions);
-
- if (PEAR::isError($result)) {
- return $result;
- }
-
- // If $remote_path last character is not a slash, add one
- if (substr($remote_path, strlen($remote_path)-1) != "/") {
-
- $remote_path .= "/";
- }
-
- $dir_list = array();
- $mode = NET_FTP_DIRS_ONLY;
- $dir_list = $this->ls($remote_path, $mode);
- foreach ($dir_list as $dir_entry) {
- if ($dir_entry['name'] == '.' || $dir_entry['name'] == '..') {
- continue;
- }
-
- $remote_path_new = $remote_path.$dir_entry["name"]."/";
-
- // Chmod the directory we're about to enter
- $result = $this->chmod($remote_path_new, $dir_permissions);
-
- if (PEAR::isError($result)) {
- return $result;
- }
-
- $result = $this->chmodRecursive($remote_path_new, $permissions);
-
- if (PEAR::isError($result)) {
- return $result;
- }
-
- } // end foreach dir_list as dir_entry
-
- $file_list = array();
- $mode = NET_FTP_FILES_ONLY;
- $file_list = $this->ls($remote_path, $mode);
-
- foreach ($file_list as $file_entry) {
-
- $remote_file = $remote_path.$file_entry["name"];
-
- $result = $this->chmod($remote_file, $permissions);
-
- if (PEAR::isError($result)) {
- return $result;
- }
-
- } // end foreach $file_list
-
- } // end if is_array
-
- return true; // No errors
-
- } // end method chmodRecursive
-
- /**
- * Rename or move a file or a directory from the ftp-server
- *
- * @param string $remote_from The remote file or directory original to rename or
- * move
- * @param string $remote_to The remote file or directory final to rename or
- * move
- *
- * @access public
- * @return bool $res True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_RENAME_FAILED
- */
- function rename ($remote_from, $remote_to)
- {
- $res = @ftp_rename($this->_handle, $remote_from, $remote_to);
- if (!$res) {
- return $this->raiseError("Could not rename ".$remote_from." to ".
- $remote_to." !", NET_FTP_ERR_RENAME_FAILED);
- }
- return true;
- }
-
- /**
- * This will return logical permissions mask for directory.
- * if directory has to be readable it have also be executable
- *
- * @param string $permissions File permissions in digits for file (i.e. 666)
- *
- * @access private
- * @return string File permissions in digits for directory (i.e. 777)
- */
- function _makeDirPermissions($permissions)
- {
- $permissions = (string)$permissions;
-
- // going through (user, group, world)
- for ($i = 0; $i < strlen($permissions); $i++) {
- // Read permission is set but execute not yet
- if ((int)$permissions{$i} & 4 and !((int)$permissions{$i} & 1)) {
- // Adding execute flag
- (int)$permissions{$i} = (int)$permissions{$i} + 1;
- }
- }
-
- return (string)$permissions;
- }
-
- /**
- * This will return the last modification-time of a file. You can either give
- * this function a relative or an absolute path to the file to check.
- * NOTE: Some servers will not support this feature and the function works
- * only on files, not directories! When successful,
- * it will return the last modification-time as a unix-timestamp or, when
- * $format is specified, a preformated timestring.
- *
- * @param string $file The file to check
- * @param string $format (optional) The format to give the date back
- * if not set, it will return a Unix timestamp
- *
- * @access public
- * @return mixed Unix timestamp, a preformated date-string or PEAR::Error
- * @see NET_FTP_ERR_MDTMDIR_UNSUPPORTED, NET_FTP_ERR_MDTM_FAILED,
- * NET_FTP_ERR_DATEFORMAT_FAILED
- */
- function mdtm($file, $format = null)
- {
- $file = $this->_constructPath($file);
- if ($this->_checkDir($file)) {
- return $this->raiseError("Filename '$file' seems to be a directory.",
- NET_FTP_ERR_MDTMDIR_UNSUPPORTED);
- }
- $res = @ftp_mdtm($this->_handle, $file);
- if ($res == -1) {
- return $this->raiseError("Could not get last-modification-date of '".
- $file."'.", NET_FTP_ERR_MDTM_FAILED);
- }
- if (isset($format)) {
- $res = date($format, $res);
- if (!$res) {
- return $this->raiseError("Date-format failed on timestamp '".$res.
- "'.", NET_FTP_ERR_DATEFORMAT_FAILED);
- }
- }
- return $res;
- }
-
- /**
- * This will return the size of a given file in bytes. You can either give this
- * function a relative or an absolute file-path. NOTE: Some servers do not
- * support this feature!
- *
- * @param string $file The file to check
- *
- * @access public
- * @return mixed Size in bytes or PEAR::Error
- * @see NET_FTP_ERR_SIZE_FAILED
- */
- function size($file)
- {
- $file = $this->_constructPath($file);
- $res = @ftp_size($this->_handle, $file);
- if ($res == -1) {
- return $this->raiseError("Could not determine filesize of '$file'.",
- NET_FTP_ERR_SIZE_FAILED);
- } else {
- return $res;
- }
- }
-
- /**
- * This method returns a directory-list of the current directory or given one.
- * To display the current selected directory, simply set the first parameter to
- * null
- * or leave it blank, if you do not want to use any other parameters.
- *
- * There are 4 different modes of listing directories. Either to list only
- * the files (using NET_FTP_FILES_ONLY), to list only directories (using
- * NET_FTP_DIRS_ONLY) or to show both (using NET_FTP_DIRS_FILES, which is
- * default).
- *
- * The 4th one is the NET_FTP_RAWLIST, which returns just the array created by
- * the ftp_rawlist()-function build into PHP.
- *
- * The other function-modes will return an array containing the requested data.
- * The files and dirs are listed in human-sorted order, but if you select
- * NET_FTP_DIRS_FILES the directories will be added above the files,
- * but although both sorted.
- *
- * All elements in the arrays are associative arrays themselves. They have the
- * following structure:
- *
- * Dirs:
- * ["name"] => string The name of the directory
- * ["rights"] => string The rights of the directory (in style
- * "rwxr-xr-x")
- * ["user"] => string The owner of the directory
- * ["group"] => string The group-owner of the directory
- * ["files_inside"]=> string The number of files/dirs inside the
- * directory excluding "." and ".."
- * ["date"] => int The creation-date as Unix timestamp
- * ["is_dir"] => bool true, cause this is a dir
- *
- * Files:
- * ["name"] => string The name of the file
- * ["size"] => int Size in bytes
- * ["rights"] => string The rights of the file (in style
- * "rwxr-xr-x")
- * ["user"] => string The owner of the file
- * ["group"] => string The group-owner of the file
- * ["date"] => int The creation-date as Unix timestamp
- * ["is_dir"] => bool false, cause this is a file
- *
- * @param string $dir (optional) The directory to list or null, when listing
- * the current directory.
- * @param int $mode (optional) The mode which types to list (files,
- * directories or both).
- *
- * @access public
- * @return mixed The directory list as described above or PEAR::Error on failure
- * @see NET_FTP_DIRS_FILES, NET_FTP_DIRS_ONLY, NET_FTP_FILES_ONLY,
- * NET_FTP_RAWLIST, NET_FTP_ERR_DETERMINEPATH_FAILED,
- * NET_FTP_ERR_RAWDIRLIST_FAILED, NET_FTP_ERR_DIRLIST_UNSUPPORTED
- */
- function ls($dir = null, $mode = NET_FTP_DIRS_FILES)
- {
- if (!isset($dir)) {
- $dir = @ftp_pwd($this->_handle);
- if (!$dir) {
- return $this->raiseError("Could not retrieve current directory",
- NET_FTP_ERR_DETERMINEPATH_FAILED);
- }
- }
- if (($mode != NET_FTP_FILES_ONLY) && ($mode != NET_FTP_DIRS_ONLY) &&
- ($mode != NET_FTP_RAWLIST)) {
- $mode = NET_FTP_DIRS_FILES;
- }
-
- switch ($mode) {
- case NET_FTP_DIRS_FILES:
- $res = $this->_lsBoth($dir);
- break;
- case NET_FTP_DIRS_ONLY:
- $res = $this->_lsDirs($dir);
- break;
- case NET_FTP_FILES_ONLY:
- $res = $this->_lsFiles($dir);
- break;
- case NET_FTP_RAWLIST:
- $res = @ftp_rawlist($this->_handle, $dir);
- break;
- }
-
- return $res;
- }
-
- /**
- * This method will delete the given file or directory ($path) from the server
- * (maybe recursive).
- *
- * Whether the given string is a file or directory is only determined by the
- * last sign inside the string ("/" or not).
- *
- * If you specify a directory, you can optionally specify $recursive as true,
- * to let the directory be deleted recursive (with all sub-directories and files
- * inherited).
- *
- * You can either give a absolute or relative path for the file / dir. If you
- * choose to use the relative path, it will be automatically completed with the
- * actual selected directory.
- *
- * @param string $path The absolute or relative path to the file/directory.
- * @param bool $recursive (optional)
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_DELETEFILE_FAILED, NET_FTP_ERR_DELETEDIR_FAILED,
- * NET_FTP_ERR_REMOTEPATHNODIR
- */
- function rm($path, $recursive = false)
- {
- $path = $this->_constructPath($path);
- if ($this->_checkDir($path)) {
- if ($recursive) {
- return $this->_rmDirRecursive($path);
- } else {
- return $this->_rmDir($path);
- }
- } else {
- return $this->_rmFile($path);
- }
- }
-
- /**
- * This function will download a file from the ftp-server. You can either
- * specify an absolute path to the file (beginning with "/") or a relative one,
- * which will be completed with the actual directory you selected on the server.
- * You can specify the path to which the file will be downloaded on the local
- * machine, if the file should be overwritten if it exists (optionally, default
- * is no overwriting) and in which mode (FTP_ASCII or FTP_BINARY) the file
- * should be downloaded (if you do not specify this, the method tries to
- * determine it automatically from the mode-directory or uses the default-mode,
- * set by you).
- * If you give a relative path to the local-file, the script-path is used as
- * basepath.
- *
- * @param string $remote_file The absolute or relative path to the file to
- * download
- * @param string $local_file The local file to put the downloaded in
- * @param bool $overwrite (optional) Whether to overwrite existing file
- * @param int $mode (optional) Either FTP_ASCII or FTP_BINARY
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_OVERWRITELOCALFILE_FORBIDDEN,
- * NET_FTP_ERR_OVERWRITELOCALFILE_FAILED,
- * NET_FTP_ERR_OVERWRITELOCALFILE_FAILED
- */
- function get($remote_file, $local_file, $overwrite = false, $mode = null)
- {
- if (!isset($mode)) {
- $mode = $this->checkFileExtension($remote_file);
- }
-
- $remote_file = $this->_constructPath($remote_file);
-
- if (@file_exists($local_file) && !$overwrite) {
- return $this->raiseError("Local file '".$local_file.
- "' exists and may not be overwriten.",
- NET_FTP_ERR_OVERWRITELOCALFILE_FORBIDDEN);
- }
- if (@file_exists($local_file) &&
- !@is_writeable($local_file) && $overwrite) {
- return $this->raiseError("Local file '".$local_file.
- "' is not writeable. Can not overwrite.",
- NET_FTP_ERR_OVERWRITELOCALFILE_FAILED);
- }
-
- if (@function_exists('ftp_nb_get')) {
- $res = @ftp_nb_get($this->_handle, $local_file, $remote_file, $mode);
- while ($res == FTP_MOREDATA) {
- $this->_announce('nb_get');
- $res = @ftp_nb_continue($this->_handle);
- }
- } else {
- $res = @ftp_get($this->_handle, $local_file, $remote_file, $mode);
- }
- if (!$res) {
- return $this->raiseError("File '".$remote_file.
- "' could not be downloaded to '$local_file'.",
- NET_FTP_ERR_OVERWRITELOCALFILE_FAILED);
- } else {
- return true;
- }
- }
-
- /**
- * This function will upload a file to the ftp-server. You can either specify a
- * absolute path to the remote-file (beginning with "/") or a relative one,
- * which will be completed with the actual directory you selected on the server.
- * You can specify the path from which the file will be uploaded on the local
- * maschine, if the file should be overwritten if it exists (optionally, default
- * is no overwriting) and in which mode (FTP_ASCII or FTP_BINARY) the file
- * should be downloaded (if you do not specify this, the method tries to
- * determine it automatically from the mode-directory or uses the default-mode,
- * set by you).
- * If you give a relative path to the local-file, the script-path is used as
- * basepath.
- *
- * @param string $local_file The local file to upload
- * @param string $remote_file The absolute or relative path to the file to
- * upload to
- * @param bool $overwrite (optional) Whether to overwrite existing file
- * @param int $mode (optional) Either FTP_ASCII or FTP_BINARY
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_LOCALFILENOTEXIST,
- * NET_FTP_ERR_OVERWRITEREMOTEFILE_FORBIDDEN,
- * NET_FTP_ERR_UPLOADFILE_FAILED
- */
- function put($local_file, $remote_file, $overwrite = false, $mode = null)
- {
- if (!isset($mode)) {
- $mode = $this->checkFileExtension($local_file);
- }
- $remote_file = $this->_constructPath($remote_file);
-
- if (!@file_exists($local_file)) {
- return $this->raiseError("Local file '$local_file' does not exist.",
- NET_FTP_ERR_LOCALFILENOTEXIST);
- }
- if ((@ftp_size($this->_handle, $remote_file) != -1) && !$overwrite) {
- return $this->raiseError("Remote file '".$remote_file.
- "' exists and may not be overwriten.",
- NET_FTP_ERR_OVERWRITEREMOTEFILE_FORBIDDEN);
- }
-
- if (function_exists('ftp_alloc')) {
- ftp_alloc($this->_handle, filesize($local_file));
- }
- if (function_exists('ftp_nb_put')) {
- $res = @ftp_nb_put($this->_handle, $remote_file, $local_file, $mode);
- while ($res == FTP_MOREDATA) {
- $this->_announce('nb_put');
- $res = @ftp_nb_continue($this->_handle);
- }
-
- } else {
- $res = @ftp_put($this->_handle, $remote_file, $local_file, $mode);
- }
- if (!$res) {
- return $this->raiseError("File '$local_file' could not be uploaded to '"
- .$remote_file."'.",
- NET_FTP_ERR_UPLOADFILE_FAILED);
- } else {
- return true;
- }
- }
-
- /**
- * This functionality allows you to transfer a whole directory-structure from
- * the remote-ftp to your local host. You have to give a remote-directory
- * (ending with '/') and the local directory (ending with '/') where to put the
- * files you download.
- * The remote path is automatically completed with the current-remote-dir, if
- * you give a relative path to this function. You can give a relative path for
- * the $local_path, too. Then the script-basedir will be used for comletion of
- * the path.
- * The parameter $overwrite will determine, whether to overwrite existing files
- * or not. Standard for this is false. Fourth you can explicitly set a mode for
- * all transfer actions done. If you do not set this, the method tries to
- * determine the transfer mode by checking your mode-directory for the file
- * extension. If the extension is not inside the mode-directory, it will get
- * your default mode.
- *
- * @param string $remote_path The path to download
- * @param string $local_path The path to download to
- * @param bool $overwrite (optional) Whether to overwrite existing files
- * (true) or not (false, standard).
- * @param int $mode (optional) The transfermode (either FTP_ASCII or
- * FTP_BINARY).
- *
- * @access public
- * @return mixed True on succes, otherwise PEAR::Error
- * @see NET_FTP_ERR_OVERWRITELOCALFILE_FORBIDDEN,
- * NET_FTP_ERR_OVERWRITELOCALFILE_FAILED, NET_FTP_ERR_OVERWRITELOCALFILE_FAILED,
- * NET_FTP_ERR_REMOTEPATHNODIR, NET_FTP_ERR_LOCALPATHNODIR,
- * NET_FTP_ERR_CREATELOCALDIR_FAILED
- */
- function getRecursive($remote_path, $local_p, $overwrite = false,
- $mode = null)
- {
- if (!class_exists('G')) {
- $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
- $docuroot = explode( '/', $realdocuroot );
- array_pop( $docuroot );
- $pathhome = implode( '/', $docuroot ) . '/';
- array_pop( $docuroot );
- $pathTrunk = implode( '/', $docuroot ) . '/';
- require_once($pathTrunk.'gulliver/system/class.g.php');
- }
-
- $filter = new InputFilter();
- $remote_path = $this->_constructPath($remote_path);
- if (!$this->_checkDir($remote_path)) {
- return $this->raiseError("Given remote-path '".$remote_path.
- "' seems not to be a directory.",
- NET_FTP_ERR_REMOTEPATHNODIR);
- }
- if (!$this->_checkDir($local_p)) {
- return $this->raiseError("Given local-path '".$local_p.
- "' seems not to be a directory.",
- NET_FTP_ERR_LOCALPATHNODIR);
- }
-
- if (!@is_dir($filter->validatePath($local_p))) {
- $sLocal_p = $filter->validatePath($local_p);
- $mkdir = self::mkdir;
- $res = $mkdir($sLocal_p);
- if (!$res) {
- return $this->raiseError("Could not create dir '$local_p'",
- NET_FTP_ERR_CREATELOCALDIR_FAILED);
- }
- }
- $dir_list = array();
- $dir_list = $this->ls($remote_path, NET_FTP_DIRS_ONLY);
- if (PEAR::isError($dir_list)) {
- return $dir_list;
- }
- foreach ($dir_list as $dir_entry) {
- if ($dir_entry['name'] != '.' && $dir_entry['name'] != '..') {
- $remote_path_new = $remote_path.$dir_entry["name"]."/";
- $local_p_new = $local_p.$dir_entry["name"]."/";
- $result = $this->getRecursive($remote_path_new,
- $local_p_new, $overwrite, $mode);
- if ($this->isError($result)) {
- return $result;
- }
- }
- }
- $file_list = array();
- $file_list = $this->ls($remote_path, NET_FTP_FILES_ONLY);
- if (PEAR::isError($file_list)) {
- return $file_list;
- }
- foreach ($file_list as $file_entry) {
- $remote_file = $remote_path.$file_entry["name"];
- $local_file = $local_p.$file_entry["name"];
- $result = $this->get($remote_file, $local_file, $overwrite, $mode);
- if ($this->isError($result)) {
- return $result;
- }
- }
- return true;
- }
-
- /**
- * This functionality allows you to transfer a whole directory-structure from
- * your local host to the remote-ftp. You have to give a remote-directory
- * (ending with '/') and the local directory (ending with '/') where to put the
- * files you download. The remote path is automatically completed with the
- * current-remote-dir, if you give a relative path to this function. You can
- * give a relative path for the $local_path, too. Then the script-basedir will
- * be used for comletion of the path.
- * The parameter $overwrite will determine, whether to overwrite existing files
- * or not.
- * Standard for this is false. Fourth you can explicitly set a mode for all
- * transfer actions done. If you do not set this, the method tries to determine
- * the transfer mode by checking your mode-directory for the file-extension. If
- * the extension is not inside the mode-directory, it will get your default
- * mode.
- *
- * @param string $local_path The path to download to
- * @param string $remote_path The path to download
- * @param bool $overwrite (optional) Whether to overwrite existing files
- * (true) or not (false, standard).
- * @param int $mode (optional) The transfermode (either FTP_ASCII or
- * FTP_BINARY).
- *
- * @access public
- * @return mixed True on succes, otherwise PEAR::Error
- * @see NET_FTP_ERR_LOCALFILENOTEXIST,
- * NET_FTP_ERR_OVERWRITEREMOTEFILE_FORBIDDEN,
- * NET_FTP_ERR_UPLOADFILE_FAILED, NET_FTP_ERR_LOCALPATHNODIR,
- * NET_FTP_ERR_REMOTEPATHNODIR
- */
- function putRecursive($local_path, $remote_path, $overwrite = false,
- $mode = null)
- {
- $remote_path = $this->_constructPath($remote_path);
- if (!file_exists($local_path) || !is_dir($local_path)) {
- return $this->raiseError("Given local-path '".$local_path.
- "' seems not to be a directory.",
- NET_FTP_ERR_LOCALPATHNODIR);
- }
- if (!$this->_checkDir($remote_path)) {
- return $this->raiseError("Given remote-path '".$remote_path.
- "' seems not to be a directory.",
- NET_FTP_ERR_REMOTEPATHNODIR);
- }
- $old_path = $this->pwd();
- if ($this->isError($this->cd($remote_path))) {
- $res = $this->mkdir($remote_path);
- if ($this->isError($res)) {
- return $res;
- }
- }
- $this->cd($old_path);
- $dir_list = $this->_lsLocal($local_path);
- foreach ($dir_list["dirs"] as $dir_entry) {
- // local directories do not have arrays as entry
- $remote_path_new = $remote_path.$dir_entry."/";
- $local_path_new = $local_path.$dir_entry."/";
- $result = $this->putRecursive($local_path_new,
- $remote_path_new, $overwrite, $mode);
- if ($this->isError($result)) {
- return $result;
- }
- }
-
- foreach ($dir_list["files"] as $file_entry) {
- $remote_file = $remote_path.$file_entry;
- $local_file = $local_path.$file_entry;
- $result = $this->put($local_file, $remote_file, $overwrite, $mode);
- if ($this->isError($result)) {
- return $result;
- }
- }
- return true;
- }
-
- /**
- * This checks, whether a file should be transfered in ascii- or binary-mode
- * by it's file-extension. If the file-extension is not set or
- * the extension is not inside one of the extension-dirs, the actual set
- * transfer-mode is returned.
- *
- * @param string $filename The filename to be checked
- *
- * @access public
- * @return int Either FTP_ASCII or FTP_BINARY
- */
- function checkFileExtension($filename)
- {
- if (($pos = strrpos($filename, '.')) === false) {
- return $this->_mode;
- } else {
- $ext = substr($filename, $pos + 1);
- }
-
- if (isset($this->_file_extensions[$ext])) {
- return $this->_file_extensions[$ext];
- }
-
- return $this->_mode;
- }
-
- /**
- * Set the hostname
- *
- * @param string $host The hostname to set
- *
- * @access public
- * @return bool True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_HOSTNAMENOSTRING
- */
- function setHostname($host)
- {
- if (!is_string($host)) {
- return PEAR::raiseError("Hostname must be a string.",
- NET_FTP_ERR_HOSTNAMENOSTRING);
- }
- $this->_hostname = $host;
- return true;
- }
-
- /**
- * Set the Port
- *
- * @param int $port The port to set
- *
- * @access public
- * @return bool True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_PORTLESSZERO
- */
- function setPort($port)
- {
- if (!is_int($port) || ($port < 0)) {
- PEAR::raiseError("Invalid port. Has to be integer >= 0",
- NET_FTP_ERR_PORTLESSZERO);
- }
- $this->_port = $port;
- return true;
- }
-
- /**
- * Set the Username
- *
- * @param string $user The username to set
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_USERNAMENOSTRING
- */
- function setUsername($user)
- {
- if (empty($user) || !is_string($user)) {
- return PEAR::raiseError('Username $user invalid.',
- NET_FTP_ERR_USERNAMENOSTRING);
- }
- $this->_username = $user;
- }
-
- /**
- * Set the password
- *
- * @param string $password The password to set
- *
- * @access private
- * @return void
- * @see NET_FTP_ERR_PASSWORDNOSTRING
- */
- function setPassword($password)
- {
- if (empty($password) || !is_string($password)) {
- return PEAR::raiseError('Password xxx invalid.',
- NET_FTP_ERR_PASSWORDNOSTRING);
- }
- $this->_password = $password;
- }
-
- /**
- * Set the transfer-mode. You can use the predefined constants
- * FTP_ASCII or FTP_BINARY. The mode will be stored for any further transfers.
- *
- * @param int $mode The mode to set
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_NOMODECONST
- */
- function setMode($mode)
- {
- if (($mode == FTP_ASCII) || ($mode == FTP_BINARY)) {
- $this->_mode = $mode;
- return true;
- } else {
- return $this->raiseError('FTP-Mode has either to be FTP_ASCII or'.
- 'FTP_BINARY', NET_FTP_ERR_NOMODECONST);
- }
- }
-
- /**
- * Set the transfer-method to passive mode
- *
- * @access public
- * @return void
- */
- function setPassive()
- {
- $this->_passv = true;
- @ftp_pasv($this->_handle, true);
- }
-
- /**
- * Set the transfer-method to active mode
- *
- * @access public
- * @return void
- */
- function setActive()
- {
- $this->_passv = false;
- @ftp_pasv($this->_handle, false);
- }
-
- /**
- * Set the timeout for FTP operations
- *
- * Use this method to set a timeout for FTP operation. Timeout has to be an
- * integer.
- *
- * @param int $timeout the timeout to use
- *
- * @access public
- * @return bool True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_TIMEOUTLESSZERO, NET_FTP_ERR_SETTIMEOUT_FAILED
- */
- function setTimeout ( $timeout = 0 )
- {
- if (!is_int($timeout) || ($timeout < 0)) {
- return PEAR::raiseError('Timeout '.$timeout.
- ' is invalid, has to be an integer >= 0',
- NET_FTP_ERR_TIMEOUTLESSZERO);
- }
- $this->_timeout = $timeout;
- if (isset($this->_handle) && is_resource($this->_handle)) {
- $res = @ftp_set_option($this->_handle, FTP_TIMEOUT_SEC, $timeout);
- } else {
- $res = true;
- }
- if (!$res) {
- return PEAR::raiseError("Set timeout failed.",
- NET_FTP_ERR_SETTIMEOUT_FAILED);
- }
- return true;
- }
-
- /**
- * Adds an extension to a mode-directory
- *
- * The mode-directory saves file-extensions coresponding to filetypes
- * (ascii e.g.: 'php', 'txt', 'htm',...; binary e.g.: 'jpg', 'gif', 'exe',...).
- * The extensions have to be saved without the '.'. And
- * can be predefined in an external file (see: getExtensionsFile()).
- *
- * The array is build like this: 'php' => FTP_ASCII, 'png' => FTP_BINARY
- *
- * To change the mode of an extension, just add it again with the new mode!
- *
- * @param int $mode Either FTP_ASCII or FTP_BINARY
- * @param string $ext Extension
- *
- * @access public
- * @return void
- */
- function addExtension($mode, $ext)
- {
- $this->_file_extensions[$ext] = $mode;
- }
-
- /**
- * This function removes an extension from the mode-directories
- * (described above).
- *
- * @param string $ext The extension to remove
- *
- * @access public
- * @return void
- */
- function removeExtension($ext)
- {
- if (isset($this->_file_extensions[$ext])) {
- unset($this->_file_extensions[$ext]);
- }
- }
-
- /**
- * This get's both (ascii- and binary-mode-directories) from the given file.
- * Beware, if you read a file into the mode-directory, all former set values
- * will be unset!
- *
- * Example file contents:
- * [ASCII]
- * asc = 0
- * txt = 0
- * [BINARY]
- * bin = 1
- * jpg = 1
- *
- * @param string $filename The file to get from
- *
- * @access public
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_EXTFILENOTEXIST, NET_FTP_ERR_EXTFILEREAD_FAILED
- */
- function getExtensionsFile($filename)
- {
- if (!file_exists($filename)) {
- return $this->raiseError("Extensions-file '$filename' does not exist",
- NET_FTP_ERR_EXTFILENOTEXIST);
- }
-
- if (!is_readable($filename)) {
- return $this->raiseError("Extensions-file '$filename' is not readable",
- NET_FTP_ERR_EXTFILEREAD_FAILED);
- }
-
- $exts = @parse_ini_file($filename, true);
- if (!is_array($exts)) {
- return $this->raiseError("Extensions-file '$filename' could not be".
- "loaded", NET_FTP_ERR_EXTFILELOAD_FAILED);
- }
-
- $this->_file_extensions = array();
-
- if (isset($exts['ASCII'])) {
- foreach ($exts['ASCII'] as $ext => $bogus) {
- $this->_file_extensions[$ext] = FTP_ASCII;
- }
- }
-
- if (isset($exts['BINARY'])) {
- foreach ($exts['BINARY'] as $ext => $bogus) {
- $this->_file_extensions[$ext] = FTP_BINARY;
- }
- }
-
- return true;
- }
-
- /**
- * Returns the hostname
- *
- * @access public
- * @return string The hostname
- */
- function getHostname()
- {
- return $this->_hostname;
- }
-
- /**
- * Returns the port
- *
- * @access public
- * @return int The port
- */
- function getPort()
- {
- return $this->_port;
- }
-
- /**
- * Returns the username
- *
- * @access public
- * @return string The username
- */
- function getUsername()
- {
- return $this->_username;
- }
-
- /**
- * Returns the password
- *
- * @access public
- * @return string The password
- */
- function getPassword()
- {
- return $this->_password;
- }
-
- /**
- * Returns the transfermode
- *
- * @access public
- * @return int The transfermode, either FTP_ASCII or FTP_BINARY.
- */
- function getMode()
- {
- return $this->_mode;
- }
-
- /**
- * Returns, whether the connection is set to passive mode or not
- *
- * @access public
- * @return bool True if passive-, false if active-mode
- */
- function isPassive()
- {
- return $this->_passv;
- }
-
- /**
- * Returns the mode set for a file-extension
- *
- * @param string $ext The extension you wanna ask for
- *
- * @return int Either FTP_ASCII, FTP_BINARY or NULL (if not set a mode for it)
- * @access public
- */
- function getExtensionMode($ext)
- {
- return @$this->_file_extensions[$ext];
- }
-
- /**
- * Get the currently set timeout.
- * Returns the actual timeout set.
- *
- * @access public
- * @return int The actual timeout
- */
- function getTimeout()
- {
- return ftp_get_option($this->_handle, FTP_TIMEOUT_SEC);
- }
-
- /**
- * Adds a Net_FTP_Observer instance to the list of observers
- * that are listening for messages emitted by this Net_FTP instance.
- *
- * @param object &$observer The Net_FTP_Observer instance to attach
- * as a listener.
- *
- * @return boolean True if the observer is successfully attached.
- * @access public
- * @since 1.3
- */
- function attach(&$observer)
- {
- if (!is_a($observer, 'Net_FTP_Observer')) {
- return false;
- }
-
- $this->_listeners[$observer->getId()] = &$observer;
- return true;
- }
-
- /**
- * Removes a Net_FTP_Observer instance from the list of observers.
- *
- * @param object $observer The Net_FTP_Observer instance to detach
- * from the list of listeners.
- *
- * @return boolean True if the observer is successfully detached.
- * @access public
- * @since 1.3
- */
- function detach($observer)
- {
- if (!is_a($observer, 'Net_FTP_Observer') ||
- !isset($this->_listeners[$observer->getId()])) {
- return false;
- }
-
- unset($this->_listeners[$observer->getId()]);
- return true;
- }
-
- /**
- * Informs each registered observer instance that a new message has been
- * sent.
- *
- * @param mixed $event A hash describing the net event.
- *
- * @access private
- * @since 1.3
- * @return void
- */
- function _announce($event)
- {
- foreach ($this->_listeners as $id => $listener) {
- $this->_listeners[$id]->notify($event);
- }
- }
-
- /**
- * Rebuild the path, if given relative
- *
- * This method will make a relative path absolute by prepending the current
- * remote directory in front of it.
- *
- * @param string $path The path to check and construct
- *
- * @access private
- * @return string The build path
- */
- function _constructPath($path)
- {
- if ((substr($path, 0, 1) != '/') && (substr($path, 0, 2) != './')) {
- $actual_dir = @ftp_pwd($this->_handle);
- if (substr($actual_dir, -1) != '/') {
- $actual_dir .= '/';
- }
- $path = $actual_dir.$path;
- }
- return $path;
- }
-
- /**
- * Checks, whether a given string is a directory-path (ends with "/") or not.
- *
- * @param string $path Path to check
- *
- * @access private
- * @return bool True if $path is a directory, otherwise false
- */
- function _checkDir($path)
- {
- if (!empty($path) && substr($path, (strlen($path) - 1), 1) == "/") {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * This will remove a file
- *
- * @param string $file The file to delete
- *
- * @access private
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_DELETEFILE_FAILED
- */
- function _rmFile($file)
- {
- if (substr($file, 0, 1) != "/") {
- $actual_dir = @ftp_pwd($this->_handle);
- if (substr($actual_dir, (strlen($actual_dir) - 2), 1) != "/") {
- $actual_dir .= "/";
- }
- $file = $actual_dir.$file;
- }
- $res = @ftp_delete($this->_handle, $file);
-
- if (!$res) {
- return $this->raiseError("Could not delete file '$file'.",
- NET_FTP_ERR_DELETEFILE_FAILED);
- } else {
- return true;
- }
- }
-
- /**
- * This will remove a dir
- *
- * @param string $dir The dir to delete
- *
- * @access private
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_REMOTEPATHNODIR, NET_FTP_ERR_DELETEDIR_FAILED
- */
- function _rmDir($dir)
- {
- if (substr($dir, (strlen($dir) - 1), 1) != "/") {
- return $this->raiseError("Directory name '".$dir.
- "' is invalid, has to end with '/'",
- NET_FTP_ERR_REMOTEPATHNODIR);
- }
- $res = @ftp_rmdir($this->_handle, $dir);
- if (!$res) {
- return $this->raiseError("Could not delete directory '$dir'.",
- NET_FTP_ERR_DELETEDIR_FAILED);
- } else {
- return true;
- }
- }
-
- /**
- * This will remove a dir and all subdirs and -files
- *
- * @param string $dir The dir to delete recursively
- *
- * @access private
- * @return mixed True on success, otherwise PEAR::Error
- * @see NET_FTP_ERR_REMOTEPATHNODIR, NET_FTP_ERR_DELETEDIR_FAILED
- */
- function _rmDirRecursive($dir)
- {
- if (substr($dir, (strlen($dir) - 1), 1) != "/") {
- return $this->raiseError("Directory name '".$dir.
- "' is invalid, has to end with '/'",
- NET_FTP_ERR_REMOTEPATHNODIR);
- }
- $file_list = $this->_lsFiles($dir);
- foreach ($file_list as $file) {
- $file = $dir.$file["name"];
- $res = $this->rm($file);
- if ($this->isError($res)) {
- return $res;
- }
- }
- $dir_list = $this->_lsDirs($dir);
- foreach ($dir_list as $new_dir) {
- if ($new_dir["name"] == '.' || $new_dir["name"] == '..') {
- continue;
- }
- $new_dir = $dir.$new_dir["name"]."/";
- $res = $this->_rmDirRecursive($new_dir);
- if ($this->isError($res)) {
- return $res;
- }
- }
- $res = $this->_rmDir($dir);
- if (PEAR::isError($res)) {
- return $res;
- } else {
- return true;
- }
- }
-
- /**
- * Lists up files and directories
- *
- * @param string $dir The directory to list up
- *
- * @access private
- * @return array An array of dirs and files
- */
- function _lsBoth($dir)
- {
- $list_splitted = $this->_listAndParse($dir);
- if (PEAR::isError($list_splitted)) {
- return $list_splitted;
- }
- if (!is_array($list_splitted["files"])) {
- $list_splitted["files"] = array();
- }
- if (!is_array($list_splitted["dirs"])) {
- $list_splitted["dirs"] = array();
- }
- $res = array();
- @array_splice($res, 0, 0, $list_splitted["files"]);
- @array_splice($res, 0, 0, $list_splitted["dirs"]);
- return $res;
- }
-
- /**
- * Lists up directories
- *
- * @param string $dir The directory to list up
- *
- * @access private
- * @return array An array of dirs
- */
- function _lsDirs($dir)
- {
- $list = $this->_listAndParse($dir);
- if (PEAR::isError($list)) {
- return $list;
- }
- return $list["dirs"];
- }
-
- /**
- * Lists up files
- *
- * @param string $dir The directory to list up
- *
- * @access private
- * @return array An array of files
- */
- function _lsFiles($dir)
- {
- $list = $this->_listAndParse($dir);
- if (PEAR::isError($list)) {
- return $list;
- }
- return $list["files"];
- }
-
- /**
- * This lists up the directory-content and parses the items into well-formated
- * arrays.
- * The results of this array are sorted (dirs on top, sorted by name;
- * files below, sorted by name).
- *
- * @param string $dir The directory to parse
- *
- * @access private
- * @return array Lists of dirs and files
- * @see NET_FTP_ERR_RAWDIRLIST_FAILED
- */
- function _listAndParse($dir)
- {
- $dirs_list = array();
- $files_list = array();
- $dir_list = @ftp_rawlist($this->_handle, $dir);
- if (!is_array($dir_list)) {
- return PEAR::raiseError('Could not get raw directory listing.',
- NET_FTP_ERR_RAWDIRLIST_FAILED);
- }
-
- foreach ($dir_list AS $k=>$v) {
- if (strncmp($v, 'total: ', 7) == 0 && preg_match('/total: \d+/', $v)) {
- unset($dir_list[$k]);
- break; // usually there is just one line like this
- }
- }
-
- // Handle empty directories
- if (count($dir_list) == 0) {
- return array('dirs' => $dirs_list, 'files' => $files_list);
- }
-
- // Exception for some FTP servers seem to return this wiered result instead
- // of an empty list
- if (count($dirs_list) == 1 && $dirs_list[0] == 'total 0') {
- return array('dirs' => array(), 'files' => $files_list);
- }
-
- if (!isset($this->_matcher) || PEAR::isError($this->_matcher)) {
- $this->_matcher = $this->_determineOSMatch($dir_list);
- if (PEAR::isError($this->_matcher)) {
- return $this->_matcher;
- }
- }
- foreach ($dir_list as $entry) {
- if (!preg_match($this->_matcher['pattern'], $entry, $m)) {
- continue;
- }
- $entry = array();
- foreach ($this->_matcher['map'] as $key=>$val) {
- $entry[$key] = $m[$val];
- }
- $entry['stamp'] = $this->_parseDate($entry['date']);
-
- if ($entry['is_dir']) {
- $dirs_list[] = $entry;
- } else {
- $files_list[] = $entry;
- }
- }
- @usort($dirs_list, array("Net_FTP", "_natSort"));
- @usort($files_list, array("Net_FTP", "_natSort"));
- $res["dirs"] = (is_array($dirs_list)) ? $dirs_list : array();
- $res["files"] = (is_array($files_list)) ? $files_list : array();
- return $res;
- }
-
- /**
- * Determine server OS
- * This determines the server OS and returns a valid regex to parse
- * ls() output.
- *
- * @param array &$dir_list The raw dir list to parse
- *
- * @access private
- * @return mixed An array of 'pattern' and 'map' on success, otherwise
- * PEAR::Error
- * @see NET_FTP_ERR_DIRLIST_UNSUPPORTED
- */
- function _determineOSMatch(&$dir_list)
- {
- foreach ($dir_list as $entry) {
- foreach ($this->_ls_match as $os => $match) {
- $matches = array();
- if (preg_match($match['pattern'], $entry, $matches)) {
- return $match;
- }
- }
- }
- $error = 'The list style of your server seems not to be supported. Please'.
- 'email a "$ftp->ls(NET_FTP_RAWLIST);" output plus info on the'.
- 'server to the maintainer of this package to get it supported!'.
- 'Thanks for your help!';
- return PEAR::raiseError($error, NET_FTP_ERR_DIRLIST_UNSUPPORTED);
- }
-
- /**
- * Lists a local directory
- *
- * @param string $dir_path The dir to list
- *
- * @access private
- * @return array The list of dirs and files
- */
- function _lsLocal($dir_path)
- {
- $dir = dir($dir_path);
- $dir_list = array();
- $file_list = array();
- while (false !== ($entry = $dir->read())) {
- if (($entry != '.') && ($entry != '..')) {
- if (is_dir($dir_path.$entry)) {
- $dir_list[] = $entry;
- } else {
- $file_list[] = $entry;
- }
- }
- }
- $dir->close();
- $res['dirs'] = $dir_list;
- $res['files'] = $file_list;
- return $res;
- }
-
- /**
- * Function for use with usort().
- * Compares the list-array-elements by name.
- *
- * @param string $item_1 first item to be compared
- * @param string $item_2 second item to be compared
- *
- * @access private
- * @return int < 0 if $item_1 is less than $item_2, 0 if equal and > 0 otherwise
- */
- function _natSort($item_1, $item_2)
- {
- return strnatcmp($item_1['name'], $item_2['name']);
- }
-
- /**
- * Parse dates to timestamps
- *
- * @param string $date Date
- *
- * @access private
- * @return int Timestamp
- * @see NET_FTP_ERR_DATEFORMAT_FAILED
- */
- function _parseDate($date)
- {
- // Sep 10 22:06 => Sep 10, 22:06
- if (preg_match('/([A-Za-z]+)[ ]+([0-9]+)[ ]+([0-9]+):([0-9]+)/', $date,
- $res)) {
- $year = date('Y');
- $month = $res[1];
- $day = $res[2];
- $hour = $res[3];
- $minute = $res[4];
- $date = "$month $day, $year $hour:$minute";
- $tmpDate = strtotime($date);
- if ($tmpDate > time()) {
- $year--;
- $date = "$month $day, $year $hour:$minute";
- }
- } elseif (preg_match('/^\d\d-\d\d-\d\d/', $date)) {
- // 09-10-04 => 09/10/04
- $date = str_replace('-', '/', $date);
- }
- $res = strtotime($date);
- if (!$res) {
- return $this->raiseError('Dateconversion failed.',
- NET_FTP_ERR_DATEFORMAT_FAILED);
- }
- return $res;
- }
-}
-?>
diff --git a/thirdparty/pear/Net/FTP/Observer.php b/thirdparty/pear/Net/FTP/Observer.php
deleted file mode 100644
index d3e38b62e..000000000
--- a/thirdparty/pear/Net/FTP/Observer.php
+++ /dev/null
@@ -1,116 +0,0 @@
-
- * @author Laurent Laville
- * @author Chuck Hagenbuch
- * @copyright 1997-2008 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Observer.php,v 1.4.2.1 2008/01/07 14:21:22 jschippers Exp $
- * @link http://pear.php.net/package/Net_FTP
- * @since File available since Release 0.0.1
- */
-
-/**
- * This class implements the Observer part of a Subject-Observer
- * design pattern. It listens to the events sent by a Net_FTP instance.
- * This module had many influences from the Log_observer code.
- *
- * @category Networking
- * @package FTP
- * @author Laurent Laville
- * @author Chuck Hagenbuch
- * @author Tobias Schlitt
- * @copyright 1997-2008 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version Release: 1.3.7
- * @link http://pear.php.net/package/Net_FTP
- * @since 1.3.0.0
- * @access public
- *
- * @example observer_upload.php An example of Net_FTP_Observer implementation.
- */
-class Net_FTP_Observer
-{
- /**
- * Instance-specific unique identification number.
- *
- * @var integer
- * @since 1.3.0
- * @access private
- */
- var $_id;
-
- /**
- * Creates a new basic Net_FTP_Observer instance.
- *
- * @since 1.3.0
- * @access public
- */
- function Net_FTP_Observer()
- {
- $this->_id = $this->encryptOld(microtime());
- }
-
- /**
- * Returns the listener's identifier
- *
- * @return string The listener's identifier
- * @since 1.3.0
- * @access public
- */
- function getId()
- {
- return $this->_id;
- }
-
- /**
- * This is a stub method to make sure that Net_FTP_Observer classes do
- * something when they are notified of a message. The default behavior
- * is to just do nothing.
- * You should override this method.
- *
- * @param mixed $event A hash describing the net event.
- *
- * @since 1.3.0
- * @access public
- * @return void
- */
- function notify($event)
- {
- return;
- }
-
- public function encryptOld($string)
- {
- if (!class_exists('G')) {
- $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
- $docuroot = explode( '/', $realdocuroot );
- array_pop( $docuroot );
- $pathhome = implode( '/', $docuroot ) . '/';
- array_pop( $docuroot );
- $pathTrunk = implode( '/', $docuroot ) . '/';
- require_once($pathTrunk.'gulliver/system/class.g.php');
- }
- return G::encryptOld($string);
- }
-
-}
-?>
diff --git a/thirdparty/pear/Net/FTP/Socket.php b/thirdparty/pear/Net/FTP/Socket.php
deleted file mode 100644
index 2888125ea..000000000
--- a/thirdparty/pear/Net/FTP/Socket.php
+++ /dev/null
@@ -1,800 +0,0 @@
-
- * @copyright 1997-2008 The PHP Group
- * @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Socket.php,v 1.5.2.2 2008/04/22 19:47:08 jschippers Exp $
- * @link http://pear.php.net/package/Net_FTP
- * @since File available since Release 0.0.1
- */
-
-error_reporting(E_ALL);
-
-/**
-* Default FTP extension constants
-*/
-define('FTP_ASCII', 0);
-define('FTP_TEXT', 0);
-define('FTP_BINARY', 1);
-define('FTP_IMAGE', 1);
-define('FTP_TIMEOUT_SEC', 0);
-
-/**
-* What needs to be done overall?
-* #1 Install the rest of these functions
-* #2 Document better
-* #3 Alot of other things I don't remember
-*/
-
-/*
- * !!! NOTE !!!
- * Most of the comment's are "not working",
- * meaning they are not all up-to-date
- * !!! NOTE !!!
- */
-
-/**
- * &resource ftp_connect ( string host [, int port [, int timeout ] ] );
- *
- * Opens an FTP connection and return resource or false on failure.
- *
- * FTP Success respons code: 220
- *
- * @param string $host Host to connect to
- * @param int $port Optional, port to connect to
- * @param int $timeout Optional, seconds until function timeouts
- *
- * @todo The FTP extension has ftp_get_option() function which returns the
- * timeout variable. This function needs to be created and contain it as
- * static variable.
- * @todo The FTP extension has ftp_set_option() function which sets the
- * timeout variable. This function needs to be created and called here.
- * @access public
- * @return &resource
- */
-function &ftp_connect($host, $port = 21, $timeout = 90)
-{
- $false = false; // We are going to return refrence (E_STRICT)
-
- if (!is_string($host) || !is_integer($port) || !is_integer($timeout)) {
- return $false;
- }
-
- $control = @fsockopen($host, $port, $iError, $sError,
- $timeout);
- $GLOBALS['_NET_FTP']['timeout'] = $timeout;
-
- if (!is_resource($control)) {
- return $false;
- }
-
- stream_set_blocking($control, true);
- stream_set_timeout($control, $timeout);
-
- do {
- $content[] = fgets($control, 8129);
- $array = socket_get_status($control);
- } while ($array['unread_bytes'] > 0);
-
- if (substr($content[count($content)-1], 0, 3) == 220) {
- return $control;
- }
-
- return $false;
-}
-
-/**
- * boolean ftp_login ( resource stream, string username, string password );
- *
- * Logs in to an given FTP connection stream.
- * Returns TRUE on success or FALSE on failure.
- *
- * NOTE:
- * Username and password are *not* optional. Function will *not*
- * assume "anonymous" if username and/or password is empty
- *
- * FTP Success respons code: 230
- *
- * @param resource &$control FTP resource to login to
- * @param string $username FTP Username to be used
- * @param string $password FTP Password to be used
- *
- * @access public
- * @return boolean
- */
-function ftp_login(&$control, $username, $password)
-{
- if (!is_resource($control) || is_null($username)) {
- return false;
- }
-
- fputs($control, 'USER '.$username."\r\n");
- $contents = array();
- do {
- $contents[] = fgets($control, 8192);
- $array = socket_get_status($control);
- } while ($array['unread_bytes'] > 0);
-
- if (substr($contents[count($contents)-1], 0, 3) != 331) {
- return false;
- }
-
- fputs($control, 'PASS '.$password."\r\n");
- $contents = array();
- do {
- $contents[] = fgets($control, 8192);
- $array = socket_get_status($control);
- } while ($array['unread_bytes']);
-
- if (substr($contents[count($contents)-1], 0, 3) == 230) {
- return true;
- }
-
- trigger_error('ftp_login() [function.ftp-login'.
- ']: '.$contents[count($contents)-1], E_USER_WARNING);
-
- return false;
-}
-
-/**
- * boolean ftp_quit ( resource stream );
- *
- * Closes FTP connection.
- * Returns TRUE or FALSE on error.
- *
- * NOTE: The PHP function ftp_quit is *alias* to ftp_close, here it is
- * the *other-way-around* ( ftp_close() is alias to ftp_quit() ).
- *
- * NOTE:
- * resource is set to null since unset() can't unset the variable.
- *
- * @param resource &$control FTP resource
- *
- * @access public
- * @return boolean
- */
-function ftp_quit(&$control)
-{
- if (!is_resource($control)) {
- return false;
- }
-
- fputs($control, 'QUIT'."\r\n");
- fclose($control);
- $control = null;
- return true;
-}
-
-/**
- * Alias to ftp_quit()
- *
- * @param resource &$control FTP resource
- *
- * @see ftp_quit()
- * @access public
- * @return boolean
- */
-function ftp_close(&$control)
-{
- return ftp_quit($control);
-}
-
-/**
- * string ftp_pwd ( resource stream );
- *
- * Gets the current directory name.
- * Returns the current directory.
- *
- * Needs data connection: NO
- * Success response code: 257
- *
- * @param resource &$control FTP resource
- *
- * @access public
- * @return string
- */
-function ftp_pwd(&$control)
-{
- if (!is_resource($control)) {
- return $control;
- }
-
- fputs($control, 'PWD'."\r\n");
-
- $content = array();
- do {
- $content[] = fgets($control, 8192);
- $array = socket_get_status($control);
- } while ($array['unread_bytes'] > 0);
-
- if (substr($cont = $content[count($content)-1], 0, 3) == 257) {
- $pos = strpos($cont, '"')+1;
- $pos2 = strrpos($cont, '"') - $pos;
- $path = substr($cont, $pos, $pos2);
- return $path;
- }
-
- return false;
-}
-
-/**
- * boolean ftp_chdir ( resource stream, string directory );
- *
- * Changes the current directory to the specified directory.
- * Returns TRUE on success or FALSE on failure.
- *
- * FTP success response code: 250
- * Needs data connection: NO
- *
- * @param resource &$control FTP stream
- * @param string $pwd Directory name
- *
- * @access public
- * @return boolean
- */
-function ftp_chdir(&$control, $pwd)
-{
- if (!is_resource($control) || !is_string($pwd)) {
- return false;
- }
-
- fputs($control, 'CWD '.$pwd."\r\n");
- $content = array();
- do {
- $content[] = fgets($control, 8192);
- $array = socket_get_status($control);
- } while ($array['unread_bytes'] > 0);
-
- if (substr($content[count($content)-1], 0, 3) == 250) {
- return true;
- }
-
- trigger_error('ftp_chdir() [function.ftp-chdir]:
- ' .$content[count($content)-1], E_USER_WARNING);
-
- return false;
-}
-
-$_NET_FTP = array();
-$_NET_FTP['USE_PASSIVE'] = false;
-$_NET_FTP['DATA'] = null;
-
-/**
- * boolean ftp_pasv ( resource stream, boolean passive );
- *
- * Toggles passive mode ON/OFF.
- * Returns TRUE on success or FALSE on failure.
- *
- * Comment:
- * Although my lack of C knowlege I checked how the PHP FTP extension
- * do things here. Seems like they create the data connection and store
- * it in object for other functions to use.
- * This is now done here.
- *
- * FTP success response code: 227
- *
- * @param stream &$control FTP stream
- * @param boolean $pasv True to switch to passive, false for active mode
- *
- * @access public
- * @return boolean
- */
-function ftp_pasv(&$control, $pasv)
-{
- if (!is_resource($control) || !is_bool($pasv)) {
- return false;
- }
-
- // If data connection exists, destroy it
- if (isset($GLOBALS['_NET_FTP']['DATA'])) {
- fclose($GLOBALS['_NET_FTP']['DATA']);
- $GLOBALS['_NET_FTP']['DATA'] = null;
-
- do {
- fgets($control, 16);
- $array = socket_get_status($control);
- } while ($array['unread_bytes'] > 0);
- }
-
- // Are we suppost to create active or passive connection?
- if (!$pasv) {
- $GLOBALS['_NET_FTP']['USE_PASSIVE'] = false;
- // Pick random "low bit"
- $low = rand(39, 250);
- // Pick random "high bit"
- $high = rand(39, 250);
- // Lowest possible port would be; 10023
- // Highest possible port would be; 64246
-
- $port = ($low<<8)+$high;
- $ip = str_replace('.', ',', $_SERVER['SERVER_ADDR']);
- $s = $ip.','.$low.','.$high;
-
- $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- if (is_resource($socket)) {
- if (socket_bind($socket, '0.0.0.0', $port)) {
- if (socket_listen($socket)) {
- $GLOBALS['_NET_FTP']['DATA'] = &$socket;
- fputs($control, 'PORT '.$s."\r\n");
- $line = fgets($control, 512);
- if (substr($line, 0, 3) == 200) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- // Since we are here, we are suppost to create passive data connection.
- $i = fputs($control, 'PASV' ."\r\n");
-
- $content = array();
- do {
- $content[] = fgets($control, 128);
- $array = socket_get_status($control);
- } while ($array['unread_bytes']);
-
- if (substr($cont = $content[count($content)-1], 0, 3) != 227) {
- return false;
- }
-
- $pos = strpos($cont, '(')+1;
- $pos2 = strrpos($cont, ')')-$pos;
- $string = substr($cont, $pos, $pos2);
-
- $array = explode(',', $string);
- // IP we are connecting to
- $ip = $array[0]. '.' .$array[1]. '.' .$array[2]. '.' .$array[3];
- // Port ( 256*lowbit + highbit
- $port = ($array[4] << 8)+$array[5];
-
- // Our data connection
- $data = fsockopen($ip, $port, $iError, $sError,
- $GLOBALS['_NET_FTP']['timeout']);
-
- if (is_resource($data)) {
- $GLOBALS['_NET_FTP']['USE_PASSIVE'] = true;
- $GLOBALS['_NET_FTP']['DATA'] = &$data;
- stream_set_blocking($data, true);
- stream_set_timeout($data, $GLOBALS['_NET_FTP']['timeout']);
-
- return true;
- }
-
- return false;
-}
-
-/**
- * array ftp_rawlist ( resource stream, string directory [,bool recursive] );
- *
- * Returns a detailed list of files in the given directory.
- *
- * Needs data connection: YES
- *
- * @param integer &$control FTP resource
- * @param string $pwd Path to retrieve
- * @param boolean $recursive Optional, retrieve recursive listing
- *
- * @todo Enable the recursive feature.
- * @access public
- * @return array
- */
-function ftp_rawlist(&$control, $pwd, $recursive = false)
-{
- if (!is_resource($control) || !is_string($pwd)) {
- return false;
- }
-
- if (!isset($GLOBALS['_NET_FTP']['DATA']) ||
- !is_resource($GLOBALS['_NET_FTP']['DATA'])) {
- ftp_pasv($control, $GLOBALS['_NET_FTP']['USE_PASSIVE']);
- }
- fputs($control, 'LIST '.$pwd."\r\n");
-
- $msg = fgets($control, 512);
- if (substr($msg, 0, 3) == 425) {
- return false;
- }
-
- $data = &$GLOBALS['_NET_FTP']['DATA'];
- if (!$GLOBALS['_NET_FTP']['USE_PASSIVE']) {
- $data = &socket_accept($data);
- }
-
- $content = array();
-
- switch ($GLOBALS['_NET_FTP']['USE_PASSIVE']) {
- case true:
- while (true) {
- $string = rtrim(fgets($data, 1024));
-
- if ($string=='') {
- break;
- }
-
- $content[] = $string;
- }
-
- fclose($data);
- break;
-
- case false:
- $string = socket_read($data, 1024, PHP_BINARY_READ);
-
- $content = explode("\n", $string);
- unset($content[count($content)-1]);
-
- socket_close($GLOBALS['_NET_FTP']['DATA']);
- socket_close($data);
- break;
- }
-
- $data = $GLOBALS['_NET_FTP']['DATA'] = null;
-
- $f = fgets($control, 1024);
- return $content;
-}
-
-/**
- * string ftp_systype ( resource stream );
- *
- * Gets system type identifier of remote FTP server
- * Returns the remote system type
- *
- * @param resource &$control FTP resource
- *
- * @access public
- * @return string
- */
-function ftp_systype(&$control)
-{
- if (!is_resource($control)) {
- return false;
- }
-
- fputs($control, 'SYST'."\r\n");
- $line = fgets($control, 256);
-
- if (substr($line, 0, 3) != 215) {
- return false;
- }
-
- $os = substr($line, 4, strpos($line, ' ', 4)-4);
- return $os;
-}
-
-/**
- * boolean ftp_alloc ( resource stream, integer bytes [, string &message ] );
- *
- * Allocates space for a file to be uploaded
- * Return TRUE on success or FALSE on failure
- *
- * NOTE; Many FTP servers do not support this command and/or don't need it.
- *
- * FTP success respons key: Belive it's 200
- * Needs data connection: NO
- *
- * @param resource &$control FTP stream
- * @param integer $int Space to allocate
- * @param string &$msg Optional, textual representation of the servers response
- * will be returned by reference
- *
- * @access public
- * @return boolean
- */
-function ftp_alloc(&$control, $int, &$msg = null)
-{
- if (!is_resource($control) || !is_integer($int)) {
- return false;
- }
-
- fputs($control, 'ALLO '.$int.' R '.$int."\r\n");
-
- $msg = rtrim(fgets($control, 256));
-
- $code = substr($msg, 0, 3);
- if ($code == 200 || $code == 202) {
- return true;
- }
-
- return false;
-}
-
-/**
- * bool ftp_put ( resource stream, string remote_file, string local_file,
- * int mode [, int startpos ] );
- *
- * Uploads a file to the FTP server
- * Returns TRUE on success or FALSE on failure.
- *
- * NOTE:
- * The transfer mode specified must be either FTP_ASCII or FTP_BINARY.
- *
- * @param resource &$control FTP stream
- * @param string $remote Remote file to write
- * @param string $local Local file to upload
- * @param integer $mode Upload mode, FTP_ASCI || FTP_BINARY
- * @param integer $pos Optional, start upload at position
- *
- * @access public
- * @return boolean
- */
-function ftp_put(&$control, $remote, $local, $mode, $pos = 0)
-{
- if (!is_resource($control) || !is_readable($local) ||
- !is_integer($mode) || !is_integer($pos)) {
- return false;
- }
-
- $types = array (
- 0 => 'A',
- 1 => 'I'
- );
- $windows = array (
- 0 => 't',
- 1 => 'b'
- );
-
- /**
- * TYPE values:
- * A ( ASCII )
- * I ( BINARY )
- * E ( EBCDIC )
- * L ( BYTE )
- */
-
- if (!isset($GLOBALS['_NET_FTP']['DATA']) ||
- !is_resource($GLOBALS['_NET_FTP']['DATA'])) {
- ftp_pasv($control, $GLOBALS['_NET_FTP']['USE_PASSIVE']);
-
- }
- // Establish data connection variable
- $data = &$GLOBALS['_NET_FTP']['DATA'];
-
- // Decide TYPE to use
- fputs($control, 'TYPE '.$types[$mode]."\r\n");
- $line = fgets($control, 256); // "Type set to TYPE"
- if (substr($line, 0, 3) != 200) {
- return false;
- }
-
- fputs($control, 'STOR '.$remote."\r\n");
- sleep(1);
- $line = fgets($control, 256); // "Opening TYPE mode data connect."
-
- if (substr($line, 0, 3) != 150) {
- return false;
- }
-
- // Creating resource to $local file
- $fp = fopen($local, 'r'. $windows[$mode]);
- if (!is_resource($fp)) {
- $fp = null;
- return false;
- }
-
- // Loop throu that file and echo it to the data socket
- $i = 0;
- switch ($GLOBALS['_NET_FTP']['USE_PASSIVE']) {
- case false:
- $data = &socket_accept($data);
- while (!feof($fp)) {
- $i += socket_write($data, fread($fp, 10240), 10240);
- }
- socket_close($data);
- break;
-
- case true:
- while (!feof($fp)) {
- $i += fputs($data, fread($fp, 10240), 10240);
- }
-
- fclose($data);
- break;
- }
-
- $data = null;
- do {
- $line = fgets($control, 256);
- } while (substr($line, 0, 4) != "226 ");
- return true;
-}
-
-/**
- * Retrieve a remote file to a local file
- * Returns TRUE on success or FALSE on failure
- *
- * @param integer &$control Stream ID
- * @param string $local Local filename
- * @param string $remote Remote filename
- * @param integer $mode Transfer mode (FTP_ASCII or FTP_BINARY)
- * @param integer $resume Resume the file transfer or not
- *
- * @access public
- * @return boolean
- */
-function ftp_get(&$control, $local, $remote, $mode, $resume = 0, $wr='w')
-{
- if (!class_exists('G')) {
- $realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
- $docuroot = explode('/', $realdocuroot);
- array_pop($docuroot);
- $pathhome = implode('/', $docuroot) . '/';
- array_pop($docuroot);
- $pathTrunk = implode('/', $docuroot) . '/';
- require_once($pathTrunk . 'gulliver/system/class.g.php');
- }
-
- $filter = new InputFilter();
- if (!is_resource($control) || !is_writable(dirname($local)) ||
- !is_integer($mode) || !is_integer($resume)) {
- return false;
- }
- $types = array (
- 0 => 'A',
- 1 => 'I'
- );
- $windows = array (
- 0 => 't',
- 1 => 'b'
- );
-
- if (!isset($GLOBALS['_NET_FTP']['DATA']) ||
- !is_resource($GLOBALS['_NET_FTP'][ 'DATA'])) {
- ftp_pasv($control, $GLOBALS['_NET_FTP']['USE_PASSIVE']);
- }
- $data = &$GLOBALS['NET_FTP']['DATA'];
-
- fputs($control, 'TYPE '.$types[$mode]."\r\n");
- $line = fgets($control, 256);
- if (substr($line, 0, 3) != 200) {
- return false;
- }
-
- if(is_file($filter->validatePath($local))) {
- $var = $wr.$windows[$mode];
- $fp = fopen($filter->validatePath($local), $var);
- } else {
- $fp = false;
- }
-
- if (!is_resource($fp)) {
- $fp = null;
- return false;
- }
-}
-
-/**
- * Changes to the parent directory
- * Returns TRUE on success or FALSE on failure
- *
- * @param integer &$control Stream ID
- *
- * @access public
- * @return boolean
- */
-function ftp_cdup(&$control)
-{
- fputs($control, 'CDUP'."\r\n");
- $line = fgets($control, 256);
-
- if (substr($line, 0, 3) != 250) {
- return false;
- }
-
- return true;
-}
-
-/**
- * Set permissions on a file via FTP
- * Returns the new file permission on success or false on error
- *
- * NOTE: This command is *not* supported by the standard
- * NOTE: This command not ready!
- *
- * @param integer &$control Stream ID
- * @param integer $mode Octal value
- * @param string $file File to change permissions on
- *
- * @todo Figure out a way to chmod files via FTP
- * @access public
- * @return integer
- */
-function ftp_chmod(&$control, $mode, $file)
-{
- if (!is_resource($control) || !is_integer($mode) || !is_string($file)) {
- return false;
- }
-
- // chmod not in the standard, proftpd doesn't recognize it
- // use SITE CHMOD?
- fputs($control, 'SITE CHMOD '.$mode. ' ' .$file."\r\n");
- $line = fgets($control, 256);
-
- if (substr($line, 0, 3) == 200) {
- return $mode;
- }
-
- trigger_error('ftp_chmod() [function.ftp-chmod]: ' .
- rtrim($line), E_USER_WARNING);
- return false;
-}
-
-/**
- * Deletes a file on the FTP server
- * Returns TRUE on success or FALSE on failure
- *
- * @param integer &$control Stream ID
- * @param string $path File to delete
- *
- * @access public
- * @return boolean
- */
-function ftp_delete(&$control, $path)
-{
- if (!is_resource($control) || !is_string($path)) {
- return false;
- }
-
- fputs($control, 'DELE '.$path."\r\n");
- $line = fgets($control, 256);
-
- if (substr($line, 0, 3) == 250) {
- return true;
- }
-
- return false;
-}
-
-/**
- * Requests execution of a program on the FTP server
- * NOTE; SITE EXEC is *not* supported by the standart
- * Returns TRUE on success or FALSE on error
- *
- * @param integer &$control Stream ID
- * @param string $cmd Command to send
- *
- * @access public
- * @todo Look a littlebit better into this
- * @return boolean
- */
-function ftp_exec(&$control, $cmd)
-{
- if (!is_resource($control) || !is_string($cmd)) {
- return false;
- }
- // Command not defined in the standart
- // proftpd doesn't recognize SITE EXEC (only help,chgrp,chmod and ratio)
- fputs($control, 'SITE EXEC '.$cmd."\r\n");
- $line = fgets($control, 256);
-
- // php.net/ftp_exec uses respons code 200 to verify if command was sent
- // successfully or not, so we'll just do the same
- if (substr($line, 0, 3) == 200) {
- return true;
- }
-
- return false;
-}
-?>
diff --git a/thirdparty/pear/Net/IDNA.php b/thirdparty/pear/Net/IDNA.php
deleted file mode 100644
index 14749d580..000000000
--- a/thirdparty/pear/Net/IDNA.php
+++ /dev/null
@@ -1,101 +0,0 @@
-
- * @author Matthias Sommerfeld
- * @package Net
- * @version $Id: IDNA.php,v 1.1 2008/03/22 12:39:37 neufeind Exp $
- */
-
-class Net_IDNA
-{
- // {{{ factory
- /**
- * Attempts to return a concrete IDNA instance for either php4 or php5.
- *
- * @param array $params Set of paramaters
- * @return object IDNA The newly created concrete Log instance, or an
- * false on an error.
- * @access public
- */
- function &getInstance($params = array())
- {
- $version = explode( '.', phpversion() );
- $handler = ((int)$version[0] > 4) ? 'php5' : 'php4';
- $class = 'Net_IDNA_' . $handler;
- $classfile = 'Net/IDNA/' . $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)) {
- $instance = &new $class($params);
- return $instance;
- }
-
- return false;
- }
- // }}}
-
- // {{{ singleton
- /**
- * Attempts to return a concrete IDNA instance for either php4 or php5,
- * only creating a new instance if no IDNA instance with the same
- * parameters currently exists.
- *
- * @param array $params Set of paramaters
- * @return object IDNA The newly created concrete Log instance, or an
- * false on an error.
- * @access public
- */
- function &singleton($params = array())
- {
- static $instances;
- if (!isset($instances)) {
- $instances = array();
- }
-
- $signature = serialize($params);
- if (!isset($instances[$signature])) {
- $instances[$signature] = &Net_IDNA::getInstance($params);
- }
-
- return $instances[$signature];
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Net/IDNA/php5.php b/thirdparty/pear/Net/IDNA/php5.php
deleted file mode 100644
index cc8484b92..000000000
--- a/thirdparty/pear/Net/IDNA/php5.php
+++ /dev/null
@@ -1,3233 +0,0 @@
-
- * @author Matthias Sommerfeld
- * @author Stefan Neufeind
- * @package Net
- * @version $Id: php5.php,v 1.3 2008/03/22 15:24:17 neufeind Exp $
- */
-
-class Net_IDNA_php5
-{
- // {{{ npdata
- /**
- * These Unicode codepoints are
- * mapped to nothing, See RFC3454 for details
- *
- * @static
- * @var array
- * @access private
- */
- private static $_np_map_nothing = array(
- 0xAD,
- 0x34F,
- 0x1806,
- 0x180B,
- 0x180C,
- 0x180D,
- 0x200B,
- 0x200C,
- 0x200D,
- 0x2060,
- 0xFE00,
- 0xFE01,
- 0xFE02,
- 0xFE03,
- 0xFE04,
- 0xFE05,
- 0xFE06,
- 0xFE07,
- 0xFE08,
- 0xFE09,
- 0xFE0A,
- 0xFE0B,
- 0xFE0C,
- 0xFE0D,
- 0xFE0E,
- 0xFE0F,
- 0xFEFF
- );
-
- /**
- * Prohibited codepints
- *
- * @static
- * @var array
- * @access private
- */
- private static $_general_prohibited = array(
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9,
- 0xA,
- 0xB,
- 0xC,
- 0xD,
- 0xE,
- 0xF,
- 0x10,
- 0x11,
- 0x12,
- 0x13,
- 0x14,
- 0x15,
- 0x16,
- 0x17,
- 0x18,
- 0x19,
- 0x1A,
- 0x1B,
- 0x1C,
- 0x1D,
- 0x1E,
- 0x1F,
- 0x20,
- 0x21,
- 0x22,
- 0x23,
- 0x24,
- 0x25,
- 0x26,
- 0x27,
- 0x28,
- 0x29,
- 0x2A,
- 0x2B,
- 0x2C,
- 0x2F,
- 0x3B,
- 0x3C,
- 0x3D,
- 0x3E,
- 0x3F,
- 0x40,
- 0x5B,
- 0x5C,
- 0x5D,
- 0x5E,
- 0x5F,
- 0x60,
- 0x7B,
- 0x7C,
- 0x7D,
- 0x7E,
- 0x7F,
- 0x3002
- );
-
- /**
- * Codepints prohibited by Nameprep
- * @static
- * @var array
- * @access private
- */
- private static $_np_prohibit = array(
- 0xA0,
- 0x1680,
- 0x2000,
- 0x2001,
- 0x2002,
- 0x2003,
- 0x2004,
- 0x2005,
- 0x2006,
- 0x2007,
- 0x2008,
- 0x2009,
- 0x200A,
- 0x200B,
- 0x202F,
- 0x205F,
- 0x3000,
- 0x6DD,
- 0x70F,
- 0x180E,
- 0x200C,
- 0x200D,
- 0x2028,
- 0x2029,
- 0xFEFF,
- 0xFFF9,
- 0xFFFA,
- 0xFFFB,
- 0xFFFC,
- 0xFFFE,
- 0xFFFF,
- 0x1FFFE,
- 0x1FFFF,
- 0x2FFFE,
- 0x2FFFF,
- 0x3FFFE,
- 0x3FFFF,
- 0x4FFFE,
- 0x4FFFF,
- 0x5FFFE,
- 0x5FFFF,
- 0x6FFFE,
- 0x6FFFF,
- 0x7FFFE,
- 0x7FFFF,
- 0x8FFFE,
- 0x8FFFF,
- 0x9FFFE,
- 0x9FFFF,
- 0xAFFFE,
- 0xAFFFF,
- 0xBFFFE,
- 0xBFFFF,
- 0xCFFFE,
- 0xCFFFF,
- 0xDFFFE,
- 0xDFFFF,
- 0xEFFFE,
- 0xEFFFF,
- 0xFFFFE,
- 0xFFFFF,
- 0x10FFFE,
- 0x10FFFF,
- 0xFFF9,
- 0xFFFA,
- 0xFFFB,
- 0xFFFC,
- 0xFFFD,
- 0x340,
- 0x341,
- 0x200E,
- 0x200F,
- 0x202A,
- 0x202B,
- 0x202C,
- 0x202D,
- 0x202E,
- 0x206A,
- 0x206B,
- 0x206C,
- 0x206D,
- 0x206E,
- 0x206F,
- 0xE0001
- );
-
- /**
- * Codepoint ranges prohibited by nameprep
- *
- * @static
- * @var array
- * @access private
- */
- private static $_np_prohibit_ranges = array(
- array(0x80, 0x9F ),
- array(0x2060, 0x206F ),
- array(0x1D173, 0x1D17A ),
- array(0xE000, 0xF8FF ),
- array(0xF0000, 0xFFFFD ),
- array(0x100000, 0x10FFFD),
- array(0xFDD0, 0xFDEF ),
- array(0xD800, 0xDFFF ),
- array(0x2FF0, 0x2FFB ),
- array(0xE0020, 0xE007F )
- );
-
- /**
- * Replacement mappings (casemapping, replacement sequences, ...)
- *
- * @static
- * @var array
- * @access private
- */
- private static $_np_replacemaps = array(
- 0x41 => array(0x61),
- 0x42 => array(0x62),
- 0x43 => array(0x63),
- 0x44 => array(0x64),
- 0x45 => array(0x65),
- 0x46 => array(0x66),
- 0x47 => array(0x67),
- 0x48 => array(0x68),
- 0x49 => array(0x69),
- 0x4A => array(0x6A),
- 0x4B => array(0x6B),
- 0x4C => array(0x6C),
- 0x4D => array(0x6D),
- 0x4E => array(0x6E),
- 0x4F => array(0x6F),
- 0x50 => array(0x70),
- 0x51 => array(0x71),
- 0x52 => array(0x72),
- 0x53 => array(0x73),
- 0x54 => array(0x74),
- 0x55 => array(0x75),
- 0x56 => array(0x76),
- 0x57 => array(0x77),
- 0x58 => array(0x78),
- 0x59 => array(0x79),
- 0x5A => array(0x7A),
- 0xB5 => array(0x3BC),
- 0xC0 => array(0xE0),
- 0xC1 => array(0xE1),
- 0xC2 => array(0xE2),
- 0xC3 => array(0xE3),
- 0xC4 => array(0xE4),
- 0xC5 => array(0xE5),
- 0xC6 => array(0xE6),
- 0xC7 => array(0xE7),
- 0xC8 => array(0xE8),
- 0xC9 => array(0xE9),
- 0xCA => array(0xEA),
- 0xCB => array(0xEB),
- 0xCC => array(0xEC),
- 0xCD => array(0xED),
- 0xCE => array(0xEE),
- 0xCF => array(0xEF),
- 0xD0 => array(0xF0),
- 0xD1 => array(0xF1),
- 0xD2 => array(0xF2),
- 0xD3 => array(0xF3),
- 0xD4 => array(0xF4),
- 0xD5 => array(0xF5),
- 0xD6 => array(0xF6),
- 0xD8 => array(0xF8),
- 0xD9 => array(0xF9),
- 0xDA => array(0xFA),
- 0xDB => array(0xFB),
- 0xDC => array(0xFC),
- 0xDD => array(0xFD),
- 0xDE => array(0xFE),
- 0xDF => array(0x73, 0x73),
- 0x100 => array(0x101),
- 0x102 => array(0x103),
- 0x104 => array(0x105),
- 0x106 => array(0x107),
- 0x108 => array(0x109),
- 0x10A => array(0x10B),
- 0x10C => array(0x10D),
- 0x10E => array(0x10F),
- 0x110 => array(0x111),
- 0x112 => array(0x113),
- 0x114 => array(0x115),
- 0x116 => array(0x117),
- 0x118 => array(0x119),
- 0x11A => array(0x11B),
- 0x11C => array(0x11D),
- 0x11E => array(0x11F),
- 0x120 => array(0x121),
- 0x122 => array(0x123),
- 0x124 => array(0x125),
- 0x126 => array(0x127),
- 0x128 => array(0x129),
- 0x12A => array(0x12B),
- 0x12C => array(0x12D),
- 0x12E => array(0x12F),
- 0x130 => array(0x69, 0x307),
- 0x132 => array(0x133),
- 0x134 => array(0x135),
- 0x136 => array(0x137),
- 0x139 => array(0x13A),
- 0x13B => array(0x13C),
- 0x13D => array(0x13E),
- 0x13F => array(0x140),
- 0x141 => array(0x142),
- 0x143 => array(0x144),
- 0x145 => array(0x146),
- 0x147 => array(0x148),
- 0x149 => array(0x2BC, 0x6E),
- 0x14A => array(0x14B),
- 0x14C => array(0x14D),
- 0x14E => array(0x14F),
- 0x150 => array(0x151),
- 0x152 => array(0x153),
- 0x154 => array(0x155),
- 0x156 => array(0x157),
- 0x158 => array(0x159),
- 0x15A => array(0x15B),
- 0x15C => array(0x15D),
- 0x15E => array(0x15F),
- 0x160 => array(0x161),
- 0x162 => array(0x163),
- 0x164 => array(0x165),
- 0x166 => array(0x167),
- 0x168 => array(0x169),
- 0x16A => array(0x16B),
- 0x16C => array(0x16D),
- 0x16E => array(0x16F),
- 0x170 => array(0x171),
- 0x172 => array(0x173),
- 0x174 => array(0x175),
- 0x176 => array(0x177),
- 0x178 => array(0xFF),
- 0x179 => array(0x17A),
- 0x17B => array(0x17C),
- 0x17D => array(0x17E),
- 0x17F => array(0x73),
- 0x181 => array(0x253),
- 0x182 => array(0x183),
- 0x184 => array(0x185),
- 0x186 => array(0x254),
- 0x187 => array(0x188),
- 0x189 => array(0x256),
- 0x18A => array(0x257),
- 0x18B => array(0x18C),
- 0x18E => array(0x1DD),
- 0x18F => array(0x259),
- 0x190 => array(0x25B),
- 0x191 => array(0x192),
- 0x193 => array(0x260),
- 0x194 => array(0x263),
- 0x196 => array(0x269),
- 0x197 => array(0x268),
- 0x198 => array(0x199),
- 0x19C => array(0x26F),
- 0x19D => array(0x272),
- 0x19F => array(0x275),
- 0x1A0 => array(0x1A1),
- 0x1A2 => array(0x1A3),
- 0x1A4 => array(0x1A5),
- 0x1A6 => array(0x280),
- 0x1A7 => array(0x1A8),
- 0x1A9 => array(0x283),
- 0x1AC => array(0x1AD),
- 0x1AE => array(0x288),
- 0x1AF => array(0x1B0),
- 0x1B1 => array(0x28A),
- 0x1B2 => array(0x28B),
- 0x1B3 => array(0x1B4),
- 0x1B5 => array(0x1B6),
- 0x1B7 => array(0x292),
- 0x1B8 => array(0x1B9),
- 0x1BC => array(0x1BD),
- 0x1C4 => array(0x1C6),
- 0x1C5 => array(0x1C6),
- 0x1C7 => array(0x1C9),
- 0x1C8 => array(0x1C9),
- 0x1CA => array(0x1CC),
- 0x1CB => array(0x1CC),
- 0x1CD => array(0x1CE),
- 0x1CF => array(0x1D0),
- 0x1D1 => array(0x1D2),
- 0x1D3 => array(0x1D4),
- 0x1D5 => array(0x1D6),
- 0x1D7 => array(0x1D8),
- 0x1D9 => array(0x1DA),
- 0x1DB => array(0x1DC),
- 0x1DE => array(0x1DF),
- 0x1E0 => array(0x1E1),
- 0x1E2 => array(0x1E3),
- 0x1E4 => array(0x1E5),
- 0x1E6 => array(0x1E7),
- 0x1E8 => array(0x1E9),
- 0x1EA => array(0x1EB),
- 0x1EC => array(0x1ED),
- 0x1EE => array(0x1EF),
- 0x1F0 => array(0x6A, 0x30C),
- 0x1F1 => array(0x1F3),
- 0x1F2 => array(0x1F3),
- 0x1F4 => array(0x1F5),
- 0x1F6 => array(0x195),
- 0x1F7 => array(0x1BF),
- 0x1F8 => array(0x1F9),
- 0x1FA => array(0x1FB),
- 0x1FC => array(0x1FD),
- 0x1FE => array(0x1FF),
- 0x200 => array(0x201),
- 0x202 => array(0x203),
- 0x204 => array(0x205),
- 0x206 => array(0x207),
- 0x208 => array(0x209),
- 0x20A => array(0x20B),
- 0x20C => array(0x20D),
- 0x20E => array(0x20F),
- 0x210 => array(0x211),
- 0x212 => array(0x213),
- 0x214 => array(0x215),
- 0x216 => array(0x217),
- 0x218 => array(0x219),
- 0x21A => array(0x21B),
- 0x21C => array(0x21D),
- 0x21E => array(0x21F),
- 0x220 => array(0x19E),
- 0x222 => array(0x223),
- 0x224 => array(0x225),
- 0x226 => array(0x227),
- 0x228 => array(0x229),
- 0x22A => array(0x22B),
- 0x22C => array(0x22D),
- 0x22E => array(0x22F),
- 0x230 => array(0x231),
- 0x232 => array(0x233),
- 0x345 => array(0x3B9),
- 0x37A => array(0x20, 0x3B9),
- 0x386 => array(0x3AC),
- 0x388 => array(0x3AD),
- 0x389 => array(0x3AE),
- 0x38A => array(0x3AF),
- 0x38C => array(0x3CC),
- 0x38E => array(0x3CD),
- 0x38F => array(0x3CE),
- 0x390 => array(0x3B9, 0x308, 0x301),
- 0x391 => array(0x3B1),
- 0x392 => array(0x3B2),
- 0x393 => array(0x3B3),
- 0x394 => array(0x3B4),
- 0x395 => array(0x3B5),
- 0x396 => array(0x3B6),
- 0x397 => array(0x3B7),
- 0x398 => array(0x3B8),
- 0x399 => array(0x3B9),
- 0x39A => array(0x3BA),
- 0x39B => array(0x3BB),
- 0x39C => array(0x3BC),
- 0x39D => array(0x3BD),
- 0x39E => array(0x3BE),
- 0x39F => array(0x3BF),
- 0x3A0 => array(0x3C0),
- 0x3A1 => array(0x3C1),
- 0x3A3 => array(0x3C3),
- 0x3A4 => array(0x3C4),
- 0x3A5 => array(0x3C5),
- 0x3A6 => array(0x3C6),
- 0x3A7 => array(0x3C7),
- 0x3A8 => array(0x3C8),
- 0x3A9 => array(0x3C9),
- 0x3AA => array(0x3CA),
- 0x3AB => array(0x3CB),
- 0x3B0 => array(0x3C5, 0x308, 0x301),
- 0x3C2 => array(0x3C3),
- 0x3D0 => array(0x3B2),
- 0x3D1 => array(0x3B8),
- 0x3D2 => array(0x3C5),
- 0x3D3 => array(0x3CD),
- 0x3D4 => array(0x3CB),
- 0x3D5 => array(0x3C6),
- 0x3D6 => array(0x3C0),
- 0x3D8 => array(0x3D9),
- 0x3DA => array(0x3DB),
- 0x3DC => array(0x3DD),
- 0x3DE => array(0x3DF),
- 0x3E0 => array(0x3E1),
- 0x3E2 => array(0x3E3),
- 0x3E4 => array(0x3E5),
- 0x3E6 => array(0x3E7),
- 0x3E8 => array(0x3E9),
- 0x3EA => array(0x3EB),
- 0x3EC => array(0x3ED),
- 0x3EE => array(0x3EF),
- 0x3F0 => array(0x3BA),
- 0x3F1 => array(0x3C1),
- 0x3F2 => array(0x3C3),
- 0x3F4 => array(0x3B8),
- 0x3F5 => array(0x3B5),
- 0x400 => array(0x450),
- 0x401 => array(0x451),
- 0x402 => array(0x452),
- 0x403 => array(0x453),
- 0x404 => array(0x454),
- 0x405 => array(0x455),
- 0x406 => array(0x456),
- 0x407 => array(0x457),
- 0x408 => array(0x458),
- 0x409 => array(0x459),
- 0x40A => array(0x45A),
- 0x40B => array(0x45B),
- 0x40C => array(0x45C),
- 0x40D => array(0x45D),
- 0x40E => array(0x45E),
- 0x40F => array(0x45F),
- 0x410 => array(0x430),
- 0x411 => array(0x431),
- 0x412 => array(0x432),
- 0x413 => array(0x433),
- 0x414 => array(0x434),
- 0x415 => array(0x435),
- 0x416 => array(0x436),
- 0x417 => array(0x437),
- 0x418 => array(0x438),
- 0x419 => array(0x439),
- 0x41A => array(0x43A),
- 0x41B => array(0x43B),
- 0x41C => array(0x43C),
- 0x41D => array(0x43D),
- 0x41E => array(0x43E),
- 0x41F => array(0x43F),
- 0x420 => array(0x440),
- 0x421 => array(0x441),
- 0x422 => array(0x442),
- 0x423 => array(0x443),
- 0x424 => array(0x444),
- 0x425 => array(0x445),
- 0x426 => array(0x446),
- 0x427 => array(0x447),
- 0x428 => array(0x448),
- 0x429 => array(0x449),
- 0x42A => array(0x44A),
- 0x42B => array(0x44B),
- 0x42C => array(0x44C),
- 0x42D => array(0x44D),
- 0x42E => array(0x44E),
- 0x42F => array(0x44F),
- 0x460 => array(0x461),
- 0x462 => array(0x463),
- 0x464 => array(0x465),
- 0x466 => array(0x467),
- 0x468 => array(0x469),
- 0x46A => array(0x46B),
- 0x46C => array(0x46D),
- 0x46E => array(0x46F),
- 0x470 => array(0x471),
- 0x472 => array(0x473),
- 0x474 => array(0x475),
- 0x476 => array(0x477),
- 0x478 => array(0x479),
- 0x47A => array(0x47B),
- 0x47C => array(0x47D),
- 0x47E => array(0x47F),
- 0x480 => array(0x481),
- 0x48A => array(0x48B),
- 0x48C => array(0x48D),
- 0x48E => array(0x48F),
- 0x490 => array(0x491),
- 0x492 => array(0x493),
- 0x494 => array(0x495),
- 0x496 => array(0x497),
- 0x498 => array(0x499),
- 0x49A => array(0x49B),
- 0x49C => array(0x49D),
- 0x49E => array(0x49F),
- 0x4A0 => array(0x4A1),
- 0x4A2 => array(0x4A3),
- 0x4A4 => array(0x4A5),
- 0x4A6 => array(0x4A7),
- 0x4A8 => array(0x4A9),
- 0x4AA => array(0x4AB),
- 0x4AC => array(0x4AD),
- 0x4AE => array(0x4AF),
- 0x4B0 => array(0x4B1),
- 0x4B2 => array(0x4B3),
- 0x4B4 => array(0x4B5),
- 0x4B6 => array(0x4B7),
- 0x4B8 => array(0x4B9),
- 0x4BA => array(0x4BB),
- 0x4BC => array(0x4BD),
- 0x4BE => array(0x4BF),
- 0x4C1 => array(0x4C2),
- 0x4C3 => array(0x4C4),
- 0x4C5 => array(0x4C6),
- 0x4C7 => array(0x4C8),
- 0x4C9 => array(0x4CA),
- 0x4CB => array(0x4CC),
- 0x4CD => array(0x4CE),
- 0x4D0 => array(0x4D1),
- 0x4D2 => array(0x4D3),
- 0x4D4 => array(0x4D5),
- 0x4D6 => array(0x4D7),
- 0x4D8 => array(0x4D9),
- 0x4DA => array(0x4DB),
- 0x4DC => array(0x4DD),
- 0x4DE => array(0x4DF),
- 0x4E0 => array(0x4E1),
- 0x4E2 => array(0x4E3),
- 0x4E4 => array(0x4E5),
- 0x4E6 => array(0x4E7),
- 0x4E8 => array(0x4E9),
- 0x4EA => array(0x4EB),
- 0x4EC => array(0x4ED),
- 0x4EE => array(0x4EF),
- 0x4F0 => array(0x4F1),
- 0x4F2 => array(0x4F3),
- 0x4F4 => array(0x4F5),
- 0x4F8 => array(0x4F9),
- 0x500 => array(0x501),
- 0x502 => array(0x503),
- 0x504 => array(0x505),
- 0x506 => array(0x507),
- 0x508 => array(0x509),
- 0x50A => array(0x50B),
- 0x50C => array(0x50D),
- 0x50E => array(0x50F),
- 0x531 => array(0x561),
- 0x532 => array(0x562),
- 0x533 => array(0x563),
- 0x534 => array(0x564),
- 0x535 => array(0x565),
- 0x536 => array(0x566),
- 0x537 => array(0x567),
- 0x538 => array(0x568),
- 0x539 => array(0x569),
- 0x53A => array(0x56A),
- 0x53B => array(0x56B),
- 0x53C => array(0x56C),
- 0x53D => array(0x56D),
- 0x53E => array(0x56E),
- 0x53F => array(0x56F),
- 0x540 => array(0x570),
- 0x541 => array(0x571),
- 0x542 => array(0x572),
- 0x543 => array(0x573),
- 0x544 => array(0x574),
- 0x545 => array(0x575),
- 0x546 => array(0x576),
- 0x547 => array(0x577),
- 0x548 => array(0x578),
- 0x549 => array(0x579),
- 0x54A => array(0x57A),
- 0x54B => array(0x57B),
- 0x54C => array(0x57C),
- 0x54D => array(0x57D),
- 0x54E => array(0x57E),
- 0x54F => array(0x57F),
- 0x550 => array(0x580),
- 0x551 => array(0x581),
- 0x552 => array(0x582),
- 0x553 => array(0x583),
- 0x554 => array(0x584),
- 0x555 => array(0x585),
- 0x556 => array(0x586),
- 0x587 => array(0x565, 0x582),
- 0x1E00 => array(0x1E01),
- 0x1E02 => array(0x1E03),
- 0x1E04 => array(0x1E05),
- 0x1E06 => array(0x1E07),
- 0x1E08 => array(0x1E09),
- 0x1E0A => array(0x1E0B),
- 0x1E0C => array(0x1E0D),
- 0x1E0E => array(0x1E0F),
- 0x1E10 => array(0x1E11),
- 0x1E12 => array(0x1E13),
- 0x1E14 => array(0x1E15),
- 0x1E16 => array(0x1E17),
- 0x1E18 => array(0x1E19),
- 0x1E1A => array(0x1E1B),
- 0x1E1C => array(0x1E1D),
- 0x1E1E => array(0x1E1F),
- 0x1E20 => array(0x1E21),
- 0x1E22 => array(0x1E23),
- 0x1E24 => array(0x1E25),
- 0x1E26 => array(0x1E27),
- 0x1E28 => array(0x1E29),
- 0x1E2A => array(0x1E2B),
- 0x1E2C => array(0x1E2D),
- 0x1E2E => array(0x1E2F),
- 0x1E30 => array(0x1E31),
- 0x1E32 => array(0x1E33),
- 0x1E34 => array(0x1E35),
- 0x1E36 => array(0x1E37),
- 0x1E38 => array(0x1E39),
- 0x1E3A => array(0x1E3B),
- 0x1E3C => array(0x1E3D),
- 0x1E3E => array(0x1E3F),
- 0x1E40 => array(0x1E41),
- 0x1E42 => array(0x1E43),
- 0x1E44 => array(0x1E45),
- 0x1E46 => array(0x1E47),
- 0x1E48 => array(0x1E49),
- 0x1E4A => array(0x1E4B),
- 0x1E4C => array(0x1E4D),
- 0x1E4E => array(0x1E4F),
- 0x1E50 => array(0x1E51),
- 0x1E52 => array(0x1E53),
- 0x1E54 => array(0x1E55),
- 0x1E56 => array(0x1E57),
- 0x1E58 => array(0x1E59),
- 0x1E5A => array(0x1E5B),
- 0x1E5C => array(0x1E5D),
- 0x1E5E => array(0x1E5F),
- 0x1E60 => array(0x1E61),
- 0x1E62 => array(0x1E63),
- 0x1E64 => array(0x1E65),
- 0x1E66 => array(0x1E67),
- 0x1E68 => array(0x1E69),
- 0x1E6A => array(0x1E6B),
- 0x1E6C => array(0x1E6D),
- 0x1E6E => array(0x1E6F),
- 0x1E70 => array(0x1E71),
- 0x1E72 => array(0x1E73),
- 0x1E74 => array(0x1E75),
- 0x1E76 => array(0x1E77),
- 0x1E78 => array(0x1E79),
- 0x1E7A => array(0x1E7B),
- 0x1E7C => array(0x1E7D),
- 0x1E7E => array(0x1E7F),
- 0x1E80 => array(0x1E81),
- 0x1E82 => array(0x1E83),
- 0x1E84 => array(0x1E85),
- 0x1E86 => array(0x1E87),
- 0x1E88 => array(0x1E89),
- 0x1E8A => array(0x1E8B),
- 0x1E8C => array(0x1E8D),
- 0x1E8E => array(0x1E8F),
- 0x1E90 => array(0x1E91),
- 0x1E92 => array(0x1E93),
- 0x1E94 => array(0x1E95),
- 0x1E96 => array(0x68, 0x331),
- 0x1E97 => array(0x74, 0x308),
- 0x1E98 => array(0x77, 0x30A),
- 0x1E99 => array(0x79, 0x30A),
- 0x1E9A => array(0x61, 0x2BE),
- 0x1E9B => array(0x1E61),
- 0x1EA0 => array(0x1EA1),
- 0x1EA2 => array(0x1EA3),
- 0x1EA4 => array(0x1EA5),
- 0x1EA6 => array(0x1EA7),
- 0x1EA8 => array(0x1EA9),
- 0x1EAA => array(0x1EAB),
- 0x1EAC => array(0x1EAD),
- 0x1EAE => array(0x1EAF),
- 0x1EB0 => array(0x1EB1),
- 0x1EB2 => array(0x1EB3),
- 0x1EB4 => array(0x1EB5),
- 0x1EB6 => array(0x1EB7),
- 0x1EB8 => array(0x1EB9),
- 0x1EBA => array(0x1EBB),
- 0x1EBC => array(0x1EBD),
- 0x1EBE => array(0x1EBF),
- 0x1EC0 => array(0x1EC1),
- 0x1EC2 => array(0x1EC3),
- 0x1EC4 => array(0x1EC5),
- 0x1EC6 => array(0x1EC7),
- 0x1EC8 => array(0x1EC9),
- 0x1ECA => array(0x1ECB),
- 0x1ECC => array(0x1ECD),
- 0x1ECE => array(0x1ECF),
- 0x1ED0 => array(0x1ED1),
- 0x1ED2 => array(0x1ED3),
- 0x1ED4 => array(0x1ED5),
- 0x1ED6 => array(0x1ED7),
- 0x1ED8 => array(0x1ED9),
- 0x1EDA => array(0x1EDB),
- 0x1EDC => array(0x1EDD),
- 0x1EDE => array(0x1EDF),
- 0x1EE0 => array(0x1EE1),
- 0x1EE2 => array(0x1EE3),
- 0x1EE4 => array(0x1EE5),
- 0x1EE6 => array(0x1EE7),
- 0x1EE8 => array(0x1EE9),
- 0x1EEA => array(0x1EEB),
- 0x1EEC => array(0x1EED),
- 0x1EEE => array(0x1EEF),
- 0x1EF0 => array(0x1EF1),
- 0x1EF2 => array(0x1EF3),
- 0x1EF4 => array(0x1EF5),
- 0x1EF6 => array(0x1EF7),
- 0x1EF8 => array(0x1EF9),
- 0x1F08 => array(0x1F00),
- 0x1F09 => array(0x1F01),
- 0x1F0A => array(0x1F02),
- 0x1F0B => array(0x1F03),
- 0x1F0C => array(0x1F04),
- 0x1F0D => array(0x1F05),
- 0x1F0E => array(0x1F06),
- 0x1F0F => array(0x1F07),
- 0x1F18 => array(0x1F10),
- 0x1F19 => array(0x1F11),
- 0x1F1A => array(0x1F12),
- 0x1F1B => array(0x1F13),
- 0x1F1C => array(0x1F14),
- 0x1F1D => array(0x1F15),
- 0x1F28 => array(0x1F20),
- 0x1F29 => array(0x1F21),
- 0x1F2A => array(0x1F22),
- 0x1F2B => array(0x1F23),
- 0x1F2C => array(0x1F24),
- 0x1F2D => array(0x1F25),
- 0x1F2E => array(0x1F26),
- 0x1F2F => array(0x1F27),
- 0x1F38 => array(0x1F30),
- 0x1F39 => array(0x1F31),
- 0x1F3A => array(0x1F32),
- 0x1F3B => array(0x1F33),
- 0x1F3C => array(0x1F34),
- 0x1F3D => array(0x1F35),
- 0x1F3E => array(0x1F36),
- 0x1F3F => array(0x1F37),
- 0x1F48 => array(0x1F40),
- 0x1F49 => array(0x1F41),
- 0x1F4A => array(0x1F42),
- 0x1F4B => array(0x1F43),
- 0x1F4C => array(0x1F44),
- 0x1F4D => array(0x1F45),
- 0x1F50 => array(0x3C5, 0x313),
- 0x1F52 => array(0x3C5, 0x313, 0x300),
- 0x1F54 => array(0x3C5, 0x313, 0x301),
- 0x1F56 => array(0x3C5, 0x313, 0x342),
- 0x1F59 => array(0x1F51),
- 0x1F5B => array(0x1F53),
- 0x1F5D => array(0x1F55),
- 0x1F5F => array(0x1F57),
- 0x1F68 => array(0x1F60),
- 0x1F69 => array(0x1F61),
- 0x1F6A => array(0x1F62),
- 0x1F6B => array(0x1F63),
- 0x1F6C => array(0x1F64),
- 0x1F6D => array(0x1F65),
- 0x1F6E => array(0x1F66),
- 0x1F6F => array(0x1F67),
- 0x1F80 => array(0x1F00, 0x3B9),
- 0x1F81 => array(0x1F01, 0x3B9),
- 0x1F82 => array(0x1F02, 0x3B9),
- 0x1F83 => array(0x1F03, 0x3B9),
- 0x1F84 => array(0x1F04, 0x3B9),
- 0x1F85 => array(0x1F05, 0x3B9),
- 0x1F86 => array(0x1F06, 0x3B9),
- 0x1F87 => array(0x1F07, 0x3B9),
- 0x1F88 => array(0x1F00, 0x3B9),
- 0x1F89 => array(0x1F01, 0x3B9),
- 0x1F8A => array(0x1F02, 0x3B9),
- 0x1F8B => array(0x1F03, 0x3B9),
- 0x1F8C => array(0x1F04, 0x3B9),
- 0x1F8D => array(0x1F05, 0x3B9),
- 0x1F8E => array(0x1F06, 0x3B9),
- 0x1F8F => array(0x1F07, 0x3B9),
- 0x1F90 => array(0x1F20, 0x3B9),
- 0x1F91 => array(0x1F21, 0x3B9),
- 0x1F92 => array(0x1F22, 0x3B9),
- 0x1F93 => array(0x1F23, 0x3B9),
- 0x1F94 => array(0x1F24, 0x3B9),
- 0x1F95 => array(0x1F25, 0x3B9),
- 0x1F96 => array(0x1F26, 0x3B9),
- 0x1F97 => array(0x1F27, 0x3B9),
- 0x1F98 => array(0x1F20, 0x3B9),
- 0x1F99 => array(0x1F21, 0x3B9),
- 0x1F9A => array(0x1F22, 0x3B9),
- 0x1F9B => array(0x1F23, 0x3B9),
- 0x1F9C => array(0x1F24, 0x3B9),
- 0x1F9D => array(0x1F25, 0x3B9),
- 0x1F9E => array(0x1F26, 0x3B9),
- 0x1F9F => array(0x1F27, 0x3B9),
- 0x1FA0 => array(0x1F60, 0x3B9),
- 0x1FA1 => array(0x1F61, 0x3B9),
- 0x1FA2 => array(0x1F62, 0x3B9),
- 0x1FA3 => array(0x1F63, 0x3B9),
- 0x1FA4 => array(0x1F64, 0x3B9),
- 0x1FA5 => array(0x1F65, 0x3B9),
- 0x1FA6 => array(0x1F66, 0x3B9),
- 0x1FA7 => array(0x1F67, 0x3B9),
- 0x1FA8 => array(0x1F60, 0x3B9),
- 0x1FA9 => array(0x1F61, 0x3B9),
- 0x1FAA => array(0x1F62, 0x3B9),
- 0x1FAB => array(0x1F63, 0x3B9),
- 0x1FAC => array(0x1F64, 0x3B9),
- 0x1FAD => array(0x1F65, 0x3B9),
- 0x1FAE => array(0x1F66, 0x3B9),
- 0x1FAF => array(0x1F67, 0x3B9),
- 0x1FB2 => array(0x1F70, 0x3B9),
- 0x1FB3 => array(0x3B1, 0x3B9),
- 0x1FB4 => array(0x3AC, 0x3B9),
- 0x1FB6 => array(0x3B1, 0x342),
- 0x1FB7 => array(0x3B1, 0x342, 0x3B9),
- 0x1FB8 => array(0x1FB0),
- 0x1FB9 => array(0x1FB1),
- 0x1FBA => array(0x1F70),
- 0x1FBB => array(0x1F71),
- 0x1FBC => array(0x3B1, 0x3B9),
- 0x1FBE => array(0x3B9),
- 0x1FC2 => array(0x1F74, 0x3B9),
- 0x1FC3 => array(0x3B7, 0x3B9),
- 0x1FC4 => array(0x3AE, 0x3B9),
- 0x1FC6 => array(0x3B7, 0x342),
- 0x1FC7 => array(0x3B7, 0x342, 0x3B9),
- 0x1FC8 => array(0x1F72),
- 0x1FC9 => array(0x1F73),
- 0x1FCA => array(0x1F74),
- 0x1FCB => array(0x1F75),
- 0x1FCC => array(0x3B7, 0x3B9),
- 0x1FD2 => array(0x3B9, 0x308, 0x300),
- 0x1FD3 => array(0x3B9, 0x308, 0x301),
- 0x1FD6 => array(0x3B9, 0x342),
- 0x1FD7 => array(0x3B9, 0x308, 0x342),
- 0x1FD8 => array(0x1FD0),
- 0x1FD9 => array(0x1FD1),
- 0x1FDA => array(0x1F76),
- 0x1FDB => array(0x1F77),
- 0x1FE2 => array(0x3C5, 0x308, 0x300),
- 0x1FE3 => array(0x3C5, 0x308, 0x301),
- 0x1FE4 => array(0x3C1, 0x313),
- 0x1FE6 => array(0x3C5, 0x342),
- 0x1FE7 => array(0x3C5, 0x308, 0x342),
- 0x1FE8 => array(0x1FE0),
- 0x1FE9 => array(0x1FE1),
- 0x1FEA => array(0x1F7A),
- 0x1FEB => array(0x1F7B),
- 0x1FEC => array(0x1FE5),
- 0x1FF2 => array(0x1F7C, 0x3B9),
- 0x1FF3 => array(0x3C9, 0x3B9),
- 0x1FF4 => array(0x3CE, 0x3B9),
- 0x1FF6 => array(0x3C9, 0x342),
- 0x1FF7 => array(0x3C9, 0x342, 0x3B9),
- 0x1FF8 => array(0x1F78),
- 0x1FF9 => array(0x1F79),
- 0x1FFA => array(0x1F7C),
- 0x1FFB => array(0x1F7D),
- 0x1FFC => array(0x3C9, 0x3B9),
- 0x20A8 => array(0x72, 0x73),
- 0x2102 => array(0x63),
- 0x2103 => array(0xB0, 0x63),
- 0x2107 => array(0x25B),
- 0x2109 => array(0xB0, 0x66),
- 0x210B => array(0x68),
- 0x210C => array(0x68),
- 0x210D => array(0x68),
- 0x2110 => array(0x69),
- 0x2111 => array(0x69),
- 0x2112 => array(0x6C),
- 0x2115 => array(0x6E),
- 0x2116 => array(0x6E, 0x6F),
- 0x2119 => array(0x70),
- 0x211A => array(0x71),
- 0x211B => array(0x72),
- 0x211C => array(0x72),
- 0x211D => array(0x72),
- 0x2120 => array(0x73, 0x6D),
- 0x2121 => array(0x74, 0x65, 0x6C),
- 0x2122 => array(0x74, 0x6D),
- 0x2124 => array(0x7A),
- 0x2126 => array(0x3C9),
- 0x2128 => array(0x7A),
- 0x212A => array(0x6B),
- 0x212B => array(0xE5),
- 0x212C => array(0x62),
- 0x212D => array(0x63),
- 0x2130 => array(0x65),
- 0x2131 => array(0x66),
- 0x2133 => array(0x6D),
- 0x213E => array(0x3B3),
- 0x213F => array(0x3C0),
- 0x2145 => array(0x64),
- 0x2160 => array(0x2170),
- 0x2161 => array(0x2171),
- 0x2162 => array(0x2172),
- 0x2163 => array(0x2173),
- 0x2164 => array(0x2174),
- 0x2165 => array(0x2175),
- 0x2166 => array(0x2176),
- 0x2167 => array(0x2177),
- 0x2168 => array(0x2178),
- 0x2169 => array(0x2179),
- 0x216A => array(0x217A),
- 0x216B => array(0x217B),
- 0x216C => array(0x217C),
- 0x216D => array(0x217D),
- 0x216E => array(0x217E),
- 0x216F => array(0x217F),
- 0x24B6 => array(0x24D0),
- 0x24B7 => array(0x24D1),
- 0x24B8 => array(0x24D2),
- 0x24B9 => array(0x24D3),
- 0x24BA => array(0x24D4),
- 0x24BB => array(0x24D5),
- 0x24BC => array(0x24D6),
- 0x24BD => array(0x24D7),
- 0x24BE => array(0x24D8),
- 0x24BF => array(0x24D9),
- 0x24C0 => array(0x24DA),
- 0x24C1 => array(0x24DB),
- 0x24C2 => array(0x24DC),
- 0x24C3 => array(0x24DD),
- 0x24C4 => array(0x24DE),
- 0x24C5 => array(0x24DF),
- 0x24C6 => array(0x24E0),
- 0x24C7 => array(0x24E1),
- 0x24C8 => array(0x24E2),
- 0x24C9 => array(0x24E3),
- 0x24CA => array(0x24E4),
- 0x24CB => array(0x24E5),
- 0x24CC => array(0x24E6),
- 0x24CD => array(0x24E7),
- 0x24CE => array(0x24E8),
- 0x24CF => array(0x24E9),
- 0x3371 => array(0x68, 0x70, 0x61),
- 0x3373 => array(0x61, 0x75),
- 0x3375 => array(0x6F, 0x76),
- 0x3380 => array(0x70, 0x61),
- 0x3381 => array(0x6E, 0x61),
- 0x3382 => array(0x3BC, 0x61),
- 0x3383 => array(0x6D, 0x61),
- 0x3384 => array(0x6B, 0x61),
- 0x3385 => array(0x6B, 0x62),
- 0x3386 => array(0x6D, 0x62),
- 0x3387 => array(0x67, 0x62),
- 0x338A => array(0x70, 0x66),
- 0x338B => array(0x6E, 0x66),
- 0x338C => array(0x3BC, 0x66),
- 0x3390 => array(0x68, 0x7A),
- 0x3391 => array(0x6B, 0x68, 0x7A),
- 0x3392 => array(0x6D, 0x68, 0x7A),
- 0x3393 => array(0x67, 0x68, 0x7A),
- 0x3394 => array(0x74, 0x68, 0x7A),
- 0x33A9 => array(0x70, 0x61),
- 0x33AA => array(0x6B, 0x70, 0x61),
- 0x33AB => array(0x6D, 0x70, 0x61),
- 0x33AC => array(0x67, 0x70, 0x61),
- 0x33B4 => array(0x70, 0x76),
- 0x33B5 => array(0x6E, 0x76),
- 0x33B6 => array(0x3BC, 0x76),
- 0x33B7 => array(0x6D, 0x76),
- 0x33B8 => array(0x6B, 0x76),
- 0x33B9 => array(0x6D, 0x76),
- 0x33BA => array(0x70, 0x77),
- 0x33BB => array(0x6E, 0x77),
- 0x33BC => array(0x3BC, 0x77),
- 0x33BD => array(0x6D, 0x77),
- 0x33BE => array(0x6B, 0x77),
- 0x33BF => array(0x6D, 0x77),
- 0x33C0 => array(0x6B, 0x3C9),
- 0x33C1 => array(0x6D, 0x3C9), /*
- 0x33C2 => array(0x61, 0x2E, 0x6D, 0x2E), */
- 0x33C3 => array(0x62, 0x71),
- 0x33C6 => array(0x63, 0x2215, 0x6B, 0x67),
- 0x33C7 => array(0x63, 0x6F, 0x2E),
- 0x33C8 => array(0x64, 0x62),
- 0x33C9 => array(0x67, 0x79),
- 0x33CB => array(0x68, 0x70),
- 0x33CD => array(0x6B, 0x6B),
- 0x33CE => array(0x6B, 0x6D),
- 0x33D7 => array(0x70, 0x68),
- 0x33D9 => array(0x70, 0x70, 0x6D),
- 0x33DA => array(0x70, 0x72),
- 0x33DC => array(0x73, 0x76),
- 0x33DD => array(0x77, 0x62),
- 0xFB00 => array(0x66, 0x66),
- 0xFB01 => array(0x66, 0x69),
- 0xFB02 => array(0x66, 0x6C),
- 0xFB03 => array(0x66, 0x66, 0x69),
- 0xFB04 => array(0x66, 0x66, 0x6C),
- 0xFB05 => array(0x73, 0x74),
- 0xFB06 => array(0x73, 0x74),
- 0xFB13 => array(0x574, 0x576),
- 0xFB14 => array(0x574, 0x565),
- 0xFB15 => array(0x574, 0x56B),
- 0xFB16 => array(0x57E, 0x576),
- 0xFB17 => array(0x574, 0x56D),
- 0xFF21 => array(0xFF41),
- 0xFF22 => array(0xFF42),
- 0xFF23 => array(0xFF43),
- 0xFF24 => array(0xFF44),
- 0xFF25 => array(0xFF45),
- 0xFF26 => array(0xFF46),
- 0xFF27 => array(0xFF47),
- 0xFF28 => array(0xFF48),
- 0xFF29 => array(0xFF49),
- 0xFF2A => array(0xFF4A),
- 0xFF2B => array(0xFF4B),
- 0xFF2C => array(0xFF4C),
- 0xFF2D => array(0xFF4D),
- 0xFF2E => array(0xFF4E),
- 0xFF2F => array(0xFF4F),
- 0xFF30 => array(0xFF50),
- 0xFF31 => array(0xFF51),
- 0xFF32 => array(0xFF52),
- 0xFF33 => array(0xFF53),
- 0xFF34 => array(0xFF54),
- 0xFF35 => array(0xFF55),
- 0xFF36 => array(0xFF56),
- 0xFF37 => array(0xFF57),
- 0xFF38 => array(0xFF58),
- 0xFF39 => array(0xFF59),
- 0xFF3A => array(0xFF5A),
- 0x10400 => array(0x10428),
- 0x10401 => array(0x10429),
- 0x10402 => array(0x1042A),
- 0x10403 => array(0x1042B),
- 0x10404 => array(0x1042C),
- 0x10405 => array(0x1042D),
- 0x10406 => array(0x1042E),
- 0x10407 => array(0x1042F),
- 0x10408 => array(0x10430),
- 0x10409 => array(0x10431),
- 0x1040A => array(0x10432),
- 0x1040B => array(0x10433),
- 0x1040C => array(0x10434),
- 0x1040D => array(0x10435),
- 0x1040E => array(0x10436),
- 0x1040F => array(0x10437),
- 0x10410 => array(0x10438),
- 0x10411 => array(0x10439),
- 0x10412 => array(0x1043A),
- 0x10413 => array(0x1043B),
- 0x10414 => array(0x1043C),
- 0x10415 => array(0x1043D),
- 0x10416 => array(0x1043E),
- 0x10417 => array(0x1043F),
- 0x10418 => array(0x10440),
- 0x10419 => array(0x10441),
- 0x1041A => array(0x10442),
- 0x1041B => array(0x10443),
- 0x1041C => array(0x10444),
- 0x1041D => array(0x10445),
- 0x1041E => array(0x10446),
- 0x1041F => array(0x10447),
- 0x10420 => array(0x10448),
- 0x10421 => array(0x10449),
- 0x10422 => array(0x1044A),
- 0x10423 => array(0x1044B),
- 0x10424 => array(0x1044C),
- 0x10425 => array(0x1044D),
- 0x1D400 => array(0x61),
- 0x1D401 => array(0x62),
- 0x1D402 => array(0x63),
- 0x1D403 => array(0x64),
- 0x1D404 => array(0x65),
- 0x1D405 => array(0x66),
- 0x1D406 => array(0x67),
- 0x1D407 => array(0x68),
- 0x1D408 => array(0x69),
- 0x1D409 => array(0x6A),
- 0x1D40A => array(0x6B),
- 0x1D40B => array(0x6C),
- 0x1D40C => array(0x6D),
- 0x1D40D => array(0x6E),
- 0x1D40E => array(0x6F),
- 0x1D40F => array(0x70),
- 0x1D410 => array(0x71),
- 0x1D411 => array(0x72),
- 0x1D412 => array(0x73),
- 0x1D413 => array(0x74),
- 0x1D414 => array(0x75),
- 0x1D415 => array(0x76),
- 0x1D416 => array(0x77),
- 0x1D417 => array(0x78),
- 0x1D418 => array(0x79),
- 0x1D419 => array(0x7A),
- 0x1D434 => array(0x61),
- 0x1D435 => array(0x62),
- 0x1D436 => array(0x63),
- 0x1D437 => array(0x64),
- 0x1D438 => array(0x65),
- 0x1D439 => array(0x66),
- 0x1D43A => array(0x67),
- 0x1D43B => array(0x68),
- 0x1D43C => array(0x69),
- 0x1D43D => array(0x6A),
- 0x1D43E => array(0x6B),
- 0x1D43F => array(0x6C),
- 0x1D440 => array(0x6D),
- 0x1D441 => array(0x6E),
- 0x1D442 => array(0x6F),
- 0x1D443 => array(0x70),
- 0x1D444 => array(0x71),
- 0x1D445 => array(0x72),
- 0x1D446 => array(0x73),
- 0x1D447 => array(0x74),
- 0x1D448 => array(0x75),
- 0x1D449 => array(0x76),
- 0x1D44A => array(0x77),
- 0x1D44B => array(0x78),
- 0x1D44C => array(0x79),
- 0x1D44D => array(0x7A),
- 0x1D468 => array(0x61),
- 0x1D469 => array(0x62),
- 0x1D46A => array(0x63),
- 0x1D46B => array(0x64),
- 0x1D46C => array(0x65),
- 0x1D46D => array(0x66),
- 0x1D46E => array(0x67),
- 0x1D46F => array(0x68),
- 0x1D470 => array(0x69),
- 0x1D471 => array(0x6A),
- 0x1D472 => array(0x6B),
- 0x1D473 => array(0x6C),
- 0x1D474 => array(0x6D),
- 0x1D475 => array(0x6E),
- 0x1D476 => array(0x6F),
- 0x1D477 => array(0x70),
- 0x1D478 => array(0x71),
- 0x1D479 => array(0x72),
- 0x1D47A => array(0x73),
- 0x1D47B => array(0x74),
- 0x1D47C => array(0x75),
- 0x1D47D => array(0x76),
- 0x1D47E => array(0x77),
- 0x1D47F => array(0x78),
- 0x1D480 => array(0x79),
- 0x1D481 => array(0x7A),
- 0x1D49C => array(0x61),
- 0x1D49E => array(0x63),
- 0x1D49F => array(0x64),
- 0x1D4A2 => array(0x67),
- 0x1D4A5 => array(0x6A),
- 0x1D4A6 => array(0x6B),
- 0x1D4A9 => array(0x6E),
- 0x1D4AA => array(0x6F),
- 0x1D4AB => array(0x70),
- 0x1D4AC => array(0x71),
- 0x1D4AE => array(0x73),
- 0x1D4AF => array(0x74),
- 0x1D4B0 => array(0x75),
- 0x1D4B1 => array(0x76),
- 0x1D4B2 => array(0x77),
- 0x1D4B3 => array(0x78),
- 0x1D4B4 => array(0x79),
- 0x1D4B5 => array(0x7A),
- 0x1D4D0 => array(0x61),
- 0x1D4D1 => array(0x62),
- 0x1D4D2 => array(0x63),
- 0x1D4D3 => array(0x64),
- 0x1D4D4 => array(0x65),
- 0x1D4D5 => array(0x66),
- 0x1D4D6 => array(0x67),
- 0x1D4D7 => array(0x68),
- 0x1D4D8 => array(0x69),
- 0x1D4D9 => array(0x6A),
- 0x1D4DA => array(0x6B),
- 0x1D4DB => array(0x6C),
- 0x1D4DC => array(0x6D),
- 0x1D4DD => array(0x6E),
- 0x1D4DE => array(0x6F),
- 0x1D4DF => array(0x70),
- 0x1D4E0 => array(0x71),
- 0x1D4E1 => array(0x72),
- 0x1D4E2 => array(0x73),
- 0x1D4E3 => array(0x74),
- 0x1D4E4 => array(0x75),
- 0x1D4E5 => array(0x76),
- 0x1D4E6 => array(0x77),
- 0x1D4E7 => array(0x78),
- 0x1D4E8 => array(0x79),
- 0x1D4E9 => array(0x7A),
- 0x1D504 => array(0x61),
- 0x1D505 => array(0x62),
- 0x1D507 => array(0x64),
- 0x1D508 => array(0x65),
- 0x1D509 => array(0x66),
- 0x1D50A => array(0x67),
- 0x1D50D => array(0x6A),
- 0x1D50E => array(0x6B),
- 0x1D50F => array(0x6C),
- 0x1D510 => array(0x6D),
- 0x1D511 => array(0x6E),
- 0x1D512 => array(0x6F),
- 0x1D513 => array(0x70),
- 0x1D514 => array(0x71),
- 0x1D516 => array(0x73),
- 0x1D517 => array(0x74),
- 0x1D518 => array(0x75),
- 0x1D519 => array(0x76),
- 0x1D51A => array(0x77),
- 0x1D51B => array(0x78),
- 0x1D51C => array(0x79),
- 0x1D538 => array(0x61),
- 0x1D539 => array(0x62),
- 0x1D53B => array(0x64),
- 0x1D53C => array(0x65),
- 0x1D53D => array(0x66),
- 0x1D53E => array(0x67),
- 0x1D540 => array(0x69),
- 0x1D541 => array(0x6A),
- 0x1D542 => array(0x6B),
- 0x1D543 => array(0x6C),
- 0x1D544 => array(0x6D),
- 0x1D546 => array(0x6F),
- 0x1D54A => array(0x73),
- 0x1D54B => array(0x74),
- 0x1D54C => array(0x75),
- 0x1D54D => array(0x76),
- 0x1D54E => array(0x77),
- 0x1D54F => array(0x78),
- 0x1D550 => array(0x79),
- 0x1D56C => array(0x61),
- 0x1D56D => array(0x62),
- 0x1D56E => array(0x63),
- 0x1D56F => array(0x64),
- 0x1D570 => array(0x65),
- 0x1D571 => array(0x66),
- 0x1D572 => array(0x67),
- 0x1D573 => array(0x68),
- 0x1D574 => array(0x69),
- 0x1D575 => array(0x6A),
- 0x1D576 => array(0x6B),
- 0x1D577 => array(0x6C),
- 0x1D578 => array(0x6D),
- 0x1D579 => array(0x6E),
- 0x1D57A => array(0x6F),
- 0x1D57B => array(0x70),
- 0x1D57C => array(0x71),
- 0x1D57D => array(0x72),
- 0x1D57E => array(0x73),
- 0x1D57F => array(0x74),
- 0x1D580 => array(0x75),
- 0x1D581 => array(0x76),
- 0x1D582 => array(0x77),
- 0x1D583 => array(0x78),
- 0x1D584 => array(0x79),
- 0x1D585 => array(0x7A),
- 0x1D5A0 => array(0x61),
- 0x1D5A1 => array(0x62),
- 0x1D5A2 => array(0x63),
- 0x1D5A3 => array(0x64),
- 0x1D5A4 => array(0x65),
- 0x1D5A5 => array(0x66),
- 0x1D5A6 => array(0x67),
- 0x1D5A7 => array(0x68),
- 0x1D5A8 => array(0x69),
- 0x1D5A9 => array(0x6A),
- 0x1D5AA => array(0x6B),
- 0x1D5AB => array(0x6C),
- 0x1D5AC => array(0x6D),
- 0x1D5AD => array(0x6E),
- 0x1D5AE => array(0x6F),
- 0x1D5AF => array(0x70),
- 0x1D5B0 => array(0x71),
- 0x1D5B1 => array(0x72),
- 0x1D5B2 => array(0x73),
- 0x1D5B3 => array(0x74),
- 0x1D5B4 => array(0x75),
- 0x1D5B5 => array(0x76),
- 0x1D5B6 => array(0x77),
- 0x1D5B7 => array(0x78),
- 0x1D5B8 => array(0x79),
- 0x1D5B9 => array(0x7A),
- 0x1D5D4 => array(0x61),
- 0x1D5D5 => array(0x62),
- 0x1D5D6 => array(0x63),
- 0x1D5D7 => array(0x64),
- 0x1D5D8 => array(0x65),
- 0x1D5D9 => array(0x66),
- 0x1D5DA => array(0x67),
- 0x1D5DB => array(0x68),
- 0x1D5DC => array(0x69),
- 0x1D5DD => array(0x6A),
- 0x1D5DE => array(0x6B),
- 0x1D5DF => array(0x6C),
- 0x1D5E0 => array(0x6D),
- 0x1D5E1 => array(0x6E),
- 0x1D5E2 => array(0x6F),
- 0x1D5E3 => array(0x70),
- 0x1D5E4 => array(0x71),
- 0x1D5E5 => array(0x72),
- 0x1D5E6 => array(0x73),
- 0x1D5E7 => array(0x74),
- 0x1D5E8 => array(0x75),
- 0x1D5E9 => array(0x76),
- 0x1D5EA => array(0x77),
- 0x1D5EB => array(0x78),
- 0x1D5EC => array(0x79),
- 0x1D5ED => array(0x7A),
- 0x1D608 => array(0x61),
- 0x1D609 => array(0x62),
- 0x1D60A => array(0x63),
- 0x1D60B => array(0x64),
- 0x1D60C => array(0x65),
- 0x1D60D => array(0x66),
- 0x1D60E => array(0x67),
- 0x1D60F => array(0x68),
- 0x1D610 => array(0x69),
- 0x1D611 => array(0x6A),
- 0x1D612 => array(0x6B),
- 0x1D613 => array(0x6C),
- 0x1D614 => array(0x6D),
- 0x1D615 => array(0x6E),
- 0x1D616 => array(0x6F),
- 0x1D617 => array(0x70),
- 0x1D618 => array(0x71),
- 0x1D619 => array(0x72),
- 0x1D61A => array(0x73),
- 0x1D61B => array(0x74),
- 0x1D61C => array(0x75),
- 0x1D61D => array(0x76),
- 0x1D61E => array(0x77),
- 0x1D61F => array(0x78),
- 0x1D620 => array(0x79),
- 0x1D621 => array(0x7A),
- 0x1D63C => array(0x61),
- 0x1D63D => array(0x62),
- 0x1D63E => array(0x63),
- 0x1D63F => array(0x64),
- 0x1D640 => array(0x65),
- 0x1D641 => array(0x66),
- 0x1D642 => array(0x67),
- 0x1D643 => array(0x68),
- 0x1D644 => array(0x69),
- 0x1D645 => array(0x6A),
- 0x1D646 => array(0x6B),
- 0x1D647 => array(0x6C),
- 0x1D648 => array(0x6D),
- 0x1D649 => array(0x6E),
- 0x1D64A => array(0x6F),
- 0x1D64B => array(0x70),
- 0x1D64C => array(0x71),
- 0x1D64D => array(0x72),
- 0x1D64E => array(0x73),
- 0x1D64F => array(0x74),
- 0x1D650 => array(0x75),
- 0x1D651 => array(0x76),
- 0x1D652 => array(0x77),
- 0x1D653 => array(0x78),
- 0x1D654 => array(0x79),
- 0x1D655 => array(0x7A),
- 0x1D670 => array(0x61),
- 0x1D671 => array(0x62),
- 0x1D672 => array(0x63),
- 0x1D673 => array(0x64),
- 0x1D674 => array(0x65),
- 0x1D675 => array(0x66),
- 0x1D676 => array(0x67),
- 0x1D677 => array(0x68),
- 0x1D678 => array(0x69),
- 0x1D679 => array(0x6A),
- 0x1D67A => array(0x6B),
- 0x1D67B => array(0x6C),
- 0x1D67C => array(0x6D),
- 0x1D67D => array(0x6E),
- 0x1D67E => array(0x6F),
- 0x1D67F => array(0x70),
- 0x1D680 => array(0x71),
- 0x1D681 => array(0x72),
- 0x1D682 => array(0x73),
- 0x1D683 => array(0x74),
- 0x1D684 => array(0x75),
- 0x1D685 => array(0x76),
- 0x1D686 => array(0x77),
- 0x1D687 => array(0x78),
- 0x1D688 => array(0x79),
- 0x1D689 => array(0x7A),
- 0x1D6A8 => array(0x3B1),
- 0x1D6A9 => array(0x3B2),
- 0x1D6AA => array(0x3B3),
- 0x1D6AB => array(0x3B4),
- 0x1D6AC => array(0x3B5),
- 0x1D6AD => array(0x3B6),
- 0x1D6AE => array(0x3B7),
- 0x1D6AF => array(0x3B8),
- 0x1D6B0 => array(0x3B9),
- 0x1D6B1 => array(0x3BA),
- 0x1D6B2 => array(0x3BB),
- 0x1D6B3 => array(0x3BC),
- 0x1D6B4 => array(0x3BD),
- 0x1D6B5 => array(0x3BE),
- 0x1D6B6 => array(0x3BF),
- 0x1D6B7 => array(0x3C0),
- 0x1D6B8 => array(0x3C1),
- 0x1D6B9 => array(0x3B8),
- 0x1D6BA => array(0x3C3),
- 0x1D6BB => array(0x3C4),
- 0x1D6BC => array(0x3C5),
- 0x1D6BD => array(0x3C6),
- 0x1D6BE => array(0x3C7),
- 0x1D6BF => array(0x3C8),
- 0x1D6C0 => array(0x3C9),
- 0x1D6D3 => array(0x3C3),
- 0x1D6E2 => array(0x3B1),
- 0x1D6E3 => array(0x3B2),
- 0x1D6E4 => array(0x3B3),
- 0x1D6E5 => array(0x3B4),
- 0x1D6E6 => array(0x3B5),
- 0x1D6E7 => array(0x3B6),
- 0x1D6E8 => array(0x3B7),
- 0x1D6E9 => array(0x3B8),
- 0x1D6EA => array(0x3B9),
- 0x1D6EB => array(0x3BA),
- 0x1D6EC => array(0x3BB),
- 0x1D6ED => array(0x3BC),
- 0x1D6EE => array(0x3BD),
- 0x1D6EF => array(0x3BE),
- 0x1D6F0 => array(0x3BF),
- 0x1D6F1 => array(0x3C0),
- 0x1D6F2 => array(0x3C1),
- 0x1D6F3 => array(0x3B8),
- 0x1D6F4 => array(0x3C3),
- 0x1D6F5 => array(0x3C4),
- 0x1D6F6 => array(0x3C5),
- 0x1D6F7 => array(0x3C6),
- 0x1D6F8 => array(0x3C7),
- 0x1D6F9 => array(0x3C8),
- 0x1D6FA => array(0x3C9),
- 0x1D70D => array(0x3C3),
- 0x1D71C => array(0x3B1),
- 0x1D71D => array(0x3B2),
- 0x1D71E => array(0x3B3),
- 0x1D71F => array(0x3B4),
- 0x1D720 => array(0x3B5),
- 0x1D721 => array(0x3B6),
- 0x1D722 => array(0x3B7),
- 0x1D723 => array(0x3B8),
- 0x1D724 => array(0x3B9),
- 0x1D725 => array(0x3BA),
- 0x1D726 => array(0x3BB),
- 0x1D727 => array(0x3BC),
- 0x1D728 => array(0x3BD),
- 0x1D729 => array(0x3BE),
- 0x1D72A => array(0x3BF),
- 0x1D72B => array(0x3C0),
- 0x1D72C => array(0x3C1),
- 0x1D72D => array(0x3B8),
- 0x1D72E => array(0x3C3),
- 0x1D72F => array(0x3C4),
- 0x1D730 => array(0x3C5),
- 0x1D731 => array(0x3C6),
- 0x1D732 => array(0x3C7),
- 0x1D733 => array(0x3C8),
- 0x1D734 => array(0x3C9),
- 0x1D747 => array(0x3C3),
- 0x1D756 => array(0x3B1),
- 0x1D757 => array(0x3B2),
- 0x1D758 => array(0x3B3),
- 0x1D759 => array(0x3B4),
- 0x1D75A => array(0x3B5),
- 0x1D75B => array(0x3B6),
- 0x1D75C => array(0x3B7),
- 0x1D75D => array(0x3B8),
- 0x1D75E => array(0x3B9),
- 0x1D75F => array(0x3BA),
- 0x1D760 => array(0x3BB),
- 0x1D761 => array(0x3BC),
- 0x1D762 => array(0x3BD),
- 0x1D763 => array(0x3BE),
- 0x1D764 => array(0x3BF),
- 0x1D765 => array(0x3C0),
- 0x1D766 => array(0x3C1),
- 0x1D767 => array(0x3B8),
- 0x1D768 => array(0x3C3),
- 0x1D769 => array(0x3C4),
- 0x1D76A => array(0x3C5),
- 0x1D76B => array(0x3C6),
- 0x1D76C => array(0x3C7),
- 0x1D76D => array(0x3C8),
- 0x1D76E => array(0x3C9),
- 0x1D781 => array(0x3C3),
- 0x1D790 => array(0x3B1),
- 0x1D791 => array(0x3B2),
- 0x1D792 => array(0x3B3),
- 0x1D793 => array(0x3B4),
- 0x1D794 => array(0x3B5),
- 0x1D795 => array(0x3B6),
- 0x1D796 => array(0x3B7),
- 0x1D797 => array(0x3B8),
- 0x1D798 => array(0x3B9),
- 0x1D799 => array(0x3BA),
- 0x1D79A => array(0x3BB),
- 0x1D79B => array(0x3BC),
- 0x1D79C => array(0x3BD),
- 0x1D79D => array(0x3BE),
- 0x1D79E => array(0x3BF),
- 0x1D79F => array(0x3C0),
- 0x1D7A0 => array(0x3C1),
- 0x1D7A1 => array(0x3B8),
- 0x1D7A2 => array(0x3C3),
- 0x1D7A3 => array(0x3C4),
- 0x1D7A4 => array(0x3C5),
- 0x1D7A5 => array(0x3C6),
- 0x1D7A6 => array(0x3C7),
- 0x1D7A7 => array(0x3C8),
- 0x1D7A8 => array(0x3C9),
- 0x1D7BB => array(0x3C3),
- 0x3F9 => array(0x3C3),
- 0x1D2C => array(0x61),
- 0x1D2D => array(0xE6),
- 0x1D2E => array(0x62),
- 0x1D30 => array(0x64),
- 0x1D31 => array(0x65),
- 0x1D32 => array(0x1DD),
- 0x1D33 => array(0x67),
- 0x1D34 => array(0x68),
- 0x1D35 => array(0x69),
- 0x1D36 => array(0x6A),
- 0x1D37 => array(0x6B),
- 0x1D38 => array(0x6C),
- 0x1D39 => array(0x6D),
- 0x1D3A => array(0x6E),
- 0x1D3C => array(0x6F),
- 0x1D3D => array(0x223),
- 0x1D3E => array(0x70),
- 0x1D3F => array(0x72),
- 0x1D40 => array(0x74),
- 0x1D41 => array(0x75),
- 0x1D42 => array(0x77),
- 0x213B => array(0x66, 0x61, 0x78),
- 0x3250 => array(0x70, 0x74, 0x65),
- 0x32CC => array(0x68, 0x67),
- 0x32CE => array(0x65, 0x76),
- 0x32CF => array(0x6C, 0x74, 0x64),
- 0x337A => array(0x69, 0x75),
- 0x33DE => array(0x76, 0x2215, 0x6D),
- 0x33DF => array(0x61, 0x2215, 0x6D)
- );
-
- /**
- * Normalization Combining Classes; Code Points not listed
- * got Combining Class 0.
- *
- * @static
- * @var array
- * @access private
- */
- private static $_np_norm_combcls = array(
- 0x334 => 1,
- 0x335 => 1,
- 0x336 => 1,
- 0x337 => 1,
- 0x338 => 1,
- 0x93C => 7,
- 0x9BC => 7,
- 0xA3C => 7,
- 0xABC => 7,
- 0xB3C => 7,
- 0xCBC => 7,
- 0x1037 => 7,
- 0x3099 => 8,
- 0x309A => 8,
- 0x94D => 9,
- 0x9CD => 9,
- 0xA4D => 9,
- 0xACD => 9,
- 0xB4D => 9,
- 0xBCD => 9,
- 0xC4D => 9,
- 0xCCD => 9,
- 0xD4D => 9,
- 0xDCA => 9,
- 0xE3A => 9,
- 0xF84 => 9,
- 0x1039 => 9,
- 0x1714 => 9,
- 0x1734 => 9,
- 0x17D2 => 9,
- 0x5B0 => 10,
- 0x5B1 => 11,
- 0x5B2 => 12,
- 0x5B3 => 13,
- 0x5B4 => 14,
- 0x5B5 => 15,
- 0x5B6 => 16,
- 0x5B7 => 17,
- 0x5B8 => 18,
- 0x5B9 => 19,
- 0x5BB => 20,
- 0x5Bc => 21,
- 0x5BD => 22,
- 0x5BF => 23,
- 0x5C1 => 24,
- 0x5C2 => 25,
- 0xFB1E => 26,
- 0x64B => 27,
- 0x64C => 28,
- 0x64D => 29,
- 0x64E => 30,
- 0x64F => 31,
- 0x650 => 32,
- 0x651 => 33,
- 0x652 => 34,
- 0x670 => 35,
- 0x711 => 36,
- 0xC55 => 84,
- 0xC56 => 91,
- 0xE38 => 103,
- 0xE39 => 103,
- 0xE48 => 107,
- 0xE49 => 107,
- 0xE4A => 107,
- 0xE4B => 107,
- 0xEB8 => 118,
- 0xEB9 => 118,
- 0xEC8 => 122,
- 0xEC9 => 122,
- 0xECA => 122,
- 0xECB => 122,
- 0xF71 => 129,
- 0xF72 => 130,
- 0xF7A => 130,
- 0xF7B => 130,
- 0xF7C => 130,
- 0xF7D => 130,
- 0xF80 => 130,
- 0xF74 => 132,
- 0x321 => 202,
- 0x322 => 202,
- 0x327 => 202,
- 0x328 => 202,
- 0x31B => 216,
- 0xF39 => 216,
- 0x1D165 => 216,
- 0x1D166 => 216,
- 0x1D16E => 216,
- 0x1D16F => 216,
- 0x1D170 => 216,
- 0x1D171 => 216,
- 0x1D172 => 216,
- 0x302A => 218,
- 0x316 => 220,
- 0x317 => 220,
- 0x318 => 220,
- 0x319 => 220,
- 0x31C => 220,
- 0x31D => 220,
- 0x31E => 220,
- 0x31F => 220,
- 0x320 => 220,
- 0x323 => 220,
- 0x324 => 220,
- 0x325 => 220,
- 0x326 => 220,
- 0x329 => 220,
- 0x32A => 220,
- 0x32B => 220,
- 0x32C => 220,
- 0x32D => 220,
- 0x32E => 220,
- 0x32F => 220,
- 0x330 => 220,
- 0x331 => 220,
- 0x332 => 220,
- 0x333 => 220,
- 0x339 => 220,
- 0x33A => 220,
- 0x33B => 220,
- 0x33C => 220,
- 0x347 => 220,
- 0x348 => 220,
- 0x349 => 220,
- 0x34D => 220,
- 0x34E => 220,
- 0x353 => 220,
- 0x354 => 220,
- 0x355 => 220,
- 0x356 => 220,
- 0x591 => 220,
- 0x596 => 220,
- 0x59B => 220,
- 0x5A3 => 220,
- 0x5A4 => 220,
- 0x5A5 => 220,
- 0x5A6 => 220,
- 0x5A7 => 220,
- 0x5AA => 220,
- 0x655 => 220,
- 0x656 => 220,
- 0x6E3 => 220,
- 0x6EA => 220,
- 0x6ED => 220,
- 0x731 => 220,
- 0x734 => 220,
- 0x737 => 220,
- 0x738 => 220,
- 0x739 => 220,
- 0x73B => 220,
- 0x73C => 220,
- 0x73E => 220,
- 0x742 => 220,
- 0x744 => 220,
- 0x746 => 220,
- 0x748 => 220,
- 0x952 => 220,
- 0xF18 => 220,
- 0xF19 => 220,
- 0xF35 => 220,
- 0xF37 => 220,
- 0xFC6 => 220,
- 0x193B => 220,
- 0x20E8 => 220,
- 0x1D17B => 220,
- 0x1D17C => 220,
- 0x1D17D => 220,
- 0x1D17E => 220,
- 0x1D17F => 220,
- 0x1D180 => 220,
- 0x1D181 => 220,
- 0x1D182 => 220,
- 0x1D18A => 220,
- 0x1D18B => 220,
- 0x59A => 222,
- 0x5AD => 222,
- 0x1929 => 222,
- 0x302D => 222,
- 0x302E => 224,
- 0x302F => 224,
- 0x1D16D => 226,
- 0x5AE => 228,
- 0x18A9 => 228,
- 0x302B => 228,
- 0x300 => 230,
- 0x301 => 230,
- 0x302 => 230,
- 0x303 => 230,
- 0x304 => 230,
- 0x305 => 230,
- 0x306 => 230,
- 0x307 => 230,
- 0x308 => 230,
- 0x309 => 230,
- 0x30A => 230,
- 0x30B => 230,
- 0x30C => 230,
- 0x30D => 230,
- 0x30E => 230,
- 0x30F => 230,
- 0x310 => 230,
- 0x311 => 230,
- 0x312 => 230,
- 0x313 => 230,
- 0x314 => 230,
- 0x33D => 230,
- 0x33E => 230,
- 0x33F => 230,
- 0x340 => 230,
- 0x341 => 230,
- 0x342 => 230,
- 0x343 => 230,
- 0x344 => 230,
- 0x346 => 230,
- 0x34A => 230,
- 0x34B => 230,
- 0x34C => 230,
- 0x350 => 230,
- 0x351 => 230,
- 0x352 => 230,
- 0x357 => 230,
- 0x363 => 230,
- 0x364 => 230,
- 0x365 => 230,
- 0x366 => 230,
- 0x367 => 230,
- 0x368 => 230,
- 0x369 => 230,
- 0x36A => 230,
- 0x36B => 230,
- 0x36C => 230,
- 0x36D => 230,
- 0x36E => 230,
- 0x36F => 230,
- 0x483 => 230,
- 0x484 => 230,
- 0x485 => 230,
- 0x486 => 230,
- 0x592 => 230,
- 0x593 => 230,
- 0x594 => 230,
- 0x595 => 230,
- 0x597 => 230,
- 0x598 => 230,
- 0x599 => 230,
- 0x59C => 230,
- 0x59D => 230,
- 0x59E => 230,
- 0x59F => 230,
- 0x5A0 => 230,
- 0x5A1 => 230,
- 0x5A8 => 230,
- 0x5A9 => 230,
- 0x5AB => 230,
- 0x5AC => 230,
- 0x5AF => 230,
- 0x5C4 => 230,
- 0x610 => 230,
- 0x611 => 230,
- 0x612 => 230,
- 0x613 => 230,
- 0x614 => 230,
- 0x615 => 230,
- 0x653 => 230,
- 0x654 => 230,
- 0x657 => 230,
- 0x658 => 230,
- 0x6D6 => 230,
- 0x6D7 => 230,
- 0x6D8 => 230,
- 0x6D9 => 230,
- 0x6DA => 230,
- 0x6DB => 230,
- 0x6DC => 230,
- 0x6DF => 230,
- 0x6E0 => 230,
- 0x6E1 => 230,
- 0x6E2 => 230,
- 0x6E4 => 230,
- 0x6E7 => 230,
- 0x6E8 => 230,
- 0x6EB => 230,
- 0x6EC => 230,
- 0x730 => 230,
- 0x732 => 230,
- 0x733 => 230,
- 0x735 => 230,
- 0x736 => 230,
- 0x73A => 230,
- 0x73D => 230,
- 0x73F => 230,
- 0x740 => 230,
- 0x741 => 230,
- 0x743 => 230,
- 0x745 => 230,
- 0x747 => 230,
- 0x749 => 230,
- 0x74A => 230,
- 0x951 => 230,
- 0x953 => 230,
- 0x954 => 230,
- 0xF82 => 230,
- 0xF83 => 230,
- 0xF86 => 230,
- 0xF87 => 230,
- 0x170D => 230,
- 0x193A => 230,
- 0x20D0 => 230,
- 0x20D1 => 230,
- 0x20D4 => 230,
- 0x20D5 => 230,
- 0x20D6 => 230,
- 0x20D7 => 230,
- 0x20DB => 230,
- 0x20DC => 230,
- 0x20E1 => 230,
- 0x20E7 => 230,
- 0x20E9 => 230,
- 0xFE20 => 230,
- 0xFE21 => 230,
- 0xFE22 => 230,
- 0xFE23 => 230,
- 0x1D185 => 230,
- 0x1D186 => 230,
- 0x1D187 => 230,
- 0x1D189 => 230,
- 0x1D188 => 230,
- 0x1D1AA => 230,
- 0x1D1AB => 230,
- 0x1D1AC => 230,
- 0x1D1AD => 230,
- 0x315 => 232,
- 0x31A => 232,
- 0x302C => 232,
- 0x35F => 233,
- 0x362 => 233,
- 0x35D => 234,
- 0x35E => 234,
- 0x360 => 234,
- 0x361 => 234,
- 0x345 => 240
- );
- // }}}
-
- // {{{ properties
- /**
- * @var string
- * @access private
- */
- private $_punycode_prefix = 'xn--';
-
- /**
- * @access private
- */
- private $_invalid_ucs = 0x80000000;
-
- /**
- * @access private
- */
- private $_max_ucs = 0x10FFFF;
-
- /**
- * @var int
- * @access private
- */
- private $_base = 36;
-
- /**
- * @var int
- * @access private
- */
- private $_tmin = 1;
-
- /**
- * @var int
- * @access private
- */
- private $_tmax = 26;
-
- /**
- * @var int
- * @access private
- */
- private $_skew = 38;
-
- /**
- * @var int
- * @access private
- */
- private $_damp = 700;
-
- /**
- * @var int
- * @access private
- */
- private $_initial_bias = 72;
-
- /**
- * @var int
- * @access private
- */
- private $_initial_n = 0x80;
-
- /**
- * @var int
- * @access private
- */
- private $_slast;
-
- /**
- * @access private
- */
- private $_sbase = 0xAC00;
-
- /**
- * @access private
- */
- private $_lbase = 0x1100;
-
- /**
- * @access private
- */
- private $_vbase = 0x1161;
-
- /**
- * @access private
- */
- private $_tbase = 0x11a7;
-
- /**
- * @var int
- * @access private
- */
- private $_lcount = 19;
-
- /**
- * @var int
- * @access private
- */
- private $_vcount = 21;
-
- /**
- * @var int
- * @access private
- */
- private $_tcount = 28;
-
- /**
- * vcount * tcount
- *
- * @var int
- * @access private
- */
- private $_ncount = 588;
-
- /**
- * lcount * tcount * vcount
- *
- * @var int
- * @access private
- */
- private $_scount = 11172;
-
- /**
- * Default encoding for encode()'s input and decode()'s output is UTF-8;
- * Other possible encodings are ucs4_string and ucs4_array
- * See {@link setParams()} for how to select these
- *
- * @var bool
- * @access private
- */
- private $_api_encoding = 'utf8';
-
- /**
- * Overlong UTF-8 encodings are forbidden
- *
- * @var bool
- * @access private
- */
- private $_allow_overlong = false;
-
- /**
- * Behave strict or not
- *
- * @var bool
- * @access private
- */
- private $_strict_mode = false;
- // }}}
-
-
- // {{{ constructor
- /**
- * Constructor
- *
- * @param array $options
- * @access public
- * @see setParams()
- */
- public function __construct($options = null)
- {
- $this->_slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount;
-
- if (is_array($options)) {
- $this->setParams($options);
- }
- }
- // }}}
-
-
- /**
- * Sets a new option value. Available options and values:
- *
- * [utf8 - Use either UTF-8 or ISO-8859-1 as input (true for UTF-8, false
- * otherwise); The output is always UTF-8]
- * [overlong - Unicode does not allow unnecessarily long encodings of chars,
- * to allow this, set this parameter to true, else to false;
- * default is false.]
- * [strict - true: strict mode, good for registration purposes - Causes errors
- * on failures; false: loose mode, ideal for "wildlife" applications
- * by silently ignoring errors and returning the original input instead]
- *
- * @param mixed $option Parameter to set (string: single parameter; array of Parameter => Value pairs)
- * @param string $value Value to use (if parameter 1 is a string)
- * @return boolean true on success, false otherwise
- * @access public
- */
- public function setParams($option, $value = false)
- {
- if (!is_array($option)) {
- $option = array($option => $value);
- }
-
- foreach ($option as $k => $v) {
- switch ($k) {
- case 'encoding':
- switch ($v) {
- case 'utf8':
- case 'ucs4_string':
- case 'ucs4_array':
- $this->_api_encoding = $v;
- break;
-
- default:
- throw new Exception('Set Parameter: Unknown parameter '.$v.' for option '.$k);
- }
-
- break;
-
- case 'overlong':
- $this->_allow_overlong = ($v) ? true : false;
- break;
-
- case 'strict':
- $this->_strict_mode = ($v) ? true : false;
- break;
-
- default:
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Encode a given UTF-8 domain name.
- *
- * @param string $decoded Domain name (UTF-8 or UCS-4)
- * [@param string $encoding Desired input encoding, see {@link set_parameter}]
- * @return string Encoded Domain name (ACE string)
- * @return mixed processed string
- * @throws Exception
- * @access public
- */
- public function encode($decoded, $one_time_encoding = false)
- {
- // Forcing conversion of input to UCS4 array
- // If one time encoding is given, use this, else the objects property
- switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
- case 'utf8':
- $decoded = $this->_utf8_to_ucs4($decoded);
- break;
- case 'ucs4_string':
- $decoded = $this->_ucs4_string_to_ucs4($decoded);
- case 'ucs4_array': // No break; before this line. Catch case, but do nothing
- break;
- default:
- throw new Exception('Unsupported input format');
- }
-
- // No input, no output, what else did you expect?
- if (empty($decoded)) return '';
-
- // Anchors for iteration
- $last_begin = 0;
- // Output string
- $output = '';
-
- foreach ($decoded as $k => $v) {
- // Make sure to use just the plain dot
- switch($v) {
- case 0x3002:
- case 0xFF0E:
- case 0xFF61:
- $decoded[$k] = 0x2E;
- // It's right, no break here
- // The codepoints above have to be converted to dots anyway
-
- // Stumbling across an anchoring character
- case 0x2E:
- case 0x2F:
- case 0x3A:
- case 0x3F:
- case 0x40:
- // Neither email addresses nor URLs allowed in strict mode
- if ($this->_strict_mode) {
- throw new Exception('Neither email addresses nor URLs are allowed in strict mode.');
- } else {
- // Skip first char
- if ($k) {
- $encoded = '';
- $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin)));
- if ($encoded) {
- $output .= $encoded;
- } else {
- $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin)));
- }
- $output .= chr($decoded[$k]);
- }
- $last_begin = $k + 1;
- }
- }
- }
- // Catch the rest of the string
- if ($last_begin) {
- $inp_len = sizeof($decoded);
- $encoded = '';
- $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
- if ($encoded) {
- $output .= $encoded;
- } else {
- $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
- }
- return $output;
- } else {
- if ($output = $this->_encode($decoded)) {
- return $output;
- } else {
- return $this->_ucs4_to_utf8($decoded);
- }
- }
- }
-
- /**
- * Decode a given ACE domain name.
- *
- * @param string $encoded Domain name (ACE string)
- * @param string $encoding Desired output encoding, see {@link set_parameter}
- * @return string Decoded Domain name (UTF-8 or UCS-4)
- * @throws Exception
- * @access public
- */
- public function decode($input, $one_time_encoding = false)
- {
- // Optionally set
- if ($one_time_encoding) {
- switch ($one_time_encoding) {
- case 'utf8':
- case 'ucs4_string':
- case 'ucs4_array':
- break;
- default:
- throw new Exception('Unknown encoding '.$one_time_encoding);
- return false;
- }
- }
- // Make sure to drop any newline characters around
- $input = trim($input);
-
- // Negotiate input and try to determine, wether it is a plain string,
- // an email address or something like a complete URL
- if (strpos($input, '@')) { // Maybe it is an email address
- // No no in strict mode
- if ($this->_strict_mode) {
- throw new Exception('Only simple domain name parts can be handled in strict mode');
- }
- list($email_pref, $input) = explode('@', $input, 2);
- $arr = explode('.', $input);
- foreach ($arr as $k => $v) {
- $conv = $this->_decode($v);
- if ($conv) $arr[$k] = $conv;
- }
- $return = $email_pref . '@' . join('.', $arr);
- } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
- // No no in strict mode
- if ($this->_strict_mode) {
- throw new Exception('Only simple domain name parts can be handled in strict mode');
- }
- $parsed = parse_url($input);
- if (isset($parsed['host'])) {
- $arr = explode('.', $parsed['host']);
- foreach ($arr as $k => $v) {
- $conv = $this->_decode($v);
- if ($conv) $arr[$k] = $conv;
- }
- $parsed['host'] = join('.', $arr);
- if (isset($parsed['scheme'])) {
- $parsed['scheme'] .= (strtolower($parsed['scheme']) == 'mailto') ? ':' : '://';
- }
- $return = join('', $parsed);
- } else { // parse_url seems to have failed, try without it
- $arr = explode('.', $input);
- foreach ($arr as $k => $v) {
- $conv = $this->_decode($v);
- if ($conv) $arr[$k] = $conv;
- }
- $return = join('.', $arr);
- }
- } else { // Otherwise we consider it being a pure domain name string
- $return = $this->_decode($input);
- }
- // The output is UTF-8 by default, other output formats need conversion here
- // If one time encoding is given, use this, else the objects property
- switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
- case 'utf8':
- return $return;
- break;
- case 'ucs4_string':
- return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));
- break;
- case 'ucs4_array':
- return $this->_utf8_to_ucs4($return);
- break;
- default:
- throw new Exception('Unsupported output format');
- }
- }
-
-
- // {{{ private
- /**
- * The actual encoding algorithm.
- *
- * @return string
- * @throws Exception
- * @access private
- */
- private function _encode($decoded)
- {
- // We cannot encode a domain name containing the Punycode prefix
- $extract = strlen($this->_punycode_prefix);
- $check_pref = $this->_utf8_to_ucs4($this->_punycode_prefix);
- $check_deco = array_slice($decoded, 0, $extract);
-
- if ($check_pref == $check_deco) {
- throw new Exception('This is already a punycode string');
- }
- // We will not try to encode strings consisting of basic code points only
- $encodable = false;
- foreach ($decoded as $k => $v) {
- if ($v > 0x7a) {
- $encodable = true;
- break;
- }
- }
- if (!$encodable) {
- if ($this->_strict_mode) {
- throw new Exception('The given string does not contain encodable chars');
- } else {
- return false;
- }
- }
-
- // Do NAMEPREP
- try {
- $decoded = $this->_nameprep($decoded);
- } catch (Exception $e) {
- // hmm, serious - rethrow
- throw $e;
- }
-
- $deco_len = count($decoded);
-
- // Empty array
- if (!$deco_len) {
- return false;
- }
-
- // How many chars have been consumed
- $codecount = 0;
-
- // Start with the prefix; copy it to output
- $encoded = $this->_punycode_prefix;
-
- $encoded = '';
- // Copy all basic code points to output
- for ($i = 0; $i < $deco_len; ++$i) {
- $test = $decoded[$i];
- // Will match [0-9a-zA-Z-]
- if ((0x2F < $test && $test < 0x40)
- || (0x40 < $test && $test < 0x5B)
- || (0x60 < $test && $test <= 0x7B)
- || (0x2D == $test)) {
- $encoded .= chr($decoded[$i]);
- $codecount++;
- }
- }
-
- // All codepoints were basic ones
- if ($codecount == $deco_len) {
- return $encoded;
- }
-
- // Start with the prefix; copy it to output
- $encoded = $this->_punycode_prefix . $encoded;
-
- // If we have basic code points in output, add an hyphen to the end
- if ($codecount) {
- $encoded .= '-';
- }
-
- // Now find and encode all non-basic code points
- $is_first = true;
- $cur_code = $this->_initial_n;
- $bias = $this->_initial_bias;
- $delta = 0;
-
- while ($codecount < $deco_len) {
- // Find the smallest code point >= the current code point and
- // remember the last ouccrence of it in the input
- for ($i = 0, $next_code = $this->_max_ucs; $i < $deco_len; $i++) {
- if ($decoded[$i] >= $cur_code && $decoded[$i] <= $next_code) {
- $next_code = $decoded[$i];
- }
- }
-
- $delta += ($next_code - $cur_code) * ($codecount + 1);
- $cur_code = $next_code;
-
- // Scan input again and encode all characters whose code point is $cur_code
- for ($i = 0; $i < $deco_len; $i++) {
- if ($decoded[$i] < $cur_code) {
- $delta++;
- } else if ($decoded[$i] == $cur_code) {
- for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
- $t = ($k <= $bias)?
- $this->_tmin :
- (($k >= $bias + $this->_tmax)? $this->_tmax : $k - $bias);
-
- if ($q < $t) {
- break;
- }
-
- $encoded .= $this->_encodeDigit(ceil($t + (($q - $t) % ($this->_base - $t))));
- $q = ($q - $t) / ($this->_base - $t);
- }
-
- $encoded .= $this->_encodeDigit($q);
- $bias = $this->_adapt($delta, $codecount + 1, $is_first);
- $codecount++;
- $delta = 0;
- $is_first = false;
- }
- }
-
- $delta++;
- $cur_code++;
- }
-
- return $encoded;
- }
-
- /**
- * The actual decoding algorithm.
- *
- * @return string
- * @throws Exception
- * @access private
- */
- private function _decode($encoded)
- {
- // We do need to find the Punycode prefix
- if (!preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) {
- return false;
- }
-
- $encode_test = preg_replace('!^' . preg_quote($this->_punycode_prefix, '!') . '!', '', $encoded);
-
- // If nothing left after removing the prefix, it is hopeless
- if (!$encode_test) {
- return false;
- }
-
- // Find last occurence of the delimiter
- $delim_pos = strrpos($encoded, '-');
-
- if ($delim_pos > strlen($this->_punycode_prefix)) {
- for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
- $decoded[] = ord($encoded{$k});
- }
- } else {
- $decoded = array();
- }
-
- $deco_len = count($decoded);
- $enco_len = strlen($encoded);
-
- // Wandering through the strings; init
- $is_first = true;
- $bias = $this->_initial_bias;
- $idx = 0;
- $char = $this->_initial_n;
-
- for ($enco_idx = ($delim_pos)? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
- for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
- $digit = $this->_decodeDigit($encoded{$enco_idx++});
- $idx += $digit * $w;
-
- $t = ($k <= $bias) ?
- $this->_tmin :
- (($k >= $bias + $this->_tmax)? $this->_tmax : ($k - $bias));
-
- if ($digit < $t) {
- break;
- }
-
- $w = (int)($w * ($this->_base - $t));
- }
-
- $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
- $is_first = false;
- $char += (int) ($idx / ($deco_len + 1));
- $idx %= ($deco_len + 1);
-
- if ($deco_len > 0) {
- // Make room for the decoded char
- for ($i = $deco_len; $i > $idx; $i--) {
- $decoded[$i] = $decoded[($i - 1)];
- }
- }
-
- $decoded[$idx++] = $char;
- }
-
- try {
- return $this->_ucs4_to_utf8($decoded);
- } catch (Exception $e) {
- // rethrow
- throw $e;
- }
- }
-
- /**
- * Adapt the bias according to the current code point and position.
- *
- * @access private
- */
- private function _adapt($delta, $npoints, $is_first)
- {
- $delta = (int) ($is_first ? ($delta / $this->_damp) : ($delta / 2));
- $delta += (int) ($delta / $npoints);
-
- for ($k = 0; $delta > (($this->_base - $this->_tmin) * $this->_tmax) / 2; $k += $this->_base) {
- $delta = (int) ($delta / ($this->_base - $this->_tmin));
- }
-
- return (int) ($k + ($this->_base - $this->_tmin + 1) * $delta / ($delta + $this->_skew));
- }
-
- /**
- * Encoding a certain digit.
- *
- * @access private
- */
- private function _encodeDigit($d)
- {
- return chr($d + 22 + 75 * ($d < 26));
- }
-
- /**
- * Decode a certain digit.
- *
- * @access private
- */
- private function _decodeDigit($cp)
- {
- $cp = ord($cp);
- return ($cp - 48 < 10)? $cp - 22 : (($cp - 65 < 26)? $cp - 65 : (($cp - 97 < 26)? $cp - 97 : $this->_base));
- }
-
- /**
- * Do Nameprep according to RFC3491 and RFC3454.
- *
- * @param array $input Unicode Characters
- * @return string Unicode Characters, Nameprep'd
- * @throws Exception
- * @access private
- */
- private function _nameprep($input)
- {
- $output = array();
-
- // Walking through the input array, performing the required steps on each of
- // the input chars and putting the result into the output array
- // While mapping required chars we apply the cannonical ordering
-
- foreach ($input as $v) {
- // Map to nothing == skip that code point
- if (in_array($v, self::$_np_map_nothing)) {
- continue;
- }
-
- // Try to find prohibited input
- if (in_array($v, self::$_np_prohibit) || in_array($v, self::$_general_prohibited)) {
- throw new Exception('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v));
- }
-
- foreach (self::$_np_prohibit_ranges as $range) {
- if ($range[0] <= $v && $v <= $range[1]) {
- throw new Exception('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v));
- }
- }
-
- // Hangul syllable decomposition
- if (0xAC00 <= $v && $v <= 0xD7AF) {
- foreach ($this->_hangulDecompose($v) as $out) {
- $output[] = $out;
- }
- } else if (isset(self::$_np_replacemaps[$v])) { // There's a decomposition mapping for that code point
- foreach ($this->_applyCannonicalOrdering(self::$_np_replacemaps[$v]) as $out) {
- $output[] = $out;
- }
- } else {
- $output[] = $v;
- }
- }
-
- // Combine code points
-
- $last_class = 0;
- $last_starter = 0;
- $out_len = count($output);
-
- for ($i = 0; $i < $out_len; ++$i) {
- $class = $this->_getCombiningClass($output[$i]);
-
- if ((!$last_class || $last_class != $class) && $class) {
- // Try to match
- $seq_len = $i - $last_starter;
- $out = $this->_combine(array_slice($output, $last_starter, $seq_len));
-
- // On match: Replace the last starter with the composed character and remove
- // the now redundant non-starter(s)
- if ($out) {
- $output[$last_starter] = $out;
-
- if (count($out) != $seq_len) {
- for ($j = $i + 1; $j < $out_len; ++$j) {
- $output[$j - 1] = $output[$j];
- }
-
- unset($output[$out_len]);
- }
-
- // Rewind the for loop by one, since there can be more possible compositions
- $i--;
- $out_len--;
- $last_class = ($i == $last_starter)? 0 : $this->_getCombiningClass($output[$i - 1]);
-
- continue;
- }
- }
-
- // The current class is 0
- if (!$class) {
- $last_starter = $i;
- }
-
- $last_class = $class;
- }
-
- return $output;
- }
-
- /**
- * Decomposes a Hangul syllable
- * (see http://www.unicode.org/unicode/reports/tr15/#Hangul).
- *
- * @param integer $char 32bit UCS4 code point
- * @return array Either Hangul Syllable decomposed or original 32bit
- * value as one value array
- * @access private
- */
- private function _hangulDecompose($char)
- {
- $sindex = $char - $this->_sbase;
-
- if ($sindex < 0 || $sindex >= $this->_scount) {
- return array($char);
- }
-
- $result = array();
- $T = $this->_tbase + $sindex % $this->_tcount;
- $result[] = (int)($this->_lbase + $sindex / $this->_ncount);
- $result[] = (int)($this->_vbase + ($sindex % $this->_ncount) / $this->_tcount);
-
- if ($T != $this->_tbase) {
- $result[] = $T;
- }
-
- return $result;
- }
-
- /**
- * Ccomposes a Hangul syllable
- * (see http://www.unicode.org/unicode/reports/tr15/#Hangul).
- *
- * @param array $input Decomposed UCS4 sequence
- * @return array UCS4 sequence with syllables composed
- * @access private
- */
- private function _hangulCompose($input)
- {
- $inp_len = count($input);
-
- if (!$inp_len) {
- return array();
- }
-
- $result = array();
- $last = $input[0];
- $result[] = $last; // copy first char from input to output
-
- for ($i = 1; $i < $inp_len; ++$i) {
- $char = $input[$i];
-
- // Find out, wether two current characters from L and V
- $lindex = $last - $this->_lbase;
-
- if (0 <= $lindex && $lindex < $this->_lcount) {
- $vindex = $char - $this->_vbase;
-
- if (0 <= $vindex && $vindex < $this->_vcount) {
- // create syllable of form LV
- $last = ($this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount);
- $out_off = count($result) - 1;
- $result[$out_off] = $last; // reset last
-
- // discard char
- continue;
- }
- }
-
- // Find out, wether two current characters are LV and T
- $sindex = $last - $this->_sbase;
-
- if (0 <= $sindex && $sindex < $this->_scount && ($sindex % $this->_tcount) == 0) {
- $tindex = $char - $this->_tbase;
-
- if (0 <= $tindex && $tindex <= $this->_tcount) {
- // create syllable of form LVT
- $last += $tindex;
- $out_off = count($result) - 1;
- $result[$out_off] = $last; // reset last
-
- // discard char
- continue;
- }
- }
-
- // if neither case was true, just add the character
- $last = $char;
- $result[] = $char;
- }
-
- return $result;
- }
-
- /**
- * Returns the combining class of a certain wide char.
- *
- * @param integer $char Wide char to check (32bit integer)
- * @return integer Combining class if found, else 0
- * @access private
- */
- private function _getCombiningClass($char)
- {
- return isset(self::$_np_norm_combcls[$char])? self::$_np_norm_combcls[$char] : 0;
- }
-
- /**
- * Apllies the cannonical ordering of a decomposed UCS4 sequence.
- *
- * @param array $input Decomposed UCS4 sequence
- * @return array Ordered USC4 sequence
- * @access private
- */
- private function _applyCannonicalOrdering($input)
- {
- $swap = true;
- $size = count($input);
-
- while ($swap) {
- $swap = false;
- $last = $this->_getCombiningClass($input[0]);
-
- for ($i = 0; $i < $size - 1; ++$i) {
- $next = $this->_getCombiningClass($input[$i + 1]);
-
- if ($next != 0 && $last > $next) {
- // Move item leftward until it fits
- for ($j = $i + 1; $j > 0; --$j) {
- if ($this->_getCombiningClass($input[$j - 1]) <= $next) {
- break;
- }
-
- $t = $input[$j];
- $input[$j] = $input[$j - 1];
- $input[$j - 1] = $t;
- $swap = 1;
- }
-
- // Reentering the loop looking at the old character again
- $next = $last;
- }
-
- $last = $next;
- }
- }
-
- return $input;
- }
-
- /**
- * Do composition of a sequence of starter and non-starter.
- *
- * @param array $input UCS4 Decomposed sequence
- * @return array Ordered USC4 sequence
- * @access private
- */
- private function _combine($input)
- {
- $inp_len = count($input);
-
- // Is it a Hangul syllable?
- if (1 != $inp_len) {
- $hangul = $this->_hangulCompose($input);
-
- // This place is probably wrong
- if (count($hangul) != $inp_len) {
- return $hangul;
- }
- }
-
- foreach (self::$_np_replacemaps as $np_src => $np_target) {
- if ($np_target[0] != $input[0]) {
- continue;
- }
-
- if (count($np_target) != $inp_len) {
- continue;
- }
-
- $hit = false;
-
- foreach ($input as $k2 => $v2) {
- if ($v2 == $np_target[$k2]) {
- $hit = true;
- } else {
- $hit = false;
- break;
- }
- }
-
- if ($hit) {
- return $np_src;
- }
- }
-
- return false;
- }
-
- /**
- * This converts an UTF-8 encoded string to its UCS-4 (array) representation
- * By talking about UCS-4 we mean arrays of 32bit integers representing
- * each of the "chars". This is due to PHP not being able to handle strings with
- * bit depth different from 8. This applies to the reverse method _ucs4_to_utf8(), too.
- * The following UTF-8 encodings are supported:
- *
- * bytes bits representation
- * 1 7 0xxxxxxx
- * 2 11 110xxxxx 10xxxxxx
- * 3 16 1110xxxx 10xxxxxx 10xxxxxx
- * 4 21 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 5 26 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 6 31 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- *
- * Each x represents a bit that can be used to store character data.
- *
- * @access private
- */
- private function _utf8_to_ucs4($input)
- {
- $output = array();
- $out_len = 0;
- $inp_len = strlen($input);
- $mode = 'next';
- $test = 'none';
- for ($k = 0; $k < $inp_len; ++$k) {
- $v = ord($input{$k}); // Extract byte from input string
-
- if ($v < 128) { // We found an ASCII char - put into stirng as is
- $output[$out_len] = $v;
- ++$out_len;
- if ('add' == $mode) {
- throw new Exception('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
- return false;
- }
- continue;
- }
- if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char
- $start_byte = $v;
- $mode = 'add';
- $test = 'range';
- if ($v >> 5 == 6) { // &110xxxxx 10xxxxx
- $next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left
- $v = ($v - 192) << 6;
- } elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx
- $next_byte = 1;
- $v = ($v - 224) << 12;
- } elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- $next_byte = 2;
- $v = ($v - 240) << 18;
- } elseif ($v >> 2 == 62) { // &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- $next_byte = 3;
- $v = ($v - 248) << 24;
- } elseif ($v >> 1 == 126) { // &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- $next_byte = 4;
- $v = ($v - 252) << 30;
- } else {
- throw new Exception('This might be UTF-8, but I don\'t understand it at byte '.$k);
- return false;
- }
- if ('add' == $mode) {
- $output[$out_len] = (int) $v;
- ++$out_len;
- continue;
- }
- }
- if ('add' == $mode) {
- if (!$this->_allow_overlong && $test == 'range') {
- $test = 'none';
- if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
- throw new Exception('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
- return false;
- }
- }
- if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx
- $v = ($v - 128) << ($next_byte * 6);
- $output[($out_len - 1)] += $v;
- --$next_byte;
- } else {
- throw new Exception('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
- return false;
- }
- if ($next_byte < 0) {
- $mode = 'next';
- }
- }
- } // for
- return $output;
- }
-
- /**
- * Convert UCS-4 array into UTF-8 string.
- *
- * @throws Exception
- * @access private
- */
- private function _ucs4_to_utf8($input)
- {
- $output = '';
-
- foreach ($input as $v) {
- // $v = ord($v);
-
- if ($v < 128) {
- // 7bit are transferred literally
- $output .= chr($v);
- } else if ($v < 1 << 11) {
- // 2 bytes
- $output .= chr(192 + ($v >> 6))
- . chr(128 + ($v & 63));
- } else if ($v < 1 << 16) {
- // 3 bytes
- $output .= chr(224 + ($v >> 12))
- . chr(128 + (($v >> 6) & 63))
- . chr(128 + ($v & 63));
- } else if ($v < 1 << 21) {
- // 4 bytes
- $output .= chr(240 + ($v >> 18))
- . chr(128 + (($v >> 12) & 63))
- . chr(128 + (($v >> 6) & 63))
- . chr(128 + ($v & 63));
- } else if ($v < 1 << 26) {
- // 5 bytes
- $output .= chr(248 + ($v >> 24))
- . chr(128 + (($v >> 18) & 63))
- . chr(128 + (($v >> 12) & 63))
- . chr(128 + (($v >> 6) & 63))
- . chr(128 + ($v & 63));
- } else if ($v < 1 << 31) {
- // 6 bytes
- $output .= chr(252 + ($v >> 30))
- . chr(128 + (($v >> 24) & 63))
- . chr(128 + (($v >> 18) & 63))
- . chr(128 + (($v >> 12) & 63))
- . chr(128 + (($v >> 6) & 63))
- . chr(128 + ($v & 63));
- } else {
- throw new Exception('Conversion from UCS-4 to UTF-8 failed: malformed input at byte ' . $k);
- }
- }
-
- return $output;
- }
-
- /**
- * Convert UCS-4 array into UCS-4 string
- *
- * @throws Exception
- * @access private
- */
- private function _ucs4_to_ucs4_string($input)
- {
- $output = '';
- // Take array values and split output to 4 bytes per value
- // The bit mask is 255, which reads &11111111
- foreach ($input as $v) {
- $output .= ($v & (255 << 24) >> 24) . ($v & (255 << 16) >> 16) . ($v & (255 << 8) >> 8) . ($v & 255);
- }
- return $output;
- }
-
- /**
- * Convert UCS-4 strin into UCS-4 garray
- *
- * @throws Exception
- * @access private
- */
- private function _ucs4_string_to_ucs4($input)
- {
- $output = array();
-
- $inp_len = strlen($input);
- // Input length must be dividable by 4
- if ($inp_len % 4) {
- throw new Exception('Input UCS4 string is broken');
- return false;
- }
-
- // Empty input - return empty output
- if (!$inp_len) return $output;
-
- for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
- // Increment output position every 4 input bytes
- if (!$i % 4) {
- $out_len++;
- $output[$out_len] = 0;
- }
- $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
- }
- return $output;
- }
-
- /**
- * Echo hex representation of UCS4 sequence.
- *
- * @param array $input UCS4 sequence
- * @param boolean $include_bit Include bitmask in output
- * @return void
- * @static
- * @access private
- */
- private static function _showHex($input, $include_bit = false)
- {
- foreach ($input as $k => $v) {
- echo '[', $k, '] => ', sprintf('%X', $v);
-
- if ($include_bit) {
- echo ' (', Net_IDNA::_showBitmask($v), ')';
- }
-
- echo "\n";
- }
- }
-
- /**
- * Gives you a bit representation of given Byte (8 bits), Word (16 bits) or DWord (32 bits)
- * Output width is automagically determined
- *
- * @static
- * @access private
- */
- private static function _showBitmask($octet)
- {
- if ($octet >= (1 << 16)) {
- $w = 31;
- } else if ($octet >= (1 << 8)) {
- $w = 15;
- } else {
- $w = 7;
- }
-
- $return = '';
-
- for ($i = $w; $i > -1; $i--) {
- $return .= ($octet & (1 << $i))? 1 : '0';
- }
-
- return $return;
- }
- // }}}}
-}
-
-?>
diff --git a/thirdparty/pear/Net/IPv4.php b/thirdparty/pear/Net/IPv4.php
deleted file mode 100644
index e9195715d..000000000
--- a/thirdparty/pear/Net/IPv4.php
+++ /dev/null
@@ -1,458 +0,0 @@
-
-* @author Marco Kaiser
-* @author Florian Anderiasch
-* @copyright 1997-2005 The PHP Group
-* @license http://www.php.net/license/3_01.txt PHP License 3.01
-* @version CVS: $Id: IPv4.php,v 1.11 2005/11/29 12:56:35 fa Exp $
-* @link http://pear.php.net/package/Net_IPv4
-*/
-
-require_once 'PEAR.php';
-
-// {{{ GLOBALS
-/**
- * Map of bitmasks to subnets
- *
- * This array contains every valid netmask. The index of the dot quad
- * netmask value is the corresponding CIDR notation (bitmask).
- *
- * @global array $GLOBALS['Net_IPv4_Netmask_Map']
- */
-$GLOBALS['Net_IPv4_Netmask_Map'] = array(
- 0 => "0.0.0.0",
- 1 => "128.0.0.0",
- 2 => "192.0.0.0",
- 3 => "224.0.0.0",
- 4 => "240.0.0.0",
- 5 => "248.0.0.0",
- 6 => "252.0.0.0",
- 7 => "254.0.0.0",
- 8 => "255.0.0.0",
- 9 => "255.128.0.0",
- 10 => "255.192.0.0",
- 11 => "255.224.0.0",
- 12 => "255.240.0.0",
- 13 => "255.248.0.0",
- 14 => "255.252.0.0",
- 15 => "255.254.0.0",
- 16 => "255.255.0.0",
- 17 => "255.255.128.0",
- 18 => "255.255.192.0",
- 19 => "255.255.224.0",
- 20 => "255.255.240.0",
- 21 => "255.255.248.0",
- 22 => "255.255.252.0",
- 23 => "255.255.254.0",
- 24 => "255.255.255.0",
- 25 => "255.255.255.128",
- 26 => "255.255.255.192",
- 27 => "255.255.255.224",
- 28 => "255.255.255.240",
- 29 => "255.255.255.248",
- 30 => "255.255.255.252",
- 31 => "255.255.255.254",
- 32 => "255.255.255.255"
- );
-// }}}
-// {{{ Net_IPv4
-
-/**
-* Class to provide IPv4 calculations
-*
-* Provides methods for validating IP addresses, calculating netmasks,
-* broadcast addresses, network addresses, conversion routines, etc.
-*
-* @category Net
-* @package Net_IPv4
-* @author Eric Kilfoil
-* @author Marco Kaiser
-* @author Florian Anderiasch
-* @copyright 1997-2005 The PHP Group
-* @license http://www.php.net/license/3_01.txt PHP License 3.01
-* @version CVS: 1.3.0
-* @link http://pear.php.net/package/Net_IPv4
-* @access public
-*/
-class Net_IPv4
-{
- // {{{ properties
- var $ip = "";
- var $bitmask = false;
- var $netmask = "";
- var $network = "";
- var $broadcast = "";
- var $long = 0;
-
- // }}}
- // {{{ validateIP()
-
- /**
- * Validate the syntax of the given IP adress
- *
- * Using the PHP long2ip() and ip2long() functions, convert the IP
- * address from a string to a long and back. If the original still
- * matches the converted IP address, it's a valid address. This
- * function does not allow for IP addresses to be formatted as long
- * integers.
- *
- * @param string $ip IP address in the format x.x.x.x
- * @return bool true if syntax is valid, otherwise false
- */
- function validateIP($ip)
- {
- if ($ip == long2ip(ip2long($ip))) {
- return true;
- } else {
- return false;
- }
- }
-
- // }}}
- // {{{ check_ip()
-
- /**
- * Validate the syntax of the given IP address (compatibility)
- *
- * This function is identical to Net_IPv4::validateIP(). It is included
- * merely for compatibility reasons.
- *
- * @param string $ip IP address
- * @return bool true if syntax is valid, otherwise false
- */
- function check_ip($ip)
- {
- return $this->validateIP($ip);
- }
-
- // }}}
- // {{{ validateNetmask()
-
- /**
- * Validate the syntax of a four octet netmask
- *
- * There are 33 valid netmask values. This function will compare the
- * string passed as $netmask to the predefined 33 values and return
- * true or false. This is most likely much faster than performing the
- * calculation to determine the validity of the netmask.
- *
- * @param string $netmask Netmask
- * @return bool true if syntax is valid, otherwise false
- */
- function validateNetmask($netmask)
- {
- if (! in_array($netmask, $GLOBALS['Net_IPv4_Netmask_Map'])) {
- return false;
- }
- return true;
- }
-
- // }}}
- // {{{ parseAddress()
-
- /**
- * Parse a formatted IP address
- *
- * Given a network qualified IP address, attempt to parse out the parts
- * and calculate qualities of the address.
- *
- * The following formats are possible:
- *
- * [dot quad ip]/[ bitmask ]
- * [dot quad ip]/[ dot quad netmask ]
- * [dot quad ip]/[ hex string netmask ]
- *
- * The first would be [IP Address]/[BitMask]:
- * 192.168.0.0/16
- *
- * The second would be [IP Address] [Subnet Mask in dot quad notation]:
- * 192.168.0.0/255.255.0.0
- *
- * The third would be [IP Address] [Subnet Mask as Hex string]
- * 192.168.0.0/ffff0000
- *
- * Usage:
- *
- * $cidr = '192.168.0.50/16';
- * $net = Net_IPv4::parseAddress($cidr);
- * echo $net->network; // 192.168.0.0
- * echo $net->ip; // 192.168.0.50
- * echo $net->broadcast; // 192.168.255.255
- * echo $net->bitmask; // 16
- * echo $net->long; // 3232235520 (long/double version of 192.168.0.50)
- * echo $net->netmask; // 255.255.0.0
- *
- * @param string $ip IP address netmask combination
- * @return object true if syntax is valid, otherwise false
- */
- function parseAddress($address)
- {
- $myself = new Net_IPv4;
- if (strchr($address, "/")) {
- $parts = explode("/", $address);
- if (! $myself->validateIP($parts[0])) {
- return PEAR::raiseError("invalid IP address");
- }
- $myself->ip = $parts[0];
-
- // Check the style of netmask that was entered
- /*
- * a hexadecimal string was entered
- */
- if (preg_match("/([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/", $parts[1], $regs)) {
- // hexadecimal string
- $myself->netmask = hexdec($regs[1]) . "." . hexdec($regs[2]) . "." .
- hexdec($regs[3]) . "." . hexdec($regs[4]);
-
- /*
- * a standard dot quad netmask was entered.
- */
- } else if (strchr($parts[1], ".")) {
- if (! $myself->validateNetmask($parts[1])) {
- return PEAR::raiseError("invalid netmask value");
- }
- $myself->netmask = $parts[1];
-
- /*
- * a CIDR bitmask type was entered
- */
- } else if ($parts[1] >= 0 && $parts[1] <= 32) {
- // bitmask was entered
- $myself->bitmask = $parts[1];
-
- /*
- * Some unknown format of netmask was entered
- */
- } else {
- return PEAR::raiseError("invalid netmask value");
- }
- $myself->calculate();
- return $myself;
- } else if ($myself->validateIP($address)) {
- $myself->ip = $address;
- return $myself;
- } else {
- return PEAR::raiseError("invalid IP address");
- }
- }
-
- // }}}
- // {{{ calculate()
-
- /**
- * Calculates network information based on an IP address and netmask.
- *
- * Fully populates the object properties based on the IP address and
- * netmask/bitmask properties. Once these two fields are populated,
- * calculate() will perform calculations to determine the network and
- * broadcast address of the network.
- *
- * @return mixed true if no errors occured, otherwise PEAR_Error object
- */
- function calculate()
- {
- $validNM = $GLOBALS['Net_IPv4_Netmask_Map'];
-
- if (! is_a($this, "net_ipv4")) {
- $myself = new Net_IPv4;
- return PEAR::raiseError("cannot calculate on uninstantiated Net_IPv4 class");
- }
-
- /* Find out if we were given an ip address in dot quad notation or
- * a network long ip address. Whichever was given, populate the
- * other field
- */
- if (strlen($this->ip)) {
- if (! $this->validateIP($this->ip)) {
- return PEAR::raiseError("invalid IP address");
- }
- $this->long = $this->ip2double($this->ip);
- } else if (is_numeric($this->long)) {
- $this->ip = long2ip($this->long);
- } else {
- return PEAR::raiseError("ip address not specified");
- }
-
- /*
- * Check to see if we were supplied with a bitmask or a netmask.
- * Populate the other field as needed.
- */
- if (strlen($this->bitmask)) {
- $this->netmask = $validNM[$this->bitmask];
- } else if (strlen($this->netmask)) {
- $validNM_rev = array_flip($validNM);
- $this->bitmask = $validNM_rev[$this->netmask];
- } else {
- return PEAR::raiseError("netmask or bitmask are required for calculation");
- }
- $this->network = long2ip(ip2long($this->ip) & ip2long($this->netmask));
- $this->broadcast = long2ip(ip2long($this->ip) |
- (ip2long($this->netmask) ^ ip2long("255.255.255.255")));
- return true;
- }
-
- // }}}
- // {{{ getNetmask()
-
- function getNetmask($length)
- {
- if (! PEAR::isError($ipobj = Net_IPv4::parseAddress("0.0.0.0/" . $length))) {
- $mask = $ipobj->netmask;
- unset($ipobj);
- return $mask;
- }
- return false;
- }
-
- // }}}
- // {{{ getNetLength()
-
- function getNetLength($netmask)
- {
- if (! PEAR::isError($ipobj = Net_IPv4::parseAddress("0.0.0.0/" . $netmask))) {
- $bitmask = $ipobj->bitmask;
- unset($ipobj);
- return $bitmask;
- }
- return false;
- }
-
- // }}}
- // {{{ getSubnet()
-
- function getSubnet($ip, $netmask)
- {
- if (! PEAR::isError($ipobj = Net_IPv4::parseAddress($ip . "/" . $netmask))) {
- $net = $ipobj->network;
- unset($ipobj);
- return $net;
- }
- return false;
- }
-
- // }}}
- // {{{ inSameSubnet()
-
- function inSameSubnet($ip1, $ip2)
- {
- if (! is_object($ip1) || strcasecmp(get_class($ip1), 'net_ipv4') <> 0) {
- $ipobj1 = Net_IPv4::parseAddress($ip1);
- if (PEAR::isError($ipobj)) {
- return PEAR::raiseError("IP addresses must be an understood format or a Net_IPv4 object");
- }
- }
- if (! is_object($ip2) || strcasecmp(get_class($ip2), 'net_ipv4') <> 0) {
- $ipobj2 = Net_IPv4::parseAddress($ip2);
- if (PEAR::isError($ipobj)) {
- return PEAR::raiseError("IP addresses must be an understood format or a Net_IPv4 object");
- }
- }
- if ($ipobj1->network == $ipobj2->network &&
- $ipobj1->bitmask == $ipobj2->bitmask) {
- return true;
- }
- return false;
- }
-
- // }}}
- // {{{ atoh()
-
- /**
- * Converts a dot-quad formatted IP address into a hexadecimal string
- * @param string $addr IP-adress in dot-quad format
- * @return mixed false if invalid IP and hexadecimal representation as string if valid
- */
- function atoh($addr)
- {
- if (! Net_IPv4::validateIP($addr)) {
- return false;
- }
- $ap = explode(".", $addr);
- return sprintf("%02x%02x%02x%02x", $ap[0], $ap[1], $ap[2], $ap[3]);
- }
-
- // }}}
- // {{{ htoa()
-
- /**
- * Converts a hexadecimal string into a dot-quad formatted IP address
- * @param string $addr IP-adress in hexadecimal format
- * @return mixed false if invalid IP and dot-quad formatted IP as string if valid
- */
- function htoa($addr)
- {
- if (preg_match("/([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/",
- $addr, $regs)) {
- return hexdec($regs[1]) . "." . hexdec($regs[2]) . "." .
- hexdec($regs[3]) . "." . hexdec($regs[4]);
- }
- return false;
- }
-
- // }}}
- // {{{ ip2double()
-
- /**
- * Converts an IP address to a PHP double. Better than ip2long because
- * a long in PHP is a signed integer.
- * @param string $ip dot-quad formatted IP adress
- * @return float IP adress as double - positive value unlike ip2long
- */
- function ip2double($ip)
- {
- return (double)(sprintf("%u", ip2long($ip)));
- }
-
- // }}}
- // {{{ ipInNetwork()
-
- /**
- * Determines whether or not the supplied IP is within the supplied network.
- *
- * This function determines whether an IP address is within a network.
- * The IP address ($ip) must be supplied in dot-quad format, and the
- * network ($network) may be either a string containing a CIDR
- * formatted network definition, or a Net_IPv4 object.
- *
- * @param string $ip A dot quad representation of an IP address
- * @param string $network A string representing the network in CIDR format or a Net_IPv4 object.
- * @return bool true if the IP address exists within the network
- */
- function ipInNetwork($ip, $network)
- {
- if (! is_object($network) || strcasecmp(get_class($network), 'net_ipv4') <> 0) {
- $network = Net_IPv4::parseAddress($network);
- }
-
- $net = Net_IPv4::ip2double($network->network);
- $bcast = Net_IPv4::ip2double($network->broadcast);
- $ip = Net_IPv4::ip2double($ip);
- unset($network);
- if ($ip >= $net && $ip <= $bcast) {
- return true;
- }
- return false;
- }
-
- // }}}
-}
-
-// }}}
-
-/*
- * vim: sts=4 ts=4 sw=4 cindent fdm=marker
- */
-?>
diff --git a/thirdparty/pear/Net/IPv6.php b/thirdparty/pear/Net/IPv6.php
deleted file mode 100644
index 29a4d53c6..000000000
--- a/thirdparty/pear/Net/IPv6.php
+++ /dev/null
@@ -1,218 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: IPv6.php,v 1.12 2005/09/01 12:42:00 alexmerz Exp $
-
-/**
-* Class to validate and to work with IPv6
-*
-* @author Alexander Merz
-* @author elfrink at introweb dot nl
-* @package Net_IPv6
-* @version $Id: IPv6.php,v 1.12 2005/09/01 12:42:00 alexmerz Exp $
-* @access public
-*/
-class Net_IPv6 {
-
- // {{{ Uncompress()
-
- /**
- * Uncompresses an IPv6 adress
- *
- * RFC 2373 allows you to compress zeros in an adress to '::'. This
- * function expects an valid IPv6 adress and expands the '::' to
- * the required zeros.
- *
- * Example: FF01::101 -> FF01:0:0:0:0:0:0:101
- * ::1 -> 0:0:0:0:0:0:0:1
- *
- * @access public
- * @see Compress()
- * @static
- * @param string $ip a valid IPv6-adress (hex format)
- * @return string the uncompressed IPv6-adress (hex format)
- */
- function Uncompress($ip) {
- $uip = $ip;
- $c1 = -1;
- $c2 = -1;
- if (false !== strpos($ip, '::') ) {
- list($ip1, $ip2) = explode('::', $ip);
- if(""==$ip1) {
- $c1 = -1;
- } else {
- $pos = 0;
- if(0 < ($pos = substr_count($ip1, ':'))) {
- $c1 = $pos;
- } else {
- $c1 = 0;
- }
- }
- if(""==$ip2) {
- $c2 = -1;
- } else {
- $pos = 0;
- if(0 < ($pos = substr_count($ip2, ':'))) {
- $c2 = $pos;
- } else {
- $c2 = 0;
- }
- }
- if(strstr($ip2, '.')) {
- $c2++;
- }
- if(-1 == $c1 && -1 == $c2) { // ::
- $uip = "0:0:0:0:0:0:0:0";
- } else if(-1==$c1) { // ::xxx
- $fill = str_repeat('0:', 7-$c2);
- $uip = str_replace('::', $fill, $uip);
- } else if(-1==$c2) { // xxx::
- $fill = str_repeat(':0', 7-$c1);
- $uip = str_replace('::', $fill, $uip);
- } else { // xxx::xxx
- $fill = str_repeat(':0:', 6-$c2-$c1);
- $uip = str_replace('::', $fill, $uip);
- $uip = str_replace('::', ':', $uip);
- }
- }
- return $uip;
- }
-
- // }}}
- // {{{ Compress()
-
- /**
- * Compresses an IPv6 adress
- *
- * RFC 2373 allows you to compress zeros in an adress to '::'. This
- * function expects an valid IPv6 adress and compresses successive zeros
- * to '::'
- *
- * Example: FF01:0:0:0:0:0:0:101 -> FF01::101
- * 0:0:0:0:0:0:0:1 -> ::1
- *
- * @access public
- * @see Uncompress()
- * @static
- * @param string $ip a valid IPv6-adress (hex format)
- * @return string the compressed IPv6-adress (hex format)
- * @author elfrink at introweb dot nl
- */
- function Compress($ip) {
- $cip = $ip;
-
- if (!strstr($ip, '::')) {
- $ipp = explode(':',$ip);
- for($i=0; $i0) {
- $match = '';
- foreach($zeros[0] as $zero) {
- if (strlen($zero) > strlen($match))
- $match = $zero;
- }
- $cip = preg_replace('/' . $match . '/', ':', $cip, 1);
- }
- $cip = preg_replace('/((^:)|(:$))/', '' ,$cip);
- $cip = preg_replace('/((^:)|(:$))/', '::' ,$cip);
- }
- return $cip;
- }
-
- // }}}
- // {{{ SplitV64()
-
- /**
- * Splits an IPv6 adress into the IPv6 and a possible IPv4 part
- *
- * RFC 2373 allows you to note the last two parts of an IPv6 adress as
- * an IPv4 compatible adress
- *
- * Example: 0:0:0:0:0:0:13.1.68.3
- * 0:0:0:0:0:FFFF:129.144.52.38
- *
- * @access public
- * @static
- * @param string $ip a valid IPv6-adress (hex format)
- * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
- */
- function SplitV64($ip) {
- $ip = Net_IPv6::Uncompress($ip);
- if (strstr($ip, '.')) {
- $pos = strrpos($ip, ':');
- $ip{$pos} = '_';
- $ipPart = explode('_', $ip);
- return $ipPart;
- } else {
- return array($ip, "");
- }
- }
-
- // }}}
- // {{{ checkIPv6
-
- /**
- * Checks an IPv6 adress
- *
- * Checks if the given IP is IPv6-compatible
- *
- * @access public
- * @static
- * @param string $ip a valid IPv6-adress
- * @return boolean true if $ip is an IPv6 adress
- */
- function checkIPv6($ip) {
-
- $ipPart = Net_IPv6::SplitV64($ip);
- $count = 0;
- if (!empty($ipPart[0])) {
- $ipv6 =explode(':', $ipPart[0]);
- for ($i = 0; $i < count($ipv6); $i++) {
- $dec = hexdec($ipv6[$i]);
- $hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", $ipv6[$i]));
- if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex == strtoupper(dechex($dec))) {
- $count++;
- }
- }
- if (8 == $count) {
- return true;
- } elseif (6 == $count and !empty($ipPart[1])) {
- $ipv4 = explode('.',$ipPart[1]);
- $count = 0;
- for ($i = 0; $i < count($ipv4); $i++) {
- if ($ipv4[$i] >= 0 && (integer)$ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) {
- $count++;
- }
- }
- if (4 == $count) {
- return true;
- }
- } else {
- return false;
- }
-
- } else {
- return false;
- }
- }
- // }}}
-}
-?>
diff --git a/thirdparty/pear/Net/JSON.php b/thirdparty/pear/Net/JSON.php
deleted file mode 100644
index 71dcdea5d..000000000
--- a/thirdparty/pear/Net/JSON.php
+++ /dev/null
@@ -1,806 +0,0 @@
-
- * @author Matt Knapp
- * @author Brett Stimmerman
- * @copyright 2005 Michal Migurski
- * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
- * @license http://www.opensource.org/licenses/bsd-license.php
- * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
- */
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_SLICE', 1);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_STR', 2);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_ARR', 3);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_OBJ', 4);
-
-/**
- * Marker constant for Services_JSON::decode(), used to flag stack state
- */
-define('SERVICES_JSON_IN_CMT', 5);
-
-/**
- * Behavior switch for Services_JSON::decode()
- */
-define('SERVICES_JSON_LOOSE_TYPE', 16);
-
-/**
- * Behavior switch for Services_JSON::decode()
- */
-define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
-
-/**
- * Converts to and from JSON format.
- *
- * Brief example of use:
- *
- *
- * // create a new instance of Services_JSON
- * $json = new Services_JSON();
- *
- * // convert a complexe value to JSON notation, and send it to the browser
- * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
- * $output = $json->encode($value);
- *
- * print($output);
- * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
- *
- * // accept incoming POST data, assumed to be in JSON notation
- * $input = file_get_contents('php://input', 1000000);
- * $value = $json->decode($input);
- *
- */
-class Services_JSON
-{
- /**
- * constructs a new JSON instance
- *
- * @param int $use object behavior flags; combine with boolean-OR
- *
- * possible values:
- * - SERVICES_JSON_LOOSE_TYPE: loose typing.
- * "{...}" syntax creates associative arrays
- * instead of objects in decode().
- * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
- * Values which can't be encoded (e.g. resources)
- * appear as NULL instead of throwing errors.
- * By default, a deeply-nested resource will
- * bubble up with an error, so all return values
- * from encode() should be checked with isError()
- */
- function Services_JSON($use = 0)
- {
- $this->use = $use;
- }
-
- /**
- * convert a string from one UTF-16 char to one UTF-8 char
- *
- * Normally should be handled by mb_convert_encoding, but
- * provides a slower PHP-only method for installations
- * that lack the multibye string extension.
- *
- * @param string $utf16 UTF-16 character
- * @return string UTF-8 character
- * @access private
- */
- function utf162utf8($utf16)
- {
- // oh please oh please oh please oh please oh please
- if(function_exists('mb_convert_encoding')) {
- return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
- }
-
- $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
-
- switch(true) {
- case ((0x7F & $bytes) == $bytes):
- // this case should never be reached, because we are in ASCII range
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x7F & $bytes);
-
- case (0x07FF & $bytes) == $bytes:
- // return a 2-byte UTF-8 character
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0xC0 | (($bytes >> 6) & 0x1F))
- . chr(0x80 | ($bytes & 0x3F));
-
- case (0xFFFF & $bytes) == $bytes:
- // return a 3-byte UTF-8 character
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0xE0 | (($bytes >> 12) & 0x0F))
- . chr(0x80 | (($bytes >> 6) & 0x3F))
- . chr(0x80 | ($bytes & 0x3F));
- }
-
- // ignoring UTF-32 for now, sorry
- return '';
- }
-
- /**
- * convert a string from one UTF-8 char to one UTF-16 char
- *
- * Normally should be handled by mb_convert_encoding, but
- * provides a slower PHP-only method for installations
- * that lack the multibye string extension.
- *
- * @param string $utf8 UTF-8 character
- * @return string UTF-16 character
- * @access private
- */
- function utf82utf16($utf8)
- {
- // oh please oh please oh please oh please oh please
- if(function_exists('mb_convert_encoding')) {
- return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
- }
-
- switch(strlen($utf8)) {
- case 1:
- // this case should never be reached, because we are in ASCII range
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return $utf8;
-
- case 2:
- // return a UTF-16 character from a 2-byte UTF-8 char
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr(0x07 & (ord($utf8{0}) >> 2))
- . chr((0xC0 & (ord($utf8{0}) << 6))
- | (0x3F & ord($utf8{1})));
-
- case 3:
- // return a UTF-16 character from a 3-byte UTF-8 char
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- return chr((0xF0 & (ord($utf8{0}) << 4))
- | (0x0F & (ord($utf8{1}) >> 2)))
- . chr((0xC0 & (ord($utf8{1}) << 6))
- | (0x7F & ord($utf8{2})));
- }
-
- // ignoring UTF-32 for now, sorry
- return '';
- }
-
- /**
- * encodes an arbitrary variable into JSON format
- *
- * @param mixed $var any number, boolean, string, array, or object to be encoded.
- * see argument 1 to Services_JSON() above for array-parsing behavior.
- * if var is a strng, note that encode() always expects it
- * to be in ASCII or UTF-8 format!
- *
- * @return mixed JSON string representation of input var or an error if a problem occurs
- * @access public
- */
- function encode($var)
- {
- switch (gettype($var)) {
- case 'boolean':
- return $var ? 'true' : 'false';
-
- case 'NULL':
- return 'null';
-
- case 'integer':
- return (int) $var;
-
- case 'double':
- case 'float':
- return (float) $var;
-
- case 'string':
- // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
- $ascii = '';
- $strlen_var = strlen($var);
-
- /*
- * Iterate over every character in the string,
- * escaping with a slash or encoding to UTF-8 where necessary
- */
- for ($c = 0; $c < $strlen_var; ++$c) {
-
- $ord_var_c = ord($var{$c});
-
- switch (true) {
- case $ord_var_c == 0x08:
- $ascii .= '\b';
- break;
- case $ord_var_c == 0x09:
- $ascii .= '\t';
- break;
- case $ord_var_c == 0x0A:
- $ascii .= '\n';
- break;
- case $ord_var_c == 0x0C:
- $ascii .= '\f';
- break;
- case $ord_var_c == 0x0D:
- $ascii .= '\r';
- break;
-
- case $ord_var_c == 0x22:
- case $ord_var_c == 0x2F:
- case $ord_var_c == 0x5C:
- // double quote, slash, slosh
- $ascii .= '\\'.$var{$c};
- break;
-
- case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
- // characters U-00000000 - U-0000007F (same as ASCII)
- $ascii .= $var{$c};
- break;
-
- case (($ord_var_c & 0xE0) == 0xC0):
- // characters U-00000080 - U-000007FF, mask 110XXXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
- $c += 1;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xF0) == 0xE0):
- // characters U-00000800 - U-0000FFFF, mask 1110XXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}));
- $c += 2;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xF8) == 0xF0):
- // characters U-00010000 - U-001FFFFF, mask 11110XXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}));
- $c += 3;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xFC) == 0xF8):
- // characters U-00200000 - U-03FFFFFF, mask 111110XX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}));
- $c += 4;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
-
- case (($ord_var_c & 0xFE) == 0xFC):
- // characters U-04000000 - U-7FFFFFFF, mask 1111110X
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $char = pack('C*', $ord_var_c,
- ord($var{$c + 1}),
- ord($var{$c + 2}),
- ord($var{$c + 3}),
- ord($var{$c + 4}),
- ord($var{$c + 5}));
- $c += 5;
- $utf16 = $this->utf82utf16($char);
- $ascii .= sprintf('\u%04s', bin2hex($utf16));
- break;
- }
- }
-
- return '"'.$ascii.'"';
-
- case 'array':
- /*
- * As per JSON spec if any array key is not an integer
- * we must treat the the whole array as an object. We
- * also try to catch a sparsely populated associative
- * array with numeric keys here because some JS engines
- * will create an array with empty indexes up to
- * max_index which can cause memory issues and because
- * the keys, which may be relevant, will be remapped
- * otherwise.
- *
- * As per the ECMA and JSON specification an object may
- * have any string as a property. Unfortunately due to
- * a hole in the ECMA specification if the key is a
- * ECMA reserved word or starts with a digit the
- * parameter is only accessible using ECMAScript's
- * bracket notation.
- */
-
- // treat as a JSON object
- if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
- $properties = array_map(array($this, 'name_value'),
- array_keys($var),
- array_values($var));
-
- foreach($properties as $property) {
- if(Services_JSON::isError($property)) {
- return $property;
- }
- }
-
- return '{' . join(',', $properties) . '}';
- }
-
- // treat it like a regular array
- $elements = array_map(array($this, 'encode'), $var);
-
- foreach($elements as $element) {
- if(Services_JSON::isError($element)) {
- return $element;
- }
- }
-
- return '[' . join(',', $elements) . ']';
-
- case 'object':
- $vars = get_object_vars($var);
-
- $properties = array_map(array($this, 'name_value'),
- array_keys($vars),
- array_values($vars));
-
- foreach($properties as $property) {
- if(Services_JSON::isError($property)) {
- return $property;
- }
- }
-
- return '{' . join(',', $properties) . '}';
-
- default:
- return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
- ? 'null'
- : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
- }
- }
-
- /**
- * array-walking function for use in generating JSON-formatted name-value pairs
- *
- * @param string $name name of key to use
- * @param mixed $value reference to an array element to be encoded
- *
- * @return string JSON-formatted name-value pair, like '"name":value'
- * @access private
- */
- function name_value($name, $value)
- {
- $encoded_value = $this->encode($value);
-
- if(Services_JSON::isError($encoded_value)) {
- return $encoded_value;
- }
-
- return $this->encode(strval($name)) . ':' . $encoded_value;
- }
-
- /**
- * reduce a string by removing leading and trailing comments and whitespace
- *
- * @param $str string string value to strip of comments and whitespace
- *
- * @return string string value stripped of comments and whitespace
- * @access private
- */
- function reduce_string($str)
- {
- $str = preg_replace(array(
-
- // eliminate single line comments in '// ...' form
- '#^\s*//(.+)$#m',
-
- // eliminate multi-line comments in '/* ... */' form, at start of string
- '#^\s*/\*(.+)\*/#Us',
-
- // eliminate multi-line comments in '/* ... */' form, at end of string
- '#/\*(.+)\*/\s*$#Us'
-
- ), '', $str);
-
- // eliminate extraneous space
- return trim($str);
- }
-
- /**
- * decodes a JSON string into appropriate variable
- *
- * @param string $str JSON-formatted string
- *
- * @return mixed number, boolean, string, array, or object
- * corresponding to given JSON input string.
- * See argument 1 to Services_JSON() above for object-output behavior.
- * Note that decode() always returns strings
- * in ASCII or UTF-8 format!
- * @access public
- */
- function decode($str)
- {
- $str = $this->reduce_string($str);
-
- switch (strtolower($str)) {
- case 'true':
- return true;
-
- case 'false':
- return false;
-
- case 'null':
- return null;
-
- default:
- $m = array();
-
- if (is_numeric($str)) {
- // Lookie-loo, it's a number
-
- // This would work on its own, but I'm trying to be
- // good about returning integers where appropriate:
- // return (float)$str;
-
- // Return float or int, as appropriate
- return ((float)$str == (integer)$str)
- ? (integer)$str
- : (float)$str;
-
- } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
- // STRINGS RETURNED IN UTF-8 FORMAT
- $delim = substr($str, 0, 1);
- $chrs = substr($str, 1, -1);
- $utf8 = '';
- $strlen_chrs = strlen($chrs);
-
- for ($c = 0; $c < $strlen_chrs; ++$c) {
-
- $substr_chrs_c_2 = substr($chrs, $c, 2);
- $ord_chrs_c = ord($chrs{$c});
-
- switch (true) {
- case $substr_chrs_c_2 == '\b':
- $utf8 .= chr(0x08);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\t':
- $utf8 .= chr(0x09);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\n':
- $utf8 .= chr(0x0A);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\f':
- $utf8 .= chr(0x0C);
- ++$c;
- break;
- case $substr_chrs_c_2 == '\r':
- $utf8 .= chr(0x0D);
- ++$c;
- break;
-
- case $substr_chrs_c_2 == '\\"':
- case $substr_chrs_c_2 == '\\\'':
- case $substr_chrs_c_2 == '\\\\':
- case $substr_chrs_c_2 == '\\/':
- if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
- ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
- $utf8 .= $chrs{++$c};
- }
- break;
-
- case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
- // single, escaped unicode character
- $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
- . chr(hexdec(substr($chrs, ($c + 4), 2)));
- $utf8 .= $this->utf162utf8($utf16);
- $c += 5;
- break;
-
- case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
- $utf8 .= $chrs{$c};
- break;
-
- case ($ord_chrs_c & 0xE0) == 0xC0:
- // characters U-00000080 - U-000007FF, mask 110XXXXX
- //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 2);
- ++$c;
- break;
-
- case ($ord_chrs_c & 0xF0) == 0xE0:
- // characters U-00000800 - U-0000FFFF, mask 1110XXXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 3);
- $c += 2;
- break;
-
- case ($ord_chrs_c & 0xF8) == 0xF0:
- // characters U-00010000 - U-001FFFFF, mask 11110XXX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 4);
- $c += 3;
- break;
-
- case ($ord_chrs_c & 0xFC) == 0xF8:
- // characters U-00200000 - U-03FFFFFF, mask 111110XX
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 5);
- $c += 4;
- break;
-
- case ($ord_chrs_c & 0xFE) == 0xFC:
- // characters U-04000000 - U-7FFFFFFF, mask 1111110X
- // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- $utf8 .= substr($chrs, $c, 6);
- $c += 5;
- break;
-
- }
-
- }
-
- return $utf8;
-
- } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
- // array, or object notation
-
- if ($str{0} == '[') {
- $stk = array(SERVICES_JSON_IN_ARR);
- $arr = array();
- } else {
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
- $stk = array(SERVICES_JSON_IN_OBJ);
- $obj = array();
- } else {
- $stk = array(SERVICES_JSON_IN_OBJ);
- $obj = new stdClass();
- }
- }
-
- array_push($stk, array('what' => SERVICES_JSON_SLICE,
- 'where' => 0,
- 'delim' => false));
-
- $chrs = substr($str, 1, -1);
- $chrs = $this->reduce_string($chrs);
-
- if ($chrs == '') {
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
- return $arr;
-
- } else {
- return $obj;
-
- }
- }
-
- //print("\nparsing {$chrs}\n");
-
- $strlen_chrs = strlen($chrs);
-
- for ($c = 0; $c <= $strlen_chrs; ++$c) {
-
- $top = end($stk);
- $substr_chrs_c_2 = substr($chrs, $c, 2);
-
- if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
- // found a comma that is not inside a string, array, etc.,
- // OR we've reached the end of the character list
- $slice = substr($chrs, $top['where'], ($c - $top['where']));
- array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
- //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
- // we are in an array, so just push an element onto the stack
- array_push($arr, $this->decode($slice));
-
- } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
- // we are in an object, so figure
- // out the property name and set an
- // element in an associative array,
- // for now
- $parts = array();
-
- if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
- // "name":value pair
- $key = $this->decode($parts[1]);
- $val = $this->decode($parts[2]);
-
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
- $obj[$key] = $val;
- } else {
- $obj->$key = $val;
- }
- } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
- // name:value pair, where name is unquoted
- $key = $parts[1];
- $val = $this->decode($parts[2]);
-
- if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
- $obj[$key] = $val;
- } else {
- $obj->$key = $val;
- }
- }
-
- }
-
- } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
- // found a quote, and we are not inside a string
- array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
- //print("Found start of string at {$c}\n");
-
- } elseif (($chrs{$c} == $top['delim']) &&
- ($top['what'] == SERVICES_JSON_IN_STR) &&
- ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
- // found a quote, we're in a string, and it's not escaped
- // we know that it's not escaped becase there is _not_ an
- // odd number of backslashes at the end of the string so far
- array_pop($stk);
- //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
-
- } elseif (($chrs{$c} == '[') &&
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
- // found a left-bracket, and we are in an array, object, or slice
- array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
- //print("Found start of array at {$c}\n");
-
- } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
- // found a right-bracket, and we're in an array
- array_pop($stk);
- //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- } elseif (($chrs{$c} == '{') &&
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
- // found a left-brace, and we are in an array, object, or slice
- array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
- //print("Found start of object at {$c}\n");
-
- } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
- // found a right-brace, and we're in an object
- array_pop($stk);
- //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- } elseif (($substr_chrs_c_2 == '/*') &&
- in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
- // found a comment start, and we are in an array, object, or slice
- array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
- $c++;
- //print("Found start of comment at {$c}\n");
-
- } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
- // found a comment end, and we're in one now
- array_pop($stk);
- $c++;
-
- for ($i = $top['where']; $i <= $c; ++$i)
- $chrs = substr_replace($chrs, ' ', $i, 1);
-
- //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
-
- }
-
- }
-
- if (reset($stk) == SERVICES_JSON_IN_ARR) {
- return $arr;
-
- } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
- return $obj;
-
- }
-
- }
- }
- }
-
- /**
- * @todo Ultimately, this should just call PEAR::isError()
- */
- function isError($data, $code = null)
- {
- if (class_exists('pear')) {
- return PEAR::isError($data, $code);
- } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
- is_subclass_of($data, 'services_json_error'))) {
- return true;
- }
-
- return false;
- }
-}
-
-if (class_exists('PEAR_Error')) {
-
- class Services_JSON_Error extends PEAR_Error
- {
- function Services_JSON_Error($message = 'unknown error', $code = null,
- $mode = null, $options = null, $userinfo = null)
- {
- parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
- }
- }
-
-} else {
-
- /**
- * @todo Ultimately, this class shall be descended from PEAR_Error
- */
- class Services_JSON_Error
- {
- function Services_JSON_Error($message = 'unknown error', $code = null,
- $mode = null, $options = null, $userinfo = null)
- {
-
- }
- }
-
-}
-
-?>
diff --git a/thirdparty/pear/Net/LDAP.php b/thirdparty/pear/Net/LDAP.php
deleted file mode 100644
index 7a8f43f21..000000000
--- a/thirdparty/pear/Net/LDAP.php
+++ /dev/null
@@ -1,1065 +0,0 @@
- '',
- 'host' => 'localhost',
- 'password' => '',
- 'tls' => false,
- 'base' => '',
- 'port' => 389,
- 'version' => 3,
- 'options' => array(),
- 'filter' => '(objectClass=*)',
- 'scope' => 'sub');
-
- /**
- * LDAP resource link.
- *
- * @access private
- * @var resource
- */
- var $_link;
-
- /**
- * Net_LDAP Release Version
- *
- * @access private
- * @var string
- */
- var $_version = "0.6.6";
-
- /**
- * Net_LDAP_Schema object
- *
- * @access private
- * @var object Net_LDAP_Schema
- */
- var $_schema = null;
-
- /**
- * Cache for attribute encoding checks
- *
- * @access private
- * @var array Hash with attribute names as key and boolean value
- * to determine whether they should be utf8 encoded or not.
- */
- var $_schemaAttrs = array();
-
- /**
- * Net_LDAP constructor
- *
- * Sets the config array
- *
- * @access protected
- * @param array Configuration array
- * @return void
- * @see $_config
- */
- function Net_LDAP($_config = array())
- {
- $this->PEAR('Net_LDAP_Error');
-
- foreach ($_config as $k => $v) {
- $this->_config[$k] = $v;
- }
- }
-
- /**
- * Creates the initial ldap-object
- *
- * Static function that returns either an error object or the new Net_LDAP object.
- * Something like a factory. Takes a config array with the needed parameters.
- *
- * @access public
- * @param array Configuration array
- * @return mixed object Net_LDAP_Error or Net_LDAP
- * @see $_config
- */
- function &connect($config = array())
- {
- if (!function_exists('ldap_connect')){
- return Net_LDAP::raiseError("It seems that you do not have the ldap-extension installed. Please install it before using this package.");
- }
- @$obj =& new Net_LDAP($config);
- $err = $obj->bind();
-
- if (Net_LDAP::isError($err)) {
- return $err;
- }
- return $obj;
- }
-
- /**
- * Bind to the ldap-server
- *
- * The function may be used if you do not create the object using Net_LDAP::connect.
- *
- * @access public
- * @param array Configuration array
- * @return mixed Net_LDAP_Error or true
- * @see $_config
- */
- function bind($config = array())
- {
- foreach ($config as $k => $v) {
- $this->_config[$k] = $v;
- }
-
- if ($this->_config['host']) {
- $this->_link = @ldap_connect($this->_config['host'], $this->_config['port']);
- } else {
- return $this->raiseError("Host not defined in config. {$this->_config['host']}");
- }
-
- if (!$this->_link) {
- // there is no good errorcode for this one! I chose 52.
- return $this->raiseError("Could not connect to server. ldap_connect failed.", 52);
- }
- // You must set the version and start tls BEFORE binding!
-
- if ($this->_config['version'] != 2 && Net_LDAP::isError($msg = $this->setLDAPVersion())) {
- return $msg;
- }
-
- if ($this->_config['tls'] && Net_LDAP::isError($msg = $this->startTLS())) {
- return $msg;
- }
-
- if (isset($this->_config['options']) &&
- is_array($this->_config['options']) &&
- count($this->_config['options']))
- {
- foreach ($this->_config['options'] as $opt => $val) {
- $err = $this->setOption($opt, $val);
- if (Net_LDAP::isError($err)) {
- return $err;
- }
- }
- }
-
- if (isset($this->_config['dn']) && isset($this->_config['password'])) {
- $bind = @ldap_bind($this->_link, $this->_config['dn'], $this->_config['password']);
- } else {
- $bind = @ldap_bind($this->_link);
- }
-
- if (!$bind) {
- return $this->raiseError("Bind failed " . @ldap_error($this->_link), @ldap_errno($this->_link));
- }
-
- return true;
- }
-
- /**
- * ReBind to the ldap-server using another dn and password
- *
- * The function may be used if you do not create the object using Net_LDAP::connect.
- *
- * @access public
- * @param string $dn - the DN to bind as.
- * string $password - the bassword to use.
- * @return mixed Net_LDAP_Error or true
- * @see $_config
- */
-
- function reBind ($dn = null, $password = null)
- {
-
- if ($dn && $password ) {
- $bind = @ldap_bind($this->_link, $dn, $password);
- } else {
- $bind = @ldap_bind($this->_link);
- }
-
- if (!$bind) {
- return $this->raiseError("Bind failed " . @ldap_error($this->_link), @ldap_errno($this->_link));
- }
- return true;
- }
-
- /**
- * Starts an encrypted session
- *
- * @access public
- * @return mixed True or Net_LDAP_Error
- */
- function startTLS()
- {
- if (!@ldap_start_tls($this->_link)) {
- return $this->raiseError("TLS not started. Error:" . @ldap_error($this->_link), @ldap_errno($this->_link));
- }
- return true;
- }
-
- /**
- * alias function of startTLS() for perl-ldap interface
- *
- * @see startTLS()
- */
- function start_tls()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'startTLS' ), $args);
- }
-
- /**
- * Close LDAP connection.
- *
- * Closes the connection. Use this when the session is over.
- *
- * @return void
- */
- function done()
- {
- $this->_Net_LDAP();
- }
-
- /**
- * Destructor
- *
- * @access private
- */
- function _Net_LDAP()
- {
- @ldap_close($this->_link);
- }
-
- /**
- * Add a new entryobject to a directory.
- *
- * Use add to add a new Net_LDAP_Entry object to the directory.
- *
- * @param object Net_LDAP_Entry
- * @return mixed Net_LDAP_Error or true
- */
- function add($entry)
- {
- if (@ldap_add($this->_link, $entry->dn(), $entry->attributes())) {
- return true;
- } else {
- return $this->raiseError("Could not add entry " . $entry->dn() . " " . @ldap_error($this->_link),
- @ldap_errno($this->_link));
- }
- }
-
- /**
- * Delete an entry from the directory
- *
- * The object may either be a string representing the dn or a Net_LDAP_Entry object.
- * The param array may contain a boolean value named recursive. When set, all subentries
- * of the Entry will be deleted as well
- *
- * @access public
- * @param mixed string or Net_LDAP_Entry
- * @param array
- * @return mixed Net_LDAP_Error or true
- */
- function delete($dn, $param = array())
- {
- if (is_object($dn) && strtolower(get_class($dn)) == 'net_ldap_entry') {
- $dn = $dn->dn();
- } else {
- if (!is_string($dn)) {
- // this is what the server would say: invalid_dn_syntax.
- return $this->raiseError("$dn not a string nor an entryobject!", 34);
- }
- }
-
- if ($param['recursive'] ) {
- $searchresult = @ldap_list($this->_link, $dn, '(objectClass=*)', array());
-
- if ($searchresult) {
- $entries = @ldap_get_entries($this->_link, $searchresult);
-
- for ($i=0; $i<$entries['count']; $i++) {
- $result = $this->delete($entries[$i]['dn'], array('recursive' => true));
- if (!$result) {
- $errno = @ldap_errno($this->_link);
- return $this->raiseMessage ("Net_LDAP::delete: " . $this->errorMessage($errno), $errno);
- }
- if(PEAR::isError($result)){
- return $result;
- }
- }
- }
- }
- if (!@ldap_delete($this->_link, $dn)) {
- $error = ldap_errno($this->_link );
- if ($error == 66) {
- /* entry has subentries */
- return $this->raiseError('Net_LDAP::delete: Cound not delete entry ' . $dn .
- ' because of subentries. Use the recursive param to delete them.');
- } else {
- return $this->raiseError("Net_LDAP::delete: Could not delete entry " . $dn ." because: ".
- $this->errorMessage($error), $error);
- }
- }
- return true;
- }
-
- /**
- * Modify an ldapentry
- *
- * This is taken from the perlpod of net::ldap, and explains things quite nicely.
- * modify ( DN, OPTIONS )
- * Modify the contents of DN on the server. DN May be a
- * string or a Net::LDAP::Entry object.
- *
- * dn This option is here for compatibility only, and
- * may be removed in future. Previous releases did
- * not take the DN argument which replaces this
- * option.
- *
- * add The add option should be a reference to a HASH.
- * The values of the HASH are the attributes to add,
- * and the values may be a string or a reference to a
- * list of values.
- *
- * delete
- * A reference to an ARRAY of attributes to delete.
- * TODO: This does not support deleting one or two values yet - use
- * replace.
- *
- * replace
- * The option takes a argument in the same
- * form as add, but will cause any existing
- * attributes with the same name to be replaced. If
- * the value for any attribute in the årray is a ref
- * erence to an empty string the all instances of the
- * attribute will be deleted.
- *
- * changes
- * This is an alternative to add, delete and replace
- * where the whole operation can be given in a single
- * argument. The argument should be a array
- *
- * Values in the ARRAY are used in pairs, the first
- * is the operation add, delete or replace and the
- * second is a reference to an ARRAY of attribute
- * values.
- *
- * The attribute value list is also used in pairs.
- * The first value in each pair is the attribute name
- * and the second is a reference to a list of values.
- *
- * Example:
- * $ldap->modify ( $dn, array (changes => array(
- * 'delete' => array('faxNumber' => ''),
- * 'add' => array('sn' => 'Barr'),
- * 'replace' => array(email => 'tarjei@nu.no'))));
- *
- * @access public
- * @param string
- * @param array
- * @return mixed Net_LDAP_Error or true
- */
- function modify($dn , $params = array())
- {
- if (is_object($dn)) {
- $dn = $dn->dn();
- }
- // since $params['dn'] is not used in net::ldap now:
- if (isset($params['dn'])) {
- return $this->raiseError("This feature will not be implemented!");
- }
- // new code from rafael at krysciak dot de
- if(array_key_exists('changes', $params)) {
- $_params = $params;
- } else {
- $_params['changes'] = $params;
- }
- if (is_array($_params['changes'])) {
- foreach($_params['changes'] AS $option => $atrr) {
- switch($option) {
- case 'add':
- $command = $dn_exists ? 'ldap_mod_add':'ldap_add';
- break;
- case 'replace':
- $command = 'ldap_mod_replace';
- break;
- case 'delete':
- $command = 'ldap_mod_del';
- // to delete an attribute with a specific value you
- // need a hash array('attr_name' => array('attr_value_1', ... ,'attr_value_n'))
- // the hash array('attr_name' => 'attr_value') will be converted
- // automatically to array('attr_name' => array('attr_value'))
- foreach($atrr AS $atrr_field => $atrr_value) {
- if(!is_array($atrr_value)) {
- $atrr[$atrr_field] = array($atrr_value);
- }
- }
- break;
- default:
- return $this->raiseError("Net_LDAP::modify: not supported option " . $option);
- break;
- } // end switch($option) {
-
- if(!@call_user_func($command, $this->_link, $dn, $atrr)) {
- return $this->raiseError("Net_LDAP::modify: $dn not modified because:" . ldap_error($this->_link), ldap_errno($this->_link));
- }
- } // end foreach($_params['changes'] AS $option => $atrr) {
- } // end if (is_array($_params['changes'])) {
- // everything went fine :)
- return true;
-
- /* old broken code see bug#2987
- if (isset($params['changes'])) {
-
- if (isset($params['changes']['add']) &&
- !@ldap_modify($this->_link, $dn, $params['changes']['add'])) {
-
- return $this->raiseError("Net_LDAP::modify: $dn not modified because:" . ldap_error($this->_link),
- ldap_errno($this->_link));
- }
-
- if (isset($params['changes']['replace']) &&
- !@ldap_modify($this->_link, $dn, $params['changes']['replace'])) {
-
- return $this->raiseError("Net_LDAP::modify: replace change didn't work: " . ldap_error($this->_link),
- ldap_errno($this->_link));
- }
-
- if (isset($params['changes']['delete']) &&
- !@ldap_mod_del($this->_link, $dn, $params['changes']['delete'])) {
-
- return $this->raiseError("Net_LDAP::modify:delete did not work" . ldap_error($this->_link),
- ldap_errno($this->_link));
- }
- }
-
- if (isset($params['add']) && !@ldap_add($this->_link, $dn, $params['add'])) {
- return $this->raiseError(ldap_error($this->_link), ldap_errno($this->_link));
- }
-
- if (isset($params['replace']) && !@ldap_modify($this->_link, $dn, $params['replace'])) {
- return $this->raiseError(ldap_error($this->_link), ldap_errno($this->_link));
- }
-
- if (isset($params['delete'])) {
- // since you delete an attribute by making it empty:
- foreach ($params['delete'] as $k) {
- $params['delete'][$k] = '';
- }
-
- if (!@ldap_modify($this->_link, $dn, $params['delete'])) {
- return $this->raiseError(ldap_error($this->_link), ldap_errno($this->_link));
- }
- }
- // everything went fine :)
- return true;
- */
-
- }
-
- /**
- * Run a ldap query
- *
- * Search is used to query the ldap-database.
- * $base and $filter may be ommitted. BaseDN and default filter will then be used.
- * Params may contain:
- *
- * scope: The scope which will be used for searching
- * base - Just one entry
- * sub - The whole tree
- * one - Immediately below $base
- * sizelimit: Limit the number of entries returned (default: 0),
- * timelimit: Limit the time spent for searching (default: 0),
- * attrsonly: If true, the search will only return the attribute names, NO values
- * attributes: Array of attribute names, which the entry should contain. It is good practice
- * to limit this to just the ones you need, so by default this function does not
- * return any attributes at all.
- * [NOT IMPLEMENTED]
- * deref: By default aliases are dereferenced to locate the base object for the search, but not when
- * searching subordinates of the base object. This may be changed by specifying one of the
- * following values:
- *
- * never - Do not dereference aliases in searching or in locating the base object of the search.
- * search - Dereference aliases in subordinates of the base object in searching, but not in
- * locating the base object of the search.
- * find
- * always
- *
- * @access public
- * @param string LDAP searchbase
- * @param string LDAP search filter
- * @param array Array of options
- * @return object mixed Net_LDAP_Search or Net_LDAP_Error
- */
- function search($base = null, $filter = null, $params = array())
- {
- if (is_null($base)) {
- $base = $this->_config['base'];
- }
- if (is_null($filter)) {
- $filter = $this->_config['filter'];
- }
-
- /* setting searchparameters */
- (isset($params['sizelimit'])) ? $sizelimit = $params['sizelimit'] : $sizelimit = 0;
- (isset($params['timelimit'])) ? $timelimit = $params['timelimit'] : $timelimit = 0;
- (isset($params['attrsonly'])) ? $attrsonly = $params['attrsonly'] : $attrsonly = 0;
- (isset($params['attributes'])) ? $attributes = $params['attributes'] : $attributes = array('');
-
- if (!is_array($attributes)) {
- $this->raiseError("The param attributes must be an array!");
- }
-
- /* scoping makes searches faster! */
- $scope = (isset($params['scope']) ? $params['scope'] : $this->_config['scope']);
-
- switch ($scope) {
- case 'one':
- $search_function = 'ldap_list';
- break;
- case 'base':
- $search_function = 'ldap_read';
- break;
- default:
- $search_function = 'ldap_search';
- }
-
- $search = @call_user_func($search_function,
- $this->_link,
- $base,
- $filter,
- $attributes,
- $attrsonly,
- $sizelimit,
- $timelimit);
-
- if ($err = ldap_errno($this->_link)) {
-
- if ($err == 32) {
- // Errorcode 32 = no such object, i.e. a nullresult.
- return $obj =& new Net_LDAP_Search ($search, $this->_link);
-
- // Errorcode 4 = sizelimit exeeded. this will be handled better in time...
- //} elseif ($err == 4) {
- // return $obj = & new Net_LDAP_Search ($search, $this->_link);
-
- } elseif ($err == 87) {
- // bad search filter
- return $this->raiseError($this->errorMessage($err) . "($filter)", $err);
- } else {
- $msg = "\nParameters:\nBase: $base\nFilter: $filter\nScope: $scope";
- return $this->raiseError($this->errorMessage($err) . $msg, $err);
- }
- } else {
- @$obj =& new Net_LDAP_Search($search, $this->_link);
- return $obj;
- }
-
- }
-
- /**
- * Set an LDAP option
- *
- * @access public
- * @param string Option to set
- * @param mixed Value to set Option to
- * @return mixed Net_LDAP_Error or true
- */
- function setOption($option, $value)
- {
- if ($this->_link) {
- if (defined($option)) {
- if (@ldap_set_option($this->_link, constant($option), $value)) {
- return true;
- } else {
- $err = @ldap_errno($this->_link);
- if ($err) {
- $msg = @ldap_err2str($err);
- } else {
- $err = NET_LDAP_ERROR;
- $msg = $this->errorMessage($err);
- }
- return $this->raiseError($msg, $err);
- }
- } else {
- return $this->raiseError("Unkown Option requested");
- }
- } else {
- return $this->raiseError("No LDAP connection");
- }
- }
-
- /**
- * Get an LDAP option value
- *
- * @access public
- * @param string Option to get
- * @return mixed Net_LDAP_Error or option value
- */
- function getOption($option)
- {
- if ($this->_link) {
- if (defined($option)) {
- if (@ldap_get_option($this->_link, constant($option), $value)) {
- return $value;
- } else {
- $err = @ldap_errno($this->_link);
- if ($err) {
- $msg = @ldap_err2str($err);
- } else {
- $err = NET_LDAP_ERROR;
- $msg = $this->errorMessage($err);
- }
- return $this->raiseError($msg, $err);
- }
- } else {
- $this->raiseError("Unkown Option requested");
- }
- } else {
- $this->raiseError("No LDAP connection");
- }
- }
-
- /**
- * Get the LDAP_PROTOCOL_VERSION that is used on the connection.
- *
- * A lot of ldap functionality is defined by what protocol version the ldap server speaks.
- * This might be 2 or 3.
- *
- * @return int
- */
- function getLDAPVersion()
- {
- if($this->_link) {
- $version = $this->getOption("LDAP_OPT_PROTOCOL_VERSION");
- } else {
- $version = $this->_config['version'];
- }
- return $version;
- }
-
- /**
- * Set the LDAP_PROTOCOL_VERSION that is used on the connection.
- *
- * @param int Version to set
- * @return mixed Net_LDAP_Error or TRUE
- */
- function setLDAPVersion($version = 0)
- {
- if (!$version) {
- $version = $this->_config['version'];
- }
- return $this->setOption("LDAP_OPT_PROTOCOL_VERSION", $version);
- }
-
- /**
- * Get the Net_LDAP version.
- *
- * Return the Net_LDAP version
- *
- * @return string Net_LDAP version
- */
- function getVersion ()
- {
- return $this->_version;
- }
-
- /**
- * Tell if a dn already exists
- *
- * @param string
- * @return boolean
- */
- function dnExists($dn)
- {
- $dns = explode(",",$dn);
- $filter = array_shift($dns);
- $base= implode($dns,',');
- //$base = $dn;
- //$filter = '(objectclass=*)';
-
- $result = @ldap_list($this->_link, $base, $filter, array(), 1, 1);
- if (ldap_errno($this->_link) == 32) {
- return false;
- }
- if (ldap_errno($this->_link) != 0) {
- $this->raiseError(ldap_error($this->_link), ldap_errno($this->_link));
- }
- if (@ldap_count_entries($this->_link, $result)) {
- return true;
- }
- return false;
- }
-
-
- /**
- * Get a specific entry based on the dn
- *
- * @param string dn
- * @param array Array of Attributes to select
- * @return object Net_LDAP_Entry or Net_LDAP_Error
- */
- function &getEntry($dn, $attr = array(''))
- {
- $result = $this->search($dn, '(objectClass=*)', array('scope' => 'base', 'attributes' => $attr));
- if (Net_LDAP::isError($result)) {
- return $result;
- }
- $entry = $result->shiftEntry();
- if (false == $entry) {
- return $this->raiseError('Could not fetch entry');
- }
- return $entry;
- }
-
-
- /**
- * Returns the string for an ldap errorcode.
- *
- * Made to be able to make better errorhandling
- * Function based on DB::errorMessage()
- * Tip: The best description of the errorcodes is found here: http://www.directory-info.com/LDAP/LDAPErrorCodes.html
- *
- * @param int Error code
- * @return string The errorstring for the error.
- */
- function errorMessage($errorcode)
- {
- $errorMessages = array(
- 0x00 => "LDAP_SUCCESS",
- 0x01 => "LDAP_OPERATIONS_ERROR",
- 0x02 => "LDAP_PROTOCOL_ERROR",
- 0x03 => "LDAP_TIMELIMIT_EXCEEDED",
- 0x04 => "LDAP_SIZELIMIT_EXCEEDED",
- 0x05 => "LDAP_COMPARE_FALSE",
- 0x06 => "LDAP_COMPARE_TRUE",
- 0x07 => "LDAP_AUTH_METHOD_NOT_SUPPORTED",
- 0x08 => "LDAP_STRONG_AUTH_REQUIRED",
- 0x09 => "LDAP_PARTIAL_RESULTS",
- 0x0a => "LDAP_REFERRAL",
- 0x0b => "LDAP_ADMINLIMIT_EXCEEDED",
- 0x0c => "LDAP_UNAVAILABLE_CRITICAL_EXTENSION",
- 0x0d => "LDAP_CONFIDENTIALITY_REQUIRED",
- 0x0e => "LDAP_SASL_BIND_INPROGRESS",
- 0x10 => "LDAP_NO_SUCH_ATTRIBUTE",
- 0x11 => "LDAP_UNDEFINED_TYPE",
- 0x12 => "LDAP_INAPPROPRIATE_MATCHING",
- 0x13 => "LDAP_CONSTRAINT_VIOLATION",
- 0x14 => "LDAP_TYPE_OR_VALUE_EXISTS",
- 0x15 => "LDAP_INVALID_SYNTAX",
- 0x20 => "LDAP_NO_SUCH_OBJECT",
- 0x21 => "LDAP_ALIAS_PROBLEM",
- 0x22 => "LDAP_INVALID_DN_SYNTAX",
- 0x23 => "LDAP_IS_LEAF",
- 0x24 => "LDAP_ALIAS_DEREF_PROBLEM",
- 0x30 => "LDAP_INAPPROPRIATE_AUTH",
- 0x31 => "LDAP_INVALID_CREDENTIALS",
- 0x32 => "LDAP_INSUFFICIENT_ACCESS",
- 0x33 => "LDAP_BUSY",
- 0x34 => "LDAP_UNAVAILABLE",
- 0x35 => "LDAP_UNWILLING_TO_PERFORM",
- 0x36 => "LDAP_LOOP_DETECT",
- 0x3C => "LDAP_SORT_CONTROL_MISSING",
- 0x3D => "LDAP_INDEX_RANGE_ERROR",
- 0x40 => "LDAP_NAMING_VIOLATION",
- 0x41 => "LDAP_OBJECT_CLASS_VIOLATION",
- 0x42 => "LDAP_NOT_ALLOWED_ON_NONLEAF",
- 0x43 => "LDAP_NOT_ALLOWED_ON_RDN",
- 0x44 => "LDAP_ALREADY_EXISTS",
- 0x45 => "LDAP_NO_OBJECT_CLASS_MODS",
- 0x46 => "LDAP_RESULTS_TOO_LARGE",
- 0x47 => "LDAP_AFFECTS_MULTIPLE_DSAS",
- 0x50 => "LDAP_OTHER",
- 0x51 => "LDAP_SERVER_DOWN",
- 0x52 => "LDAP_LOCAL_ERROR",
- 0x53 => "LDAP_ENCODING_ERROR",
- 0x54 => "LDAP_DECODING_ERROR",
- 0x55 => "LDAP_TIMEOUT",
- 0x56 => "LDAP_AUTH_UNKNOWN",
- 0x57 => "LDAP_FILTER_ERROR",
- 0x58 => "LDAP_USER_CANCELLED",
- 0x59 => "LDAP_PARAM_ERROR",
- 0x5a => "LDAP_NO_MEMORY",
- 0x5b => "LDAP_CONNECT_ERROR",
- 0x5c => "LDAP_NOT_SUPPORTED",
- 0x5d => "LDAP_CONTROL_NOT_FOUND",
- 0x5e => "LDAP_NO_RESULTS_RETURNED",
- 0x5f => "LDAP_MORE_RESULTS_TO_RETURN",
- 0x60 => "LDAP_CLIENT_LOOP",
- 0x61 => "LDAP_REFERRAL_LIMIT_EXCEEDED",
- 1000 => "Unknown Net_LDAP error"
- );
-
- return isset($errorMessages[$errorcode]) ? $errorMessages[$errorcode] : $errorMessages[NET_LDAP_ERROR];
- }
-
- /**
- * Tell whether value is a Net_LDAP_Error or not
- *
- * @access public
- * @param mixed
- * @return boolean
- */
- function isError($value)
- {
- return (is_a($value, "Net_LDAP_Error") || parent::isError($value));
- }
-
- /**
- * gets a root dse object
- *
- * @access public
- * @author Jan Wagner
- * @param array Array of attributes to search for
- * @return object mixed Net_LDAP_Error or Net_LDAP_RootDSE
- */
- function &rootDse($attrs = null)
- {
- require_once('Net/LDAP/RootDSE.php');
-
- if (is_array($attrs) && count($attrs) > 0 ) {
- $attributes = $attrs;
- } else {
- $attributes = array('namingContexts',
- 'altServer',
- 'supportedExtension',
- 'supportedControl',
- 'supportedSASLMechanisms',
- 'supportedLDAPVersion',
- 'subschemaSubentry' );
- }
- $result = $this->search('', '(objectClass=*)', array('attributes' => $attributes, 'scope' => 'base'));
- if (Net_LDAP::isError($result)) return $result;
-
- $entry = $result->shift_entry();
- if (false === $entry) return $this->raiseError('Could not fetch RootDSE entry');
-
- return new Net_LDAP_RootDSE($entry);
- }
-
- /**
- * alias function of rootDse() for perl-ldap interface
- *
- * @access public
- * @see rootDse()
- */
- function &root_dse()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'rootDse'), $args);
- }
-
- /**
- * get a schema object
- *
- * @access public
- * @author Jan Wagner
- * @param string Subschema entry dn
- * @return object mixed Net_LDAP_Schema or Net_LDAP_Error
- */
- function &schema($dn = null)
- {
- require_once('Net/LDAP/Schema.php');
-
- $schema =& new Net_LDAP_Schema();
-
- if (is_null($dn)) {
- // get the subschema entry via root dse
- $dse = $this->rootDSE(array('subschemaSubentry'));
- if (false == Net_LDAP::isError($dse)) {
- $base = $dse->getValue('subschemaSubentry', 'single');
- if (!Net_LDAP::isError($base)) {
- $dn = $base;
- }
- }
- }
- if (is_null($dn)) {
- $dn = 'cn=Subschema';
- }
-
- // fetch the subschema entry
- $result = $this->search($dn, '(objectClass=*)',
- array('attributes' => array_values($schema->types), 'scope' => 'base'));
- if (Net_LDAP::isError($result)) {
- return $result;
- }
-
- $entry = $result->shift_entry();
- if (false === $entry) {
- return $this->raiseError('Could not fetch Subschema entry');
- }
-
- $schema->parse($entry);
-
- return $schema;
- }
-
- /**
- * Encodes given attributes to UTF8 if needed
- *
- * This function takes attributes in an array and then checks against the schema if they need
- * UTF8 encoding. If that is so, they will be encoded. An encoded array will be returned and
- * can be used for adding or modifying.
- *
- * @access public
- * @param array Array of attributes
- * @return array Array of UTF8 encoded attributes
- */
- function utf8Encode($attributes)
- {
- return $this->_utf8($attributes, 'utf8_encode');
- }
-
- /**
- * Decodes the given attribute values
- *
- * @access public
- * @param array Array of attributes
- * @return array Array with decoded attribute values
- */
- function utf8Decode($attributes)
- {
- return $this->_utf8($attributes, 'utf8_decode');
- }
-
- /**
- * Encodes or decodes attribute values if needed
- *
- * @access private
- * @param array Array of attributes
- * @param array Function to apply to attribute values
- * @return array Array of attributes with function applied to values
- */
- function _utf8($attributes, $function)
- {
- if (!$this->_schema) {
- $this->_schema = $this->schema();
- }
-
- if (!$this->_link || Net_LDAP::isError($this->_schema) || !function_exists($function)) {
- return $attributes;
- }
-
- if (is_array($attributes) && count($attributes) > 0) {
-
- foreach( $attributes as $k => $v ) {
-
- if (!isset($this->_schemaAttrs[$k])) {
-
- $attr = $this->_schema->get('attribute', $k);
- if (Net_LDAP::isError($attr)) {
- continue;
- }
-
- if (false !== strpos($attr['syntax'], '1.3.6.1.4.1.1466.115.121.1.15')) {
- $encode = true;
- } else {
- $encode = false;
- }
- $this->_schemaAttrs[$k] = $encode;
-
- } else {
- $encode = $this->_schemaAttrs[$k];
- }
-
- if ($encode) {
- if (is_array($v)) {
- foreach ($v as $ak => $av) {
- $v[$ak] = call_user_func($function, $av );
- }
- } else {
- $v = call_user_func($function, $v);
- }
- }
- $attributes[$k] = $v;
- }
- }
- return $attributes;
- }
-}
-
-/**
- * Net_LDAP_Error implements a class for reporting portable LDAP error messages.
- *
- * @package Net_LDAP
- */
-class Net_LDAP_Error extends PEAR_Error
-{
- /**
- * Net_LDAP_Error constructor.
- *
- * @param mixed Net_LDAP error code, or string with error message.
- * @param integer what "error mode" to operate in
- * @param integer what error level to use for $mode & PEAR_ERROR_TRIGGER
- * @param mixed additional debug info, such as the last query
- * @access public
- * @see PEAR_Error
- */
- function Net_LDAP_Error($code = NET_LDAP_ERROR, $mode = PEAR_ERROR_RETURN,
- $level = E_USER_NOTICE, $debuginfo = null)
- {
- $mode = PEAR_ERROR_RETURN;
- if (is_int($code)) {
- $this->PEAR_Error('Net_LDAP_Error: ' . Net_LDAP::errorMessage($code), $code, $mode, $level, $debuginfo);
- } else {
- $this->PEAR_Error("Net_LDAP_Error: $code", NET_LDAP_ERROR, $mode, $level, $debuginfo);
- }
- }
-}
-?>
diff --git a/thirdparty/pear/Net/LDAP/Entry.php b/thirdparty/pear/Net/LDAP/Entry.php
deleted file mode 100644
index 56ecdefa8..000000000
--- a/thirdparty/pear/Net/LDAP/Entry.php
+++ /dev/null
@@ -1,524 +0,0 @@
- false,
- 'modify' => false,
- 'newEntry' => true
- ); // since the entry is not changed before the update();
-
- /**
- * Net_LDAP_Schema object TO BE REMOVED
- */
- var $_schema;
- /**#@-*/
-
- /** Constructor
- *
- * @param - link - ldap_resource_link, dn = string entry dn, attributes - array entry attributes array.
- * @return - none
- **/
- function Net_LDAP_Entry($link = null, $dn = null, $attributes = null)
- {
- if (!is_null($link)) {
- $this->_link = $link;
- }
- if (!is_null($dn)) {
- $this->_set_dn($dn);
- }
- if (is_array($attributes) && count($attributes) > 0) {
- $this->_set_attributes($attributes);
- } else {
- $this->updateCheck['newEntry'] = true;
- }
- }
-
- /**
- * Set the reasourcelink to the ldapserver.
- *
- * @access private
- * @param resource LDAP link
- */
- function _set_link(&$link)
- {
- $this->_link = $link;
- }
-
- /**
- * set the entrys DN
- *
- * @access private
- * @param string
- */
- function _set_dn($dn)
- {
- $this->_dn = $dn;
- }
-
- /**
- * sets the internal array of the entrys attributes.
- *
- * @access private
- * @param array
- */
- function _set_attributes($attributes= array())
- {
- $this->_attrs = $attributes;
- // this is the sign that the entry exists in the first place:
- $this->updateCheck['newEntry'] = false;
- }
-
- /**
- * removes [count] entries from the array.
- *
- * remove all the count elements in the array:
- * Used before ldap_modify, ldap_add
- *
- * @access private
- * @return array Cleaned array of attributes
- */
- function _clean_entry()
- {
- $attributes = array();
-
- for ($i=0; $i < $this->_attrs['count'] ; $i++) {
-
- $attr = $this->_attrs[$i];
-
- if ($this->_attrs[$attr]['count'] == 1) {
- $attributes[$this->_attrs[$i]] = $this->_attrs[$attr][0];
- } else {
- $attributes[$attr] = $this->_attrs[$attr];
- unset ($attributes[ $attr ]['count']);
- }
- }
-
- return $attributes;
-
- }
-
- /**
- * returns an assosiative array of all the attributes in the array
- *
- * attributes - returns an assosiative array of all the attributes in the array
- * of the form array ('attributename'=>'singelvalue' , 'attribute'=>array('multiple','values'))
- *
- * @param none
- * @return array Array of attributes and values.
- */
- function attributes()
- {
- return $this->_clean_entry();
- }
-
- /**
- * Add one or more attribute to the entry
- *
- * The values given will be added to the values which already exist for the given attributes.
- * usage:
- * $entry->add ( array('sn'=>'huse',objectclass=>array(top,posixAccount)))
- *
- * @param array Array of attributes
- * @return mixed Net_Ldap_Error if error, else true.
- */
- function add($attr = array())
- {
- if (!isset($this->_attrs['count'])) {
- $this->_attrs['count'] = 0;
- }
- if (!is_array($attr)) {
- return $this->raiseError("Net_LDAP::add : the parameter supplied is not an array, $attr", 1000);
- }
- /* if you passed an empty array, that is your problem! */
- if (count ($attr)==0) {
- return true;
- }
- foreach ($attr as $k => $v ) {
- // empty entrys should not be added to the entry.
- if ($v == '') {
- continue;
- }
-
- if ($this->exists($k)) {
- if (!is_array($this->_attrs[$k])) {
- return $this->raiseError("Possible malformed array as parameter to Net_LDAP::add().");
- }
- array_push($this->_attrs[$k],$v);
- $this->_attrs[$k]['count']++;
- } else {
- $this->_attrs[$k][0] = $v;
- $this->_attrs[$k]['count'] = 1;
- $this->_attrs[$this->_attrs['count']] = $k;
- $this->_attrs['count']++;
- }
- // Fix for bug #952
- if (empty($this->_addAttrs[$k])) {
- $this->_addAttrs[$k] = array();
- }
- if (false == is_array($v)) {
- $v = array($v);
- }
- foreach ($v as $value) {
- array_push($this->_addAttrs[$k], $value);
- }
- }
- return true;
- }
-
- /**
- * Set or get the DN for the object
- *
- * If a new dn is supplied, this will move the object when running $obj->update();
- *
- * @param string DN
- */
- function dn($newdn = '')
- {
- if ($newdn == '') {
- return $this->_dn;
- }
-
- $this->_olddn = $this->_dn;
- $this->_dn = $newdn;
- $this->updateCheck['newdn'] = true;
- }
-
- /**
- * check if a certain attribute exists in the directory
- *
- * @param string attribute name.
- * @return boolean
- */
- function exists($attr)
- {
- if (array_key_exists($attr, $this->_attrs)) {
- return true;
- }
- return false;
- }
-
- /**
- * get_value get the values for a attribute
- *
- * returns either an array or a string
- * possible values for option:
- * alloptions - returns an array with the values + a countfield.
- * i.e.: array (count=>1, 'sn'=>'huse');
- * single - returns the, first value in the array as a string.
- *
- * @param $attr string attribute name
- * @param $options array
- */
- function get_value($attr = '', $options = '')
- {
- if (array_key_exists($attr, $this->_attrs)) {
-
- if ($options == 'single') {
- if (is_array($this->_attrs[$attr])) {
- return $this->_attrs[$attr][0];
- } else {
- return $this->_attrs[$attr];
- }
- }
-
- $value = $this->_attrs[$attr];
-
- if (!$options == 'alloptions') {
- unset ($value['count']);
- }
- return $value;
- } else {
- return '';
- }
- }
-
- /**
- * add/delete/modify attributes
- *
- * this function tries to do all the things that replace(),delete() and add() does on an object.
- * Syntax:
- * array ( 'attribute' => newval, 'delattribute' => '', newattrivute => newval);
- * Note: You cannot use this function to modify parts of an attribute. You must modify the whole attribute.
- * You may call the function many times before running $entry->update();
- *
- * @param array attributes to be modified
- * @return mixed errorObject if failure, true if success.
- */
- function modify($attrs = array()) {
-
- if (!is_array($attrs) || count ($attrs) < 1 ) {
- return $this->raiseError("You did not supply an array as expected",1000);
- }
-
- foreach ($attrs as $k => $v) {
- // empty values are deleted (ldap v3 handling is in update() )
- if ($v == '' && $this->exists($k)) {
- $this->_delAttrs[$k] = '';
- continue;
- }
- /* existing attributes are modified*/
- if ($this->exists($k) ) {
- if (is_array($v)) {
- $this->_modAttrs[$k] = $v;
- } else {
- $this->_modAttrs[$k][0] = $v;
- }
- } else {
- /* new ones are created */
- if (is_array($v) ) {
- // an empty array is deleted...
- if (count($v) == 0 ) {
- $this->_delAttrs[$k] = '';
- } else {
- $this->_addAttrs[$k] = $v;
- }
- } else {
- // dont't add empty attributes
- if ($v != null) $this->_addAttrs[$k][0] = $v;
- }
- }
- }
- return true;
- }
-
-
- /**
- * replace a certain attributes value
- *
- * replace - replace a certain attributes value
- * example:
- * $entry->replace(array('uid'=>array('tarjei')));
- *
- * @param array attributes to be replaced
- * @return mixed error if failure, true if sucess.
- */
- function replace($attrs = array() )
- {
- foreach ($attrs as $k => $v) {
-
- if ($this->exists($k)) {
-
- if (is_array($v)) {
- $this->_attrs[$k] = $v;
- $this->_attrs[$k]['count'] = count($v);
- $this->_modAttrs[$k] = $v;
- } else {
- $this->_attrs[$k]['count'] = 1;
- $this->_attrs[$k][0] = $v;
- $this->_modAttrs[$k][0] = $v;
- }
- } else {
- return $this->raiseError("Attribute $k does not exist",16); // 16 = no such attribute exists.
- }
- }
- return true;
- }
-
- /**
- * delete attributes
- *
- * Use this function to delete certain attributes from an object.
- *
- * @param - array of attributes to be deleted
- * @return mixed Net_Ldap_Error if failure, true if success.
- */
- function delete($attrs = array())
- {
- foreach ($attrs as $k => $v) {
-
- if ($this->exists ($k)) {
- // if v is a null, then remove the whole attribute, else only the value.
- if ($v == '') {
- unset($this->_attrs[$k]);
- $this->_delAttrs[$k] = "";
- // else we remove only the correct value.
- } else {
- for ($i = 0;$i< $this->_attrs[$k]['count'];$i++) {
- if ($this->_attrs[$k][$i] == $v ) {
- unset ($this->_attrs[$k][$i]);
- $this->_delAttrs[$k] = $v;
- continue;
- }
- }
- }
- } else {
- $this->raiseError("You tried to delete a nonexisting attribute!",16);
- }
- }
- return true;
- }
-
- /**
- * update the Entry in LDAP
- *
- * After modifying an object, you must run update() to
- * make the updates on the ldap server. Before that, they only exists in the object.
- *
- * @param object Net_LDAP
- * @return mixed Net_LDAP_Error object on failure or true on success
- */
- function update ($ldapObject = null)
- {
- if ($ldapObject == null && $this->_link == null ) {
- $this->raiseError("No link to database");
- }
-
- if ($ldapObject != null) {
- $this->_link =& $ldapObject->_link;
- }
-
- //if it's a new
- if ($this->updateCheck['newdn'] && !$this->updateCheck['newEntry']) {
- if (@ldap_get_option( $this->_link, LDAP_OPT_PROTOCOL_VERSION, $version) && $version != 3) {
- return $this->raiseError("Moving or renaming an dn is only supported in LDAP V3!", 80);
- }
-
- $newparent = ldap_explode_dn($this->_dn, 0);
- unset($newparent['count']);
- $relativeDn = array_shift($newparent);
- $newparent = join(',', $newparent);
-
- if (!@ldap_rename($this->_link, $this->_olddn, $relativeDn, $newparent, true)) {
- return $this->raiseError("DN not renamed: " . ldap_error($this->_link), ldap_errno($this->_link));
- }
- }
-
- if ($this->updateCheck['newEntry']) {
- //print " "; print_r($this->_clean_entry());
-
- if (!@ldap_add($this->_link, $this->dn(), $this->_clean_entry()) ) {
- return $this->raiseError("Entry" . $this->dn() . " not added!" .
- ldap_error($this->_link), ldap_errno($this->_link));
- } else {
- return true;
- }
- // update existing entry
- } else {
- $this->_error['first'] = $this->_modAttrs;
- $this->_error['count'] = count($this->_modAttrs);
-
- // modified attributes
- if (( count($this->_modAttrs)>0) &&
- !ldap_modify($this->_link, $this->dn(), $this->_modAttrs))
- {
- return $this->raiseError("Entry " . $this->dn() . " not modified(attribs not modified): " .
- ldap_error($this->_link),ldap_errno($this->_link));
- }
-
- // attributes to be deleted
- if (( count($this->_delAttrs) > 0 ))
- {
- // in ldap v3 we need to supply the old attribute values for deleting
- if (@ldap_get_option( $this->_link, LDAP_OPT_PROTOCOL_VERSION, $version) && $version == 3) {
- foreach ( $this->_delAttrs as $k => $v ) {
- if ( $v == '' && $this->exists($k) ) {
- $this->_delAttrs[$k] = $this->get_value( $k );
- }
- }
- }
- if ( !ldap_mod_del($this->_link, $this->dn(), $this->_delAttrs) ) {
- return $this->raiseError("Entry " . $this->dn() . " not modified (attributes not deleted): " .
- ldap_error($this->_link),ldap_errno($this->_link));
- }
- }
-
- // new attributes
- if ((count($this->_addAttrs)) > 0 && !ldap_modify($this->_link, $this->dn(), $this->_addAttrs)) {
- return $this->raiseError( "Entry " . $this->dn() . " not modified (attributes not added): " .
- ldap_error($this->_link),ldap_errno($this->_link));
- }
- return true;
- }
- }
-}
-
-?>
diff --git a/thirdparty/pear/Net/LDAP/RootDSE.php b/thirdparty/pear/Net/LDAP/RootDSE.php
deleted file mode 100644
index a2f3fc090..000000000
--- a/thirdparty/pear/Net/LDAP/RootDSE.php
+++ /dev/null
@@ -1,192 +0,0 @@
-
- * @version $Revision: 4831 $
- */
-class Net_LDAP_RootDSE extends PEAR
-{
- /**
- * @access private
- * @var object Net_LDAP_Entry
- **/
- var $_entry;
-
- /**
- * class constructor
- *
- * @param object Net_LDAP_Entry
- */
- function Net_LDAP_RootDSE(&$entry)
- {
- $this->_entry = $entry;
- }
-
- /**
- * Gets the requested attribute value
- *
- * Same usuage as Net_LDAP_Entry::get_value()
- *
- * @access public
- * @param string Attribute name
- * @param array Array of options
- * @return mixed Net_LDAP_Error object or attribute values
- * @see Net_LDAP_Entry::get_value()
- */
- function getValue($attr = '', $options = '')
- {
- return $this->_entry->get_value($attr, $options);
- }
-
- /**
- * alias function of getValue() for perl-ldap interface
- *
- * @see getValue()
- */
- function get_value()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'getValue' ), $args);
- }
-
- /**
- * Determines if the extension is supported
- *
- * @access public
- * @param array Array of oids to check
- * @return boolean
- */
- function supportedExtension($oids)
- {
- return $this->_checkAttr($oids, 'supportedExtension');
- }
-
- /**
- * alias function of supportedExtension() for perl-ldap interface
- *
- * @see supportedExtension()
- */
- function supported_extension()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'supportedExtension'), $args);
- }
-
- /**
- * Determines if the version is supported
- *
- * @access public
- * @param array Versions to check
- * @return boolean
- */
- function supportedVersion($versions)
- {
- return $this->_checkAttr($versions, 'supportedLDAPVersion');
- }
-
- /**
- * alias function of supportedVersion() for perl-ldap interface
- *
- * @see supportedVersion()
- */
- function supported_version()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'supportedVersion'), $args);
- }
-
- /**
- * Determines if the control is supported
- *
- * @access public
- * @param array Control oids to check
- * @return boolean
- */
- function supportedControl($oids)
- {
- return $this->_checkAttr($oids, 'supportedControl');
- }
-
- /**
- * alias function of supportedControl() for perl-ldap interface
- *
- * @see supportedControl()
- */
- function supported_control()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'supportedControl' ), $args);
- }
-
- /**
- * Determines if the sasl mechanism is supported
- *
- * @access public
- * @param array SASL mechanisms to check
- * @return boolean
- */
- function supportedSASLMechanism($mechlist)
- {
- return $this->_checkAttr($mechlist, 'supportedSASLMechanisms');
- }
-
- /**
- * alias function of supportedSASLMechanism() for perl-ldap interface
- *
- * @see supportedSASLMechanism()
- */
- function supported_sasl_mechanism()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'supportedSASLMechanism'), $args);
- }
-
- /**
- * Checks for existance of value in attribute
- *
- * @access private
- * @param array $values values to check
- * @param attr $attr attribute name
- * @return boolean
- */
- function _checkAttr($values, $attr)
- {
- if (!is_array($values)) $values = array($values);
-
- foreach ($values as $value) {
- if (!@in_array($value, $this->get_value($attr))) {
- return false;
- }
- }
- return true;
- }
-}
-
-?>
\ No newline at end of file
diff --git a/thirdparty/pear/Net/LDAP/Schema.php b/thirdparty/pear/Net/LDAP/Schema.php
deleted file mode 100644
index 5fdd650d8..000000000
--- a/thirdparty/pear/Net/LDAP/Schema.php
+++ /dev/null
@@ -1,355 +0,0 @@
-
- * @version $Revision: 4831 $
- */
- class Net_LDAP_Schema extends PEAR
- {
- /**
- * Map of entry types to ldap attributes of subschema entry
- *
- * @access public
- * @var array
- */
- var $types = array('attribute' => 'attributeTypes',
- 'ditcontentrule' => 'dITContentRules',
- 'ditstructurerule' => 'dITStructureRules',
- 'matchingrule' => 'matchingRules',
- 'matchingruleuse' => 'matchingRuleUse',
- 'nameform' => 'nameForms',
- 'objectclass' => 'objectClasses',
- 'syntax' => 'ldapSyntaxes');
-
- /**#@+
- * Array of entries belonging to this type
- *
- * @access private
- * @var array
- */
- var $_attributeTypes = array();
- var $_matchingRules = array();
- var $_matchingRuleUse = array();
- var $_ldapSyntaxes = array();
- var $_objectClasses = array();
- var $_dITContentRules = array();
- var $_dITStructureRules = array();
- var $_nameForms = array();
- /**#@-*/
-
- /**
- * hash of all fetched oids
- *
- * @access private
- * @var array
- */
- var $_oids = array();
-
- /**
- * constructor of the class
- *
- * @access protected
- */
- function Net_LDAP_Schema()
- {
- $this->PEAR('Net_LDAP_Error'); // default error class
- }
-
- /**
- * Return a hash of entries for the given type
- *
- * Returns a hash of entry for th givene type. Types may be:
- * objectclasses, attributes, ditcontentrules, ditstructurerules, matchingrules,
- * matchingruleuses, nameforms, syntaxes
- *
- * @access public
- * @param string Type to fetch
- * @return mixed Array or Net_LDAP_Error
- */
- function &getAll($type)
- {
- $map = array('objectclasses' => &$this->_objectClasses,
- 'attributes' => &$this->_attributeTypes,
- 'ditcontentrules' => &$this->_dITContentRules,
- 'ditstructurerules' => &$this->_dITStructureRules,
- 'matchingrules' => &$this->_matchingRules,
- 'matchingruleuses' => &$this->_matchingRuleUse,
- 'nameforms' => &$this->_nameForms,
- 'syntaxes' => &$this->_ldapSyntaxes );
-
- $key = strtolower($type);
- return ((key_exists($key, $map)) ? $map[$key] : $this->raiseError("Unknown type $type"));
- }
-
- /**
- * Return a specific entry
- *
- * @access public
- * @param string Type of name
- * @param string Name or OID to fetch
- * @return mixed Entry or Net_LDAP_Error
- */
- function &get($type, $name)
- {
- $type = strtolower($type);
- if (false == key_exists($type, $this->types)) {
- return $this->raiseError("No such type $type");
- }
-
- $name = strtolower($name);
- $type_var = &$this->{'_' . $this->types[$type]};
-
- if( key_exists($name, $type_var)) {
- return $type_var[$name];
- } elseif(key_exists($name, $this->_oids) && $this->_oids[$name]['type'] == $type) {
- return $this->_oids[$name];
- } else {
- return $this->raiseError("Could not find $type $name");
- }
- }
-
-
- /**
- * Fetches attributes that MAY be present in the given objectclass
- *
- * @access public
- * @param string Name or OID of objectclass
- * @return mixed Array with attributes or Net_LDAP_Error
- */
- function may($oc)
- {
- return $this->_getAttr($oc, 'may');
- }
-
- /**
- * Fetches attributes that MUST be present in the given objectclass
- *
- * @access public
- * @param string Name or OID of objectclass
- * @return mixed Array with attributes or Net_LDAP_Error
- */
- function must($oc)
- {
- return $this->_getAttr($oc, 'must');
- }
-
- /**
- * Fetches the given attribute from the given objectclass
- *
- * @access private
- * @param string Name or OID of objectclass
- * @param string Name of attribute to fetch
- * @return mixed The attribute or Net_LDAP_Error
- */
- function _getAttr($oc, $attr)
- {
- $oc = strtolower($oc);
- if (key_exists($oc, $this->_objectClasses) && key_exists($attr, $this->_objectClasses[$oc])) {
- return $this->_objectClasses[$oc][$attr];
- }
- elseif (key_exists($oc, $this->_oids) &&
- $this->_oids[$oc]['type'] == 'objectclass' &&
- key_exists($attr, $this->_oids[$oc])) {
- return $this->_oids[$oc][$attr];
- } else {
- return $this->raiseError("Could not find $attr attributes for $oc ");
- }
- }
-
- /**
- * Returns the name(s) of the immediate superclass(es)
- *
- * @param string Name or OID of objectclass
- * @return mixed Array of names or Net_LDAP_Error
- */
- function superclass($oc)
- {
- $o = $this->get('objectclass', $oc);
- if (Net_LDAP::isError($o)) {
- return $o;
- }
- return (key_exists('sup', $o) ? $o['sup'] : array());
- }
-
- /**
- * Parses the schema of the given Subschema entry
- *
- * @access public
- * @param object Net_LDAP_Entry Subschema entry
- */
- function parse(&$entry)
- {
- foreach ($this->types as $type => $attr)
- {
- // initialize map type to entry
- $type_var = '_' . $attr;
- $this->{$type_var} = array();
-
- // get values for this type
- $values = $entry->get_value($attr);
-
- if (is_array($values))
- {
- foreach ($values as $value) {
-
- unset($schema_entry); // this was a real mess without it
-
- // get the schema entry
- $schema_entry = $this->_parse_entry($value);
-
- // set the type
- $schema_entry['type'] = $type;
-
- // save a ref in $_oids
- $this->_oids[$schema_entry['oid']] =& $schema_entry;
-
- // save refs for all names in type map
- $names = $schema_entry['aliases'];
- array_push($names, $schema_entry['name']);
- foreach ($names as $name) {
- $this->{$type_var}[strtolower($name)] =& $schema_entry;
- }
- }
- }
- }
- }
-
- /**
- * parses an attribute value into a schema entry
- *
- * @access private
- * @param string Attribute value
- * @return mixed Schema entry array or false
- */
- function &_parse_entry($value)
- {
- // tokens that have no value associated
- $noValue = array('single-value',
- 'obsolete',
- 'collective',
- 'no-user-modification',
- 'abstract',
- 'structural',
- 'auxiliary');
-
- // tokens that can have multiple values
- $multiValue = array('must', 'may', 'sup');
-
- $schema_entry = array('aliases' => array()); // initilization
-
- $tokens = $this->_tokenize($value); // get an array of tokens
-
- // remove surrounding brackets
- if ($tokens[0] == '(') array_shift($tokens);
- if ($tokens[count($tokens) - 1] == ')') array_pop($tokens); // -1 doesnt work on arrays :-(
-
- $schema_entry['oid'] = array_shift($tokens); // first token is the oid
-
- // cycle over the tokens until none are left
- while (count($tokens) > 0) {
- $token = strtolower(array_shift($tokens));
- if (in_array($token, $noValue)) {
- $schema_entry[$token] = 1; // single value token
- } else {
- // this one follows a string or a list if it is multivalued
- if (($schema_entry[$token] = array_shift($tokens)) == '(') {
- // this creates the list of values and cycles through the tokens
- // until the end of the list is reached ')'
- $schema_entry[$token] = array();
- while ($tmp = array_shift($tokens)) {
- if ($tmp == ')') break;
- if ($tmp != '$') array_push($schema_entry[$token], $tmp);
- }
- }
- // create a array if the value should be multivalued but was not
- if (in_array($token, $multiValue ) && !is_array($schema_entry[$token])) {
- $schema_entry[$token] = array($schema_entry[$token]);
- }
- }
- }
- // get max length from syntax
- if (key_exists('syntax', $schema_entry)) {
- if (preg_match('/{(\d+)}/', $schema_entry['syntax'], $matches)) {
- $schema_entry['max_length'] = $matches[1];
- }
- }
- // force a name
- if (empty($schema_entry['name'])) {
- $schema_entry['name'] = $schema_entry['oid'];
- }
- // make one name the default and put the other ones into aliases
- if (is_array($schema_entry['name'])) {
- $aliases = $schema_entry['name'];
- $schema_entry['name'] = array_shift($aliases);
- $schema_entry['aliases'] = $aliases;
- }
- return $schema_entry;
- }
-
- /**
- * tokenizes the given value into an array of tokens
- *
- * @access private
- * @param string String to parse
- * @return array Array of tokens
- */
- function _tokenize($value)
- {
- $tokens = array(); // array of tokens
- $matches = array(); // matches[0] full pattern match, [1,2,3] subpatterns
-
- // this one is taken from perl-ldap, modified for php
- $pattern = "/\s* (?:([()]) | ([^'\s()]+) | '((?:[^']+|'[^\s)])*)') \s*/x";
-
- /**
- * This one matches one big pattern wherin only one of the three subpatterns matched
- * We are interested in the subpatterns that matched. If it matched its value will be
- * non-empty and so it is a token. Tokens may be round brackets, a string, or a string
- * enclosed by '
- */
- preg_match_all($pattern, $value, $matches);
-
- for ($i = 0; $i < count($matches[0]); $i++) { // number of tokens (full pattern match)
- for ($j = 1; $j < 4; $j++) { // each subpattern
- if (null != trim($matches[$j][$i])) { // pattern match in this subpattern
- $tokens[$i] = trim($matches[$j][$i]); // this is the token
- }
- }
- }
- return $tokens;
- }
- }
-
-?>
\ No newline at end of file
diff --git a/thirdparty/pear/Net/LDAP/Search.php b/thirdparty/pear/Net/LDAP/Search.php
deleted file mode 100644
index f6b67f460..000000000
--- a/thirdparty/pear/Net/LDAP/Search.php
+++ /dev/null
@@ -1,245 +0,0 @@
-_setSearch($search, $link);
- $this->_errorCode = ldap_errno($link);
- }
-
- /**
- * Returns an assosiative array of entry objects
- *
- * @return array Array of entry objects.
- */
- function entries()
- {
- if ($this->count() == 0) {
- return array();
- }
-
- $this->_elink = @ldap_first_entry( $this->_link,$this->_search);
- $entry = new Net_LDAP_Entry($this->_link,
- @ldap_get_dn($this->_link, $this->_elink),
- @ldap_get_attributes($this->_link, $this->_elink));
- array_push($this->_entries, $entry);
-
- while ($this->_elink = @ldap_next_entry($this->_link,$this->_elink)) {
- $entry = new Net_LDAP_Entry($this->_link,
- @ldap_get_dn($this->_link, $this->_elink),
- @ldap_get_attributes($this->_link, $this->_elink));
- array_push($this->_entries, $entry);
- }
- return $this->_entries;
- }
-
- /**
- * Get the next entry in the searchresult.
- *
- * @return mixed Net_LDAP_Entry object or false
- */
- function shiftEntry()
- {
- if ($this->count() == 0 ) {
- return false;
- }
-
- if (is_null($this->_elink)) {
- $this->_elink = @ldap_first_entry($this->_link, $this->_search);
- $entry = new Net_LDAP_Entry($this->_link,
- ldap_get_dn($this->_link, $this->_elink),
- ldap_get_attributes($this->_link, $this->_elink));
- } else {
- if (!$this->_elink = ldap_next_entry($this->_link, $this->_elink)) {
- return false;
- }
- $entry = new Net_LDAP_Entry($this->_link,
- ldap_get_dn($this->_link,$this->_elink),
- ldap_get_attributes($this->_link,$this->_elink));
- }
- return $entry;
- }
-
- /**
- * alias function of shiftEntry() for perl-ldap interface
- *
- * @see shiftEntry()
- */
- function shift_entry()
- {
- $args = func_get_args();
- return call_user_func_array(array($this, 'shiftEntry'), $args);
- }
-
- /**
- * Retrieve the last entry of the searchset. NOT IMPLEMENTED
- *
- * @return object Net_LDAP_Error
- */
- function pop_entry ()
- {
- $this->raiseError("Not implemented");
- }
-
- /**
- * Return entries sorted NOT IMPLEMENTED
- *
- * @param array Array of sort attributes
- * @return object Net_LDAP_Error
- */
- function sorted ($attrs = array())
- {
- $this->raiseError("Not impelented");
- }
-
- /**
- * Return entries as object NOT IMPLEMENTED
- *
- * @return object Net_LDAP_Error
- */
- function as_struct ()
- {
- $this->raiseError("Not implemented");
- }
-
- /**
- * Set the searchobjects resourcelinks
- *
- * @access private
- * @param resource Search result identifier
- * @param resource Resource link identifier
- */
- function _setSearch(&$search,&$link)
- {
- $this->_search = $search;
- $this->_link = $link;
- }
-
- /**
- * Returns the number of entries in the searchresult
- *
- * @return int Number of entries in search.
- */
- function count()
- {
- /* this catches the situation where OL returned errno 32 = no such object! */
- if (!$this->_search) {
- return 0;
- }
- return @ldap_count_entries($this->_link, $this->_search);
- }
-
- /**
- * Get the errorcode the object got in its search.
- *
- * @return int The ldap error number.
- */
- function getErrorCode()
- {
- return $this->_errorCode;
- }
-
- /** Destructor
- *
- * @access protected
- */
- function _Net_LDAP_Search()
- {
- @ldap_free_result($this->_search);
- }
-
- /**
- * Closes search result
- */
- function done()
- {
- $this->_Net_LDAP_Search();
- }
-}
-
-?>
diff --git a/thirdparty/pear/Net/LDAP/Util.php b/thirdparty/pear/Net/LDAP/Util.php
deleted file mode 100644
index 19f37020b..000000000
--- a/thirdparty/pear/Net/LDAP/Util.php
+++ /dev/null
@@ -1,132 +0,0 @@
-
- * @version $Revision: 4831 $
- */
-class Net_LDAP_Util extends PEAR
-{
- /**
- * Reference to LDAP object
- *
- * @access private
- * @var object Net_LDAP
- */
- var $_ldap = null;
-
- /**
- * Net_LDAP_Schema object
- *
- * @access private
- * @var object Net_LDAP_Schema
- */
- var $_schema = null;
-
- /**
- * Constructur
- *
- * Takes an LDAP object by reference and saves it. Then the schema will be fetched.
- *
- * @access public
- * @param object Net_LDAP
- */
- function Net_LDAP_Util(&$ldap)
- {
- if (is_object($ldap) && (strtolower(get_class($ldap)) == 'net_ldap')) {
- $this->_ldap = $ldap;
- $this->_schema = $this->_ldap->schema();
- if (Net_LDAP::isError($this->_schema)) $this->_schema = null;
- }
- }
-
- /**
- * Encodes given attributes to UTF8 if needed
- *
- * This function takes attributes in an array and then checks against the schema if they need
- * UTF8 encoding. If that is so, they will be encoded. An encoded array will be returned and
- * can be used for adding or modifying.
- *
- * @access public
- * @param array Array of attributes
- * @return array Array of UTF8 encoded attributes
- */
- function utf8Encode($attributes)
- {
- return $this->_utf8($attributes, 'utf8_encode');
- }
-
- /**
- * Decodes the given attribute values
- *
- * @access public
- * @param array Array of attributes
- * @return array Array with decoded attribute values
- */
- function utf8Decode($attributes)
- {
- return $this->_utf8($attributes, 'utf8_decode');
- }
-
- /**
- * Encodes or decodes attribute values if needed
- *
- * @access private
- * @param array Array of attributes
- * @param array Function to apply to attribute values
- * @return array Array of attributes with function applied to values
- */
- function _utf8($attributes, $function)
- {
- if (!$this->_ldap || !$this->_schema || !function_exists($function)) {
- return $attributes;
- }
- if (is_array($attributes) && count($attributes) > 0) {
- foreach( $attributes as $k => $v ) {
- $attr = $this->_schema->get('attribute', $k);
- if (Net_LDAP::isError($attr)) {
- continue;
- }
- if (false !== strpos($attr['syntax'], '1.3.6.1.4.1.1466.115.121.1.15')) {
- if (is_array($v)) {
- foreach ($v as $ak => $av ) {
- $v[$ak] = call_user_func($function, $av );
- }
- } else {
- $v = call_user_func($function, $v);
- }
- }
- $attributes[$k] = $v;
- }
- }
- return $attributes;
- }
-}
-
-?>
diff --git a/thirdparty/pear/Net/LDAP/fg.php b/thirdparty/pear/Net/LDAP/fg.php
deleted file mode 100644
index a7f0bfddf..000000000
--- a/thirdparty/pear/Net/LDAP/fg.php
+++ /dev/null
@@ -1,38 +0,0 @@
- $oAuthenticator->sSearchUser,
- 'password' => $oAuthenticator->sSearchPassword,
- 'host' => $oAuthenticator->sLdapServer,
- 'base' => $oAuthenticator->sBaseDN,
-);
-
-$oLdap =& Net_LDAP::connect($config);
-if (PEAR::isError($oLdap)) {
- var_dump($oLdap);
- exit(0);
-}
-
-$aParams = array(
- 'scope' => 'sub',
- 'attributes' => array('cn', 'dn', 'displayClass'),
-);
-$rootDn = $oAuthenticator->sBaseDN;
-if (is_array($rootDn)) {
- $rootDn = join(",", $rootDn);
-}
-$oResults = $oLdap->search($rootDn, '(objectClass=group)', $aParams);
-foreach ($oResults->entries() as $oEntry) {
- var_dump($oEntry->dn());
-}
-
diff --git a/thirdparty/pear/Net/POP3.php b/thirdparty/pear/Net/POP3.php
deleted file mode 100644
index 8c6b7cda0..000000000
--- a/thirdparty/pear/Net/POP3.php
+++ /dev/null
@@ -1,1240 +0,0 @@
- |
-// | Co-Author: Damian Fernandez Sosa |
-// +-----------------------------------------------------------------------+
-//
-// $Id: POP3.php,v 1.2 2004/12/05 16:34:39 damian Exp $
-
-require_once('Net/Socket.php');
-
-
-
-/**
-* +----------------------------- IMPORTANT ------------------------------+
-* | Usage of this class compared to native php extensions such as IMAP |
-* | is slow and may be feature deficient. If available you are STRONGLY |
-* | recommended to use the php extensions. |
-* +----------------------------------------------------------------------+
-*
-* POP3 Access Class
-*
-* For usage see the example script
-*/
-
-define('NET_POP3_STATE_DISCONNECTED', 1, true);
-define('NET_POP3_STATE_AUTHORISATION', 2, true);
-define('NET_POP3_STATE_TRANSACTION', 4, true);
-
-class Net_POP3 {
-
- /*
- * Some basic information about the mail drop
- * garnered from the STAT command
- *
- * @var array
- */
- var $_maildrop;
-
- /*
- * Used for APOP to store the timestamp
- *
- * @var string
- */
- var $_timestamp;
-
- /*
- * Timeout that is passed to the socket object
- *
- * @var integer
- */
- var $_timeout;
-
- /*
- * Socket object
- *
- * @var object
- */
- var $_socket;
-
- /*
- * Current state of the connection. Used with the
- * constants defined above.
- *
- * @var integer
- */
- var $_state;
-
- /*
- * Hostname to connect to
- *
- * @var string
- */
- var $_host;
-
- /*
- * Port to connect to
- *
- * @var integer
- */
- var $_port;
-
- /**
- * To allow class debuging
- * @var boolean
- */
- var $_debug = false;
-
-
- /**
- * The auth methods this class support
- * @var array
- */
- //var $supportedAuthMethods=array('DIGEST-MD5', 'CRAM-MD5', 'APOP' , 'PLAIN' , 'LOGIN', 'USER');
- //Disabling DIGEST-MD5 for now
- var $supportedAuthMethods=array( 'CRAM-MD5', 'APOP' , 'PLAIN' , 'LOGIN', 'USER');
- //var $supportedAuthMethods=array( 'CRAM-MD5', 'PLAIN' , 'LOGIN');
- //var $supportedAuthMethods=array( 'PLAIN' , 'LOGIN');
-
-
- /**
- * The auth methods this class support
- * @var array
- */
- var $supportedSASLAuthMethods=array('DIGEST-MD5', 'CRAM-MD5');
-
-
- /**
- * The capability response
- * @var array
- */
- var $_capability;
-
- /*
- * Constructor. Sets up the object variables, and instantiates
- * the socket object.
- *
- */
-
-
- function Net_POP3()
- {
- $this->_timestamp = ''; // Used for APOP
- $this->_maildrop = array();
- $this->_timeout = 3;
- $this->_state = NET_POP3_STATE_DISCONNECTED;
- $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) {
- if($this->_debug){
- echo "AUTH_SASL NOT PRESENT!\n";
- }
- foreach($this->supportedSASLAuthMethods as $SASLMethod){
- $pos = array_search( $SASLMethod, $this->supportedAuthMethods );
- if($this->_debug){
- echo "DISABLING METHOD $SASLMethod\n";
- }
- unset($this->supportedAuthMethods[$pos]);
- }
- }
-
-
-
- }
-
-
- /**
- * Handles the errors the class can find
- * on the server
- *
- * @access private
- * @return PEAR_Error
- */
-
- function _raiseError($msg, $code =-1)
- {
- include_once 'PEAR.php';
- return PEAR::raiseError($msg, $code);
- }
-
-
-
- /*
- * Connects to the given host on the given port.
- * Also looks for the timestamp in the greeting
- * needed for APOP authentication
- *
- * @param string $host Hostname/IP address to connect to
- * @param string $port Port to use to connect to on host
- * @return bool Success/Failure
- */
- function connect($host = 'localhost', $port = 110)
- {
- $this->_host = $host;
- $this->_port = $port;
-
- $result = $this->_socket->connect($host, $port, false, $this->_timeout);
- if ($result === true) {
- $data = $this->_recvLn();
-
- if( $this->_checkResponse($data) ){
- // if the response begins with '+OK' ...
-// if (@substr(strtoupper($data), 0, 3) == '+OK') {
- // Check for string matching apop timestamp
- if (preg_match('/<.+@.+>/U', $data, $matches)) {
- $this->_timestamp = $matches[0];
- }
- $this->_maildrop = array();
- $this->_state = NET_POP3_STATE_AUTHORISATION;
-
- return true;
- }
- }
-
- $this->_socket->disconnect();
- return false;
- }
-
- /*
- * Disconnect function. Sends the QUIT command
- * and closes the socket.
- *
- * @return bool Success/Failure
- */
- function disconnect()
- {
- return $this->_cmdQuit();
- }
-
- /*
- * Performs the login procedure. If there is a timestamp
- * stored, APOP will be tried first, then basic USER/PASS.
- *
- * @param string $user Username to use
- * @param string $pass Password to use
- * @param mixed $apop Whether to try APOP first, if used as string you can select the auth methd to use ( $pop3->login('validlogin', 'validpass', "CRAM-MD5");
- * Valid methods are: 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'
- * @return mixed true on Success/ PEAR_ERROR on error
- */
- function login($user, $pass, $apop = true)
- {
- if ($this->_state == NET_POP3_STATE_AUTHORISATION) {
-
- if(PEAR::isError($ret= $this->_cmdAuthenticate($user , $pass , $apop ) ) ){
- return $ret;
- }
- if( ! PEAR::isError($ret)){
- $this->_state = NET_POP3_STATE_TRANSACTION;
- return true;
- }
-
- }
- return $this->_raiseError('Generic login error' , 1);
- }
-
-
-
- /**
- * Parses the response from the capability command. Stores
- * the result in $this->_capability
- *
- * @access private
- */
- function _parseCapability()
- {
-
- if(!PEAR::isError($data = $this->_sendCmd('CAPA'))){
- $data = $this->_getMultiline();
- }else {
- // CAPA command not supported, reset data var
- // to avoid Notice errors of preg_split on an object
- $data = '';
- }
- $data = preg_split('/\r?\n/', $data, -1, PREG_SPLIT_NO_EMPTY);
-
- for ($i = 0; $i < count($data); $i++) {
-
- $capa='';
- if (preg_match('/^([a-z,\-]+)( ((.*))|$)$/i', $data[$i], $matches)) {
-
- $capa=strtolower($matches[1]);
- switch ($capa) {
- case 'implementation':
- $this->_capability['implementation'] = $matches[3];
- break;
- case 'sasl':
- $this->_capability['sasl'] = preg_split('/\s+/', $matches[3]);
- break;
- default :
- $this->_capability[$capa] = $matches[2];
- break;
- }
- }
- }
- }
-
-
-
-
- /**
- * Returns the name of the best authentication method that the server
- * has advertised.
- *
- * @param string if !=null,authenticate with this method ($userMethod).
- *
- * @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.0
- */
- function _getBestAuthMethod($userMethod = null)
- {
-
-/*
- return 'USER';
- return 'APOP';
- return 'DIGEST-MD5';
- return 'CRAM-MD5';
-*/
-
-
- $this->_parseCapability();
-
- //unset($this->_capability['sasl']);
-
- if( isset($this->_capability['sasl']) ){
- $serverMethods=$this->_capability['sasl'];
- }else{
- $serverMethods=array('USER');
- // Check for timestamp before attempting APOP
- if ($this->_timestamp != null)
- {
- $serverMethods[] = 'APOP';
- }
- }
-
- if($userMethod !== null && $userMethod !== true ){
- $methods = array();
- $methods[] = $userMethod;
- return $userMethod;
- }else{
- $methods = $this->supportedAuthMethods;
- }
-
- if( ($methods != null) && ($serverMethods != null)){
-
- foreach ( $methods as $method ) {
-
- if ( in_array( $method , $serverMethods ) ) {
- return $method;
- }
- }
- $serverMethods=implode(',' , $serverMethods );
- $myMethods=implode(',' ,$this->supportedAuthMethods);
- return $this->_raiseError("$method NOT supported authentication method!. This server " .
- "supports these methods: $serverMethods, but I support $myMethods");
- }else{
- return $this->_raiseError("This server don't support any Auth methods");
- }
- }
-
-
-
-
-
-
- /* Handles the authentication using any known method
- *
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
- * @param string The method to use ( if $usermethod == '' then the class chooses the best method (the stronger is the best ) )
- *
- * @return mixed string or PEAR_Error
- *
- * @access private
- * @since 1.0
- */
- function _cmdAuthenticate($uid , $pwd , $userMethod = null )
- {
-
-
- if ( PEAR::isError( $method = $this->_getBestAuthMethod($userMethod) ) ) {
- return $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;
- case 'APOP':
- $result = $this->_cmdApop( $uid , $pwd );
- // if APOP fails fallback to USER auth
- if( PEAR::isError( $result ) ){
- //echo "APOP FAILED!!!\n";
- $result=$this->_authUSER( $uid , $pwd );
- }
- break;
- case 'USER':
- $result = $this->_authUSER( $uid , $pwd );
- break;
-
-
- default :
- $result = $this->_raiseError( "$method is not a supported authentication method" );
- break;
- }
- return $result;
- }
-
-
-
-
- /* Authenticates the user using the USER-PASS method.
- *
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
- *
- * @return mixed true on success or PEAR_Error on failure
- *
- * @access private
- * @since 1.0
- */
- function _authUSER($user, $pass )
- {
- if ( PEAR::isError($ret=$this->_cmdUser($user) ) ){
- return $ret;
- }
- if ( PEAR::isError($ret=$this->_cmdPass($pass) ) ){
- return $ret;
- }
- return true;
- }
-
-
-
-
-
-
-
-
- /* Authenticates the user using the PLAIN method.
- *
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
- *
- * @return array Returns an array containing the response
- *
- * @access private
- * @since 1.0
- */
- function _authPLAIN($user, $pass )
- {
- $cmd=sprintf('AUTH PLAIN %s', base64_encode( chr(0) . $user . chr(0) . $pass ) );
-
- if ( PEAR::isError( $ret = $this->_send($cmd) ) ) {
- return $ret;
- }
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ){
- return $challenge;
- }
- if( PEAR::isError($ret=$this->_checkResponse($challenge) )){
- return $ret;
- }
-
- return true;
- }
-
-
-
- /* Authenticates the user using the PLAIN method.
- *
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
- *
- * @return array Returns an array containing the response
- *
- * @access private
- * @since 1.0
- */
- function _authLOGIN($user, $pass )
- {
- $this->_send('AUTH LOGIN');
-
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ) {
- return $challenge;
- }
- if( PEAR::isError($ret=$this->_checkResponse($challenge) )){
- return $ret;
- }
-
-
- if ( PEAR::isError( $ret = $this->_send(sprintf('%s', base64_encode($user))) ) ) {
- return $ret;
- }
-
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ) {
- return $challenge;
- }
- if( PEAR::isError($ret=$this->_checkResponse($challenge) )){
- return $ret;
- }
-
- if ( PEAR::isError( $ret = $this->_send(sprintf('%s', base64_encode($pass))) ) ) {
- return $ret;
- }
-
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ) {
- return $challenge;
- }
- return $this->_checkResponse($challenge);
- }
-
-
-
-
-
- /* Authenticates the user using the CRAM-MD5 method.
- *
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
- *
- * @return array Returns an array containing the response
- *
- * @access private
- * @since 1.0
- */
- function _authCRAM_MD5($uid, $pwd )
- {
- if ( PEAR::isError( $ret = $this->_send( 'AUTH CRAM-MD5' ) ) ) {
- return $ret;
- }
-
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ) {
- return $challenge;
- }
- if( PEAR::isError($ret=$this->_checkResponse($challenge) )){
- return $ret;
- }
-
- // remove '+ '
-
- $challenge=substr($challenge,2);
-
- $challenge = base64_decode( $challenge );
-
- $cram = &Auth_SASL::factory('crammd5');
- $auth_str = base64_encode( $cram->getResponse( $uid , $pwd , $challenge ) );
-
-
- if ( PEAR::isError($error = $this->_send( $auth_str ) ) ) {
- return $error;
- }
- if ( PEAR::isError( $ret = $this->_recvLn() ) ) {
- return $ret;
- }
- //echo "RET:$ret\n";
- return $this->_checkResponse($ret);
- }
-
-
-
- /* Authenticates the user using the DIGEST-MD5 method.
- *
- * @param string The userid to authenticate as.
- * @param string The password to authenticate with.
- * @param string The efective user
- *
- * @return array Returns an array containing the response
- *
- * @access private
- * @since 1.0
- */
- function _authDigest_MD5($uid, $pwd)
- {
- if ( PEAR::isError( $ret = $this->_send( 'AUTH DIGEST-MD5' ) ) ) {
- return $ret;
- }
-
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ) {
- return $challenge;
- }
- if( PEAR::isError($ret=$this->_checkResponse($challenge) )){
- return $ret;
- }
-
- // remove '+ '
- $challenge=substr($challenge,2);
-
- $challenge = base64_decode( $challenge );
- $digest = &Auth_SASL::factory('digestmd5');
- $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, "localhost", "pop3" ));
-
- if ( PEAR::isError($error = $this->_send( $auth_str ) ) ) {
- return $error;
- }
-
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ) {
- return $challenge;
- }
- if( PEAR::isError($ret=$this->_checkResponse($challenge) )){
- return $ret;
- }
- /*
- * We don't use the protocol's third step because POP3 doesn't allow
- * subsequent authentication, so we just silently ignore it.
- */
-
- if ( PEAR::isError( $challenge = $this->_send("\r\n") ) ) {
- return $challenge ;
- }
-
- if ( PEAR::isError( $challenge = $this->_recvLn() ) ) {
- return $challenge;
- }
-
- return $this->_checkResponse($challenge);
-
-
- }
-
-
-
-
-
-
-
-
-
-
- /*
- * Sends the APOP command
- *
- * @param $user Username to send
- * @param $pass Password to send
- * @return bool Success/Failure
- */
- function _cmdApop($user, $pass)
- {
- if ($this->_state == NET_POP3_STATE_AUTHORISATION) {
-
- if (!empty($this->_timestamp)) {
- if(PEAR::isError($data = $this->_sendCmd('APOP ' . $user . ' ' . $this->encryptOld($this->_timestamp . $pass)) ) ){
- return $data;
- }
- $this->_state = NET_POP3_STATE_TRANSACTION;
- return true;
- }
- }
- return $this->_raiseError('Not In NET_POP3_STATE_AUTHORISATION State1');
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*
- * Returns the raw headers of the specified message.
- *
- * @param integer $msg_id Message number
- * @return mixed Either raw headers or false on error
- */
- function getRawHeaders($msg_id)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- return $this->_cmdTop($msg_id, 0);
- }
-
- return false;
- }
-
- /*
- * Returns the headers of the specified message in an
- * associative array. Array keys are the header names, array
- * values are the header values. In the case of multiple headers
- * having the same names, eg Received:, the array value will be
- * an indexed array of all the header values.
- *
- * @param integer $msg_id Message number
- * @return mixed Either array of headers or false on error
- */
- function getParsedHeaders($msg_id)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
-
- $raw_headers = rtrim($this->getRawHeaders($msg_id));
-
- $raw_headers = preg_replace("/\r\n[ \t]+/", ' ', $raw_headers); // Unfold headers
- $raw_headers = explode("\r\n", $raw_headers);
- foreach ($raw_headers as $value) {
- $name = substr($value, 0, $pos = strpos($value, ':'));
- $value = ltrim(substr($value, $pos + 1));
- if (isset($headers[$name]) AND is_array($headers[$name])) {
- $headers[$name][] = $value;
- } elseif (isset($headers[$name])) {
- $headers[$name] = array($headers[$name], $value);
- } else {
- $headers[$name] = $value;
- }
- }
-
- return $headers;
- }
-
- return false;
- }
-
- /*
- * Returns the body of the message with given message number.
- *
- * @param integer $msg_id Message number
- * @return mixed Either message body or false on error
- */
- function getBody($msg_id)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- $msg = $this->_cmdRetr($msg_id);
- return substr($msg, strpos($msg, "\r\n\r\n")+4);
- }
-
- return false;
- }
-
- /*
- * Returns the entire message with given message number.
- *
- * @param integer $msg_id Message number
- * @return mixed Either entire message or false on error
- */
- function getMsg($msg_id)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- return $this->_cmdRetr($msg_id);
- }
-
- return false;
- }
-
- /*
- * Returns the size of the maildrop
- *
- * @return mixed Either size of maildrop or false on error
- */
- function getSize()
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if (isset($this->_maildrop['size'])) {
- return $this->_maildrop['size'];
- } else {
- list(, $size) = $this->_cmdStat();
- return $size;
- }
- }
-
- return false;
- }
-
- /*
- * Returns number of messages in this maildrop
- *
- * @return mixed Either number of messages or false on error
- */
- function numMsg()
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if (isset($this->_maildrop['num_msg'])) {
- return $this->_maildrop['num_msg'];
- } else {
- list($num_msg, ) = $this->_cmdStat();
- return $num_msg;
- }
- }
-
- return false;
- }
-
- /*
- * Marks a message for deletion. Only will be deleted if the
- * disconnect() method is called.
- *
- * @param integer $msg_id Message to delete
- * @return bool Success/Failure
- */
- function deleteMsg($msg_id)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- return $this->_cmdDele($msg_id);
- }
-
- return false;
- }
-
- /*
- * Combination of LIST/UIDL commands, returns an array
- * of data
- *
- * @param integer $msg_id Optional message number
- * @return mixed Array of data or false on error
- */
- function getListing($msg_id = null)
- {
-
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if (!isset($msg_id)){
-
- $list=array();
- if ($list = $this->_cmdList()) {
- if ($uidl = $this->_cmdUidl()) {
- foreach ($uidl as $i => $value) {
- $list[$i]['uidl'] = $value['uidl'];
- }
- }
- return $list;
- }else{
- return array();
- }
- } else {
- if ($list = $this->_cmdList($msg_id) AND $uidl = $this->_cmdUidl($msg_id)) {
- return array_merge($list, $uidl);
- }
- }
- }
-
- return false;
- }
-
- /*
- * Sends the USER command
- *
- * @param string $user Username to send
- * @return bool Success/Failure
- */
- function _cmdUser($user)
- {
- if ($this->_state == NET_POP3_STATE_AUTHORISATION) {
- return $this->_sendCmd('USER ' . $user);
- }
- return $this->_raiseError('Not In NET_POP3_STATE_AUTHORISATION State');
- }
-
-
- /*
- * Sends the PASS command
- *
- * @param string $pass Password to send
- * @return bool Success/Failure
- */
- function _cmdPass($pass)
- {
- if ($this->_state == NET_POP3_STATE_AUTHORISATION) {
- return $this->_sendCmd('PASS ' . $pass);
- }
- return $this->_raiseError('Not In NET_POP3_STATE_AUTHORISATION State');
- }
-
-
- /*
- * Sends the STAT command
- *
- * @return mixed Indexed array of number of messages and
- * maildrop size, or false on error.
- */
- function _cmdStat()
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if(!PEAR::isError($data = $this->_sendCmd('STAT'))){
- sscanf($data, '+OK %d %d', $msg_num, $size);
- $this->_maildrop['num_msg'] = $msg_num;
- $this->_maildrop['size'] = $size;
-
- return array($msg_num, $size);
- }
- }
- return false;
- }
-
-
- /*
- * Sends the LIST command
- *
- * @param integer $msg_id Optional message number
- * @return mixed Indexed array of msg_id/msg size or
- * false on error
- */
- function _cmdList($msg_id = null)
- {
- $return=array();
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if (!isset($msg_id)) {
- if(!PEAR::isError($data = $this->_sendCmd('LIST') )){
- $data = $this->_getMultiline();
- $data = explode("\r\n", $data);
- foreach ($data as $line) {
- if($line !=''){
- sscanf($line, '%s %s', $msg_id, $size);
- $return[] = array('msg_id' => $msg_id, 'size' => $size);
- }
- }
- return $return;
- }
- } else {
- if(!PEAR::isError($data = $this->_sendCmd('LIST ' . $msg_id))){
- if($data!=''){
- sscanf($data, '+OK %d %d', $msg_id, $size);
- return array('msg_id' => $msg_id, 'size' => $size);
- }
- return array();
- }
- }
- }
-
-
- return false;
- }
-
-
- /*
- * Sends the RETR command
- *
- * @param integer $msg_id The message number to retrieve
- * @return mixed The message or false on error
- */
- function _cmdRetr($msg_id)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if(!PEAR::isError($data = $this->_sendCmd('RETR ' . $msg_id) )){
- $data = $this->_getMultiline();
- return $data;
- }
- }
-
- return false;
- }
-
-
- /*
- * Sends the DELE command
- *
- * @param integer $msg_id Message number to mark as deleted
- * @return bool Success/Failure
- */
- function _cmdDele($msg_id)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- return $this->_sendCmd('DELE ' . $msg_id);
- }
-
- return false;
- }
-
-
- /*
- * Sends the NOOP command
- *
- * @return bool Success/Failure
- */
- function _cmdNoop()
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if(!PEAR::isError($data = $this->_sendCmd('NOOP'))){
- return true;
- }
- }
-
- return false;
- }
-
- /*
- * Sends the RSET command
- *
- * @return bool Success/Failure
- */
- function _cmdRset()
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
- if(!PEAR::isError($data = $this->_sendCmd('RSET'))){
- return true;
- }
- }
-
- return false;
- }
-
- /*
- * Sends the QUIT command
- *
- * @return bool Success/Failure
- */
- function _cmdQuit()
- {
- $data = $this->_sendCmd('QUIT');
- $this->_state = NET_POP3_STATE_DISCONNECTED;
- $this->_socket->disconnect();
-
- return (bool)$data;
- }
-
-
- /*
- * Sends the TOP command
- *
- * @param integer $msg_id Message number
- * @param integer $num_lines Number of lines to retrieve
- * @return mixed Message data or false on error
- */
- function _cmdTop($msg_id, $num_lines)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
-
- if(!PEAR::isError($data = $this->_sendCmd('TOP ' . $msg_id . ' ' . $num_lines))){
- return $this->_getMultiline();
- }
- }
-
- return false;
- }
-
- /*
- * Sends the UIDL command
- *
- * @param integer $msg_id Message number
- * @return mixed indexed array of msg_id/uidl or false on error
- */
- function _cmdUidl($msg_id = null)
- {
- if ($this->_state == NET_POP3_STATE_TRANSACTION) {
-
- if (!isset($msg_id)) {
- if(!PEAR::isError($data = $this->_sendCmd('UIDL') )){
- $data = $this->_getMultiline();
- $data = explode("\r\n", $data);
- foreach ($data as $line) {
- sscanf($line, '%d %s', $msg_id, $uidl);
- $return[] = array('msg_id' => $msg_id, 'uidl' => $uidl);
- }
-
- return $return;
- }
- } else {
-
- $data = $this->_sendCmd('UIDL ' . $msg_id);
- sscanf($data, '+OK %d %s', $msg_id, $uidl);
- return array('msg_id' => $msg_id, 'uidl' => $uidl);
- }
- }
-
- return false;
- }
-
-
-
-
-
-
-
-
-
- /*
- * Sends a command, checks the reponse, and
- * if good returns the reponse, other wise
- * returns false.
- *
- * @param string $cmd Command to send (\r\n will be appended)
- * @return mixed First line of response if successful, otherwise false
- */
- function _sendCmd($cmd)
- {
- if (PEAR::isError($result = $this->_send($cmd) )){
- return $result ;
- }
-
- if (PEAR::isError($data = $this->_recvLn() )){
- return $data;
- }
-
- if ( strtoupper(substr($data, 0, 3)) == '+OK') {
- return $data;
- }
-
-
- return $this->_raiseError($data);
- }
-
- /*
- * Reads a multiline reponse and returns the data
- *
- * @return string The reponse.
- */
- function _getMultiline()
- {
- $data = '';
- while(!PEAR::isError($tmp = $this->_recvLn() ) ) {
- if($tmp == '.'){
- return substr($data, 0, -2);
- }
- if (substr($tmp, 0, 2) == '..') {
- $tmp = substr($tmp, 1);
- }
- $data .= $tmp . "\r\n";
- }
- return substr($data, 0, -2);
- }
-
-
- /**
- * Sets the bebug state
- *
- * @param bool $debug
- * @access public
- * @return void
- */
- function setDebug($debug=true)
- {
- $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.0
- */
- function _send($data)
- {
- if ($this->_debug) {
- echo "C: $data\n";
- }
-
- if (PEAR::isError($error = $this->_socket->writeLine($data))) {
- return $this->_raiseError('Failed to write to socket: ' . $error->getMessage());
- }
- return true;
- }
-
-
-
- /**
- * Receive the given string of data from the server.
- *
- * @return mixed a line of response on success or a PEAR_Error object on failure.
- *
- * @access private
- * @since 1.0
- */
- function _recvLn()
- {
- if (PEAR::isError( $lastline = $this->_socket->readLine( 8192 ) ) ) {
- return $this->_raiseError('Failed to write to socket: ' . $this->lastline->getMessage() );
- }
- if($this->_debug){
- // S: means this data was sent by the POP3 Server
- echo "S:$lastline\n" ;
- }
- return $lastline;
- }
-
- /**
- * Checks de server Response
- *
- * @param string $response the response
- * @return mixed true on success or a PEAR_Error object on failure.
- *
- * @access private
- * @since 1.3.3
- */
-
- function _checkResponse($response)
- {
- if (@substr(strtoupper($response), 0, 3) == '+OK') {
- return true;
- }else{
- if (@substr(strtoupper($response), 0, 4) == '-ERR') {
- return $this->_raiseError($response);
- }else{
- if (@substr(strtoupper($response), 0, 2) == '+ ') {
- return true;
- }
- }
-
- }
- return $this->_raiseError("Unknown Response ($response)");
- }
-
- public function encryptOld($string)
- {
- if (!class_exists('G')) {
- $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
- $docuroot = explode( '/', $realdocuroot );
- array_pop( $docuroot );
- $pathhome = implode( '/', $docuroot ) . '/';
- array_pop( $docuroot );
- $pathTrunk = implode( '/', $docuroot ) . '/';
- require_once($pathTrunk.'gulliver/system/class.g.php');
- }
- return G::encryptOld($string);
- }
-
-
-
-}
-
-?>
diff --git a/thirdparty/pear/Net/SMTP.php b/thirdparty/pear/Net/SMTP.php
deleted file mode 100644
index d632258d6..000000000
--- a/thirdparty/pear/Net/SMTP.php
+++ /dev/null
@@ -1,1082 +0,0 @@
- |
-// | Jon Parise |
-// | Damian Alejandro Fernandez Sosa |
-// +----------------------------------------------------------------------+
-//
-// $Id: SMTP.php,v 1.63 2008/06/10 05:39:12 jon Exp $
-
-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');
-
- /**
- * Use SMTP command pipelining (specified in RFC 2920) if the SMTP
- * server supports it.
- *
- * When pipeling is enabled, rcptTo(), mailFrom(), sendFrom(),
- * somlFrom() and samlFrom() do not wait for a response from the
- * SMTP server but return immediately.
- *
- * @var bool
- * @access public
- */
- var $pipelining = false;
-
- /**
- * Number of pipelined commands.
- * @var int
- * @access private
- */
- var $_pipelined_commands = 0;
-
- /**
- * 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.
- *
- * If you have SSL support in PHP, you can connect to a server
- * over SSL using an 'ssl://' prefix:
- *
- * // 465 is a common smtps port.
- * $smtp = new Net_SMTP('ssl://mail.host.com', 465);
- * $smtp->connect();
- *
- * @param string $host The server to connect to.
- * @param integer $port The port to connect to.
- * @param string $localhost The value to give when sending EHLO or HELO.
- * @param boolean $pipeling Use SMTP command pipelining
- *
- * @access public
- * @since 1.0
- */
- function Net_SMTP($host = null, $port = null, $localhost = null, $pipelining = false)
- {
- if (isset($host)) {
- $this->host = $host;
- }
- if (isset($port)) {
- $this->port = $port;
- }
- if (isset($localhost)) {
- $this->localhost = $localhost;
- }
- $this->pipelining = $pipelining;
-
- $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 PEAR::raiseError('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 - an error will be thrown if the command string
- * already contains any newline characters. Use _send() for
- * commands that must contain newlines.
- *
- * @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)) {
- $command .= ' ' . $args;
- }
-
- if (strcspn($command, "\r\n") !== strlen($command)) {
- return PEAR::raiseError('Commands cannot contain newlines');
- }
-
- 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.
- * @param bool $later Do not parse the response now, but wait
- * until the last command in the pipelined
- * command group
- *
- * @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, $later = false)
- {
- $this->_code = -1;
- $this->_arguments = array();
-
- if ($later) {
- $this->_pipelined_commands++;
- return true;
- }
-
- for ($i = 0; $i <= $this->_pipelined_commands; $i++) {
- 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 PEAR::raiseError('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;
- }
- }
- }
-
- $this->_pipelined_commands = 0;
-
- /* Compare the server's response code with the valid code/codes. */
- if (is_int($valid) && ($this->_code === $valid)) {
- return true;
- } elseif (is_array($valid) && in_array($this->_code, $valid, true)) {
- return true;
- }
-
- return PEAR::raiseError('Invalid response code received from server',
- $this->_code);
- }
-
- /**
- * 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 PEAR::raiseError('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 PEAR::raiseError('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 PEAR::raiseError('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;
- }
-
- if (!isset($this->_esmtp['PIPELINING'])) {
- $this->pipelining = false;
- }
-
- 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 PEAR::raiseError('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'])) {
- if (version_compare(PHP_VERSION, '5.1.0', '>=')) {
- if (!isset($this->_esmtp['STARTTLS'])) {
- return PEAR::raiseError('SMTP server does not support authentication');
- }
- if (PEAR::isError($result = $this->_put('STARTTLS'))) {
- return $result;
- }
- if (PEAR::isError($result = $this->_parseResponse(220))) {
- return $result;
- }
- if (PEAR::isError($result = $this->_socket->enableCrypto(true, STREAM_CRYPTO_METHOD_TLS_CLIENT))) {
- return $result;
- } elseif ($result !== true) {
- return PEAR::raiseError('STARTTLS failed');
- }
-
- /* Send EHLO again to recieve the AUTH string from the
- * SMTP server. */
- $this->_negotiate();
- if (empty($this->_esmtp['AUTH'])) {
- return PEAR::raiseError('SMTP server does not support authentication');
- }
- } else {
- return PEAR::raiseError('SMTP server does not 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 PEAR::raiseError("$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 = PEAR::raiseError("$method is not a supported authentication method");
- break;
- }
-
- /* If an error was encountered, return the PEAR_Error object. */
- if (PEAR::isError($result)) {
- return $result;
- }
-
- 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;
- }
-
- /**
- * Return the list of SMTP service extensions advertised by the server.
- *
- * @return array The list of SMTP service extensions.
- * @access public
- * @since 1.3
- */
- function getServiceExtensions()
- {
- return $this->_esmtp;
- }
-
- /**
- * Send the MAIL FROM: command.
- *
- * @param string $sender The sender (reverse path) to set.
- * @param string $params String containing additional MAIL parameters,
- * such as the NOTIFY flags defined by RFC 1891
- * or the VERP protocol.
- *
- * If $params is an array, only the 'verp' option
- * is supported. If 'verp' is true, the XVERP
- * parameter is appended to the MAIL command. If
- * the 'verp' value is a string, the full
- * XVERP=value parameter is appended.
- *
- * @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, $params = null)
- {
- $args = "FROM:<$sender>";
-
- /* Support the deprecated array form of $params. */
- if (is_array($params) && isset($params['verp'])) {
- /* XVERP */
- if ($params['verp'] === true) {
- $args .= ' XVERP';
-
- /* XVERP=something */
- } elseif (trim($params['verp'])) {
- $args .= ' XVERP=' . $params['verp'];
- }
- } elseif (is_string($params)) {
- $args .= ' ' . $params;
- }
-
- if (PEAR::isError($error = $this->_put('MAIL', $args))) {
- return $error;
- }
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
- return $error;
- }
-
- return true;
- }
-
- /**
- * Send the RCPT TO: command.
- *
- * @param string $recipient The recipient (forward path) to add.
- * @param string $params String containing additional RCPT parameters,
- * such as the NOTIFY flags defined by RFC 1891.
- *
- * @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, $params = null)
- {
- $args = "TO:<$recipient>";
- if (is_string($params)) {
- $args .= ' ' . $params;
- }
-
- if (PEAR::isError($error = $this->_put('RCPT', $args))) {
- return $error;
- }
- if (PEAR::isError($error = $this->_parseResponse(array(250, 251), $this->pipelining))) {
- 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 $data 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(array('/(?_esmtp['SIZE']) && ($this->_esmtp['SIZE'] > 0)) {
- if (strlen($data) >= $this->_esmtp['SIZE']) {
- $this->disconnect();
- return PEAR::raiseError('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($result = $this->_send($data . "\r\n.\r\n"))) {
- return $result;
- }
- if (PEAR::isError($error = $this->_parseResponse(250, $this->pipelining))) {
- 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, $this->pipelining))) {
- 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, $this->pipelining))) {
- 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, $this->pipelining))) {
- 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, $this->pipelining))) {
- 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(array(250, 252)))) {
- 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/thirdparty/pear/Net/Socket.php b/thirdparty/pear/Net/Socket.php
deleted file mode 100644
index d7a049566..000000000
--- a/thirdparty/pear/Net/Socket.php
+++ /dev/null
@@ -1,576 +0,0 @@
- |
-// | Chuck Hagenbuch |
-// +----------------------------------------------------------------------+
-//
-// $Id: Socket.php,v 1.31 2007/05/04 04:30:29 chagenbu Exp $
-
-require_once 'PEAR.php';
-
-define('NET_SOCKET_READ', 1);
-define('NET_SOCKET_WRITE', 2);
-define('NET_SOCKET_ERROR', 4);
-
-/**
- * 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);
- }
-
- /**
- * Sets the file buffering size on the stream.
- * See php's stream_set_write_buffer for more information.
- *
- * @param integer $size Write buffer size.
- * @access public
- * @return mixed on success or an PEAR_Error object otherwise
- */
- function setWriteBuffer($size)
- {
- if (!is_resource($this->fp)) {
- return $this->raiseError('not connected');
- }
-
- $returned = stream_set_write_buffer($this->fp, $code);
- if ($returned == 0) {
- return true;
- }
- return $this->raiseError('Cannot set write buffer.');
- }
-
- /**
- * 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.
- *
- * Also returns true if the socket is disconnected.
- *
- * @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;
- }
-
- /**
- * Turns encryption on/off on a connected socket.
- *
- * @param bool $enabled Set this parameter to true to enable encryption
- * and false to disable encryption.
- * @param integer $type Type of encryption. See
- * http://se.php.net/manual/en/function.stream-socket-enable-crypto.php for values.
- *
- * @access public
- * @return false on error, true on success and 0 if there isn't enough data and the
- * user should try again (non-blocking sockets only). A PEAR_Error object
- * is returned if the socket is not connected
- */
- function enableCrypto($enabled, $type)
- {
- if (version_compare(phpversion(), "5.1.0", ">=")) {
- if (!is_resource($this->fp)) {
- return $this->raiseError('not connected');
- }
- return @stream_socket_enable_crypto($this->fp, $enabled, $type);
- } else {
- return $this->raiseError('Net_Socket::enableCrypto() requires php version >= 5.1.0');
- }
- }
-
-}
diff --git a/thirdparty/pear/Net/URL.php b/thirdparty/pear/Net/URL.php
deleted file mode 100644
index 3dcfef60d..000000000
--- a/thirdparty/pear/Net/URL.php
+++ /dev/null
@@ -1,485 +0,0 @@
- |
-// +-----------------------------------------------------------------------+
-//
-// $Id: URL.php,v 1.49 2007/06/28 14:43:07 davidc Exp $
-//
-// Net_URL Class
-
-
-class Net_URL
-{
- var $options = array('encode_query_keys' => false);
- /**
- * Full url
- * @var string
- */
- var $url;
-
- /**
- * Protocol
- * @var string
- */
- var $protocol;
-
- /**
- * Username
- * @var string
- */
- var $username;
-
- /**
- * Password
- * @var string
- */
- var $password;
-
- /**
- * Host
- * @var string
- */
- var $host;
-
- /**
- * Port
- * @var integer
- */
- var $port;
-
- /**
- * Path
- * @var string
- */
- var $path;
-
- /**
- * Query string
- * @var array
- */
- var $querystring;
-
- /**
- * Anchor
- * @var string
- */
- var $anchor;
-
- /**
- * Whether to use []
- * @var bool
- */
- var $useBrackets;
-
- /**
- * PHP4 Constructor
- *
- * @see __construct()
- */
- function Net_URL($url = null, $useBrackets = true)
- {
- $this->__construct($url, $useBrackets);
- }
-
- /**
- * PHP5 Constructor
- *
- * Parses the given url and stores the various parts
- * Defaults are used in certain cases
- *
- * @param string $url Optional URL
- * @param bool $useBrackets Whether to use square brackets when
- * multiple querystrings with the same name
- * exist
- */
- function __construct($url = null, $useBrackets = true)
- {
- $this->url = $url;
- $this->useBrackets = $useBrackets;
-
- $this->initialize();
- }
-
- function initialize()
- {
- $HTTP_SERVER_VARS = !empty($_SERVER) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
-
- $this->user = '';
- $this->pass = '';
- $this->host = '';
- $this->port = 80;
- $this->path = '';
- $this->querystring = array();
- $this->anchor = '';
-
- // Only use defaults if not an absolute URL given
- if (!preg_match('/^[a-z0-9]+:\/\//i', $this->url)) {
- $this->protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http');
-
- /**
- * Figure out host/port
- */
- if (!empty($HTTP_SERVER_VARS['HTTP_HOST']) &&
- preg_match('/^(.*)(:([0-9]+))?$/U', $HTTP_SERVER_VARS['HTTP_HOST'], $matches))
- {
- $host = $matches[1];
- if (!empty($matches[3])) {
- $port = $matches[3];
- } else {
- $port = $this->getStandardPort($this->protocol);
- }
- }
-
- $this->user = '';
- $this->pass = '';
- $this->host = !empty($host) ? $host : (isset($HTTP_SERVER_VARS['SERVER_NAME']) ? $HTTP_SERVER_VARS['SERVER_NAME'] : 'localhost');
- $this->port = !empty($port) ? $port : (isset($HTTP_SERVER_VARS['SERVER_PORT']) ? $HTTP_SERVER_VARS['SERVER_PORT'] : $this->getStandardPort($this->protocol));
- $this->path = !empty($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : '/';
- $this->querystring = isset($HTTP_SERVER_VARS['QUERY_STRING']) ? $this->_parseRawQuerystring($HTTP_SERVER_VARS['QUERY_STRING']) : null;
- $this->anchor = '';
- }
-
- // Parse the url and store the various parts
- if (!empty($this->url)) {
- $urlinfo = parse_url($this->url);
-
- // Default querystring
- $this->querystring = array();
-
- foreach ($urlinfo as $key => $value) {
- switch ($key) {
- case 'scheme':
- $this->protocol = $value;
- $this->port = $this->getStandardPort($value);
- break;
-
- case 'user':
- case 'pass':
- case 'host':
- case 'port':
- $this->$key = $value;
- break;
-
- case 'path':
- if ($value{0} == '/') {
- $this->path = $value;
- } else {
- $path = dirname($this->path) == DIRECTORY_SEPARATOR ? '' : dirname($this->path);
- $this->path = sprintf('%s/%s', $path, $value);
- }
- break;
-
- case 'query':
- $this->querystring = $this->_parseRawQueryString($value);
- break;
-
- case 'fragment':
- $this->anchor = $value;
- break;
- }
- }
- }
- }
- /**
- * Returns full url
- *
- * @return string Full url
- * @access public
- */
- function getURL()
- {
- $querystring = $this->getQueryString();
-
- $this->url = $this->protocol . '://'
- . $this->user . (!empty($this->pass) ? ':' : '')
- . $this->pass . (!empty($this->user) ? '@' : '')
- . $this->host . ($this->port == $this->getStandardPort($this->protocol) ? '' : ':' . $this->port)
- . $this->path
- . (!empty($querystring) ? '?' . $querystring : '')
- . (!empty($this->anchor) ? '#' . $this->anchor : '');
-
- return $this->url;
- }
-
- /**
- * Adds or updates a querystring item (URL parameter).
- * Automatically encodes parameters with rawurlencode() if $preencoded
- * is false.
- * You can pass an array to $value, it gets mapped via [] in the URL if
- * $this->useBrackets is activated.
- *
- * @param string $name Name of item
- * @param string $value Value of item
- * @param bool $preencoded Whether value is urlencoded or not, default = not
- * @access public
- */
- function addQueryString($name, $value, $preencoded = false)
- {
- if ($this->getOption('encode_query_keys')) {
- $name = rawurlencode($name);
- }
-
- if ($preencoded) {
- $this->querystring[$name] = $value;
- } else {
- $this->querystring[$name] = is_array($value) ? array_map('rawurlencode', $value): rawurlencode($value);
- }
- }
-
- /**
- * Removes a querystring item
- *
- * @param string $name Name of item
- * @access public
- */
- function removeQueryString($name)
- {
- if ($this->getOption('encode_query_keys')) {
- $name = rawurlencode($name);
- }
-
- if (isset($this->querystring[$name])) {
- unset($this->querystring[$name]);
- }
- }
-
- /**
- * Sets the querystring to literally what you supply
- *
- * @param string $querystring The querystring data. Should be of the format foo=bar&x=y etc
- * @access public
- */
- function addRawQueryString($querystring)
- {
- $this->querystring = $this->_parseRawQueryString($querystring);
- }
-
- /**
- * Returns flat querystring
- *
- * @return string Querystring
- * @access public
- */
- function getQueryString()
- {
- if (!empty($this->querystring)) {
- foreach ($this->querystring as $name => $value) {
- // Encode var name
- $name = rawurlencode($name);
-
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- $querystring[] = $this->useBrackets ? sprintf('%s[%s]=%s', $name, $k, $v) : ($name . '=' . $v);
- }
- } elseif (!is_null($value)) {
- $querystring[] = $name . '=' . $value;
- } else {
- $querystring[] = $name;
- }
- }
- $querystring = implode(ini_get('arg_separator.output'), $querystring);
- } else {
- $querystring = '';
- }
-
- return $querystring;
- }
-
- /**
- * Parses raw querystring and returns an array of it
- *
- * @param string $querystring The querystring to parse
- * @return array An array of the querystring data
- * @access private
- */
- function _parseRawQuerystring($querystring)
- {
- $parts = preg_split('/[' . preg_quote(ini_get('arg_separator.input'), '/') . ']/', $querystring, -1, PREG_SPLIT_NO_EMPTY);
- $return = array();
-
- foreach ($parts as $part) {
- if (strpos($part, '=') !== false) {
- $value = substr($part, strpos($part, '=') + 1);
- $key = substr($part, 0, strpos($part, '='));
- } else {
- $value = null;
- $key = $part;
- }
-
- if (!$this->getOption('encode_query_keys')) {
- $key = rawurldecode($key);
- }
-
- if (preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) {
- $key = $matches[1];
- $idx = $matches[2];
-
- // Ensure is an array
- if (empty($return[$key]) || !is_array($return[$key])) {
- $return[$key] = array();
- }
-
- // Add data
- if ($idx === '') {
- $return[$key][] = $value;
- } else {
- $return[$key][$idx] = $value;
- }
- } elseif (!$this->useBrackets AND !empty($return[$key])) {
- $return[$key] = (array)$return[$key];
- $return[$key][] = $value;
- } else {
- $return[$key] = $value;
- }
- }
-
- return $return;
- }
-
- /**
- * Resolves //, ../ and ./ from a path and returns
- * the result. Eg:
- *
- * /foo/bar/../boo.php => /foo/boo.php
- * /foo/bar/../../boo.php => /boo.php
- * /foo/bar/.././/boo.php => /foo/boo.php
- *
- * This method can also be called statically.
- *
- * @param string $path URL path to resolve
- * @return string The result
- */
- function resolvePath($path)
- {
- $path = explode('/', str_replace('//', '/', $path));
-
- for ($i=0; $i 1 OR ($i == 1 AND $path[0] != '') ) ) {
- unset($path[$i]);
- unset($path[$i-1]);
- $path = array_values($path);
- $i -= 2;
-
- } elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') {
- unset($path[$i]);
- $path = array_values($path);
- $i--;
-
- } else {
- continue;
- }
- }
-
- return implode('/', $path);
- }
-
- /**
- * Returns the standard port number for a protocol
- *
- * @param string $scheme The protocol to lookup
- * @return integer Port number or NULL if no scheme matches
- *
- * @author Philippe Jausions
- */
- function getStandardPort($scheme)
- {
- switch (strtolower($scheme)) {
- case 'http': return 80;
- case 'https': return 443;
- case 'ftp': return 21;
- case 'imap': return 143;
- case 'imaps': return 993;
- case 'pop3': return 110;
- case 'pop3s': return 995;
- default: return null;
- }
- }
-
- /**
- * Forces the URL to a particular protocol
- *
- * @param string $protocol Protocol to force the URL to
- * @param integer $port Optional port (standard port is used by default)
- */
- function setProtocol($protocol, $port = null)
- {
- $this->protocol = $protocol;
- $this->port = is_null($port) ? $this->getStandardPort($protocol) : $port;
- }
-
- /**
- * Set an option
- *
- * This function set an option
- * to be used thorough the script.
- *
- * @access public
- * @param string $optionName The optionname to set
- * @param string $value The value of this option.
- */
- function setOption($optionName, $value)
- {
- if (!array_key_exists($optionName, $this->options)) {
- return false;
- }
-
- $this->options[$optionName] = $value;
- $this->initialize();
- }
-
- /**
- * Get an option
- *
- * This function gets an option
- * from the $this->options array
- * and return it's value.
- *
- * @access public
- * @param string $opionName The name of the option to retrieve
- * @see $this->options
- */
- function getOption($optionName)
- {
- if (!isset($this->options[$optionName])) {
- return false;
- }
-
- return $this->options[$optionName];
- }
-
-}
-?>
diff --git a/thirdparty/pear/Net/URL2.php b/thirdparty/pear/Net/URL2.php
deleted file mode 100644
index 7a654aed8..000000000
--- a/thirdparty/pear/Net/URL2.php
+++ /dev/null
@@ -1,813 +0,0 @@
- |
-// +-----------------------------------------------------------------------+
-//
-// $Id: URL2.php,v 1.10 2008/04/26 21:57:08 schmidt Exp $
-//
-// Net_URL2 Class (PHP5 Only)
-
-// This code is released under the BSD License - http://www.opensource.org/licenses/bsd-license.php
-/**
- * @license BSD License
- */
-class Net_URL2
-{
- /**
- * Do strict parsing in resolve() (see RFC 3986, section 5.2.2). Default
- * is true.
- */
- const OPTION_STRICT = 'strict';
-
- /**
- * Represent arrays in query using PHP's [] notation. Default is true.
- */
- const OPTION_USE_BRACKETS = 'use_brackets';
-
- /**
- * URL-encode query variable keys. Default is true.
- */
- const OPTION_ENCODE_KEYS = 'encode_keys';
-
- /**
- * Query variable separators when parsing the query string. Every character
- * is considered a separator. Default is specified by the
- * arg_separator.input php.ini setting (this defaults to "&").
- */
- const OPTION_SEPARATOR_INPUT = 'input_separator';
-
- /**
- * Query variable separator used when generating the query string. Default
- * is specified by the arg_separator.output php.ini setting (this defaults
- * to "&").
- */
- const OPTION_SEPARATOR_OUTPUT = 'output_separator';
-
- /**
- * Default options corresponds to how PHP handles $_GET.
- */
- private $options = array(
- self::OPTION_STRICT => true,
- self::OPTION_USE_BRACKETS => true,
- self::OPTION_ENCODE_KEYS => true,
- self::OPTION_SEPARATOR_INPUT => 'x&',
- self::OPTION_SEPARATOR_OUTPUT => 'x&',
- );
-
- /**
- * @var string|bool
- */
- private $scheme = false;
-
- /**
- * @var string|bool
- */
- private $userinfo = false;
-
- /**
- * @var string|bool
- */
- private $host = false;
-
- /**
- * @var int|bool
- */
- private $port = false;
-
- /**
- * @var string
- */
- private $path = '';
-
- /**
- * @var string|bool
- */
- private $query = false;
-
- /**
- * @var string|bool
- */
- private $fragment = false;
-
- /**
- * @param string $url an absolute or relative URL
- * @param array $options
- */
- public function __construct($url, $options = null)
- {
- $this->setOption(self::OPTION_SEPARATOR_INPUT,
- ini_get('arg_separator.input'));
- $this->setOption(self::OPTION_SEPARATOR_OUTPUT,
- ini_get('arg_separator.output'));
- if (is_array($options)) {
- foreach ($options as $optionName => $value) {
- $this->setOption($optionName);
- }
- }
-
- if (preg_match('@^([a-z][a-z0-9.+-]*):@i', $url, $reg)) {
- $this->scheme = $reg[1];
- $url = substr($url, strlen($reg[0]));
- }
-
- if (preg_match('@^//([^/#?]+)@', $url, $reg)) {
- $this->setAuthority($reg[1]);
- $url = substr($url, strlen($reg[0]));
- }
-
- $i = strcspn($url, '?#');
- $this->path = substr($url, 0, $i);
- $url = substr($url, $i);
-
- if (preg_match('@^\?([^#]*)@', $url, $reg)) {
- $this->query = $reg[1];
- $url = substr($url, strlen($reg[0]));
- }
-
- if ($url) {
- $this->fragment = substr($url, 1);
- }
- }
-
- /**
- * Returns the scheme, e.g. "http" or "urn", or false if there is no
- * scheme specified, i.e. if this is a relative URL.
- *
- * @return string|bool
- */
- public function getScheme()
- {
- return $this->scheme;
- }
-
- /**
- * @param string|bool $scheme
- *
- * @return void
- * @see getScheme()
- */
- public function setScheme($scheme)
- {
- $this->scheme = $scheme;
- }
-
- /**
- * Returns the user part of the userinfo part (the part preceding the first
- * ":"), or false if there is no userinfo part.
- *
- * @return string|bool
- */
- public function getUser()
- {
- return $this->userinfo !== false ? preg_replace('@:.*$@', '', $this->userinfo) : false;
- }
-
- /**
- * Returns the password part of the userinfo part (the part after the first
- * ":"), or false if there is no userinfo part (i.e. the URL does not
- * contain "@" in front of the hostname) or the userinfo part does not
- * contain ":".
- *
- * @return string|bool
- */
- public function getPassword()
- {
- return $this->userinfo !== false ? substr(strstr($this->userinfo, ':'), 1) : false;
- }
-
- /**
- * Returns the userinfo part, or false if there is none, i.e. if the
- * authority part does not contain "@".
- *
- * @return string|bool
- */
- public function getUserinfo()
- {
- return $this->userinfo;
- }
-
- /**
- * Sets the userinfo part. If two arguments are passed, they are combined
- * in the userinfo part as username ":" password.
- *
- * @param string|bool $userinfo userinfo or username
- * @param string|bool $password
- *
- * @return void
- */
- public function setUserinfo($userinfo, $password = false)
- {
- $this->userinfo = $userinfo;
- if ($password !== false) {
- $this->userinfo .= ':' . $password;
- }
- }
-
- /**
- * Returns the host part, or false if there is no authority part, e.g.
- * relative URLs.
- *
- * @return string|bool
- */
- public function getHost()
- {
- return $this->host;
- }
-
- /**
- * @param string|bool $host
- *
- * @return void
- */
- public function setHost($host)
- {
- $this->host = $host;
- }
-
- /**
- * Returns the port number, or false if there is no port number specified,
- * i.e. if the default port is to be used.
- *
- * @return int|bool
- */
- public function getPort()
- {
- return $this->port;
- }
-
- /**
- * @param int|bool $port
- *
- * @return void
- */
- public function setPort($port)
- {
- $this->port = intval($port);
- }
-
- /**
- * Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or
- * false if there is no authority none.
- *
- * @return string|bool
- */
- public function getAuthority()
- {
- if (!$this->host) {
- return false;
- }
-
- $authority = '';
-
- if ($this->userinfo !== false) {
- $authority .= $this->userinfo . '@';
- }
-
- $authority .= $this->host;
-
- if ($this->port !== false) {
- $authority .= ':' . $this->port;
- }
-
- return $authority;
- }
-
- /**
- * @param string|false $authority
- *
- * @return void
- */
- public function setAuthority($authority)
- {
- $this->user = false;
- $this->pass = false;
- $this->host = false;
- $this->port = false;
- if (preg_match('@^(([^\@]+)\@)?([^:]+)(:(\d*))?$@', $authority, $reg)) {
- if ($reg[1]) {
- $this->userinfo = $reg[2];
- }
-
- $this->host = $reg[3];
- if (isset($reg[5])) {
- $this->port = intval($reg[5]);
- }
- }
- }
-
- /**
- * Returns the path part (possibly an empty string).
- *
- * @return string
- */
- public function getPath()
- {
- return $this->path;
- }
-
- /**
- * @param string $path
- *
- * @return void
- */
- public function setPath($path)
- {
- $this->path = $path;
- }
-
- /**
- * Returns the query string (excluding the leading "?"), or false if "?"
- * isn't present in the URL.
- *
- * @return string|bool
- * @see self::getQueryVariables()
- */
- public function getQuery()
- {
- return $this->query;
- }
-
- /**
- * @param string|bool $query
- *
- * @return void
- * @see self::setQueryVariables()
- */
- public function setQuery($query)
- {
- $this->query = $query;
- }
-
- /**
- * Returns the fragment name, or false if "#" isn't present in the URL.
- *
- * @return string|bool
- */
- public function getFragment()
- {
- return $this->fragment;
- }
-
- /**
- * @param string|bool $fragment
- *
- * @return void
- */
- public function setFragment($fragment)
- {
- $this->fragment = $fragment;
- }
-
- /**
- * Returns the query string like an array as the variables would appear in
- * $_GET in a PHP script.
- *
- * @return array
- */
- public function getQueryVariables()
- {
- $pattern = '/[' .
- preg_quote($this->getOption(self::OPTION_SEPARATOR_INPUT), '/') .
- ']/';
- $parts = preg_split($pattern, $this->query, -1, PREG_SPLIT_NO_EMPTY);
- $return = array();
-
- foreach ($parts as $part) {
- if (strpos($part, '=') !== false) {
- list($key, $value) = explode('=', $part, 2);
- } else {
- $key = $part;
- $value = null;
- }
-
- if ($this->getOption(self::OPTION_ENCODE_KEYS)) {
- $key = rawurldecode($key);
- }
- $value = rawurldecode($value);
-
- if ($this->getOption(self::OPTION_USE_BRACKETS) &&
- preg_match('#^(.*)\[([0-9a-z_-]*)\]#i', $key, $matches)) {
-
- $key = $matches[1];
- $idx = $matches[2];
-
- // Ensure is an array
- if (empty($return[$key]) || !is_array($return[$key])) {
- $return[$key] = array();
- }
-
- // Add data
- if ($idx === '') {
- $return[$key][] = $value;
- } else {
- $return[$key][$idx] = $value;
- }
- } elseif (!$this->getOption(self::OPTION_USE_BRACKETS)
- && !empty($return[$key])
- ) {
- $return[$key] = (array) $return[$key];
- $return[$key][] = $value;
- } else {
- $return[$key] = $value;
- }
- }
-
- return $return;
- }
-
- /**
- * @param array $array (name => value) array
- *
- * @return void
- */
- public function setQueryVariables(array $array)
- {
- if (!$array) {
- $this->query = false;
- } else {
- foreach ($array as $name => $value) {
- if ($this->getOption(self::OPTION_ENCODE_KEYS)) {
- $name = rawurlencode($name);
- }
-
- if (is_array($value)) {
- foreach ($value as $k => $v) {
- $parts[] = $this->getOption(self::OPTION_USE_BRACKETS)
- ? sprintf('%s[%s]=%s', $name, $k, $v)
- : ($name . '=' . $v);
- }
- } elseif (!is_null($value)) {
- $parts[] = $name . '=' . $value;
- } else {
- $parts[] = $name;
- }
- }
- $this->query = implode($this->getOption(self::OPTION_SEPARATOR_OUTPUT),
- $parts);
- }
- }
-
- /**
- * @param string $name
- * @param mixed $value
- *
- * @return array
- */
- public function setQueryVariable($name, $value)
- {
- $array = $this->getQueryVariables();
- $array[$name] = $value;
- $this->setQueryVariables($array);
- }
-
- /**
- * @param string $name
- *
- * @return void
- */
- public function unsetQueryVariable($name)
- {
- $array = $this->getQueryVariables();
- unset($array[$name]);
- $this->setQueryVariables($array);
- }
-
- /**
- * Returns a string representation of this URL.
- *
- * @return string
- */
- public function getURL()
- {
- // See RFC 3986, section 5.3
- $url = "";
-
- if ($this->scheme !== false) {
- $url .= $this->scheme . ':';
- }
-
- $authority = $this->getAuthority();
- if ($authority !== false) {
- $url .= '//' . $authority;
- }
- $url .= $this->path;
-
- if ($this->query !== false) {
- $url .= '?' . $this->query;
- }
-
- if ($this->fragment !== false) {
- $url .= '#' . $this->fragment;
- }
-
- return $url;
- }
-
- /**
- * Returns a normalized string representation of this URL. This is useful
- * for comparison of URLs.
- *
- * @return string
- */
- public function getNormalizedURL()
- {
- $url = clone $this;
- $url->normalize();
- return $url->getUrl();
- }
-
- /**
- * Returns a normalized Net_URL2 instance.
- *
- * @return Net_URL2
- */
- public function normalize()
- {
- // See RFC 3886, section 6
-
- // Schemes are case-insensitive
- if ($this->scheme) {
- $this->scheme = strtolower($this->scheme);
- }
-
- // Hostnames are case-insensitive
- if ($this->host) {
- $this->host = strtolower($this->host);
- }
-
- // Remove default port number for known schemes (RFC 3986, section 6.2.3)
- if ($this->port &&
- $this->scheme &&
- $this->port == getservbyname($this->scheme, 'tcp')) {
-
- $this->port = false;
- }
-
- // Normalize case of %XX percentage-encodings (RFC 3986, section 6.2.2.1)
- foreach (array('userinfo', 'host', 'path') as $part) {
- if ($this->$part) {
- $this->$part = preg_replace('/%[0-9a-f]{2}/ie', 'strtoupper("\0")', $this->$part);
- }
- }
-
- // Path segment normalization (RFC 3986, section 6.2.2.3)
- $this->path = self::removeDotSegments($this->path);
-
- // Scheme based normalization (RFC 3986, section 6.2.3)
- if ($this->host && !$this->path) {
- $this->path = '/';
- }
- }
-
- /**
- * Returns whether this instance represents an absolute URL.
- *
- * @return bool
- */
- public function isAbsolute()
- {
- return (bool) $this->scheme;
- }
-
- /**
- * Returns an Net_URL2 instance representing an absolute URL relative to
- * this URL.
- *
- * @param Net_URL2|string $reference relative URL
- *
- * @return Net_URL2
- */
- public function resolve($reference)
- {
- if (is_string($reference)) {
- $reference = new self($reference);
- }
- if (!$this->isAbsolute()) {
- throw new Exception('Base-URL must be absolute');
- }
-
- // A non-strict parser may ignore a scheme in the reference if it is
- // identical to the base URI's scheme.
- if (!$this->getOption(self::OPTION_STRICT) && $reference->scheme == $this->scheme) {
- $reference->scheme = false;
- }
-
- $target = new self('');
- if ($reference->scheme !== false) {
- $target->scheme = $reference->scheme;
- $target->setAuthority($reference->getAuthority());
- $target->path = self::removeDotSegments($reference->path);
- $target->query = $reference->query;
- } else {
- $authority = $reference->getAuthority();
- if ($authority !== false) {
- $target->setAuthority($authority);
- $target->path = self::removeDotSegments($reference->path);
- $target->query = $reference->query;
- } else {
- if ($reference->path == '') {
- $target->path = $this->path;
- if ($reference->query !== false) {
- $target->query = $reference->query;
- } else {
- $target->query = $this->query;
- }
- } else {
- if (substr($reference->path, 0, 1) == '/') {
- $target->path = self::removeDotSegments($reference->path);
- } else {
- // Merge paths (RFC 3986, section 5.2.3)
- if ($this->host !== false && $this->path == '') {
- $target->path = '/' . $this->path;
- } else {
- $i = strrpos($this->path, '/');
- if ($i !== false) {
- $target->path = substr($this->path, 0, $i + 1);
- }
- $target->path .= $reference->path;
- }
- $target->path = self::removeDotSegments($target->path);
- }
- $target->query = $reference->query;
- }
- $target->setAuthority($this->getAuthority());
- }
- $target->scheme = $this->scheme;
- }
-
- $target->fragment = $reference->fragment;
-
- return $target;
- }
-
- /**
- * Removes dots as described in RFC 3986, section 5.2.4, e.g.
- * "/foo/../bar/baz" => "/bar/baz"
- *
- * @param string $path a path
- *
- * @return string a path
- */
- private static function removeDotSegments($path)
- {
- $output = '';
-
- // Make sure not to be trapped in an infinite loop due to a bug in this
- // method
- $j = 0;
- while ($path && $j++ < 100) {
- // Step A
- if (substr($path, 0, 2) == './') {
- $path = substr($path, 2);
- } elseif (substr($path, 0, 3) == '../') {
- $path = substr($path, 3);
-
- // Step B
- } elseif (substr($path, 0, 3) == '/./' || $path == '/.') {
- $path = '/' . substr($path, 3);
-
- // Step C
- } elseif (substr($path, 0, 4) == '/../' || $path == '/..') {
- $path = '/' . substr($path, 4);
- $i = strrpos($output, '/');
- $output = $i === false ? '' : substr($output, 0, $i);
-
- // Step D
- } elseif ($path == '.' || $path == '..') {
- $path = '';
-
- // Step E
- } else {
- $i = strpos($path, '/');
- if ($i === 0) {
- $i = strpos($path, '/', 1);
- }
- if ($i === false) {
- $i = strlen($path);
- }
- $output .= substr($path, 0, $i);
- $path = substr($path, $i);
- }
- }
-
- return $output;
- }
-
- /**
- * Returns a Net_URL2 instance representing the canonical URL of the
- * currently executing PHP script.
- *
- * @return string
- */
- public static function getCanonical()
- {
- if (!isset($_SERVER['REQUEST_METHOD'])) {
- // ALERT - no current URL
- throw new Exception('Script was not called through a webserver');
- }
-
- // Begin with a relative URL
- $url = new self($_SERVER['PHP_SELF']);
- $url->scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http';
- $url->host = $_SERVER['SERVER_NAME'];
- $port = intval($_SERVER['SERVER_PORT']);
- if ($url->scheme == 'http' && $port != 80 ||
- $url->scheme == 'https' && $port != 443) {
-
- $url->port = $port;
- }
- return $url;
- }
-
- /**
- * Returns the URL used to retrieve the current request.
- *
- * @return string
- */
- public static function getRequestedURL()
- {
- return self::getRequested()->getUrl();
- }
-
- /**
- * Returns a Net_URL2 instance representing the URL used to retrieve the
- * current request.
- *
- * @return Net_URL2
- */
- public static function getRequested()
- {
- if (!isset($_SERVER['REQUEST_METHOD'])) {
- // ALERT - no current URL
- throw new Exception('Script was not called through a webserver');
- }
-
- // Begin with a relative URL
- $url = new self($_SERVER['REQUEST_URI']);
- $url->scheme = isset($_SERVER['HTTPS']) ? 'https' : 'http';
- // Set host and possibly port
- $url->setAuthority($_SERVER['HTTP_HOST']);
- return $url;
- }
-
- /**
- * Sets the specified option.
- *
- * @param string $optionName a self::OPTION_ constant
- * @param mixed $value option value
- *
- * @return void
- * @see self::OPTION_STRICT
- * @see self::OPTION_USE_BRACKETS
- * @see self::OPTION_ENCODE_KEYS
- */
- function setOption($optionName, $value)
- {
- if (!array_key_exists($optionName, $this->options)) {
- return false;
- }
- $this->options[$optionName] = $value;
- }
-
- /**
- * Returns the value of the specified option.
- *
- * @param string $optionName The name of the option to retrieve
- *
- * @return mixed
- */
- function getOption($optionName)
- {
- return isset($this->options[$optionName])
- ? $this->options[$optionName] : false;
- }
-}
diff --git a/thirdparty/pear/Net/UserAgent/Detect.php b/thirdparty/pear/Net/UserAgent/Detect.php
deleted file mode 100644
index 0ceb95faa..000000000
--- a/thirdparty/pear/Net/UserAgent/Detect.php
+++ /dev/null
@@ -1,967 +0,0 @@
- |
-// | Jason Rust |
-// +----------------------------------------------------------------------+
-
-// $Id: Detect.php,v 1.26 2007/09/19 21:31:54 jrust Exp $
-
-// }}}
-// {{{ constants
-
-define('NET_USERAGENT_DETECT_BROWSER', 'browser');
-define('NET_USERAGENT_DETECT_OS', 'os');
-define('NET_USERAGENT_DETECT_FEATURES', 'features');
-define('NET_USERAGENT_DETECT_QUIRKS', 'quirks');
-define('NET_USERAGENT_DETECT_ACCEPT', 'accept');
-define('NET_USERAGENT_DETECT_ALL', 'all');
-
-// }}}
-// {{{ class Net_UserAgent_Detect
-
-/**
- * The Net_UserAgent_Detect object does a number of tests on an HTTP user
- * agent string. The results of these tests are available via methods of
- * the object. Note that all methods in this class can be called
- * statically. The constructor and singleton methods are only retained
- * for BC.
- *
- * This module is based upon the JavaScript browser detection code
- * available at http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html.
- * This module had many influences from the lib/Browser.php code in
- * version 1.3 of Horde.
- *
- * @author Jason Rust
- * @author Dan Allen
- * @author Chuck Hagenbuch
- * @author Jon Parise
- * @package Net_UserAgent
- */
-
-// }}}
-class Net_UserAgent_Detect {
- // {{{ constructor
-
- function Net_UserAgent_Detect($in_userAgent = null, $in_detect = null)
- {
- $this->detect($in_userAgent, $in_detect);
- }
-
- // }}}
- // {{{ singleton
-
- /**
- * To be used in place of the contructor to return only open instance.
- *
- * @access public
- * @return object Net_UserAgent_Detect instance
- */
- function &singleton($in_userAgent = null, $in_detect = null)
- {
- static $instance;
-
- if (!isset($instance)) {
- $instance = new Net_UserAgent_Detect($in_userAgent, $in_detect);
- }
-
- return $instance;
- }
-
- // }}}
- // {{{ detect()
-
- /**
- * Detect the user agent and prepare flags, features and quirks
- * based on what is found
- *
- * This is the core of the Net_UserAgent_Detect class. It moves its
- * way through the user agent string setting up the flags based on
- * the vendors and versions of the browsers, determining the OS and
- * setting up the features and quirks owned by each of the relevant
- * clients. Note that if you are going to be calling methods of
- * this class statically then set all the parameters using th
- * setOption()
- *
- * @param string $in_userAgent (optional) User agent override.
- * @param mixed $in_detect (optional) The level of checking to do.
- *
- * @access public
- * @return void
- */
- function detect($in_userAgent = null, $in_detect = null)
- {
- static $hasRun;
- $options = &Net_UserAgent_Detect::_getStaticProperty('options');
- if (!empty($hasRun) && empty($options['re-evaluate'])) {
- return;
- }
-
- $hasRun = true;
- // {{{ set up static properties
-
- $in_userAgent = isset($options['userAgent']) && is_null($in_userAgent) ? $options['userAgent'] : $in_userAgent;
- $in_detect = isset($options['detectOptions']) && is_null($in_detect) ? $options['detectOptions'] : $in_detect;
-
- // User agent string that is being analyzed
- $userAgent = &Net_UserAgent_Detect::_getStaticProperty('userAgent');
-
- // Array that stores all of the flags for the vendor and version
- // of the different browsers
- $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
- $browser = array_flip(array('ns', 'ns2', 'ns3', 'ns4', 'ns4up', 'nav', 'ns6', 'belowns6', 'ns6up', 'firefox', 'firefox0.x', 'firefox1.x', 'firefox1.5', 'firefox2.x', 'gecko', 'ie', 'ie3', 'ie4', 'ie4up', 'ie5', 'ie5_5', 'ie5up', 'ie6', 'belowie6', 'ie6up', 'ie7', 'ie7up', 'opera', 'opera2', 'opera3', 'opera4', 'opera5', 'opera6', 'opera7', 'opera8', 'opera9', 'opera5up', 'opera6up', 'opera7up', 'belowopera8', 'opera8up', 'opera9up', 'aol', 'aol3', 'aol4', 'aol5', 'aol6', 'aol7', 'aol8', 'webtv', 'aoltv', 'tvnavigator', 'hotjava', 'hotjava3', 'hotjava3up', 'konq', 'safari', 'netgem', 'webdav', 'icab'));
-
- // Array that stores all of the flags for the operating systems,
- // and in some cases the versions of those operating systems (windows)
- $os = &Net_UserAgent_Detect::_getStaticProperty('os');
- $os = array_flip(array('win', 'win95', 'win16', 'win31', 'win9x', 'win98', 'wince', 'winme', 'win2k', 'winxp', 'winnt', 'win2003', 'os2', 'mac', 'mac68k', 'macppc', 'linux', 'unix', 'vms', 'sun', 'sun4', 'sun5', 'suni86', 'irix', 'irix5', 'irix6', 'hpux', 'hpux9', 'hpux10', 'aix', 'aix1', 'aix2', 'aix3', 'aix4', 'sco', 'unixware', 'mpras', 'reliant', 'dec', 'sinix', 'freebsd', 'bsd'));
-
- // Array which stores known issues with the given client that can
- // be used for on the fly tweaking so that the client may recieve
- // the proper handling of this quirk.
- $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
- $quirks = array(
- 'must_cache_forms' => false,
- 'popups_disabled' => false,
- 'empty_file_input_value' => false,
- 'cache_ssl_downloads' => false,
- 'scrollbar_in_way' => false,
- 'break_disposition_header' => false,
- 'nested_table_render_bug' => false);
-
- // Array that stores credentials for each of the browser/os
- // combinations. These allow quick access to determine if the
- // current client has a feature that is going to be implemented
- // in the script.
- $features = &Net_UserAgent_Detect::_getStaticProperty('features');
- $features = array(
- 'javascript' => false,
- 'dhtml' => false,
- 'dom' => false,
- 'sidebar' => false,
- 'gecko' => false,
- 'svg' => false,
- 'css2' => false,
- 'ajax' => false);
-
- // The leading identifier is the very first term in the user
- // agent string, which is used to identify clients which are not
- // Mosaic-based browsers.
- $leadingIdentifier = &Net_UserAgent_Detect::_getStaticProperty('leadingIdentifier');
-
- // The full version of the client as supplied by the very first
- // numbers in the user agent
- $version = &Net_UserAgent_Detect::_getStaticProperty('version');
- $version = 0;
-
- // The major part of the client version, which is the integer
- // value of the version.
- $majorVersion = &Net_UserAgent_Detect::_getStaticProperty('majorVersion');
- $majorVersion = 0;
-
- // The minor part of the client version, which is the decimal
- // parts of the version
- $subVersion = &Net_UserAgent_Detect::_getStaticProperty('subVersion');
- $subVersion = 0;
-
- // }}}
- // detemine what user agent we are using
- if (is_null($in_userAgent)) {
- if (isset($_SERVER['HTTP_USER_AGENT'])) {
- $userAgent = $_SERVER['HTTP_USER_AGENT'];
- }
- elseif (isset($GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'])) {
- $userAgent = $GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];
- }
- else {
- $userAgent = '';
- }
- }
- else {
- $userAgent = $in_userAgent;
- }
-
- // get the lowercase version for case-insensitive searching
- $agt = strtolower($userAgent);
-
- // figure out what we need to look for
- $detectOptions = array(NET_USERAGENT_DETECT_BROWSER,
- NET_USERAGENT_DETECT_OS, NET_USERAGENT_DETECT_FEATURES,
- NET_USERAGENT_DETECT_QUIRKS, NET_USERAGENT_DETECT_ACCEPT,
- NET_USERAGENT_DETECT_ALL);
- $detect = is_null($in_detect) ? NET_USERAGENT_DETECT_ALL : $in_detect;
- settype($detect, 'array');
- foreach($detectOptions as $option) {
- if (in_array($option, $detect)) {
- $detectFlags[$option] = true;
- }
- else {
- $detectFlags[$option] = false;
- }
- }
-
- // initialize the arrays of browsers and operating systems
-
- // Get the type and version of the client
- if (preg_match(";^([[:alnum:]]+)[ /\(]*[[:alpha:]]*([\d]*)(\.[\d\.]*);", $agt, $matches)) {
- list(, $leadingIdentifier, $majorVersion, $subVersion) = $matches;
- }
-
- if (empty($leadingIdentifier)) {
- $leadingIdentifier = 'Unknown';
- }
-
- $version = $majorVersion . $subVersion;
-
- // Browser type
- if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_BROWSER]) {
- $browser['webdav'] = ($agt == 'microsoft data access internet publishing provider dav' || $agt == 'microsoft data access internet publishing provider protocol discovery');
- $browser['konq'] = $browser['safari'] = (strpos($agt, 'konqueror') !== false || strpos($agt, 'safari') !== false);
- $browser['text'] = strpos($agt, 'links') !== false || strpos($agt, 'lynx') !== false || strpos($agt, 'w3m') !== false;
- $browser['ns'] = strpos($agt, 'mozilla') !== false && !(strpos($agt, 'spoofer') !== false) && !(strpos($agt, 'compatible') !== false) && !(strpos($agt, 'hotjava') !== false) && !(strpos($agt, 'opera') !== false) && !(strpos($agt, 'webtv') !== false) ? 1 : 0;
- $browser['netgem'] = strpos($agt, 'netgem') !== false;
- $browser['icab'] = strpos($agt, 'icab') !== false;
- $browser['ns2'] = $browser['ns'] && $majorVersion == 2;
- $browser['ns3'] = $browser['ns'] && $majorVersion == 3;
- $browser['ns4'] = $browser['ns'] && $majorVersion == 4;
- $browser['ns4up'] = $browser['ns'] && $majorVersion >= 4;
- // determine if this is a Netscape Navigator
- $browser['nav'] = $browser['belowns6'] = $browser['ns'] && $majorVersion < 5;
- $browser['ns6'] = !$browser['konq'] && $browser['ns'] && $majorVersion == 5;
- $browser['ns6up'] = $browser['ns6'] && $majorVersion >= 5;
- $browser['gecko'] = strpos($agt, 'gecko') !== false && !$browser['konq'];
- $browser['firefox'] = $browser['gecko'] && strpos($agt, 'firefox') !== false;
- $browser['firefox0.x'] = $browser['firefox'] && strpos($agt, 'firefox/0.') !== false;
- $browser['firefox1.x'] = $browser['firefox'] && strpos($agt, 'firefox/1.') !== false;
- $browser['firefox1.5'] = $browser['firefox'] && strpos($agt, 'firefox/1.5') !== false;
- $browser['firefox2.x'] = $browser['firefox'] && strpos($agt, 'firefox/2.') !== false;
- $browser['ie'] = strpos($agt, 'msie') !== false && !(strpos($agt, 'opera') !== false);
- $browser['ie3'] = $browser['ie'] && $majorVersion < 4;
- $browser['ie4'] = $browser['ie'] && $majorVersion == 4 && (strpos($agt, 'msie 4') !== false);
- $browser['ie4up'] = $browser['ie'] && !$browser['ie3'];
- $browser['ie5'] = $browser['ie4up'] && (strpos($agt, 'msie 5') !== false);
- $browser['ie5_5'] = $browser['ie4up'] && (strpos($agt, 'msie 5.5') !== false);
- $browser['ie5up'] = $browser['ie4up'] && !$browser['ie3'] && !$browser['ie4'];
- $browser['ie5_5up'] = $browser['ie5up'] && !$browser['ie5'];
- $browser['ie6'] = strpos($agt, 'msie 6') !== false;
- $browser['ie6up'] = $browser['ie5up'] && !$browser['ie5'] && !$browser['ie5_5'];
- $browser['ie7'] = strpos($agt, 'msie 7') !== false;
- $browser['ie7up'] = $browser['ie6up'] && !$browser['ie6'];
- $browser['belowie6']= $browser['ie'] && !$browser['ie6up'];
- $browser['opera'] = strpos($agt, 'opera') !== false;
- $browser['opera2'] = strpos($agt, 'opera 2') !== false || strpos($agt, 'opera/2') !== false;
- $browser['opera3'] = strpos($agt, 'opera 3') !== false || strpos($agt, 'opera/3') !== false;
- $browser['opera4'] = strpos($agt, 'opera 4') !== false || strpos($agt, 'opera/4') !== false;
- $browser['opera5'] = strpos($agt, 'opera 5') !== false || strpos($agt, 'opera/5') !== false;
- $browser['opera6'] = strpos($agt, 'opera 6') !== false || strpos($agt, 'opera/6') !== false;
- $browser['opera7'] = strpos($agt, 'opera 7') !== false || strpos($agt, 'opera/7') !== false;
- $browser['opera8'] = strpos($agt, 'opera 8') !== false || strpos($agt, 'opera/8') !== false;
- $browser['opera9'] = strpos($agt, 'opera 9') !== false || strpos($agt, 'opera/9') !== false;
- $browser['opera5up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'];
- $browser['opera6up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'];
- $browser['opera7up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'];
- $browser['opera8up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'] && !$browser['opera7'];
- $browser['opera9up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'] && !$browser['opera7'] && !$browser['opera8'];
- $browser['belowopera8'] = $browser['opera'] && !$browser['opera8up'];
- $browser['aol'] = strpos($agt, 'aol') !== false;
- $browser['aol3'] = $browser['aol'] && $browser['ie3'];
- $browser['aol4'] = $browser['aol'] && $browser['ie4'];
- $browser['aol5'] = strpos($agt, 'aol 5') !== false;
- $browser['aol6'] = strpos($agt, 'aol 6') !== false;
- $browser['aol7'] = strpos($agt, 'aol 7') !== false || strpos($agt, 'aol7') !== false;
- $browser['aol8'] = strpos($agt, 'aol 8') !== false || strpos($agt, 'aol8') !== false;
- $browser['webtv'] = strpos($agt, 'webtv') !== false;
- $browser['aoltv'] = $browser['tvnavigator'] = strpos($agt, 'navio') !== false || strpos($agt, 'navio_aoltv') !== false;
- $browser['hotjava'] = strpos($agt, 'hotjava') !== false;
- $browser['hotjava3'] = $browser['hotjava'] && $majorVersion == 3;
- $browser['hotjava3up'] = $browser['hotjava'] && $majorVersion >= 3;
- $browser['iemobile'] = strpos($agt, 'iemobile') !== false || strpos($agt, 'windows ce') !== false && (strpos($agt, 'ppc') !== false || strpos($agt, 'smartphone') !== false);
- }
-
- if ($detectFlags[NET_USERAGENT_DETECT_ALL] ||
- ($detectFlags[NET_USERAGENT_DETECT_BROWSER] && $detectFlags[NET_USERAGENT_DETECT_FEATURES])) {
- // Javascript Check
- if ($browser['ns2'] || $browser['ie3']) {
- Net_UserAgent_Detect::setFeature('javascript', 1.0);
- }
- elseif ($browser['iemobile']) {
- // no javascript
- }
- elseif ($browser['opera5up']) {
- Net_UserAgent_Detect::setFeature('javascript', 1.3);
- }
- elseif ($browser['opera'] || $browser['ns3']) {
- Net_UserAgent_Detect::setFeature('javascript', 1.1);
- }
- elseif (($browser['ns4'] && ($version <= 4.05)) || $browser['ie4']) {
- Net_UserAgent_Detect::setFeature('javascript', 1.2);
- }
- elseif (($browser['ie5up'] && strpos($agt, 'mac') !== false) || $browser['konq']) {
- Net_UserAgent_Detect::setFeature('javascript', 1.4);
- }
- // I can't believe IE6 still has javascript 1.3, what a shitty browser
- elseif (($browser['ns4'] && ($version > 4.05)) || $browser['ie5up'] || $browser['hotjava3up']) {
- Net_UserAgent_Detect::setFeature('javascript', 1.3);
- }
- elseif ($browser['ns6up'] || $browser['gecko'] || $browser['netgem']) {
- Net_UserAgent_Detect::setFeature('javascript', 1.5);
- }
- }
-
- /** OS Check **/
- if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_OS]) {
- $os['win'] = strpos($agt, 'win') !== false || strpos($agt, '16bit') !== false;
- $os['win95'] = strpos($agt, 'win95') !== false || strpos($agt, 'windows 95') !== false;
- $os['win16'] = strpos($agt, 'win16') !== false || strpos($agt, '16bit') !== false || strpos($agt, 'windows 3.1') !== false || strpos($agt, 'windows 16-bit') !== false;
- $os['win31'] = strpos($agt, 'windows 3.1') !== false || strpos($agt, 'win16') !== false || strpos($agt, 'windows 16-bit') !== false;
- $os['winme'] = strpos($agt, 'win 9x 4.90') !== false;
- $os['wince'] = strpos($agt, 'windows ce') !== false;
- $os['win2k'] = strpos($agt, 'windows nt 5.0') !== false;
- $os['winxp'] = strpos($agt, 'windows nt 5.1') !== false;
- $os['win2003'] = strpos($agt, 'windows nt 5.2') !== false;
- $os['win98'] = strpos($agt, 'win98') !== false || strpos($agt, 'windows 98') !== false;
- $os['win9x'] = $os['win95'] || $os['win98'];
- $os['winnt'] = (strpos($agt, 'winnt') !== false || strpos($agt, 'windows nt') !== false) && strpos($agt, 'windows nt 5') === false;
- $os['win32'] = $os['win95'] || $os['winnt'] || $os['win98'] || $majorVersion >= 4 && strpos($agt, 'win32') !== false || strpos($agt, '32bit') !== false;
- $os['os2'] = strpos($agt, 'os/2') !== false || strpos($agt, 'ibm-webexplorer') !== false;
- $os['mac'] = strpos($agt, 'mac') !== false;
- $os['mac68k'] = $os['mac'] && (strpos($agt, '68k') !== false || strpos($agt, '68000') !== false);
- $os['macppc'] = $os['mac'] && (strpos($agt, 'ppc') !== false || strpos($agt, 'powerpc') !== false);
- $os['sun'] = strpos($agt, 'sunos') !== false;
- $os['sun4'] = strpos($agt, 'sunos 4') !== false;
- $os['sun5'] = strpos($agt, 'sunos 5') !== false;
- $os['suni86'] = $os['sun'] && strpos($agt, 'i86') !== false;
- $os['irix'] = strpos($agt, 'irix') !== false;
- $os['irix5'] = strpos($agt, 'irix 5') !== false;
- $os['irix6'] = strpos($agt, 'irix 6') !== false || strpos($agt, 'irix6') !== false;
- $os['hpux'] = strpos($agt, 'hp-ux') !== false;
- $os['hpux9'] = $os['hpux'] && strpos($agt, '09.') !== false;
- $os['hpux10'] = $os['hpux'] && strpos($agt, '10.') !== false;
- $os['aix'] = strpos($agt, 'aix') !== false;
- $os['aix1'] = strpos($agt, 'aix 1') !== false;
- $os['aix2'] = strpos($agt, 'aix 2') !== false;
- $os['aix3'] = strpos($agt, 'aix 3') !== false;
- $os['aix4'] = strpos($agt, 'aix 4') !== false;
- $os['linux'] = strpos($agt, 'inux') !== false;
- $os['sco'] = strpos($agt, 'sco') !== false || strpos($agt, 'unix_sv') !== false;
- $os['unixware'] = strpos($agt, 'unix_system_v') !== false;
- $os['mpras'] = strpos($agt, 'ncr') !== false;
- $os['reliant'] = strpos($agt, 'reliant') !== false;
- $os['dec'] = strpos($agt, 'dec') !== false || strpos($agt, 'osf1') !== false || strpos($agt, 'dec_alpha') !== false || strpos($agt, 'alphaserver') !== false || strpos($agt, 'ultrix') !== false || strpos($agt, 'alphastation') !== false;
- $os['sinix'] = strpos($agt, 'sinix') !== false;
- $os['freebsd'] = strpos($agt, 'freebsd') !== false;
- $os['bsd'] = strpos($agt, 'bsd') !== false;
- $os['unix'] = strpos($agt, 'x11') !== false || strpos($agt, 'unix') !== false || $os['sun'] || $os['irix'] || $os['hpux'] || $os['sco'] || $os['unixware'] || $os['mpras'] || $os['reliant'] || $os['dec'] || $os['sinix'] || $os['aix'] || $os['linux'] || $os['bsd'] || $os['freebsd'];
- $os['vms'] = strpos($agt, 'vax') !== false || strpos($agt, 'openvms') !== false;
- }
-
- // Setup the quirks
- if ($detectFlags[NET_USERAGENT_DETECT_ALL] ||
- ($detectFlags[NET_USERAGENT_DETECT_BROWSER] && $detectFlags[NET_USERAGENT_DETECT_QUIRKS])) {
- if ($browser['konq']) {
- Net_UserAgent_Detect::setQuirk('empty_file_input_value');
- }
-
- if ($browser['ie']) {
- Net_UserAgent_Detect::setQuirk('cache_ssl_downloads');
- }
-
- if ($browser['ie6']) {
- Net_UserAgent_Detect::setQuirk('scrollbar_in_way');
- }
-
- if ($browser['ie5']) {
- Net_UserAgent_Detect::setQuirk('break_disposition_header');
- }
-
- if ($browser['ie7']) {
- Net_UserAgent_Detect::setQuirk('popups_disabled');
- }
-
- if ($browser['ns6']) {
- Net_UserAgent_Detect::setQuirk('popups_disabled');
- Net_UserAgent_Detect::setQuirk('must_cache_forms');
- }
-
- if ($browser['nav'] && $subVersion < .79) {
- Net_UserAgent_Detect::setQuirk('nested_table_render_bug');
- }
- }
-
- // Set features
- if ($detectFlags[NET_USERAGENT_DETECT_ALL] ||
- ($detectFlags[NET_USERAGENT_DETECT_BROWSER] && $detectFlags[NET_USERAGENT_DETECT_FEATURES])) {
- if ($browser['gecko']) {
- preg_match(';gecko/([\d]+)\b;i', $agt, $matches);
- Net_UserAgent_Detect::setFeature('gecko', $matches[1]);
- }
-
- if ($browser['gecko'] || ($browser['ie5up'] && !$browser['iemobile']) || $browser['konq'] || $browser['opera8up'] && !$os['wince']) {
- Net_UserAgent_Detect::setFeature('ajax');
- }
-
- if ($browser['ns6up'] || $browser['opera5up'] || $browser['konq'] || $browser['netgem']) {
- Net_UserAgent_Detect::setFeature('dom');
- }
-
- if ($browser['ie4up'] || $browser['ns4up'] || $browser['opera5up'] || $browser['konq'] || $browser['netgem']) {
- Net_UserAgent_Detect::setFeature('dhtml');
- }
-
- if ($browser['firefox1.5'] || $browser['firefox2.x'] || $browser['opera9up']) {
- Net_UserAgent_Detect::setFeature('svg');
- }
-
- if ($browser['gecko'] || $browser['ns6up'] || $browser['ie5up'] || $browser['konq'] || $browser['opera7up']) {
- Net_UserAgent_Detect::setFeature('css2');
- }
- }
-
- if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_ACCEPT]) {
- $mimetypes = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT'), 0, strpos(getenv('HTTP_ACCEPT') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
- Net_UserAgent_Detect::setAcceptType((array) $mimetypes, 'mimetype');
-
- $languages = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT_LANGUAGE'), 0, strpos(getenv('HTTP_ACCEPT_LANGUAGE') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
- if (empty($languages)) {
- $languages = 'en';
- }
-
- Net_UserAgent_Detect::setAcceptType((array) $languages, 'language');
-
- $encodings = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT_ENCODING'), 0, strpos(getenv('HTTP_ACCEPT_ENCODING') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
- Net_UserAgent_Detect::setAcceptType((array) $encodings, 'encoding');
-
- $charsets = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT_CHARSET'), 0, strpos(getenv('HTTP_ACCEPT_CHARSET') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
- Net_UserAgent_Detect::setAcceptType((array) $charsets, 'charset');
- }
- }
-
- // }}}
- // {{{ setOption()
-
- /**
- * Sets a class option. The available settings are:
- * o 'userAgent' => The user agent string to detect (useful for
- * checking a string manually).
- * o 'detectOptions' => The level of checking to do. A single level
- * or an array of options. Default is NET_USERAGENT_DETECT_ALL.
- *
- * @param string $in_field The option field (userAgent or detectOptions)
- * @param mixed $in_value The value for the field
- */
- function setOption($in_field, $in_value)
- {
- $options = &Net_UserAgent_Detect::_getStaticProperty('options');
- $options[$in_field] = $in_value;
- }
-
- // }}}
- // {{{ isBrowser()
-
- /**
- * Look up the provide browser flag and return a boolean value
- *
- * Given one of the flags listed in the properties, this function will return
- * the value associated with that flag.
- *
- * @param string $in_match flag to lookup
- *
- * @access public
- * @return boolean whether or not the browser satisfies this flag
- */
- function isBrowser($in_match)
- {
- Net_UserAgent_Detect::detect();
- $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
- return isset($browser[strtolower($in_match)]) ? $browser[strtolower($in_match)] : false;
- }
-
- // }}}
- // {{{ getBrowser()
-
- /**
- * Since simply returning the "browser" is somewhat ambiguous since there
- * are different ways to classify the browser, this function works by taking
- * an expect list and returning the string of the first match, so put the important
- * ones first in the array.
- *
- * @param array $in_expectList the browser flags to search for
- *
- * @access public
- * @return string first flag that matches
- */
- function getBrowser($in_expectList)
- {
- Net_UserAgent_Detect::detect();
- $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
- foreach((array) $in_expectList as $brwsr) {
- if (!empty($browser[strtolower($brwsr)])) {
- return $brwsr;
- }
- }
- }
-
- // }}}
- // {{{ getBrowserString()
-
- /**
- * This function returns the vendor string corresponding to the flag.
- *
- * Either use the default matches or pass in an associative array of
- * flags and corresponding vendor strings. This function will find
- * the highest version flag and return the vendor string corresponding
- * to the appropriate flag. Be sure to pass in the flags in ascending order
- * if you want a basic matches first, followed by more detailed matches.
- *
- * @param array $in_vendorStrings (optional) array of flags matched with vendor strings
- *
- * @access public
- * @return string vendor string matches appropriate flag
- */
- function getBrowserString($in_vendorStrings = null)
- {
- if (is_null($in_vendorStrings)) {
- $in_vendorStrings = array (
- 'ie' => 'Microsoft Internet Explorer',
- 'ie4up' => 'Microsoft Internet Explorer 4.x',
- 'ie5up' => 'Microsoft Internet Explorer 5.x',
- 'ie6up' => 'Microsoft Internet Explorer 6.x',
- 'ie7up' => 'Microsoft Internet Explorer 7.x',
- 'opera4' => 'Opera 4.x',
- 'opera5up' => 'Opera 5.x',
- 'nav' => 'Netscape Navigator',
- 'ns4' => 'Netscape 4.x',
- 'ns6up' => 'Mozilla/Netscape 6.x',
- 'firefox0.x' => 'Firefox 0.x',
- 'firefox1.x' => 'Firefox 1.x',
- 'firefox1.5' => 'Firefox 1.5',
- 'firefox2.x' => 'Firefox 2.x',
- 'konq' => 'Konqueror/Safari',
- 'netgem' => 'Netgem/iPlayer');
- }
-
- Net_UserAgent_Detect::detect();
- $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
- foreach((array) $in_vendorStrings as $flag => $string) {
- if (!empty($browser[$flag])) {
- $vendorString = $string;
- }
- }
-
- // if there are no matches just use the user agent leading idendifier (usually Mozilla)
- if (!isset($vendorString)) {
- $leadingIdentifier = &Net_UserAgent_Detect::_getStaticProperty('leadingIdentifier');
- $vendorString = $leadingIdentifier;
- }
-
- return $vendorString;
- }
-
- // }}}
- // {{{ isIE()
-
- /**
- * Determine if the browser is an Internet Explorer browser
- *
- * @access public
- * @return bool whether or not this browser is an ie browser
- */
- function isIE()
- {
- Net_UserAgent_Detect::detect();
- $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
- return !empty($browser['ie']);
- }
-
- // }}}
- // {{{ isNavigator()
-
- /**
- * Determine if the browser is a Netscape Navigator browser
- *
- * @access public
- * @return bool whether or not this browser is a Netscape Navigator browser
- */
- function isNavigator()
- {
- Net_UserAgent_Detect::detect();
- $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
- return !empty($browser['nav']);
- }
-
- // }}}
- // {{{ isNetscape()
-
- /**
- * Determine if the browser is a Netscape or Mozilla browser
- *
- * Note that this function is not the same as isNavigator, since the
- * new Mozilla browsers are still sponsered by Netscape, and hence are
- * Netscape products, but not the original Navigators
- *
- * @access public
- * @return bool whether or not this browser is a Netscape product
- */
- function isNetscape()
- {
- Net_UserAgent_Detect::detect();
- $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
- return !empty($browser['ns4up']);
- }
-
- // }}}
- // {{{ isOS()
-
- /**
- * Look up the provide OS flag and return a boolean value
- *
- * Given one of the flags listed in the properties, this function will return
- * the value associated with that flag for the operating system.
- *
- * @param string $in_match flag to lookup
- *
- * @access public
- * @return boolean whether or not the OS satisfies this flag
- */
- function isOS($in_match)
- {
- Net_UserAgent_Detect::detect();
- $os = &Net_UserAgent_Detect::_getStaticProperty('os');
- return isset($os[strtolower($in_match)]) ? $os[strtolower($in_match)] : false;
- }
-
- // }}}
- // {{{ getOS()
-
- /**
- * Since simply returning the "os" is somewhat ambiguous since there
- * are different ways to classify the browser, this function works by taking
- * an expect list and returning the string of the first match, so put the important
- * ones first in the array.
- *
- * @access public
- * @return string first flag that matches
- */
- function getOS($in_expectList)
- {
- Net_UserAgent_Detect::detect();
- $os = &Net_UserAgent_Detect::_getStaticProperty('os');
- foreach((array) $in_expectList as $expectOs) {
- if (!empty($os[strtolower($expectOs)])) {
- return $expectOs;
- }
- }
- }
-
- // }}}
- // {{{ getOSString()
-
- /**
- * This function returns the os string corresponding to the flag.
- *
- * Either use the default matches or pass in an associative array of
- * flags and corresponding os strings. This function will find
- * the highest version flag and return the os string corresponding
- * to the appropriate flag. Be sure to pass in the flags in ascending order
- * if you want a basic matches first, followed by more detailed matches.
- *
- * @param array $in_osStrings (optional) array of flags matched with os strings
- *
- * @access public
- * @return string os string matches appropriate flag
- */
- function getOSString($in_osStrings = null)
- {
- if (is_null($in_osStrings)) {
- $in_osStrings = array(
- 'win' => 'Microsoft Windows',
- 'wince' => 'Microsoft Windows CE',
- 'win9x' => 'Microsoft Windows 9x',
- 'winme' => 'Microsoft Windows Millenium',
- 'win2k' => 'Microsoft Windows 2000',
- 'winnt' => 'Microsoft Windows NT',
- 'winxp' => 'Microsoft Windows XP',
- 'win2003' => 'Microsoft Windows 2003',
- 'mac' => 'Macintosh',
- 'unix' => 'Linux/Unix');
- }
-
- Net_UserAgent_Detect::detect();
- $osString = 'Unknown';
-
- $os = &Net_UserAgent_Detect::_getStaticProperty('os');
- foreach((array) $in_osStrings as $flag => $string) {
- if (!empty($os[$flag])) {
- $osString = $string;
- }
- }
-
- return $osString;
- }
-
- // }}}
- // {{{ setQuirk()
-
- /**
- * Set a unique behavior for the current browser.
- *
- * Many client browsers do some really funky things, and this
- * mechanism allows the coder to determine if an excepetion must
- * be made with the current client.
- *
- * @param string $in_quirk The quirk to set
- * @param string $in_hasQuirk (optional) Does the browser have the quirk?
- *
- * @access public
- * @return void
- */
- function setQuirk($in_quirk, $in_hasQuirk = true)
- {
- $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
- $hasQuirk = !empty($in_hasQuirk);
- $quirks[strtolower($in_quirk)] = $hasQuirk;
- }
-
- // }}}
- // {{{ hasQuirk()
-
- /**
- * Check a unique behavior for the current browser.
- *
- * Many client browsers do some really funky things, and this
- * mechanism allows the coder to determine if an excepetion must
- * be made with the current client.
- *
- * @param string $in_quirk The quirk to detect
- *
- * @access public
- * @return bool whether or not browser has this quirk
- */
- function hasQuirk($in_quirk)
- {
- return (bool) Net_UserAgent_Detect::getQuirk($in_quirk);
- }
-
- // }}}
- // {{{ getQuirk()
-
- /**
- * Get the unique behavior for the current browser.
- *
- * Many client browsers do some really funky things, and this
- * mechanism allows the coder to determine if an excepetion must
- * be made with the current client.
- *
- * @param string $in_quirk The quirk to detect
- *
- * @access public
- * @return string value of the quirk, in this case usually a boolean
- */
- function getQuirk($in_quirk)
- {
- Net_UserAgent_Detect::detect();
- $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
- return isset($quirks[strtolower($in_quirk)]) ? $quirks[strtolower($in_quirk)] : null;
- }
-
- // }}}
- // {{{ setFeature()
-
- /**
- * Set capabilities for the current browser.
- *
- * Since the capabilities of client browsers vary widly, this interface
- * helps keep track of the core features of a client, such as if the client
- * supports dhtml, dom, javascript, etc.
- *
- * @param string $in_feature The feature to set
- * @param string $in_hasFeature (optional) Does the browser have the feature?
- *
- * @access public
- * @return void
- */
- function setFeature($in_feature, $in_hasFeature = true)
- {
- $features = &Net_UserAgent_Detect::_getStaticProperty('features');
- $features[strtolower($in_feature)] = $in_hasFeature;
- }
-
- // }}}
- // {{{ hasFeature()
-
- /**
- * Check the capabilities for the current browser.
- *
- * Since the capabilities of client browsers vary widly, this interface
- * helps keep track of the core features of a client, such as if the client
- * supports dhtml, dom, javascript, etc.
- *
- * @param string $in_feature The feature to detect
- *
- * @access public
- * @return bool whether or not the current client has this feature
- */
- function hasFeature($in_feature)
- {
- return (bool) Net_UserAgent_Detect::getFeature($in_feature);
- }
-
- // }}}
- // {{{ getFeature()
-
- /**
- * Get the capabilities for the current browser.
- *
- * Since the capabilities of client browsers vary widly, this interface
- * helps keep track of the core features of a client, such as if the client
- * supports dhtml, dom, javascript, etc.
- *
- * @param string $in_feature The feature to detect
- *
- * @access public
- * @return string value of the feature requested
- */
- function getFeature($in_feature)
- {
- Net_UserAgent_Detect::detect();
- $features = &Net_UserAgent_Detect::_getStaticProperty('features');
- return isset($features[strtolower($in_feature)]) ? $features[strtolower($in_feature)] : null;
- }
-
- // }}}
- // {{{ getAcceptType()
-
- /**
- * Retrive the accept type for the current browser.
- *
- * To keep track of the mime-types, languages, charsets and encodings
- * that each browser accepts we use associative arrays for each type.
- * This function works like getBrowser() as it takes an expect list
- * and returns the first match. For instance, to find the language
- * you would pass in your allowed languages and see if any of the
- * languages set in the browser match.
- *
- * @param string $in_expectList values to check
- * @param string $in_type type of accept
- *
- * @access public
- * @return string the first matched value
- */
- function getAcceptType($in_expectList, $in_type)
- {
- Net_UserAgent_Detect::detect();
- $type = strtolower($in_type);
-
- if ($type == 'mimetype' || $type == 'language' || $type == 'charset' || $type == 'encoding') {
- $typeArray = &Net_UserAgent_Detect::_getStaticProperty($type);
- foreach((array) $in_expectList as $match) {
- if (!empty($typeArray[$match])) {
- return $match;
- }
- }
- }
-
- return null;
- }
-
- // }}}
- // {{{ setAcceptType()
-
- /**
- * Set the accept types for the current browser.
- *
- * To keep track of the mime-types, languages, charsets and encodings
- * that each browser accepts we use associative arrays for each type.
- * This function takes and array of accepted values for the type and
- * records them for retrieval.
- *
- * @param array $in_values values of the accept type
- * @param string $in_type type of accept
- *
- * @access public
- * @return void
- */
- function setAcceptType($in_values, $in_type)
- {
- $type = strtolower($in_type);
-
- if ($type == 'mimetype' || $type == 'language' || $type == 'charset' || $type == 'encoding') {
- $typeArray = &Net_UserAgent_Detect::_getStaticProperty($type);
- foreach((array) $in_values as $value) {
- $typeArray[$value] = true;
- }
- }
- }
-
- // }}}
- // {{{ hasAcceptType()
-
- /**
- * Check the accept types for the current browser.
- *
- * To keep track of the mime-types, languages, charsets and encodings
- * that each browser accepts we use associative arrays for each type.
- * This function checks the array for the given type and determines if
- * the browser accepts it.
- *
- * @param string $in_value values to check
- * @param string $in_type type of accept
- *
- * @access public
- * @return bool whether or not the value is accept for this type
- */
- function hasAcceptType($in_value, $in_type)
- {
- return (bool) Net_UserAgent_Detect::getAcceptType((array) $in_value, $in_type);
- }
-
- // }}}
- // {{{ getUserAgent()
-
- /**
- * Return the user agent string that is being worked on
- *
- * @access public
- * @return string user agent
- */
- function getUserAgent()
- {
- Net_UserAgent_Detect::detect();
- $userAgent = &Net_UserAgent_Detect::_getStaticProperty('userAgent');
- return $userAgent;
- }
-
- // }}}
- // {{{ _getStaticProperty()
-
- /**
- * Copy of getStaticProperty() from PEAR.php to avoid having to
- * include PEAR.php
- *
- * @access private
- * @param string $var The variable to retrieve.
- * @return mixed A reference to the variable. If not set it will be
- * auto initialised to NULL.
- */
- function &_getStaticProperty($var)
- {
- static $properties;
- return $properties[$var];
- }
-
- // }}}
-}
-?>
diff --git a/thirdparty/pear/Net/UserAgent/Detect/APC.php b/thirdparty/pear/Net/UserAgent/Detect/APC.php
deleted file mode 100644
index 5a560cadf..000000000
--- a/thirdparty/pear/Net/UserAgent/Detect/APC.php
+++ /dev/null
@@ -1,123 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-
-// $Id: APC.php,v 1.1 2007/09/19 21:35:22 jrust Exp $
-
-require_once 'Net_UserAgent/detect.php';
-
-class Net_UserAgent_Detect_APC extends Net_UserAgent_Detect
-{
- var $key = '';
-
- function Net_UserAgent_Detect_APC($in_userAgent = null, $in_detect = null, $ua_cache_window = 600)
- {
- $data = '';
- $restored = false;
- $ua_cache_timeout = apc_fetch('useragent:cache_timeout'); // don't cache after time period
-
- if(!class_exists('G')){
- $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
- $docuroot = explode( '/', $realdocuroot );
- array_pop( $docuroot );
- $pathhome = implode( '/', $docuroot ) . '/';
- array_pop( $docuroot );
- $pathTrunk = implode( '/', $docuroot ) . '/';
- require_once($pathTrunk.'gulliver/system/class.g.php');
- }
- if ($ua_cache_window > 0) {
- if (!$ua_cache_timeout) {
- // check apc uptime and disable after x mins
- $apc_data = apc_cache_info('file', true);
-
- if (isset($apc_data['start_time'])) {
- $uptime = $apc_data['start_time'];
-
- if (time() - $uptime > $ua_cache_window) { // timeout and disable after 10 minutes of uptime
- apc_store('useragent:cache_timeout', true);
- $ua_cache_timeout = true; // don't cache this one either
- }
- }
- }
-
- if (!$this->key) {
- $key_flags = '';
- if ($in_detect !== null) {
- $key_flags = implode('-', $in_detect);
- }
- $this->key = 'useragent:'.G::encryptOld($in_userAgent.$key_flags);
- }
-
- if ($data = apc_fetch($this->key)) {
- $success = null;
- $data = unserialize($data);
- if ($data) {
- $restored = $this->cache_restore($data);
- }
- }
- }
-
- if (!$data) {
- $this->detect($in_userAgent, $in_detect);
-
- if ($ua_cache_window > 0 && !$ua_cache_timeout) {
- $this->cache_save();
- }
- }
- }
-
- function &singleton($in_userAgent = null, $in_detect = null)
- {
- static $instance;
-
- if (!isset($instance)) {
- $instance = new Net_UserAgent_Detect_APC($in_userAgent, $in_detect);
- }
-
- return $instance;
- }
-
- function cache_restore($cache)
- {
- if (is_array($cache)) {
- foreach($cache as $prop => $value) {
- $ptr = Net_UserAgent_Detect::_getStaticProperty($prop);
- $ptr = $value;
- }
- return true;
- }
- return false;
- }
-
- function cache_save()
- {
- if ($this->key) {
- $data = array('browser' => Net_UserAgent_Detect::_getStaticProperty('browser'),
- 'features' => Net_UserAgent_Detect::_getStaticProperty('features'),
- 'leadingIdentifier' => Net_UserAgent_Detect::_getStaticProperty('leadingIdentifier'),
- 'majorVersion' => Net_UserAgent_Detect::_getStaticProperty('majorVersion'),
- 'options' => Net_UserAgent_Detect::_getStaticProperty('options'),
- 'os' => Net_UserAgent_Detect::_getStaticProperty('os'),
- 'quirks' => Net_UserAgent_Detect::_getStaticProperty('quirks'),
- 'subVersion' => Net_UserAgent_Detect::_getStaticProperty('subVersion'),
- 'userAgent' => Net_UserAgent_Detect::_getStaticProperty('userAgent'),
- 'version' => Net_UserAgent_Detect::_getStaticProperty('version'),
- );
- apc_store($this->key, serialize($data));
- }
- }
-}
-?>
diff --git a/thirdparty/pear/Numbers/Words.php b/thirdparty/pear/Numbers/Words.php
deleted file mode 100644
index 7397a6437..000000000
--- a/thirdparty/pear/Numbers/Words.php
+++ /dev/null
@@ -1,145 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: Words.php,v 1.7 2003/09/29 12:23:58 makler Exp $
-//
-
-/**
- * The Numbers_Words class provides method to convert arabic numerals to
- * words (also with currency name).
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-
-// {{{ Numbers_Words
-
-/**
- * The Numbers_Words class provides method to convert arabic numerals to words.
- *
- * @access public
- * @author Piotr Klaban
- * @since PHP 4.2.3
- * @package Numbers_Words
- */
-class Numbers_Words
-{
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that should be converted to a words representation
- *
- * @param string $locale Language name abbreviation. Optional. Defaults to en_US.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Piotr Klaban
- * @since PHP 4.2.3
- */
- function toWords($num, $locale = 'en_US') {
-
- include_once("Numbers/Words/lang.${locale}.php");
-
- $classname = "Numbers_Words_${locale}";
-
- if (!class_exists($classname)) {
- return Numbers_Words::raiseError("Unable to include the Numbers/Words/lang.${locale}.php file");
- }
-
- $methods = get_class_methods($classname);
-
- if (!in_array('toWords', $methods) && !in_array('towords', $methods)) {
- return Numbers_Words::raiseError("Unable to find toWords method in '$classname' class");
- }
-
- @$obj =& new $classname;
-
- return trim($obj->toWords($num));
- }
- // }}}
- // {{{ toCurrency()
- /**
- * Converts a currency value to word representation (1.02 => one dollar two cents)
- * If the number has not any fraction part, the "cents" number is omitted.
- *
- * @param float $num A float/integer number representing currency value
- *
- * @param string $locale Language name abbreviation. Optional. Defaults to en_US.
- *
- * @param string $int_curr International currency symbol
- * as defined by the ISO 4217 standard (three characters).
- * E.g. 'EUR', 'USD', 'PLN'. Optional.
- * Defaults to $def_currency defined in the language class.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Piotr Klaban
- * @since PHP 4.2.3
- */
- function toCurrency($num, $locale = 'en_US', $int_curr = '') {
- $ret = $num;
-
- @include_once("Numbers/Words/lang.${locale}.php");
-
- $classname = "Numbers_Words_${locale}";
-
- if (!class_exists($classname)) {
- return Numbers_Words::raiseError("Unable to include the Numbers/Words/lang.${locale}.php file");
- }
-
- $methods = get_class_methods($classname);
-
- if (!in_array('toCurrencyWords', $methods) && !in_array('tocurrencywords', $methods)) {
- return Numbers_Words::raiseError("Unable to find toCurrencyWords method in '$classname' class");
- }
-
- @$obj =& new $classname;
-
- if (strpos($num, '.') === false)
- {
- $ret = trim($obj->toCurrencyWords($int_curr, $num));
- } else {
- $currency = explode('.', $num, 2);
- $ret = trim($obj->toCurrencyWords($int_curr, $currency[0], $currency[1]));
- }
- return $ret;
- }
- // }}}
- // {{{ raiseError()
- /**
- * Trigger a PEAR error
- *
- * To improve performances, the PEAR.php file is included dynamically.
- *
- * @param string error message
- */
- function raiseError($msg)
- {
- include_once('PEAR.php');
- return PEAR::raiseError($msg);
- }
- // }}}
-}
-
-// }}}
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.bg.php b/thirdparty/pear/Numbers/Words/lang.bg.php
deleted file mode 100644
index 1204d29b7..000000000
--- a/thirdparty/pear/Numbers/Words/lang.bg.php
+++ /dev/null
@@ -1,505 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Bulgarian.
- *
- * @author Kouber Saparev
- * @package Numbers_Words
- */
-class Numbers_Words_bg extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name.
- * @var string
- * @access public
- */
- var $locale = 'bg';
-
- /**
- * Language name in English.
- * @var string
- * @access public
- */
- var $lang = 'Bulgarian';
-
- /**
- * Native language name.
- * @var string
- * @access public
- */
- var $lang_native = 'Áúëãàðñêè';
-
- /**
- * Some miscellaneous words and language constructs.
- * @var string
- * @access private
- */
- var $_misc_strings = array(
- 'deset'=>'äåñåò', // "ten"
- 'edinadeset'=>'åäèíàäåñåò', // "eleven"
- 'na'=>'íà', // liaison particle for 12 to 19
- 'sto'=>'ñòî', // "hundred"
- 'sta'=>'ñòà', // suffix for 2 and 3 hundred
- 'stotin'=>'ñòîòèí', // suffix for 4 to 9 hundred
- 'hiliadi'=>'õèëÿäè' // plural form of "thousand"
- );
-
-
- /**
- * The words for digits (except zero). Note that, there are three genders for them (neuter, masculine and feminine).
- * The words for 3 to 9 (masculine) and for 2 to 9 (feminine) are the same as neuter, so they're filled
- * in the _initDigits() method, which is invoked from the constructor.
- * @var string
- * @access private
- */
- var $_digits = array(
- 0=>array(1=>"åäíî", "äâå", "òðè", "÷åòèðè", "ïåò", "øåñò", "ñåäåì", "îñåì", "äåâåò"), // neuter
- 1=>array(1=>'åäèí', 'äâà'), // masculine
- -1=>array(1=>'åäíà') // feminine
- );
-
- /**
- * A flag, that determines if the _digits array is filled for masculine and feminine genders.
- * @var string
- * @access private
- */
- var $_digits_initialized = false;
-
- /**
- * A flag, that determines if the "and" word is placed already before the last non-empty group of digits.
- * @var string
- * @access private
- */
- var $_last_and = false;
-
- /**
- * The word for zero.
- * @var string
- * @access private
- */
- var $_zero = 'íóëà';
-
- /**
- * The word for infinity.
- * @var string
- * @access private
- */
- var $_infinity = 'áåçêðàéíîñò';
-
- /**
- * The word for the "and" language construct.
- * @var string
- * @access private
- */
- var $_and = 'è';
-
- /**
- * The word separator.
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The word for the minus sign.
- * @var string
- * @access private
- */
- var $_minus = 'ìèíóñ'; // minus sign
-
- /**
- * The plural suffix (except for thousand).
- * @var string
- * @access private
- */
- var $_plural = 'à'; // plural suffix
-
- /**
- * The suffixes for exponents (singular).
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => '',
- 3 => 'õèëÿäà',
- 6 => 'ìèëèîí',
- 9 => 'ìèëèàðä',
- 12 => 'òðèëèîí',
- 15 => 'êâàäðèëèîí',
- 18 => 'êâèíòèëèîí',
- 21 => 'ñåêñòèëèîí',
- 24 => 'ñåïòèëèîí',
- 27 => 'îêòèëèîí',
- 30 => 'íîíàëèîí',
- 33 => 'äåêàëèîí',
- 36 => 'óíäåêàëèîí',
- 39 => 'äóîäåêàëèîí',
- 42 => 'òðåäåêàëèîí',
- 45 => 'êâàòîðäåêàëèîí',
- 48 => 'êâèíòäåêàëèîí',
- 51 => 'ñåêñäåêàëèîí',
- 54 => 'ñåïòäåêàëèîí',
- 57 => 'îêòîäåêàëèîí',
- 60 => 'íîâåìäåêàëèîí',
- 63 => 'âèãèíòèëèîí',
- 66 => 'óíâèãèíòèëèîí',
- 69 => 'äóîâèãèíòèëèîí',
- 72 => 'òðåâèãèíòèëèîí',
- 75 => 'êâàòîðâèãèíòèëèîí',
- 78 => 'êâèíâèãèíòèëèîí',
- 81 => 'ñåêñâèãèíòèëèîí',
- 84 => 'ñåïòåíâèãèíòèëèîí',
- 87 => 'îêòîâèãèíòèëèîí',
- 90 => 'íîâåìâèãèíòèëèîí',
- 93 => 'òðèãèíòèëèîí',
- 96 => 'óíòðèãèíòèëèîí',
- 99 => 'äóîòðèãèíòèëèîí',
- 102 => 'òðåòðèãèíòèëèîí',
- 105 => 'êâàòîðòðèãèíòèëèîí',
- 108 => 'êâèíòðèãèíòèëèîí',
- 111 => 'ñåêñòðèãèíòèëèîí',
- 114 => 'ñåïòåíòðèãèíòèëèîí',
- 117 => 'îêòîòðèãèíòèëèîí',
- 120 => 'íîâåìòðèãèíòèëèîí',
- 123 => 'êâàäðàãèíòèëèîí',
- 126 => 'óíêâàäðàãèíòèëèîí',
- 129 => 'äóîêâàäðàãèíòèëèîí',
- 132 => 'òðåêâàäðàãèíòèëèîí',
- 135 => 'êâàòîðêâàäðàãèíòèëèîí',
- 138 => 'êâèíêâàäðàãèíòèëèîí',
- 141 => 'ñåêñêâàäðàãèíòèëèîí',
- 144 => 'ñåïòåíêâàäðàãèíòèëèîí',
- 147 => 'îêòîêâàäðàãèíòèëèîí',
- 150 => 'íîâåìêâàäðàãèíòèëèîí',
- 153 => 'êâèíêâàãèíòèëèîí',
- 156 => 'óíêâèíêàãèíòèëèîí',
- 159 => 'äóîêâèíêàãèíòèëèîí',
- 162 => 'òðåêâèíêàãèíòèëèîí',
- 165 => 'êâàòîðêâèíêàãèíòèëèîí',
- 168 => 'êâèíêâèíêàãèíòèëèîí',
- 171 => 'ñåêñêâèíêàãèíòèëèîí',
- 174 => 'ñåïòåíêâèíêàãèíòèëèîí',
- 177 => 'îêòîêâèíêàãèíòèëèîí',
- 180 => 'íîâåìêâèíêàãèíòèëèîí',
- 183 => 'ñåêñàãèíòèëèîí',
- 186 => 'óíñåêñàãèíòèëèîí',
- 189 => 'äóîñåêñàãèíòèëèîí',
- 192 => 'òðåñåêñàãèíòèëèîí',
- 195 => 'êâàòîðñåêñàãèíòèëèîí',
- 198 => 'êâèíñåêñàãèíòèëèîí',
- 201 => 'ñåêññåêñàãèíòèëèîí',
- 204 => 'ñåïòåíñåêñàãèíòèëèîí',
- 207 => 'îêòîñåêñàãèíòèëèîí',
- 210 => 'íîâåìñåêñàãèíòèëèîí',
- 213 => 'ñåïòàãèíòèëèîí',
- 216 => 'óíñåïòàãèíòèëèîí',
- 219 => 'äóîñåïòàãèíòèëèîí',
- 222 => 'òðåñåïòàãèíòèëèîí',
- 225 => 'êâàòîðñåïòàãèíòèëèîí',
- 228 => 'êâèíñåïòàãèíòèëèîí',
- 231 => 'ñåêññåïòàãèíòèëèîí',
- 234 => 'ñåïòåíñåïòàãèíòèëèîí',
- 237 => 'îêòîñåïòàãèíòèëèîí',
- 240 => 'íîâåìñåïòàãèíòèëèîí',
- 243 => 'îêòîãèíòèëèîí',
- 246 => 'óíîêòîãèíòèëèîí',
- 249 => 'äóîîêòîãèíòèëèîí',
- 252 => 'òðåîêòîãèíòèëèîí',
- 255 => 'êâàòîðîêòîãèíòèëèîí',
- 258 => 'êâèíîêòîãèíòèëèîí',
- 261 => 'ñåêñîêòîãèíòèëèîí',
- 264 => 'ñåïòîêòîãèíòèëèîí',
- 267 => 'îêòîîêòîãèíòèëèîí',
- 270 => 'íîâåìîêòîãèíòèëèîí',
- 273 => 'íîíàãèíòèëèîí',
- 276 => 'óííîíàãèíòèëèîí',
- 279 => 'äóîíîíàãèíòèëèîí',
- 282 => 'òðåíîíàãèíòèëèîí',
- 285 => 'êâàòîðíîíàãèíòèëèîí',
- 288 => 'êâèííîíàãèíòèëèîí',
- 291 => 'ñåêñíîíàãèíòèëèîí',
- 294 => 'ñåïòåííîíàãèíòèëèîí',
- 297 => 'îêòîíîíàãèíòèëèîí',
- 300 => 'íîâåìíîíàãèíòèëèîí',
- 303 => 'öåíòèëèîí'
- );
- // }}}
-
- // {{{ Numbers_Words_bg()
-
- /**
- * The class constructor, used for calling the _initDigits method.
- *
- * @return void
- *
- * @access public
- * @author Kouber Saparev
- * @see function _initDigits
- */
- function Numbers_Words_bg() {
- $this->_initDigits();
- }
- // }}}
-
- // {{{ _initDigits()
-
- /**
- * Fills the _digits array for masculine and feminine genders with
- * corresponding references to neuter words (when they're the same).
- *
- * @return void
- *
- * @access private
- * @author Kouber Saparev
- */
- function _initDigits() {
- if (!$this->_digits_initialized) {
- for ($i=3; $i<=9; $i++) {
- $this->_digits[1][$i] =& $this->_digits[0][$i];
- }
- for ($i=2; $i<=9; $i++) {
- $this->_digits[-1][$i] =& $this->_digits[0][$i];
- }
- $this->_digits_initialized = true;
- }
- }
- // }}}
-
- // {{{ _splitNumber()
-
- /**
- * Split a number to groups of three-digit numbers.
- *
- * @param mixed $num An integer or its string representation
- * that need to be split
- *
- * @return array Groups of three-digit numbers.
- *
- * @access private
- * @author Kouber Saparev
- * @since PHP 4.2.3
- */
-
- function _splitNumber($num)
- {
- if (is_string($num)) {
- $ret = array();
- $strlen = strlen($num);
- $first = substr($num, 0, $strlen%3);
- preg_match_all('/\d{3}/', substr($num, $strlen%3, $strlen), $m);
- $ret =& $m[0];
- if ($first) array_unshift($ret, $first);
- return $ret;
- }
- else
- return explode(' ', number_format($num, 0, '', ' ')); // a faster version for integers
- }
- // }}}
-
- // {{{ _showDigitsGroup()
-
- /**
- * Converts a three-digit number to its word representation
- * in Bulgarian language.
- *
- * @param integer $num An integer between 1 and 999 inclusive.
- *
- * @param integer $gender An integer which represents the gender of
- * the current digits group.
- * 0 - neuter
- * 1 - masculine
- * -1 - feminine
- *
- * @param boolean $last A flag that determines if the current digits group
- * is the last one.
- *
- * @return string The words for the given number.
- *
- * @access private
- * @author Kouber Saparev
- */
- function _showDigitsGroup($num, $gender = 0, $last = false)
- {
- /* A storage array for the return string.
- Positions 1, 3, 5 are intended for digit words
- and everything else (0, 2, 4) for "and" words.
- Both of the above types are optional, so the size of
- the array may vary.
- */
- $ret = array();
-
- // extract the value of each digit from the three-digit number
- $e = $num%10; // ones
- $d = ($num-$e)%100/10; // tens
- $s = ($num-$d*10-$e)%1000/100; // hundreds
-
- // process the "hundreds" digit.
- if ($s) {
- switch ($s) {
- case 1:
- $ret[1] = $this->_misc_strings['sto'];
- break;
- case 2:
- case 3:
- $ret[1] = $this->_digits[0][$s].$this->_misc_strings['sta'];
- break;
- default:
- $ret[1] = $this->_digits[0][$s].$this->_misc_strings['stotin'];
- }
- }
-
- // process the "tens" digit, and optionally the "ones" digit.
- if ($d) {
- // in the case of 1, the "ones" digit also must be processed
- if ($d==1) {
- if (!$e) {
- $ret[3] = $this->_misc_strings['deset']; // ten
- } else {
- if ($e==1) {
- $ret[3] = $this->_misc_strings['edinadeset']; // eleven
- } else {
- $ret[3] = $this->_digits[1][$e].$this->_misc_strings['na'].$this->_misc_strings['deset']; // twelve - nineteen
- }
- // the "ones" digit is alredy processed, so skip a second processment
- $e = 0;
- }
- } else {
- $ret[3] = $this->_digits[1][$d].$this->_misc_strings['deset']; // twenty - ninety
- }
- }
-
- // process the "ones" digit
- if ($e) {
- $ret[5] = $this->_digits[$gender][$e];
- }
-
- // put "and" where needed
- if (count($ret)>1) {
- if ($e) {
- $ret[4] = $this->_and;
- } else {
- $ret[2] = $this->_and;
- }
- }
-
- // put "and" optionally in the case this is the last non-empty group
- if ($last) {
- if (!$s||count($ret)==1) {
- $ret[0] = $this->_and;
- }
- $this->_last_and = true;
- }
-
- // sort the return array so that "and" constructs go to theirs appropriate places
- ksort($ret);
-
- return implode($this->_sep, $ret);
- }
- // }}}
-
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in Bulgarian language.
- *
- * @param integer $num An integer between 9.99*-10^302 and 9.99*10^302 (999 centillions)
- * that need to be converted to words
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Kouber Saparev
- */
- function toWords($num = 0)
- {
- $ret = array();
- $ret_minus = '';
-
- // check if $num is a valid non-zero number
- if (!$num || preg_match('/^-?0+$/', $num) || !preg_match('/^-?\d+$/', $num)) return $this->_zero;
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret_minus = $this->_minus . $this->_sep;
- $num = substr($num, 1);
- }
-
- // if the absolute value is greater than 9.99*10^302, return infinity
- if (strlen($num)>306) {
- return $ret_minus . $this->_infinity;
- }
-
- // strip excessive zero signs
- $num = ltrim($num, '0');
-
- // split $num to groups of three-digit numbers
- $num_groups = $this->_splitNumber($num);
-
- $sizeof_numgroups = count($num_groups);
-
- // go through the groups in reverse order, so that the last group could be determined
- for ($i=$sizeof_numgroups-1, $j=1; $i>=0; $i--, $j++) {
- if (!isset($ret[$j])) {
- $ret[$j] = '';
- }
-
- // what is the corresponding exponent for the current group
- $pow = $sizeof_numgroups-$i;
-
- // skip processment for empty groups
- if ($num_groups[$i]!='000') {
- if ($num_groups[$i]>1) {
- if ($pow==1) {
- $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 0, !$this->_last_and && $i).$this->_sep;
- $ret[$j] .= $this->_exponent[($pow-1)*3];
- } elseif ($pow==2) {
- $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], -1, !$this->_last_and && $i).$this->_sep;
- $ret[$j] .= $this->_misc_strings['hiliadi'].$this->_sep;
- } else {
- $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 1, !$this->_last_and && $i).$this->_sep;
- $ret[$j] .= $this->_exponent[($pow-1)*3].$this->_plural.$this->_sep;
- }
- } else {
- if ($pow==1) {
- $ret[$j] .= $this->_showDigitsGroup($num_groups[$i], 0, !$this->_last_and && $i).$this->_sep;
- } elseif ($pow==2) {
- $ret[$j] .= $this->_exponent[($pow-1)*3].$this->_sep;
- } else {
- $ret[$j] .= $this->_digits[1][1].$this->_sep.$this->_exponent[($pow-1)*3].$this->_sep;
- }
- }
- }
- }
-
- return $ret_minus . rtrim(implode('', array_reverse($ret)), $this->_sep);
- }
- // }}}
-}
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.de.php b/thirdparty/pear/Numbers/Words/lang.de.php
deleted file mode 100644
index 5d6026d26..000000000
--- a/thirdparty/pear/Numbers/Words/lang.de.php
+++ /dev/null
@@ -1,318 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.de.php,v 1.5 2003/09/29 12:23:58 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in German language.
-//
-
-/**
- *
- * Class for translating numbers into German.
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into German.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-class Numbers_Words_de extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'de';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'German';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'Deutsch';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'Minus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * Names partly based on:
- * http://german.about.com/library/blzahlenaud.htm
- * http://www3.osk.3web.ne.jp/~nagatani/common/zahlwort.htm
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array(''),
- 3 => array('tausend','tausend'),
- 6 => array('Millione','Millionen'),
- 9 => array('Milliarde','Milliarden'),
- 12 => array('Billion','Billionen'),
- 15 => array('Billiarde','Billiarden'),
- 18 => array('Trillion','Trillionen'),
- 21 => array('Trilliarde','Trilliarden'),
- 24 => array('Quadrillion','Quadrillionen'),
- 27 => array('Quadrilliarde','Quadrilliarden'),
- 30 => array('Quintillion','Quintillionen'),
- 33 => array('Quintilliarde','Quintilliarden'),
- 36 => array('Sextillion','Sextillionen'),
- 39 => array('Sextilliarde','Sextilliarden'),
- 42 => array('Septillion','Septillionen'),
- 45 => array('Septilliarde','Septilliarden'),
- 48 => array('Oktillion','Oktillionen'), // oder Octillionen
- 51 => array('Oktilliarde','Oktilliarden'),
- 54 => array('Nonillion','Nonillionen'),
- 57 => array('Nonilliarde','Nonilliarden'),
- 60 => array('Dezillion','Dezillionen'),
- 63 => array('Dezilliarde','Dezilliarden'),
- 120 => array('Vigintillion','Vigintillionen'),
- 123 => array('Vigintilliarde','Vigintilliarden'),
- 600 => array('Zentillion','Zentillionen'), // oder Centillion
- 603 => array('Zentilliarde','Zentilliarden')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'null', 'ein', 'zwei', 'drei', 'vier',
- 'fünf', 'sechs', 'sieben', 'acht', 'neun'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = '';
-
- /**
- * The exponent word separator
- * @var string
- * @access private
- */
- var $_sep2 = ' ';
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in German language.
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access private
- * @author Piotr Klaban
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ($h) {
-
- $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundert';
- }
-
- if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
- if ($t > 0) {
- $ret .= $this->_digits[$d] . 'und';
- } else {
- $ret .= $this->_digits[$d];
- if ($d == 1)
- if ($power == 0)
- $ret .= 's'; // fuer eins
- else
- $ret .= 'e'; // fuer eine
- }
- }
-
- // ten, twenty etc.
- switch ($t) {
- case 9:
- case 8:
- case 5:
- $ret .= $this->_sep . $this->_digits[$t] . 'zig';
- break;
-
- case 7:
- $ret .= $this->_sep . 'siebzig';
- break;
-
- case 6:
- $ret .= $this->_sep . 'sechzig';
- break;
-
- case 4:
- $ret .= $this->_sep . 'vierzig';
- break;
-
- case 3:
- $ret .= $this->_sep . 'dreißig';
- break;
-
- case 2:
- $ret .= $this->_sep . 'zwanzig';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'zehn';
- break;
-
- case 1:
- $ret .= $this->_sep . 'elf';
- break;
-
- case 2:
- $ret .= $this->_sep . 'zwölf';
- break;
-
- case 3:
- case 4:
- case 5:
- case 8:
- case 9:
- $ret .= $this->_sep . $this->_digits[$d] . 'zehn';
- break;
-
- case 6:
- $ret .= $this->_sep . 'sechzehn';
- break;
-
- case 7:
- $ret .= $this->_sep . 'siebzehn';
- break;
- }
- break;
- }
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- if ($power == 3)
- $ret .= $this->_sep . $lev[0];
- elseif ($d == 1 && ($t+$h) == 0)
- $ret .= $this->_sep2 . $lev[0] . $this->_sep2;
- else
- $ret .= $this->_sep2 . $lev[1] . $this->_sep2;
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.ee.php b/thirdparty/pear/Numbers/Words/lang.ee.php
deleted file mode 100644
index 40446a963..000000000
--- a/thirdparty/pear/Numbers/Words/lang.ee.php
+++ /dev/null
@@ -1,349 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.ee.php,v 1.5 2003/09/29 12:23:58 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in Estonian language.
-//
-
-/**
- * Class for translating numbers into Estonian.
- *
- * @author Erkki Saarniit
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Estonian.
- *
- * @author Erkki Saarniit
- * @package Numbers_Words
- */
-class Numbers_Words_ee extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'ee';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'Estonian';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'eesti keel';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'miinus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * Names partly based on:
- * http://home.earthlink.net/~mrob/pub/math/largenum.html
- * http://mathforum.org/dr.math/faq/faq.large.numbers.html
- * http://www.mazes.com/AmericanNumberingSystem.html
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array(''),
- 3 => array('tuhat'),
- 6 => array('miljon'),
- 9 => array('miljard'),
- 12 => array('triljon'),
- 15 => array('kvadriljon'),
- 18 => array('kvintiljon'),
- 21 => array('sekstiljon'),
- 24 => array('septiljon'),
- 27 => array('oktiljon'),
- 30 => array('noniljon'),
- 33 => array('dekiljon'),
- 36 => array('undekiljon'),
- 39 => array('duodekiljon'),
- 42 => array('tredekiljon'),
- 45 => array('kvattuordekiljon'),
- 48 => array('kvindekiljon'),
- 51 => array('seksdekiljon'),
- 54 => array('septendekiljon'),
- 57 => array('oktodekiljon'),
- 60 => array('novemdekiljon'),
- 63 => array('vigintiljon'),
- 66 => array('unvigintiljon'),
- 69 => array('duovigintiljon'),
- 72 => array('trevigintiljon'),
- 75 => array('kvattuorvigintiljon'),
- 78 => array('kvinvigintiljon'),
- 81 => array('seksvigintiljon'),
- 84 => array('septenvigintiljon'),
- 87 => array('oktovigintiljon'),
- 90 => array('novemvigintiljon'),
- 93 => array('trigintiljon'),
- 96 => array('untrigintiljon'),
- 99 => array('duotrigintiljon'),
- 102 => array('trestrigintiljon'),
- 105 => array('kvattuortrigintiljon'),
- 108 => array('kvintrigintiljon'),
- 111 => array('sekstrigintiljon'),
- 114 => array('septentrigintiljon'),
- 117 => array('oktotrigintiljon'),
- 120 => array('novemtrigintiljon'),
- 123 => array('kvadragintiljon'),
- 126 => array('unkvadragintiljon'),
- 129 => array('duokvadragintiljon'),
- 132 => array('trekvadragintiljon'),
- 135 => array('kvattuorkvadragintiljon'),
- 138 => array('kvinkvadragintiljon'),
- 141 => array('sekskvadragintiljon'),
- 144 => array('septenkvadragintiljon'),
- 147 => array('oktokvadragintiljon'),
- 150 => array('novemkvadragintiljon'),
- 153 => array('kvinkvagintiljon'),
- 156 => array('unkvinkvagintiljon'),
- 159 => array('duokvinkvagintiljon'),
- 162 => array('trekvinkvagintiljon'),
- 165 => array('kvattuorkvinkvagintiljon'),
- 168 => array('kvinkvinkvagintiljon'),
- 171 => array('sekskvinkvagintiljon'),
- 174 => array('septenkvinkvagintiljon'),
- 177 => array('oktokvinkvagintiljon'),
- 180 => array('novemkvinkvagintiljon'),
- 183 => array('seksagintiljon'),
- 186 => array('unseksagintiljon'),
- 189 => array('duoseksagintiljon'),
- 192 => array('treseksagintiljon'),
- 195 => array('kvattuorseksagintiljon'),
- 198 => array('kvinseksagintiljon'),
- 201 => array('seksseksagintiljon'),
- 204 => array('septenseksagintiljon'),
- 207 => array('oktoseksagintiljon'),
- 210 => array('novemseksagintiljon'),
- 213 => array('septuagintiljon'),
- 216 => array('unseptuagintiljon'),
- 219 => array('duoseptuagintiljon'),
- 222 => array('treseptuagintiljon'),
- 225 => array('kvattuorseptuagintiljon'),
- 228 => array('kvinseptuagintiljon'),
- 231 => array('seksseptuagintiljon'),
- 234 => array('septenseptuagintiljon'),
- 237 => array('oktoseptuagintiljon'),
- 240 => array('novemseptuagintiljon'),
- 243 => array('oktogintiljon'),
- 246 => array('unoktogintiljon'),
- 249 => array('duooktogintiljon'),
- 252 => array('treoktogintiljon'),
- 255 => array('kvattuoroktogintiljon'),
- 258 => array('kvinoktogintiljon'),
- 261 => array('seksoktogintiljon'),
- 264 => array('septoktogintiljon'),
- 267 => array('oktooktogintiljon'),
- 270 => array('novemoktogintiljon'),
- 273 => array('nonagintiljon'),
- 276 => array('unnonagintiljon'),
- 279 => array('duononagintiljon'),
- 282 => array('trenonagintiljon'),
- 285 => array('kvattuornonagintiljon'),
- 288 => array('kvinnonagintiljon'),
- 291 => array('seksnonagintiljon'),
- 294 => array('septennonagintiljon'),
- 297 => array('oktononagintiljon'),
- 300 => array('novemnonagintiljon'),
- 303 => array('kentiljon'),
- 309 => array('duokentiljon'),
- 312 => array('trekentiljon'),
- 366 => array('primo-vigesimo-kentiljon'),
- 402 => array('trestrigintakentiljon'),
- 603 => array('dukentiljon'),
- 624 => array('septendukentiljon'),
- 2421 => array('seksoktingentiljon'),
- 3003 => array('milliljon'),
- 3000003 => array('milli-milliljon')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'null', 'üks', 'kaks', 'kolm', 'neli',
- 'viis', 'kuus', 'seitse', 'kaheksa', 'üheksa'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in Estonian language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
- if (isset($this->_exponent[$p])) {
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ($h) {
- $ret .= $this->_sep . $this->_digits[$h] . 'sada';
-
- }
-
- switch ($t) {
- case 9:
- case 8:
- case 7:
- case 6:
- case 5:
- case 4:
- case 3:
- case 2:
- $ret .= $this->_sep . $this->_digits[$t] . 'kümmend';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'kümme';
- break;
-
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- $ret .= $this->_sep . $this->_digits[$d] . 'teist';
- break;
- }
- break;
- }
- if ($t != 1 && $d > 0) {
- if ($t > 1) {
- $ret .= ' ' . $this->_digits[$d];
- } else {
- $ret .= $this->_sep . $this->_digits[$d];
- }
- }
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
- $ret .= $this->_sep . $lev[0].($num != 1 && $power!= 3 ? 'it' : '');
- }
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.en_100.php b/thirdparty/pear/Numbers/Words/lang.en_100.php
deleted file mode 100644
index 0032622ac..000000000
--- a/thirdparty/pear/Numbers/Words/lang.en_100.php
+++ /dev/null
@@ -1,307 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.en_100.php,v 1.6 2003/09/29 12:23:58 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in Donald Knuth system, in English language.
-//
-
-/**
- * Class for translating numbers into Donald Knuth system, in English language.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Donald Knuth system, in English language.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-class Numbers_Words_en_100 extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'en_100';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'English (Donald Knuth system)';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'English (Donald Knuth system)';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'minus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * Names based on:
- * http://home.earthlink.net/~mrob/pub/math/largenum.html
- * Donald Knuth system (power of 2)
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array(''),
- 2 => array('hundred'),
- 4 => array('myriad'),
- 8 => array('myllion'),
- 16 => array('byllion'),
- 32 => array('tryllion'),
- 64 => array('quadryllion'),
- 128 => array('quintyllion'),
- 256 => array('sextyllion'),
- 512 => array('septyllion'),
- 1024 => array('octyllion'),
- 2048 => array('nonyllion'),
- 4096 => array('decyllion'),
- 8192 => array('undecyllion'),
- 16384 => array('duodecyllion'),
- 32768 => array('tredecyllion'),
- 65536 => array('quattuordecyllion'),
- 131072 => array('quindecyllion'),
- 262144 => array('sexdecyllion'),
- 524288 => array('septendecyllion'),
- 1048576 => array('octodecyllion'),
- 2097152 => array('novemdecyllion'),
- 4194304 => array('vigintyllion')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'zero', 'one', 'two', 'three', 'four',
- 'five', 'six', 'seven', 'eight', 'nine'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
- // }}}
- // {{{ toWords()
- /**
- * Converts a number to its word representation
- * in Donald Knuth system, in English language.
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Piotr Klaban
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, ''); // $cursuffix);
- // normally cursuffix is added at the end, but not here
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ($h) {
- $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundred';
-
- // in English only - add ' and' for [1-9]01..[1-9]99
- // (also for 1001..1099, 10001..10099 but it is harder)
- // for now it is switched off, maybe some language purists
- // can force me to enable it, or to remove it completely
- // if (($t + $d) > 0)
- // $ret .= $this->_sep . 'and';
- }
-
- // ten, twenty etc.
- switch ($t) {
- case 9:
- case 7:
- case 6:
- $ret .= $this->_sep . $this->_digits[$t] . 'ty';
- break;
-
- case 8:
- $ret .= $this->_sep . 'eighty';
- break;
-
- case 5:
- $ret .= $this->_sep . 'fifty';
- break;
-
- case 4:
- $ret .= $this->_sep . 'forty';
- break;
-
- case 3:
- $ret .= $this->_sep . 'thirty';
- break;
-
- case 2:
- $ret .= $this->_sep . 'twenty';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'ten';
- break;
-
- case 1:
- $ret .= $this->_sep . 'eleven';
- break;
-
- case 2:
- $ret .= $this->_sep . 'twelve';
- break;
-
- case 3:
- $ret .= $this->_sep . 'thirteen';
- break;
-
- case 4:
- case 6:
- case 7:
- case 9:
- $ret .= $this->_sep . $this->_digits[$d] . 'teen';
- break;
-
- case 5:
- $ret .= $this->_sep . 'fifteen';
- break;
-
- case 8:
- $ret .= $this->_sep . 'eighteen';
- break;
- }
- break;
- }
-
- if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
- // add minus sign between [2-9] and digit
- if ($t > 1) {
- $ret .= '-' . $this->_digits[$d];
- } else {
- $ret .= $this->_sep . $this->_digits[$d];
- }
- }
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- $ret .= $this->_sep . $lev[0];
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.en_GB.php b/thirdparty/pear/Numbers/Words/lang.en_GB.php
deleted file mode 100644
index 961aed54b..000000000
--- a/thirdparty/pear/Numbers/Words/lang.en_GB.php
+++ /dev/null
@@ -1,308 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.en_GB.php,v 1.7 2003/09/29 12:23:58 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in British English language.
-//
-
-/**
- * Class for translating numbers into British English.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into British English.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-class Numbers_Words_en_GB extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'en_GB';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'British English';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'British English';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'minus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * Names partly based on:
- * http://www.users.dircon.co.uk/~shaunf/shaun/numbers/millions.htm
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array(''),
- 3 => array('thousand'),
- 6 => array('million'),
- 12 => array('billion'),
- 18 => array('trillion'),
- 24 => array('quadrillion'),
- 30 => array('quintillion'),
- 36 => array('sextillion'),
- 42 => array('septillion'),
- 48 => array('octillion'),
- 54 => array('nonillion'),
- 60 => array('decillion'),
- 66 => array('undecillion'),
- 72 => array('duodecillion'),
- 78 => array('tredecillion'),
- 84 => array('quattuordecillion'),
- 90 => array('quindecillion'),
- 96 => array('sexdecillion'),
- 102 => array('septendecillion'),
- 108 => array('octodecillion'),
- 114 => array('novemdecillion'),
- 120 => array('vigintillion'),
- 192 => array('duotrigintillion'),
- 600 => array('centillion')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'zero', 'one', 'two', 'three', 'four',
- 'five', 'six', 'seven', 'eight', 'nine'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in British English language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Piotr Klaban
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ($h) {
- $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundred';
-
- // in English only - add ' and' for [1-9]01..[1-9]99
- // (also for 1001..1099, 10001..10099 but it is harder)
- // for now it is switched off, maybe some language purists
- // can force me to enable it, or to remove it completely
- // if (($t + $d) > 0)
- // $ret .= $this->_sep . 'and';
- }
-
- // ten, twenty etc.
- switch ($t) {
- case 9:
- case 7:
- case 6:
- $ret .= $this->_sep . $this->_digits[$t] . 'ty';
- break;
-
- case 8:
- $ret .= $this->_sep . 'eighty';
- break;
-
- case 5:
- $ret .= $this->_sep . 'fifty';
- break;
-
- case 4:
- $ret .= $this->_sep . 'forty';
- break;
-
- case 3:
- $ret .= $this->_sep . 'thirty';
- break;
-
- case 2:
- $ret .= $this->_sep . 'twenty';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'ten';
- break;
-
- case 1:
- $ret .= $this->_sep . 'eleven';
- break;
-
- case 2:
- $ret .= $this->_sep . 'twelve';
- break;
-
- case 3:
- $ret .= $this->_sep . 'thirteen';
- break;
-
- case 4:
- case 6:
- case 7:
- case 9:
- $ret .= $this->_sep . $this->_digits[$d] . 'teen';
- break;
-
- case 5:
- $ret .= $this->_sep . 'fifteen';
- break;
-
- case 8:
- $ret .= $this->_sep . 'eighteen';
- break;
- }
- break;
- }
-
- if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
- // add minus sign between [2-9] and digit
- if ($t > 1) {
- $ret .= '-' . $this->_digits[$d];
- } else {
- $ret .= $this->_sep . $this->_digits[$d];
- }
- }
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- $ret .= $this->_sep . $lev[0];
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.en_US.php b/thirdparty/pear/Numbers/Words/lang.en_US.php
deleted file mode 100644
index 47e2f7bfa..000000000
--- a/thirdparty/pear/Numbers/Words/lang.en_US.php
+++ /dev/null
@@ -1,509 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.en_US.php,v 1.7 2003/09/29 12:23:58 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in American English language.
-//
-
-/**
- * Class for translating numbers into American English.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into American English.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-class Numbers_Words_en_US extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'en_US';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'American English';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'American English';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'minus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * Names partly based on:
- * http://home.earthlink.net/~mrob/pub/math/largenum.html
- * http://mathforum.org/dr.math/faq/faq.large.numbers.html
- * http://www.mazes.com/AmericanNumberingSystem.html
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array(''),
- 3 => array('thousand'),
- 6 => array('million'),
- 9 => array('billion'),
- 12 => array('trillion'),
- 15 => array('quadrillion'),
- 18 => array('quintillion'),
- 21 => array('sextillion'),
- 24 => array('septillion'),
- 27 => array('octillion'),
- 30 => array('nonillion'),
- 33 => array('decillion'),
- 36 => array('undecillion'),
- 39 => array('duodecillion'),
- 42 => array('tredecillion'),
- 45 => array('quattuordecillion'),
- 48 => array('quindecillion'),
- 51 => array('sexdecillion'),
- 54 => array('septendecillion'),
- 57 => array('octodecillion'),
- 60 => array('novemdecillion'),
- 63 => array('vigintillion'),
- 66 => array('unvigintillion'),
- 69 => array('duovigintillion'),
- 72 => array('trevigintillion'),
- 75 => array('quattuorvigintillion'),
- 78 => array('quinvigintillion'),
- 81 => array('sexvigintillion'),
- 84 => array('septenvigintillion'),
- 87 => array('octovigintillion'),
- 90 => array('novemvigintillion'),
- 93 => array('trigintillion'),
- 96 => array('untrigintillion'),
- 99 => array('duotrigintillion'),
- // 100 => array('googol') - not latin name
- // 10^googol = 1 googolplex
- 102 => array('trestrigintillion'),
- 105 => array('quattuortrigintillion'),
- 108 => array('quintrigintillion'),
- 111 => array('sextrigintillion'),
- 114 => array('septentrigintillion'),
- 117 => array('octotrigintillion'),
- 120 => array('novemtrigintillion'),
- 123 => array('quadragintillion'),
- 126 => array('unquadragintillion'),
- 129 => array('duoquadragintillion'),
- 132 => array('trequadragintillion'),
- 135 => array('quattuorquadragintillion'),
- 138 => array('quinquadragintillion'),
- 141 => array('sexquadragintillion'),
- 144 => array('septenquadragintillion'),
- 147 => array('octoquadragintillion'),
- 150 => array('novemquadragintillion'),
- 153 => array('quinquagintillion'),
- 156 => array('unquinquagintillion'),
- 159 => array('duoquinquagintillion'),
- 162 => array('trequinquagintillion'),
- 165 => array('quattuorquinquagintillion'),
- 168 => array('quinquinquagintillion'),
- 171 => array('sexquinquagintillion'),
- 174 => array('septenquinquagintillion'),
- 177 => array('octoquinquagintillion'),
- 180 => array('novemquinquagintillion'),
- 183 => array('sexagintillion'),
- 186 => array('unsexagintillion'),
- 189 => array('duosexagintillion'),
- 192 => array('tresexagintillion'),
- 195 => array('quattuorsexagintillion'),
- 198 => array('quinsexagintillion'),
- 201 => array('sexsexagintillion'),
- 204 => array('septensexagintillion'),
- 207 => array('octosexagintillion'),
- 210 => array('novemsexagintillion'),
- 213 => array('septuagintillion'),
- 216 => array('unseptuagintillion'),
- 219 => array('duoseptuagintillion'),
- 222 => array('treseptuagintillion'),
- 225 => array('quattuorseptuagintillion'),
- 228 => array('quinseptuagintillion'),
- 231 => array('sexseptuagintillion'),
- 234 => array('septenseptuagintillion'),
- 237 => array('octoseptuagintillion'),
- 240 => array('novemseptuagintillion'),
- 243 => array('octogintillion'),
- 246 => array('unoctogintillion'),
- 249 => array('duooctogintillion'),
- 252 => array('treoctogintillion'),
- 255 => array('quattuoroctogintillion'),
- 258 => array('quinoctogintillion'),
- 261 => array('sexoctogintillion'),
- 264 => array('septoctogintillion'),
- 267 => array('octooctogintillion'),
- 270 => array('novemoctogintillion'),
- 273 => array('nonagintillion'),
- 276 => array('unnonagintillion'),
- 279 => array('duononagintillion'),
- 282 => array('trenonagintillion'),
- 285 => array('quattuornonagintillion'),
- 288 => array('quinnonagintillion'),
- 291 => array('sexnonagintillion'),
- 294 => array('septennonagintillion'),
- 297 => array('octononagintillion'),
- 300 => array('novemnonagintillion'),
- 303 => array('centillion'),
- 309 => array('duocentillion'),
- 312 => array('trecentillion'),
- 366 => array('primo-vigesimo-centillion'),
- 402 => array('trestrigintacentillion'),
- 603 => array('ducentillion'),
- 624 => array('septenducentillion'),
- // bug on a earthlink page: 903 => array('trecentillion'),
- 2421 => array('sexoctingentillion'),
- 3003 => array('millillion'),
- 3000003 => array('milli-millillion')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'zero', 'one', 'two', 'three', 'four',
- 'five', 'six', 'seven', 'eight', 'nine'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The currency names (based on the below links,
- * informations from central bank websites and on encyclopedias)
- *
- * @var array
- * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information
- * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies
- * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English
- * @access private
- */
- var $_currency_names = array(
- 'ALL' => array(array('lek'), array('qindarka')),
- 'AUD' => array(array('Australian dollar'), array('cent')),
- 'BAM' => array(array('convertible marka'), array('fenig')),
- 'BGN' => array(array('lev'), array('stotinka')),
- 'BRL' => array(array('real'), array('centavos')),
- 'BYR' => array(array('Belarussian rouble'), array('kopiejka')),
- 'CAD' => array(array('Canadian dollar'), array('cent')),
- 'CHF' => array(array('Swiss franc'), array('rapp')),
- 'CYP' => array(array('Cypriot pound'), array('cent')),
- 'CZK' => array(array('Czech koruna'), array('halerz')),
- 'DKK' => array(array('Danish krone'), array('ore')),
- 'EEK' => array(array('kroon'), array('senti')),
- 'EUR' => array(array('euro'), array('euro-cent')),
- 'GBP' => array(array('pound', 'pounds'), array('pence')),
- 'HKD' => array(array('Hong Kong dollar'), array('cent')),
- 'HRK' => array(array('Croatian kuna'), array('lipa')),
- 'HUF' => array(array('forint'), array('filler')),
- 'ISK' => array(array('Icelandic króna'), array('aurar')),
- 'JPY' => array(array('yen'), array('sen')),
- 'LTL' => array(array('litas'), array('cent')),
- 'LVL' => array(array('lat'), array('sentim')),
- 'MKD' => array(array('Macedonian dinar'), array('deni')),
- 'MTL' => array(array('Maltese lira'), array('centym')),
- 'NOK' => array(array('Norwegian krone'), array('oere')),
- 'PLN' => array(array('zloty', 'zlotys'), array('grosz')),
- 'ROL' => array(array('Romanian leu'), array('bani')),
- 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')),
- 'SEK' => array(array('Swedish krona'), array('oere')),
- 'SIT' => array(array('Tolar'), array('stotinia')),
- 'SKK' => array(array('Slovak koruna'), array()),
- 'TRL' => array(array('lira'), array('kuruþ')),
- 'UAH' => array(array('hryvna'), array('cent')),
- 'USD' => array(array('dollar'), array('cent')),
- 'YUM' => array(array('dinars'), array('para')),
- 'ZAR' => array(array('rand'), array('cent')),
- 'MXN' => array(array('Mexican Peso'), array('cent'))
- );
-
- /**
- * The default currency name
- * @var string
- * @access public
- */
- var $def_currency = 'USD'; // Polish zloty
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in American English language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Piotr Klaban
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ($h) {
- $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundred';
-
- // in English only - add ' and' for [1-9]01..[1-9]99
- // (also for 1001..1099, 10001..10099 but it is harder)
- // for now it is switched off, maybe some language purists
- // can force me to enable it, or to remove it completely
- // if (($t + $d) > 0)
- // $ret .= $this->_sep . 'and';
- }
-
- // ten, twenty etc.
- switch ($t) {
- case 9:
- case 7:
- case 6:
- $ret .= $this->_sep . $this->_digits[$t] . 'ty';
- break;
-
- case 8:
- $ret .= $this->_sep . 'eighty';
- break;
-
- case 5:
- $ret .= $this->_sep . 'fifty';
- break;
-
- case 4:
- $ret .= $this->_sep . 'forty';
- break;
-
- case 3:
- $ret .= $this->_sep . 'thirty';
- break;
-
- case 2:
- $ret .= $this->_sep . 'twenty';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'ten';
- break;
-
- case 1:
- $ret .= $this->_sep . 'eleven';
- break;
-
- case 2:
- $ret .= $this->_sep . 'twelve';
- break;
-
- case 3:
- $ret .= $this->_sep . 'thirteen';
- break;
-
- case 4:
- case 6:
- case 7:
- case 9:
- $ret .= $this->_sep . $this->_digits[$d] . 'teen';
- break;
-
- case 5:
- $ret .= $this->_sep . 'fifteen';
- break;
-
- case 8:
- $ret .= $this->_sep . 'eighteen';
- break;
- }
- break;
- }
-
- if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
- // add minus sign between [2-9] and digit
- if ($t > 1) {
- $ret .= '-' . $this->_digits[$d];
- } else {
- $ret .= $this->_sep . $this->_digits[$d];
- }
- }
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- $ret .= $this->_sep . $lev[0];
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
- // {{{ toCurrency()
-
- /**
- * Converts a currency value to its word representation
- * (with monetary units) in English language
- *
- * @param integer $int_curr An international currency symbol
- * as defined by the ISO 4217 standard (three characters)
- * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars)
- * @param integer $fraction Fractional part of the money amount (e.g. amount of cents)
- * Optional. Defaults to false.
- *
- * @return string The corresponding word representation for the currency
- *
- * @access public
- * @author Piotr Klaban
- * @since Numbers_Words 0.4
- */
- function toCurrencyWords($int_curr, $decimal, $fraction = false) {
- $int_curr = strtoupper($int_curr);
- if (!isset($this->_currency_names[$int_curr])) {
- $int_curr = $this->def_currency;
- }
- $curr_names = $this->_currency_names[$int_curr];
- $ret = trim($this->toWords($decimal));
- $lev = ($decimal == 1) ? 0 : 1;
- if ($lev > 0) {
- if (count($curr_names[0]) > 1) {
- $ret .= $this->_sep . $curr_names[0][$lev];
- } else {
- $ret .= $this->_sep . $curr_names[0][0] . 's';
- }
- } else {
- $ret .= $this->_sep . $curr_names[0][0];
- }
-
- if ($fraction !== false) {
- $ret .= $this->_sep . trim($this->toWords($fraction));
- $lev = ($fraction == 1) ? 0 : 1;
- if ($lev > 0) {
- if (count($curr_names[1]) > 1) {
- $ret .= $this->_sep . $curr_names[1][$lev];
- } else {
- $ret .= $this->_sep . $curr_names[1][0] . 's';
- }
- } else {
- $ret .= $this->_sep . $curr_names[1][0];
- }
- }
- return $ret;
- }
- // }}}
-
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.es.php b/thirdparty/pear/Numbers/Words/lang.es.php
deleted file mode 100644
index 267937c28..000000000
--- a/thirdparty/pear/Numbers/Words/lang.es.php
+++ /dev/null
@@ -1,343 +0,0 @@
- array('',''),
- 3 => array('mil','mil'),
- 6 => array('millón','millones'),
- 12 => array('billón','billones'),
- 18 => array('trilón','trillones'),
- 24 => array('cuatrillón','cuatrillones'),
- 30 => array('quintillón','quintillones'),
- 36 => array('sextillón','sextillones'),
- 42 => array('septillón','septillones'),
- 48 => array('octallón','octallones'),
- 54 => array('nonallón','nonallones'),
- 60 => array('decallón','decallones'),
- );
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'cero', 'uno', 'dos', 'tres', 'cuatro',
- 'cinco', 'seis', 'siete', 'ocho', 'nueve'
- );
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
- // }}}
- // {{{ toWords()
- /**
- * Converts a number to its word representation
- * in Spanish (Castellano).
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that should be converted to a words representation
- * @param integer $power The power of ten for the rest of the number to the right.
- * For example toWords(12,3) should give "doce mil".
- * Optional, defaults to 0.
- * @return string The corresponding word representation
- *
- * @access private
- * @author Xavier Noguer
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0)
- {
- // The return string;
- $ret = '';
-
- // add a the word for the minus sign if necessary
- if (substr($num, 0, 1) == '-')
- {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
-
- // strip excessive zero signs
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 6)
- {
- $current_power = 6;
- // check for highest power
- if (isset($this->_exponent[$power]))
- {
- // convert the number above the first 6 digits
- // with it's corresponding $power.
- $snum = substr($num, 0, -6);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $ret .= $this->toWords($snum, $power + 6);
- }
- }
- $num = substr($num, -6);
- if ($num == 0) {
- return $ret;
- }
- }
- elseif ($num == 0 || $num == '') {
- return(' '.$this->_digits[0]);
- $current_power = strlen($num);
- }
- else {
- $current_power = strlen($num);
- }
-
- // See if we need "thousands"
- $thousands = floor($num / 1000);
- if ($thousands == 1) {
- $ret .= $this->_sep . 'mil';
- }
- elseif ($thousands > 1) {
- $ret .= $this->toWords($thousands, 3);
- }
-
- // values for digits, tens and hundreds
- $h = floor(($num / 100) % 10);
- $t = floor(($num / 10) % 10);
- $d = floor($num % 10);
-
- // cientos: doscientos, trescientos, etc...
- switch ($h)
- {
- case 1:
- if (($d == 0) and ($t == 0)) { // is it's '100' use 'cien'
- $ret .= $this->_sep . 'cien';
- }
- else {
- $ret .= $this->_sep . 'ciento';
- }
- break;
- case 2:
- case 3:
- case 4:
- case 6:
- case 8:
- $ret .= $this->_sep . $this->_digits[$h] . 'cientos';
- break;
- case 5:
- $ret .= $this->_sep . 'quinientos';
- break;
- case 7:
- $ret .= $this->_sep . 'setecientos';
- break;
- case 9:
- $ret .= $this->_sep . 'novecientos';
- break;
- }
-
- // decenas: veinte, treinta, etc...
- switch ($t)
- {
- case 9:
- $ret .= $this->_sep . 'noventa';
- break;
-
- case 8:
- $ret .= $this->_sep . 'ochenta';
- break;
-
- case 7:
- $ret .= $this->_sep . 'setenta';
- break;
-
- case 6:
- $ret .= $this->_sep . 'sesenta';
- break;
-
- case 5:
- $ret .= $this->_sep . 'cincuenta';
- break;
-
- case 4:
- $ret .= $this->_sep . 'cuarenta';
- break;
-
- case 3:
- $ret .= $this->_sep . 'treinta';
- break;
-
- case 2:
- if ($d == 0) {
- $ret .= $this->_sep . 'veinte';
- }
- else {
- if (($power > 0) and ($d == 1)) {
- $ret .= $this->_sep . 'veintiún';
- }
- else {
- $ret .= $this->_sep . 'veinti' . $this->_digits[$d];
- }
- }
- break;
-
- case 1:
- switch ($d)
- {
- case 0:
- $ret .= $this->_sep . 'diez';
- break;
-
- case 1:
- $ret .= $this->_sep . 'once';
- break;
-
- case 2:
- $ret .= $this->_sep . 'doce';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trece';
- break;
-
- case 4:
- $ret .= $this->_sep . 'catorce';
- break;
-
- case 5:
- $ret .= $this->_sep . 'quince';
- break;
-
- case 6:
- case 7:
- case 9:
- case 8:
- $ret .= $this->_sep . 'dieci' . $this->_digits[$d];
- break;
- }
- break;
- }
-
- // add digits only if it is a multiple of 10 and not 1x or 2x
- if (($t != 1) and ($t != 2) and ($d > 0))
- {
- if($t != 0) // don't add 'y' for numbers below 10
- {
- // use 'un' instead of 'uno' when there is a suffix ('mil', 'millones', etc...)
- if(($power > 0) and ($d == 1)) {
- $ret .= $this->_sep.' y un';
- }
- else {
- $ret .= $this->_sep.'y '.$this->_digits[$d];
- }
- }
- else {
- if(($power > 0) and ($d == 1)) {
- $ret .= $this->_sep.'un';
- }
- else {
- $ret .= $this->_sep.$this->_digits[$d];
- }
- }
- }
-
- if ($power > 0)
- {
- if (isset($this->_exponent[$power])) {
- $lev = $this->_exponent[$power];
- }
-
- if (!isset($lev) || !is_array($lev)) {
- return null;
- }
-
- // if it's only one use the singular suffix
- if (($d == 1) and ($t == 0) and ($h == 0)) {
- $suffix = $lev[0];
- }
- else {
- $suffix = $lev[1];
- }
- if ($num != 0) {
- $ret .= $this->_sep . $suffix;
- }
- }
-
- return $ret;
- }
- // }}}
-}
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.es_AR.php b/thirdparty/pear/Numbers/Words/lang.es_AR.php
deleted file mode 100644
index 4750631c5..000000000
--- a/thirdparty/pear/Numbers/Words/lang.es_AR.php
+++ /dev/null
@@ -1,470 +0,0 @@
- |
-// | Based On: lang_es.php - Xavier Noguer |
-// +----------------------------------------------------------------------+
-// $Id: lang.es_AR.php 503 2004-02-23 19:25:42Z mmarre $
-//
-// Numbers_Words class extension to spell numbers in Argentinian Spanish
-//
-//
-
-/**
- * Class for translating numbers into Argentinian Spanish.
- *
- * @author Martin Marrese
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Argentinian Spanish.
- * It supports up to decallones (10^6).
- * It doesn't support spanish tonic accents (acentos).
- *
- * @author Martin Marrese
- * @package Numbers_Words
- */
-class Numbers_Words_es_AR extends Numbers_Words
-{
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'es_AR';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'Spanish';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'Español';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'menos';
-
- /**
- * The sufixes for exponents (singular and plural)
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array('',''),
- 3 => array('mil','mil'),
- 6 => array('millón','millones'),
- 12 => array('billón','billones'),
- 18 => array('trilón','trillones'),
- 24 => array('cuatrillón','cuatrillones'),
- 30 => array('quintillón','quintillones'),
- 36 => array('sextillón','sextillones'),
- 42 => array('septillón','septillones'),
- 48 => array('octallón','octallones'),
- 54 => array('nonallón','nonallones'),
- 60 => array('decallón','decallones'),
- );
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'cero', 'uno', 'dos', 'tres', 'cuatro',
- 'cinco', 'seis', 'siete', 'ocho', 'nueve'
- );
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The currency names (based on the below links,
- * informations from central bank websites and on encyclopedias)
- *
- * @var array
- * @link http://30-03-67.dreamstation.com/currency_alfa.htm World Currency Information
- * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies
- * @link http://www.shoestring.co.kr/world/p.visa/change.htm Currency names in English
- * @access private
- */
- var $_currency_names = array(
- 'ALL' => array(array('lek'), array('qindarka')),
- 'AUD' => array(array('Australian dollar'), array('cent')),
- 'ARS' => array(array('Peso'), array ('centavo')),
- 'BAM' => array(array('convertible marka'), array('fenig')),
- 'BGN' => array(array('lev'), array('stotinka')),
- 'BRL' => array(array('real'), array('centavos')),
- 'BYR' => array(array('Belarussian rouble'), array('kopiejka')),
- 'CAD' => array(array('Canadian dollar'), array('cent')),
- 'CHF' => array(array('Swiss franc'), array('rapp')),
- 'CYP' => array(array('Cypriot pound'), array('cent')),
- 'CZK' => array(array('Czech koruna'), array('halerz')),
- 'DKK' => array(array('Danish krone'), array('ore')),
- 'EEK' => array(array('kroon'), array('senti')),
- 'EUR' => array(array('euro'), array('euro-cent')),
- 'GBP' => array(array('pound', 'pounds'), array('pence')),
- 'HKD' => array(array('Hong Kong dollar'), array('cent')),
- 'HRK' => array(array('Croatian kuna'), array('lipa')),
- 'HUF' => array(array('forint'), array('filler')),
- 'ISK' => array(array('Icelandic króna'), array('aurar')),
- 'JPY' => array(array('yen'), array('sen')),
- 'LTL' => array(array('litas'), array('cent')),
- 'LVL' => array(array('lat'), array('sentim')),
- 'MKD' => array(array('Macedonian dinar'), array('deni')),
- 'MTL' => array(array('Maltese lira'), array('centym')),
- 'NOK' => array(array('Norwegian krone'), array('oere')),
- 'PLN' => array(array('zloty', 'zlotys'), array('grosz')),
- 'ROL' => array(array('Romanian leu'), array('bani')),
- 'RUB' => array(array('Russian Federation rouble'), array('kopiejka')),
- 'SEK' => array(array('Swedish krona'), array('oere')),
- 'SIT' => array(array('Tolar'), array('stotinia')),
- 'SKK' => array(array('Slovak koruna'), array()),
- 'TRL' => array(array('lira'), array('kuruþ')),
- 'UAH' => array(array('hryvna'), array('cent')),
- 'USD' => array(array('dolar', 'DÓLARES'), array('centavo')),
- 'YUM' => array(array('dinars'), array('para')),
- 'ZAR' => array(array('rand'), array('cent')),
- 'MXN' => array(array('Peso Mexicano', 'Pesos Mexicanos'), array('centavo'))
- );
-
- /**
- * The default currency name
- * @var string
- * @access public
- */
- var $def_currency = 'ARS'; // Argentinian Peso
-
- // }}}
- // {{{ toWords()
- /**
- * Converts a number to its word representation
- * in Argentinian Spanish.
- *
- * @param float $num An float between -infinity and infinity inclusive :)
- * that should be converted to a words representation
- * @param integer $power The power of ten for the rest of the number to the right.
- * For example toWords(12,3) should give "doce mil".
- * Optional, defaults to 0.
- * @return string The corresponding word representation
- *
- * @access private
- * @author Martin Marrese
- */
- function toWords($num, $power = 0)
- {
- // The return string;
- $ret = '';
-
- // add a the word for the minus sign if necessary
- if (substr($num, 0, 1) == '-')
- {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
-
- // strip excessive zero signs
- $num = preg_replace('/^0+/','',$num);
-
- $num_tmp = split ('\.', $num);
-
- $num = $num_tmp[0];
- $dec = (@$num_tmp[1]) ? $num_tmp[1] : '';
-
- if (strlen($num) > 6)
- {
- $current_power = 6;
- // check for highest power
- if (isset($this->_exponent[$power]))
- {
- // convert the number above the first 6 digits
- // with it's corresponding $power.
- $snum = substr($num, 0, -6);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $ret .= $this->toWords($snum, $power + 6);
- }
- }
- $num = substr($num, -6);
- if ($num == 0) {
- return $ret;
- }
- }
- elseif ($num == 0 || $num == '') {
- return(' '.$this->_digits[0]);
- $current_power = strlen($num);
- }
- else {
- $current_power = strlen($num);
- }
-
- // See if we need "thousands"
- $thousands = floor($num / 1000);
- if ($thousands == 1) {
- $ret .= $this->_sep . 'mil';
- }
- elseif ($thousands > 1) {
- $ret .= $this->toWords($thousands, 3);
- }
-
- // values for digits, tens and hundreds
- $h = floor(($num / 100) % 10);
- $t = floor(($num / 10) % 10);
- $d = floor($num % 10);
-
- // cientos: doscientos, trescientos, etc...
- switch ($h)
- {
- case 1:
- if (($d == 0) and ($t == 0)) { // is it's '100' use 'cien'
- $ret .= $this->_sep . 'cien';
- }
- else {
- $ret .= $this->_sep . 'ciento';
- }
- break;
- case 2:
- case 3:
- case 4:
- case 6:
- case 8:
- $ret .= $this->_sep . $this->_digits[$h] . 'cientos';
- break;
- case 5:
- $ret .= $this->_sep . 'quinientos';
- break;
- case 7:
- $ret .= $this->_sep . 'setecientos';
- break;
- case 9:
- $ret .= $this->_sep . 'novecientos';
- break;
- }
-
- // decenas: veinte, treinta, etc...
- switch ($t)
- {
- case 9:
- $ret .= $this->_sep . 'noventa';
- break;
-
- case 8:
- $ret .= $this->_sep . 'ochenta';
- break;
-
- case 7:
- $ret .= $this->_sep . 'setenta';
- break;
-
- case 6:
- $ret .= $this->_sep . 'sesenta';
- break;
-
- case 5:
- $ret .= $this->_sep . 'cincuenta';
- break;
-
- case 4:
- $ret .= $this->_sep . 'cuarenta';
- break;
-
- case 3:
- $ret .= $this->_sep . 'treinta';
- break;
-
- case 2:
- if ($d == 0) {
- $ret .= $this->_sep . 'veinte';
- }
- else {
- if (($power > 0) and ($d == 1)) {
- $ret .= $this->_sep . 'veintiún';
- }
- else {
- $ret .= $this->_sep . 'veinti' . $this->_digits[$d];
- }
- }
- break;
-
- case 1:
- switch ($d)
- {
- case 0:
- $ret .= $this->_sep . 'diez';
- break;
-
- case 1:
- $ret .= $this->_sep . 'once';
- break;
-
- case 2:
- $ret .= $this->_sep . 'doce';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trece';
- break;
-
- case 4:
- $ret .= $this->_sep . 'catorce';
- break;
-
- case 5:
- $ret .= $this->_sep . 'quince';
- break;
-
- case 6:
- case 7:
- case 9:
- case 8:
- $ret .= $this->_sep . 'dieci' . $this->_digits[$d];
- break;
- }
- break;
- }
-
- // add digits only if it is a multiple of 10 and not 1x or 2x
- if (($t != 1) and ($t != 2) and ($d > 0))
- {
- if($t != 0) // don't add 'y' for numbers below 10
- {
- // use 'un' instead of 'uno' when there is a suffix ('mil', 'millones', etc...)
- if(($power > 0) and ($d == 1)) {
- $ret .= $this->_sep.' y un';
- }
- else {
- $ret .= $this->_sep.'y '.$this->_digits[$d];
- }
- }
- else {
- if(($power > 0) and ($d == 1)) {
- $ret .= $this->_sep.'un';
- }
- else {
- $ret .= $this->_sep.$this->_digits[$d];
- }
- }
- }
-
- if ($power > 0)
- {
- if (isset($this->_exponent[$power])) {
- $lev = $this->_exponent[$power];
- }
-
- if (!isset($lev) || !is_array($lev)) {
- return null;
- }
-
- // if it's only one use the singular suffix
- if (($d == 1) and ($t == 0) and ($h == 0)) {
- $suffix = $lev[0];
- }
- else {
- $suffix = $lev[1];
- }
- if ($num != 0) {
- $ret .= $this->_sep . $suffix;
- }
- }
-
- if ($dec) {
- $dec = $this->toWords(trim($dec));
- $ret.= ' con ' . trim ($dec);
- }
-
- return $ret;
- }
- // }}}
-
- // {{{ toCurrency()
-
- /**
- * Converts a currency value to its word representation
- * (with monetary units) in Agentinian Spanish language
- *
- * @param integer $int_curr An international currency symbol
- * as defined by the ISO 4217 standard (three characters)
- * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars)
- * @param integer $fraction Fractional part of the money amount (e.g. amount of cents)
- * Optional. Defaults to false.
- *
- * @return string The corresponding word representation for the currency
- *
- * @access public
- * @author Martin Marrese
- */
- function toCurrencyWords($int_curr, $decimal, $fraction = false) {
- $int_curr = strtoupper($int_curr);
- if (!isset($this->_currency_names[$int_curr])) {
- $int_curr = $this->def_currency;
- }
- $curr_names = $this->_currency_names[$int_curr];
- $ret .= $this->_sep . trim($this->toWords($decimal));
- $lev = ($decimal == 1) ? 0 : 1;
-
- if ($lev > 0) {
- if (count($curr_names[0]) > 1) {
- $ret .= $this->_sep . $curr_names[0][$lev];
- } else {
- $ret .= $this->_sep . $curr_names[0][0] . 's';
- }
- } else {
- $ret .= $this->_sep . $curr_names[0][0];
- }
-
-
- if ($fraction !== false) {
- $ret .= $this->_sep .'con'. $this->_sep . trim($this->toWords($fraction));
- $lev = ($fraction == 1) ? 0 : 1;
- if ($lev > 0) {
- if (count($curr_names[1]) > 1) {
- $ret .= $this->_sep . $curr_names[1][$lev];
- } else {
- $ret .= $this->_sep . $curr_names[1][0] . 's';
- }
- } else {
- $ret .= $this->_sep . $curr_names[1][0];
- }
- }
- return $ret;
- }
- // }}}
-
-
-
-}
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.fr.php b/thirdparty/pear/Numbers/Words/lang.fr.php
deleted file mode 100644
index ed756163f..000000000
--- a/thirdparty/pear/Numbers/Words/lang.fr.php
+++ /dev/null
@@ -1,439 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into French.
- *
- * @author Kouber Saparev
- * @package Numbers_Words
- */
-class Numbers_Words_fr extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name.
- * @var string
- * @access public
- */
- var $locale = 'fr';
-
- /**
- * Language name in English.
- * @var string
- * @access public
- */
- var $lang = 'French';
-
- /**
- * Native language name.
- * @var string
- * @access public
- */
- var $lang_native = 'Français';
-
- /**
- * The words for some numbers.
- * @var string
- * @access private
- */
- var $_misc_numbers = array(
- 10=>'dix', // 10
- 'onze', // 11
- 'douze', // 12
- 'treize', // 13
- 'quatorze', // 14
- 'quinze', // 15
- 'seize', // 16
- 20=>'vingt', // 20
- 30=>'trente', // 30
- 40=>'quarante', // 40
- 50=>'cinquante',// 50
- 60=>'soixante', // 60
- 100=>'cent' // 100
- );
-
-
- /**
- * The words for digits (except zero).
- * @var string
- * @access private
- */
- var $_digits = array(1=>"un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf");
-
- /**
- * The word for zero.
- * @var string
- * @access private
- */
- var $_zero = 'zéro';
-
- /**
- * The word for infinity.
- * @var string
- * @access private
- */
- var $_infinity = 'infini';
-
- /**
- * The word for the "and" language construct.
- * @var string
- * @access private
- */
- var $_and = 'et';
-
- /**
- * The word separator.
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The dash liaison.
- * @var string
- * @access private
- */
- var $_dash = '-';
-
- /**
- * The word for the minus sign.
- * @var string
- * @access private
- */
- var $_minus = 'moins'; // minus sign
-
- /**
- * The plural suffix (except for hundred).
- * @var string
- * @access private
- */
- var $_plural = 's'; // plural suffix
-
- /**
- * The suffixes for exponents (singular).
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => '',
- 3 => 'mille',
- 6 => 'million',
- 9 => 'milliard',
- 12 => 'trillion',
- 15 => 'quadrillion',
- 18 => 'quintillion',
- 21 => 'sextillion',
- 24 => 'septillion',
- 27 => 'octillion',
- 30 => 'nonillion',
- 33 => 'decillion',
- 36 => 'undecillion',
- 39 => 'duodecillion',
- 42 => 'tredecillion',
- 45 => 'quattuordecillion',
- 48 => 'quindecillion',
- 51 => 'sexdecillion',
- 54 => 'septendecillion',
- 57 => 'octodecillion',
- 60 => 'novemdecillion',
- 63 => 'vigintillion',
- 66 => 'unvigintillion',
- 69 => 'duovigintillion',
- 72 => 'trevigintillion',
- 75 => 'quattuorvigintillion',
- 78 => 'quinvigintillion',
- 81 => 'sexvigintillion',
- 84 => 'septenvigintillion',
- 87 => 'octovigintillion',
- 90 => 'novemvigintillion',
- 93 => 'trigintillion',
- 96 => 'untrigintillion',
- 99 => 'duotrigintillion',
- 102 => 'trestrigintillion',
- 105 => 'quattuortrigintillion',
- 108 => 'quintrigintillion',
- 111 => 'sextrigintillion',
- 114 => 'septentrigintillion',
- 117 => 'octotrigintillion',
- 120 => 'novemtrigintillion',
- 123 => 'quadragintillion',
- 126 => 'unquadragintillion',
- 129 => 'duoquadragintillion',
- 132 => 'trequadragintillion',
- 135 => 'quattuorquadragintillion',
- 138 => 'quinquadragintillion',
- 141 => 'sexquadragintillion',
- 144 => 'septenquadragintillion',
- 147 => 'octoquadragintillion',
- 150 => 'novemquadragintillion',
- 153 => 'quinquagintillion',
- 156 => 'unquinquagintillion',
- 159 => 'duoquinquagintillion',
- 162 => 'trequinquagintillion',
- 165 => 'quattuorquinquagintillion',
- 168 => 'quinquinquagintillion',
- 171 => 'sexquinquagintillion',
- 174 => 'septenquinquagintillion',
- 177 => 'octoquinquagintillion',
- 180 => 'novemquinquagintillion',
- 183 => 'sexagintillion',
- 186 => 'unsexagintillion',
- 189 => 'duosexagintillion',
- 192 => 'tresexagintillion',
- 195 => 'quattuorsexagintillion',
- 198 => 'quinsexagintillion',
- 201 => 'sexsexagintillion',
- 204 => 'septensexagintillion',
- 207 => 'octosexagintillion',
- 210 => 'novemsexagintillion',
- 213 => 'septuagintillion',
- 216 => 'unseptuagintillion',
- 219 => 'duoseptuagintillion',
- 222 => 'treseptuagintillion',
- 225 => 'quattuorseptuagintillion',
- 228 => 'quinseptuagintillion',
- 231 => 'sexseptuagintillion',
- 234 => 'septenseptuagintillion',
- 237 => 'octoseptuagintillion',
- 240 => 'novemseptuagintillion',
- 243 => 'octogintillion',
- 246 => 'unoctogintillion',
- 249 => 'duooctogintillion',
- 252 => 'treoctogintillion',
- 255 => 'quattuoroctogintillion',
- 258 => 'quinoctogintillion',
- 261 => 'sexoctogintillion',
- 264 => 'septoctogintillion',
- 267 => 'octooctogintillion',
- 270 => 'novemoctogintillion',
- 273 => 'nonagintillion',
- 276 => 'unnonagintillion',
- 279 => 'duononagintillion',
- 282 => 'trenonagintillion',
- 285 => 'quattuornonagintillion',
- 288 => 'quinnonagintillion',
- 291 => 'sexnonagintillion',
- 294 => 'septennonagintillion',
- 297 => 'octononagintillion',
- 300 => 'novemnonagintillion',
- 303 => 'centillion'
- );
- // }}}
-
- // {{{ _splitNumber()
-
- /**
- * Split a number to groups of three-digit numbers.
- *
- * @param mixed $num An integer or its string representation
- * that need to be split
- *
- * @return array Groups of three-digit numbers.
- *
- * @access private
- * @author Kouber Saparev
- * @since PHP 4.2.3
- */
-
- function _splitNumber($num)
- {
- if (is_string($num)) {
- $ret = array();
- $strlen = strlen($num);
- $first = substr($num, 0, $strlen%3);
- preg_match_all('/\d{3}/', substr($num, $strlen%3, $strlen), $m);
- $ret =& $m[0];
- if ($first) array_unshift($ret, $first);
- return $ret;
- }
- else
- return explode(' ', number_format($num, 0, '', ' ')); // a faster version for integers
- }
- // }}}
-
- // {{{ _showDigitsGroup()
-
- /**
- * Converts a three-digit number to its word representation
- * in French language.
- *
- * @param integer $num An integer between 1 and 999 inclusive.
- *
- * @param boolean $last A flag, that determines if it is the last group of digits -
- * this is used to accord the plural suffix of the "hundreds".
- * Example: 200 = "deux cents", but 200000 = "deux cent mille".
- *
- *
- * @return string The words for the given number.
- *
- * @access private
- * @author Kouber Saparev
- */
- function _showDigitsGroup($num, $last = false)
- {
- $ret = '';
-
- // extract the value of each digit from the three-digit number
- $e = $num%10; // ones
- $d = ($num-$e)%100/10; // tens
- $s = ($num-$d*10-$e)%1000/100; // hundreds
-
- // process the "hundreds" digit.
- if ($s) {
- if ($s>1) {
- $ret .= $this->_digits[$s].$this->_sep.$this->_misc_numbers[100];
- if ($last && !$e && !$d) {
- $ret .= $this->_plural;
- }
- } else {
- $ret .= $this->_misc_numbers[100];
- }
- $ret .= $this->_sep;
- }
-
- // process the "tens" digit, and optionally the "ones" digit.
- if ($d) {
- // in the case of 1, the "ones" digit also must be processed
- if ($d==1) {
- if ($e<=6) {
- $ret .= $this->_misc_numbers[10+$e];
- } else {
- $ret .= $this->_misc_numbers[10].'-'.$this->_digits[$e];
- }
- $e = 0;
- } elseif ($d>5) {
- if ($d<8) {
- $ret .= $this->_misc_numbers[60];
- $resto = $d*10+$e-60;
- if ($e==1) {
- $ret .= $this->_sep.$this->_and.$this->_sep;
- }
- elseif ($resto) {
- $ret .= $this->_dash;
- }
-
- if ($resto) {
- $ret .= $this->_showDigitsGroup($resto);
- }
- $e = 0;
- } else {
- $ret .= $this->_digits[4].$this->_dash.$this->_misc_numbers[20];
- $resto = $d*10+$e-80;
- if ($resto) {
- $ret .= $this->_dash;
- $ret .= $this->_showDigitsGroup($resto);
- $e = 0;
- } else {
- $ret .= $this->_plural;
- }
- }
- } else {
- $ret .= $this->_misc_numbers[$d*10];
- }
- }
-
- // process the "ones" digit
- if ($e) {
- if ($d) {
- if ($e==1) {
- $ret .= $this->_sep.$this->_and.$this->_sep;
- } else {
- $ret .= $this->_dash;
- }
- }
- $ret .= $this->_digits[$e];
- }
-
- // strip excessive separators
- $ret = rtrim($ret, $this->_sep);
-
- return $ret;
- }
- // }}}
-
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in French language.
- *
- * @param integer $num An integer (or its string representation) between 9.99*-10^302
- * and 9.99*10^302 (999 centillions) that need to be converted to words
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Kouber Saparev
- */
- function toWords($num = 0)
- {
- $ret = '';
-
- // check if $num is a valid non-zero number
- if (!$num || preg_match('/^-?0+$/', $num) || !preg_match('/^-?\d+$/', $num)) return $this->_zero;
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_minus . $this->_sep;
- $num = substr($num, 1);
- }
-
- // if the absolute value is greater than 9.99*10^302, return infinity
- if (strlen($num)>306) {
- return $ret . $this->_infinity;
- }
-
- // strip excessive zero signs
- $num = ltrim($num, '0');
-
- // split $num to groups of three-digit numbers
- $num_groups = $this->_splitNumber($num);
-
- $sizeof_numgroups = count($num_groups);
-
- foreach ($num_groups as $i=>$number) {
- // what is the corresponding exponent for the current group
- $pow = $sizeof_numgroups-$i;
-
- // skip processment for empty groups
- if ($number!='000') {
- if ($number!=1 || $pow!=2) {
- $ret .= $this->_showDigitsGroup($number, $i+1==$sizeof_numgroups).$this->_sep;
- }
- $ret .= $this->_exponent[($pow-1)*3];
- if ($pow>2 && $number>1) {
- $ret .= $this->_plural;
- }
- $ret .= $this->_sep;
- }
- }
-
- return rtrim($ret, $this->_sep);
- }
- // }}}
-}
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.id.php b/thirdparty/pear/Numbers/Words/lang.id.php
deleted file mode 100644
index 21ab30cfb..000000000
--- a/thirdparty/pear/Numbers/Words/lang.id.php
+++ /dev/null
@@ -1,277 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.en_GB.php,v 1.3 2002/11/26 10:33:35 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in Indonesian language.
-//
-
-require_once("PEAR.php");
-require_once("Numbers/Words.php");
-
-/**
-* Class for translating numbers into Indonesian.
-*
-* @author Ernas M. Jamil
-*/
-class Numbers_Words_id extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- */
- var $locale = 'id';
-
- /**
- * Language name in English
- * @var string
- */
- var $lang = 'Indonesia Language';
-
- /**
- * Native language name
- * @var string
- */
- var $lang_native = 'Bahasa Indonesia';
-
- /**
- * The word for the minus sign
- * @var string
- */
- var $_minus = 'minus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * Names partly based on:
- * http://www.users.dircon.co.uk/~shaunf/shaun/numbers/millions.htm
- * @var array
- */
- var $_exponent = array(
- 0 => array(''),
- 3 => array('ribu'),
- 6 => array('juta'),
- 9 => array('milyar'),
- 12 => array('trilyun'),
- 24 => array('quadrillion'),
- 30 => array('quintillion'),
- 36 => array('sextillion'),
- 42 => array('septillion'),
- 48 => array('octillion'),
- 54 => array('nonillion'),
- 60 => array('decillion'),
- 66 => array('undecillion'),
- 72 => array('duodecillion'),
- 78 => array('tredecillion'),
- 84 => array('quattuordecillion'),
- 90 => array('quindecillion'),
- 96 => array('sexdecillion'),
- 102 => array('septendecillion'),
- 108 => array('octodecillion'),
- 114 => array('novemdecillion'),
- 120 => array('vigintillion'),
- 192 => array('duotrigintillion'),
- 600 => array('centillion')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- */
- var $_digits = array(
- 0 => 'nol', 'satu', 'dua', 'tiga', 'empat',
- 'lima', 'enam', 'tujuh', 'delapan', 'sembilan'
- );
-
- /**
- * The word separator
- * @var string
- */
- var $_sep = ' ';
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in Indonesian language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Ernas M. Jamil
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 4) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = $th = 0;
-
- switch(strlen($num)) {
- case 4:
- $th = (int)substr($num,-4,1);
-
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ($th) {
- if ($th==1)
- $ret .= $this->_sep . 'seribu';
- else
- $ret .= $this->_sep . $this->_digits[$th] . $this->_sep . 'ribu';
- }
-
- if ($h) {
- if ($h==1)
- $ret .= $this->_sep . 'seratus';
- else
- $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'ratus';
-
- // in English only - add ' and' for [1-9]01..[1-9]99
- // (also for 1001..1099, 10001..10099 but it is harder)
- // for now it is switched off, maybe some language purists
- // can force me to enable it, or to remove it completely
- // if (($t + $d) > 0)
- // $ret .= $this->_sep . 'and';
- }
-
- // ten, twenty etc.
- switch ($t) {
- case 9:
- case 8:
- case 7:
- case 6:
- case 5:
- case 4:
- case 3:
- case 2:
- $ret .= $this->_sep . $this->_digits[$t] . ' puluh';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'sepuluh';
- break;
-
- case 1:
- $ret .= $this->_sep . 'sebelas';
- break;
-
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- $ret .= $this->_sep . $this->_digits[$d] . ' belas';
- break;
- }
- break;
- }
-
- if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
- // add minus sign between [2-9] and digit
- if ($t > 1) {
- $ret .= ' ' . $this->_digits[$d];
- } else {
- $ret .= $this->_sep . $this->_digits[$d];
- }
- }
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- $ret .= $this->_sep . $lev[0];
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.it_IT.php b/thirdparty/pear/Numbers/Words/lang.it_IT.php
deleted file mode 100644
index 50694f7bc..000000000
--- a/thirdparty/pear/Numbers/Words/lang.it_IT.php
+++ /dev/null
@@ -1,348 +0,0 @@
-
- * @author Davide Caironi
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Italian.
- * It supports up to quadrilions
- *
- * @author Filippo Beltramini
- * @author Davide Caironi
- * @package Numbers_Words
- */
-class Numbers_Words_it_IT extends Numbers_Words
-{
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'it_IT';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'Italian';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'Italiano';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'meno ';
-
- /**
- * The sufixes for exponents (singular and plural)
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array('',''),
- 3 => array('mille','mila'),
- 6 => array('milione','miloni'),
- 12 => array('miliardo','miliardi'),
- 18 => array('trillone','trilloni'),
- 24 => array('quadrilione','quadrilioni'),
- );
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'zero', 'uno', 'due', 'tre', 'quattro',
- 'cinque', 'sei', 'sette', 'otto', 'nove'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = '';
- // }}}
- // {{{ toWords()
- /**
- * Converts a number to its word representation
- * in italiano.
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that should be converted to a words representation
- * @param integer $power The power of ten for the rest of the number to the right.
- * For example toWords(12,3) should give "doce mil".
- * Optional, defaults to 0.
- * @return string The corresponding word representation
- *
- * @access private
- * @author Filippo Beltramini
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0)
- {
- // The return string;
- $ret = '';
-
- // add a the word for the minus sign if necessary
- if (substr($num, 0, 1) == '-')
- {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
-
- // strip excessive zero signs
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 6)
- {
- $current_power = 6;
- // check for highest power
- if (isset($this->_exponent[$power]))
- {
- // convert the number above the first 6 digits
- // with it's corresponding $power.
- $snum = substr($num, 0, -6);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $ret .= $this->toWords($snum, $power + 6);
- }
- }
- $num = substr($num, -6);
- if ($num == 0) {
- return $ret;
- }
- }
- elseif ($num == 0 || $num == '') {
- return(' '.$this->_digits[0].' ');
- $current_power = strlen($num);
- }
- else {
- $current_power = strlen($num);
- }
-
- // See if we need "thousands"
- $thousands = floor($num / 1000);
- if ($thousands == 1) {
- $ret .= $this->_sep . 'mille' . $this->_sep;
- }
- elseif ($thousands > 1) {
- $ret .= $this->toWords($thousands, 3) . $this->_sep;//. 'mil' . $this->_sep;
- }
-
- // values for digits, tens and hundreds
- $h = floor(($num / 100) % 10);
- $t = floor(($num / 10) % 10);
- $d = floor($num % 10);
-
- // centinaia: duecento, trecento, etc...
- switch ($h)
- {
- case 1:
- if (($d == 0) and ($t == 0)) { // is it's '100' use 'cien'
- $ret .= $this->_sep . 'cento';
- }
- else {
- $ret .= $this->_sep . 'cento';
- }
- break;
- case 2:
- case 3:
- case 4:
- case 6:
- case 8:
- $ret .= $this->_sep . $this->_digits[$h] . 'cento';
- break;
- case 5:
- $ret .= $this->_sep . 'cinquecento';
- break;
- case 7:
- $ret .= $this->_sep . 'settecento';
- break;
- case 9:
- $ret .= $this->_sep . 'novecento';
- break;
- }
-
- // decine: venti trenta, etc...
- switch ($t)
- {
- case 9:
- $ret .= $this->_sep . 'novanta';
- break;
-
- case 8:
- $ret .= $this->_sep . 'ottanta';
- break;
-
- case 7:
- $ret .= $this->_sep . 'settanta';
- break;
-
- case 6:
- $ret .= $this->_sep . 'sessanta';
- break;
-
- case 5:
- $ret .= $this->_sep . 'cinquanta';
- break;
-
- case 4:
- $ret .= $this->_sep . 'quaranta';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trenta';
- break;
-
- case 2:
- if ($d == 0) {
- $ret .= $this->_sep . 'venti';
- }
- else {
- if (($power > 0) and ($d == 1)) {
- $ret .= $this->_sep . 'ventuno';
- }
- else {
- $ret .= $this->_sep . 'venti' . $this->_digits[$d];
- }
- }
- break;
-
- case 1:
- switch ($d)
- {
- case 0:
- $ret .= $this->_sep . 'dieci';
- break;
-
- case 1:
- $ret .= $this->_sep . 'undici';
- break;
-
- case 2:
- $ret .= $this->_sep . 'dodici';
- break;
-
- case 3:
- $ret .= $this->_sep . 'tredici';
- break;
-
- case 4:
- $ret .= $this->_sep . 'quattordici';
- break;
-
- case 5:
- $ret .= $this->_sep . 'quindici';
- break;
-
- case 6:
- $ret .= $this->_sep . 'sedici';
- break;
-
- case 7:
- $ret .= $this->_sep . 'diciassette';
- break;
-
- case 8:
- $ret .= $this->_sep . 'diciotto';
- break;
-
- case 9:
- $ret .= $this->_sep . 'diciannove';
- break;
- }
- break;
- }
-
- // add digits only if it is a multiple of 10 and not 1x or 2x
- if (($t != 1) and ($t != 2) and ($d > 0))
- {
- if($t != 0) // don't add 'e' for numbers below 10
- {
- // use 'un' instead of 'uno' when there is a suffix ('mila', 'milloni', etc...)
- if(($power > 0) and ($d == 1)) {
- $ret .= $this->_sep.' e un';
- }
- else {
- $ret .= $this->_sep.''.$this->_digits[$d];
- }
- }
- else {
- if(($power > 0) and ($d == 1)) {
- $ret .= $this->_sep.'un ';
- }
- else {
- $ret .= $this->_sep.$this->_digits[$d];
- }
- }
- }
-
- if ($power > 0)
- {
- if (isset($this->_exponent[$power])) {
- $lev = $this->_exponent[$power];
- }
-
- if (!isset($lev) || !is_array($lev)) {
- return null;
- }
-
- // if it's only one use the singular suffix
- if (($d == 1) and ($t == 0) and ($h == 0)) {
- $suffix = $lev[0];
- }
- else {
- $suffix = $lev[1];
- }
- if ($num != 0) {
- $ret .= $this->_sep . $suffix;
- }
- }
-
- return $ret;
- }
- // }}}
-}
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.lt.php b/thirdparty/pear/Numbers/Words/lang.lt.php
deleted file mode 100644
index 48a418b2f..000000000
--- a/thirdparty/pear/Numbers/Words/lang.lt.php
+++ /dev/null
@@ -1,310 +0,0 @@
- array(''),
- 3 => array('tûkstantis','tûkstanèiai','tûkstanèiø'),
- 6 => array('milijonas','milijonai','milijonø'),
- 9 => array('bilijonas','bilijonai','bilijonø'),
- 12 => array('trilijonas','trilijonai','trilijonø'),
- 15 => array('kvadrilijonas','kvadrilijonai','kvadrilijonø'),
- 18 => array('kvintilijonas','kvintilijonai','kvintilijonø')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'nulis', 'vienas', 'du', 'trys', 'keturi',
- 'penki', 'ðeði', 'septyni', 'aðtuoni', 'devyni'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The default currency name
- * @var string
- * @access public
- */
- var $def_currency = 'LTL';
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in Lithuanian language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Laurynas Butkus
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ( $h > 1 )
- $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'ðimtai';
- elseif ( $h )
- $ret .= $this->_sep . 'ðimtas';
-
- // ten, twenty etc.
- switch ($t) {
- case 9:
- $ret .= $this->_sep . 'devyniasdeðimt';
- break;
-
- case 8:
- $ret .= $this->_sep . 'aðtuoniasdeðimt';
- break;
-
- case 7:
- $ret .= $this->_sep . 'septyniasdeðimt';
- break;
-
- case 6:
- $ret .= $this->_sep . 'ðeðiasdeðimt';
- break;
-
- case 5:
- $ret .= $this->_sep . 'penkiasdeðimt';
- break;
-
- case 4:
- $ret .= $this->_sep . 'keturiasdeðimt';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trisdeðimt';
- break;
-
- case 2:
- $ret .= $this->_sep . 'dvideðimt';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'deðimt';
- break;
-
- case 1:
- $ret .= $this->_sep . 'vienuolika';
- break;
-
- case 2:
- $ret .= $this->_sep . 'dvylika';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trylika';
- break;
-
- case 4:
- $ret .= $this->_sep . 'keturiolika';
- break;
-
- case 5:
- $ret .= $this->_sep . 'penkiolika';
- break;
-
- case 6:
- $ret .= $this->_sep . 'ðeðiolika';
- break;
-
- case 7:
- $ret .= $this->_sep . 'septyniolika';
- break;
-
- case 8:
- $ret .= $this->_sep . 'aðtuoniolika';
- break;
-
- case 9:
- $ret .= $this->_sep . 'devyniolika';
- break;
-
- }
- break;
- }
-
- if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
- if ( $d > 1 || !$power || $t )
- $ret .= $this->_sep . $this->_digits[$d];
- }
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- //echo " $t $d ";
-
- if ( $t == 1 || ( $t > 0 && $d == 0 ) )
- $ret .= $this->_sep . $lev[2];
- elseif ( $d > 1 )
- $ret .= $this->_sep . $lev[1];
- else
- $ret .= $this->_sep . $lev[0];
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
-
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.pl.php b/thirdparty/pear/Numbers/Words/lang.pl.php
deleted file mode 100644
index 54519e293..000000000
--- a/thirdparty/pear/Numbers/Words/lang.pl.php
+++ /dev/null
@@ -1,513 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.pl.php,v 1.9 2003/09/29 12:23:58 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in Polish.
-//
-
-/**
- * Class for translating numbers into Polish.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Polish.
- *
- * @author Piotr Klaban
- * @package Numbers_Words
- */
-class Numbers_Words_pl extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'pl';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'Polish';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'polski';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'minus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * Names based on:
- * mathematical tables, my memory, and also:
- * http://ux1.math.us.edu.pl/~szyjewski/FAQ/liczby/iony.htm
- * @var array
- * @access private
- */
- var $_exponent = array(
- // potêga dziesi±tki => liczba pojedyncza, podwójna, mnoga
- 0 => array('','',''),
- 3 => array('tysi±c','tysi±ce','tysiêcy'),
- 6 => array('milion','miliony','milionów'),
- 9 => array('miliard','miliardy','miliardów'),
- 12 => array('bilion','biliony','bilionów'),
- 15 => array('biliard','biliardy','biliardów'),
- 18 => array('trylion','tryliony','trylionów'),
- 21 => array('tryliard','tryliardy','tryliardów'),
- 24 => array('kwadrylion','kwadryliony','kwadrylionów'),
- 27 => array('kwadryliard','kwadryliardy','kwadryliardów'),
- 30 => array('kwintylion','kwintyliony','kwintylionów'),
- 33 => array('kwintyliiard','kwintyliardy','kwintyliardów'),
- 36 => array('sekstylion','sekstyliony','sekstylionów'),
- 39 => array('sekstyliard','sekstyliardy','sekstyliardów'),
- 42 => array('septylion','septyliony','septylionów'),
- 45 => array('septyliard','septyliardy','septyliardów'),
- 48 => array('oktylion','oktyliony','oktylionów'),
- 51 => array('oktyliard','oktyliardy','oktyliardów'),
- 54 => array('nonylion','nonyliony','nonylionów'),
- 57 => array('nonyliard','nonyliardy','nonyliardów'),
- 60 => array('decylion','decyliony','decylionów'),
- 63 => array('decyliard','decyliardy','decyliardów'),
- 100 => array('centylion','centyliony','centylionów'),
- 103 => array('centyliard','centyliardy','centyliardów'),
- 120 => array('wicylion','wicylion','wicylion'),
- 123 => array('wicyliard','wicyliardy','wicyliardów'),
- 180 => array('trycylion','trycylion','trycylion'),
- 183 => array('trycyliard','trycyliardy','trycyliardów'),
- 240 => array('kwadragilion','kwadragilion','kwadragilion'),
- 243 => array('kwadragiliard','kwadragiliardy','kwadragiliardów'),
- 300 => array('kwinkwagilion','kwinkwagilion','kwinkwagilion'),
- 303 => array('kwinkwagiliard','kwinkwagiliardy','kwinkwagiliardów'),
- 360 => array('seskwilion','seskwilion','seskwilion'),
- 363 => array('seskwiliard','seskwiliardy','seskwiliardów'),
- 420 => array('septagilion','septagilion','septagilion'),
- 423 => array('septagiliard','septagiliardy','septagiliardów'),
- 480 => array('oktogilion','oktogilion','oktogilion'),
- 483 => array('oktogiliard','oktogiliardy','oktogiliardów'),
- 540 => array('nonagilion','nonagilion','nonagilion'),
- 543 => array('nonagiliard','nonagiliardy','nonagiliardów'),
- 600 => array('centylion','centyliony','centylionów'),
- 603 => array('centyliard','centyliardy','centyliardów'),
- 6000018 => array('milinilitrylion','milinilitryliony','milinilitrylionów')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'zero', 'jeden', 'dwa', 'trzy', 'cztery',
- 'piêæ', 'sze¶æ', 'siedem', 'osiem', 'dziewiêæ'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The currency names (based on the below links,
- * informations from central bank websites and on encyclopedias)
- *
- * @var array
- * @link http://www.xe.com/iso4217.htm Currency codes
- * @link http://www.republika.pl/geographia/peuropy.htm Europe review
- * @link http://pieniadz.hoga.pl/waluty_objasnienia.asp Currency service
- * @access private
- */
- var $_currency_names = array(
- 'ALL' => array(array('lek','leki','leków'), array('quindarka','quindarki','quindarek')),
- 'AUD' => array(array('dolar australijski', 'dolary australijskie', 'dolarów australijskich'), array('cent', 'centy', 'centów')),
- 'BAM' => array(array('marka','marki','marek'), array('fenig','fenigi','fenigów')),
- 'BGN' => array(array('lew','lewy','lew'), array('stotinka','stotinki','stotinek')),
- 'BRL' => array(array('real','reale','realów'), array('centavos','centavos','centavos')),
- 'BYR' => array(array('rubel','ruble','rubli'), array('kopiejka','kopiejki','kopiejek')),
- 'CAD' => array(array('dolar kanadyjski', 'dolary kanadyjskie', 'dolarów kanadyjskich'), array('cent', 'centy', 'centów')),
- 'CHF' => array(array('frank szwajcarski','franki szwajcarskie','franków szwajcarskich'), array('rapp','rappy','rappów')),
- 'CYP' => array(array('funt cypryjski','funty cypryjskie','funtów cypryjskich'), array('cent', 'centy', 'centów')),
- 'CZK' => array(array('korona czeska','korony czeskie','koron czeskich'), array('halerz','halerze','halerzy')),
- 'DKK' => array(array('korona duñska','korony duñskie','koron duñskich'), array('ore','ore','ore')),
- 'EEK' => array(array('korona estoñska','korony estoñskie','koron estoñskich'), array('senti','senti','senti')),
- 'EUR' => array(array('euro', 'euro', 'euro'), array('eurocent', 'eurocenty', 'eurocentów')),
- 'GBP' => array(array('funt szterling','funty szterlingi','funtów szterlingów'), array('pens','pensy','pensów')),
- 'HKD' => array(array('dolar Hongkongu','dolary Hongkongu','dolarów Hongkongu'), array('cent', 'centy', 'centów')),
- 'HRK' => array(array('kuna','kuny','kun'), array('lipa','lipy','lip')),
- 'HUF' => array(array('forint','forinty','forintów'), array('filler','fillery','fillerów')),
- 'ISK' => array(array('korona islandzka','korony islandzkie','koron islandzkich'), array('aurar','aurar','aurar')),
- 'JPY' => array(array('jen','jeny','jenów'), array('sen','seny','senów')),
- 'LTL' => array(array('lit','lity','litów'), array('cent', 'centy', 'centów')),
- 'LVL' => array(array('³at','³aty','³atów'), array('sentim','sentimy','sentimów')),
- 'MKD' => array(array('denar','denary','denarów'), array('deni','deni','deni')),
- 'MTL' => array(array('lira maltañska','liry maltañskie','lir maltañskich'), array('centym','centymy','centymów')),
- 'NOK' => array(array('korona norweska','korony norweskie','koron norweskich'), array('oere','oere','oere')),
- 'PLN' => array(array('z³oty', 'z³ote', 'z³otych'), array('grosz', 'grosze', 'groszy')),
- 'ROL' => array(array('lej','leje','lei'), array('bani','bani','bani')),
- 'RUB' => array(array('rubel','ruble','rubli'), array('kopiejka','kopiejki','kopiejek')),
- 'SEK' => array(array('korona szwedzka','korony szwedzkie','koron szweckich'), array('oere','oere','oere')),
- 'SIT' => array(array('tolar','tolary','tolarów'), array('stotinia','stotinie','stotini')),
- 'SKK' => array(array('korona s³owacka','korony s³owackie','koron s³owackich'), array('halerz','halerze','halerzy')),
- 'TRL' => array(array('lira turecka','liry tureckie','lir tureckich'), array('kurusza','kurysze','kuruszy')),
- 'UAH' => array(array('hrywna','hrywna','hrywna'), array('cent', 'centy', 'centów')),
- 'USD' => array(array('dolar','dolary','dolarów'), array('cent', 'centy', 'centów')),
- 'YUM' => array(array('dinar','dinary','dinarów'), array('para','para','para')),
- 'ZAR' => array(array('rand','randy','randów'), array('cent', 'centy', 'centów'))
- );
-
- /**
- * The default currency name
- * @var string
- * @access public
- */
- var $def_currency = 'PLN'; // Polish zloty
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in Polish language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Piotr Klaban
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- switch ($h) {
- case 9:
- $ret .= $this->_sep . 'dziewiêæset';
- break;
-
- case 8:
- $ret .= $this->_sep . 'osiemset';
- break;
-
- case 7:
- $ret .= $this->_sep . 'siedemset';
- break;
-
- case 6:
- $ret .= $this->_sep . 'sze¶æset';
- break;
-
- case 5:
- $ret .= $this->_sep . 'piêæset';
- break;
-
- case 4:
- $ret .= $this->_sep . 'czterysta';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trzysta';
- break;
-
- case 2:
- $ret .= $this->_sep . 'dwie¶cie';
- break;
-
- case 1:
- $ret .= $this->_sep . 'sto';
- break;
- }
-
- switch ($t) {
- case 9:
- case 8:
- case 7:
- case 6:
- case 5:
- $ret .= $this->_sep . $this->_digits[$t] . 'dziesi±t';
- break;
-
- case 4:
- $ret .= $this->_sep . 'czterdzie¶ci';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trzydzie¶ci';
- break;
-
- case 2:
- $ret .= $this->_sep . 'dwadzie¶cia';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'dziesiêæ';
- break;
-
- case 1:
- $ret .= $this->_sep . 'jedena¶cie';
- break;
-
- case 2:
- case 3:
- case 7:
- case 8:
- $ret .= $this->_sep . $this->_digits[$d] . 'na¶cie';
- break;
-
- case 4:
- $ret .= $this->_sep . 'czterna¶cie';
- break;
-
- case 5:
- $ret .= $this->_sep . 'piêtna¶cie';
- break;
-
- case 6:
- $ret .= $this->_sep . 'szesna¶cie';
- break;
-
- case 9:
- $ret .= $this->_sep . 'dziewiêtna¶cie';
- break;
- }
- break;
- }
-
- if ($t != 1 && $d > 0)
- $ret .= $this->_sep . $this->_digits[$d];
-
- if ($t == 1)
- $d = 0;
-
- if (( $h + $t ) > 0 && $d == 1)
- $d = 0;
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- switch ($d) {
- case 1:
- $suf = $lev[0];
- break;
- case 2:
- case 3:
- case 4:
- $suf = $lev[1];
- break;
- case 0:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- $suf = $lev[2];
- break;
- }
- $ret .= $this->_sep . $suf;
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
- // {{{ toCurrency()
-
- /**
- * Converts a currency value to its word representation
- * (with monetary units) in Polish language
- *
- * @param integer $int_curr An international currency symbol
- * as defined by the ISO 4217 standard (three characters)
- * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars)
- * @param integer $fraction Fractional part of the money amount (e.g. amount of cents)
- * Optional. Defaults to false.
- *
- * @return string The corresponding word representation for the currency
- *
- * @access public
- * @author Piotr Klaban
- * @since Numbers_Words 0.4
- */
- function toCurrencyWords($int_curr, $decimal, $fraction = false) {
- $int_curr = strtoupper($int_curr);
- if (!isset($this->_currency_names[$int_curr])) {
- $int_curr = $this->def_currency;
- }
- $curr_names = $this->_currency_names[$int_curr];
- $ret = trim($this->toWords($decimal));
- $lev = $this->_get_numlevel($decimal);
- $ret .= $this->_sep . $curr_names[0][$lev];
-
- if ($fraction !== false) {
- $ret .= $this->_sep . trim($this->toWords($fraction));
- $lev = $this->_get_numlevel($fraction);
- $ret .= $this->_sep . $curr_names[1][$lev];
- }
- return $ret;
- }
- // }}}
- // {{{ _get_numlevel()
-
- /**
- * Returns grammatical "level" of the number - this is necessary
- * for choosing the right suffix for exponents and currency names.
- *
- * @param integer $num An integer between -infinity and infinity inclusive
- * that need to be converted to words
- *
- * @return integer The grammatical "level" of the number.
- *
- * @access private
- * @author Piotr Klaban
- * @since Numbers_Words 0.4
- */
- function _get_numlevel($num) {
- $num = (int)substr($num,-3);
- $h = $t = $d = $lev = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return $lev;
- break;
- }
- if ($t == 1)
- $d = 0;
-
- if (( $h + $t ) > 0 && $d == 1)
- $d = 0;
-
- switch ($d) {
- case 1:
- $lev = 0;
- break;
- case 2:
- case 3:
- case 4:
- $lev = 1;
- break;
- default:
- $lev = 2;
- }
- return $lev;
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.pt_BR.php b/thirdparty/pear/Numbers/Words/lang.pt_BR.php
deleted file mode 100644
index 665afe092..000000000
--- a/thirdparty/pear/Numbers/Words/lang.pt_BR.php
+++ /dev/null
@@ -1,241 +0,0 @@
- |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.pt_BR.php,v 1.6 2003/09/29 12:23:58 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in Brazilian Portuguese language.
-//
-
-
-/**
- * Class for translating numbers into Brazilian Portuguese.
- *
- * @author Marcelo Subtil Marcal
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once "Numbers/Words.php";
-
-/**
- * Class for translating numbers into Brazilian Portuguese.
- *
- * @author Marcelo Subtil Marcal
- * @package Numbers_Words
- */
-class Numbers_Words_pt_BR extends Numbers_Words
-{
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'pt_BR';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'Brazilian Portuguese';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'Português Brasileiro';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'menos';
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_unidade = array(
- '',
- 'um',
- 'dois',
- 'três',
- 'quatro',
- 'cinco',
- 'seis',
- 'sete',
- 'oito',
- 'nove'
- );
-
- /**
- * The array containing numbers 10-19.
- * @var array
- * @access private
- */
- var $_dezena10 = array(
- 'dez',
- 'onze',
- 'doze',
- 'treze',
- 'quatorze',
- 'quinze',
- 'dezesseis',
- 'dezessete',
- 'dezoito',
- 'dezenove'
- );
-
- /**
- * The array containing numbers for 10,20,...,90.
- * @var array
- * @access private
- */
- var $_dezena = array(
- '',
- 'dez',
- 'vinte',
- 'trinta',
- 'quarenta',
- 'cinquenta',
- 'sessenta',
- 'setenta',
- 'oitenta',
- 'noventa'
- );
-
- /**
- * The array containing numbers for hundrets.
- * @var array
- * @access private
- */
- var $_centena = array(
- '',
- 'cem',
- 'duzentos',
- 'trezentos',
- 'quatrocentos',
- 'quinhentos',
- 'seiscentos',
- 'setecentos',
- 'oitocentos',
- 'novecentos'
- );
-
- /**
- * The sufixes for exponents (singular and plural)
- * @var array
- * @access private
- */
- var $_expoente = array(
- '',
- 'mil',
- 'milhão',
- 'bilhão',
- 'trilhão',
- 'quatrilhão',
- 'quintilhão',
- 'sextilhão',
- 'setilhão',
- 'octilhão',
- 'nonilhão',
- 'decilhão',
- 'undecilhão',
- 'dodecilhão',
- 'tredecilhão',
- 'quatuordecilhão',
- 'quindecilhão',
- 'sedecilhão',
- 'septendecilhão'
- );
-
-
-
- /**
- * Converts a number to its word representation
- * in Brazilian Portuguese language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- *
- * @return string The corresponding word representation
- *
- * @access public
- * @author Marcelo Subtil Marcal
- * @since PHP 4.2.3
- */
- function toWords($num) {
-
- $ret = '';
-
- $num = trim($num);
-
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- while (strlen($num) % 3 != 0) {
- $num = "0" . $num;
- }
-
- $num = ereg_replace("(...)", "\\1.", $num);
- $num = ereg_replace("\.$", "", $num);
-
- $inteiro = explode(".", $num);
-
- for ($i = 0; $i < count($inteiro); $i++) {
- $ret .= (($inteiro[$i] > 100) && ($inteiro[$i] < 200)) ? "cento" : $this->_centena[$inteiro[$i][0]];
- $ret .= ($inteiro[$i][0] && ($inteiro[$i][1] || $inteiro[$i][2])) ? " e " : "";
- $ret .= ($inteiro[$i][1] < 2) ? "" : $this->_dezena[$inteiro[$i][1]];
- $ret .= (($inteiro[$i][1] > 1) && ($inteiro[$i][2])) ? " e " : "";
- $ret .= ($inteiro > 0) ? ( ($inteiro[$i][1] == 1) ? $this->_dezena10[$inteiro[$i][2]] : $this->_unidade[$inteiro[$i][2]] ) : "";
- $ret .= $inteiro[$i] > 0 ? " " . ($inteiro[$i] > 1 ? str_replace("ão", "ões", $this->_expoente[count($inteiro)-1-$i]) : $this->_expoente[count($inteiro)-1-$i]) : "";
-
- if ($ret && (isset($inteiro[$i+1]))) {
- if ($inteiro[$i+1] != "000") {
- $ret .= ($i+1) == (count($inteiro)-1) ? " e " : ", ";
- }
- }
-
- }
-
- return $ret ? " $ret" : " zero";
-
- }
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.ru.php b/thirdparty/pear/Numbers/Words/lang.ru.php
deleted file mode 100644
index 28735326a..000000000
--- a/thirdparty/pear/Numbers/Words/lang.ru.php
+++ /dev/null
@@ -1,616 +0,0 @@
- |
-// | Andrey Demenev |
-// +----------------------------------------------------------------------+
-//
-// $Id: $
-//
-// Numbers_Words class extension to spell numbers in Russian language.
-//
-
-/**
- * Class for translating numbers into Russian.
- *
- * @author Andrey Demenev
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Russian.
- *
- * @author Andrey Demenev
- * @package Numbers_Words
- */
-class Numbers_Words_ru extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'ru';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'Russian';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'Ðóññêèé';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'ìèíóñ'; // minus sign
-
- /**
- * The sufixes for exponents (singular)
- * Names partly based on:
- * http://home.earthlink.net/~mrob/pub/math/largenum.html
- * http://mathforum.org/dr.math/faq/faq.large.numbers.html
- * http://www.mazes.com/AmericanNumberingSystem.html
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => '',
- 6 => 'ìèëëèîí',
- 9 => 'ìèëëèàðä',
- 12 => 'òðèëëèîí',
- 15 => 'êâàäðèëëèîí',
- 18 => 'êâèíòèëëèîí',
- 21 => 'ñåêñòèëëèîí',
- 24 => 'ñåïòèëëèîí',
- 27 => 'îêòèëëèîí',
- 30 => 'íîíèëëèîí',
- 33 => 'äåöèëëèîí',
- 36 => 'óíäåöèëëèîí',
- 39 => 'äóîäåöèëëèîí',
- 42 => 'òðåäåöèëëèîí',
- 45 => 'êâàòóîðäåöèëëèîí',
- 48 => 'êâèíäåöèëëèîí',
- 51 => 'ñåêñäåöèëëèîí',
- 54 => 'ñåïòåíäåöèëëèîí',
- 57 => 'îêòîäåöèëëèîí',
- 60 => 'íîâåìäåöèëëèîí',
- 63 => 'âèãèíòèëëèîí',
- 66 => 'óíâèãèíòèëëèîí',
- 69 => 'äóîâèãèíòèëëèîí',
- 72 => 'òðåâèãèíòèëëèîí',
- 75 => 'êâàòóîðâèãèíòèëëèîí',
- 78 => 'êâèíâèãèíòèëëèîí',
- 81 => 'ñåêñâèãèíòèëëèîí',
- 84 => 'ñåïòåíâèãèíòèëëèîí',
- 87 => 'îêòîâèãèíòèëëèîí',
- 90 => 'íîâåìâèãèíòèëëèîí',
- 93 => 'òðèãèíòèëëèîí',
- 96 => 'óíòðèãèíòèëëèîí',
- 99 => 'äóîòðèãèíòèëëèîí',
- 102 => 'òðåòðèãèíòèëëèîí',
- 105 => 'êâàòîðòðèãèíòèëëèîí',
- 108 => 'êâèíòðèãèíòèëëèîí',
- 111 => 'ñåêñòðèãèíòèëëèîí',
- 114 => 'ñåïòåíòðèãèíòèëëèîí',
- 117 => 'îêòîòðèãèíòèëëèîí',
- 120 => 'íîâåìòðèãèíòèëëèîí',
- 123 => 'êâàäðàãèíòèëëèîí',
- 126 => 'óíêâàäðàãèíòèëëèîí',
- 129 => 'äóîêâàäðàãèíòèëëèîí',
- 132 => 'òðåêâàäðàãèíòèëëèîí',
- 135 => 'êâàòîðêâàäðàãèíòèëëèîí',
- 138 => 'êâèíêâàäðàãèíòèëëèîí',
- 141 => 'ñåêñêâàäðàãèíòèëëèîí',
- 144 => 'ñåïòåíêâàäðàãèíòèëëèîí',
- 147 => 'îêòîêâàäðàãèíòèëëèîí',
- 150 => 'íîâåìêâàäðàãèíòèëëèîí',
- 153 => 'êâèíêâàãèíòèëëèîí',
- 156 => 'óíêâèíêàãèíòèëëèîí',
- 159 => 'äóîêâèíêàãèíòèëëèîí',
- 162 => 'òðåêâèíêàãèíòèëëèîí',
- 165 => 'êâàòîðêâèíêàãèíòèëëèîí',
- 168 => 'êâèíêâèíêàãèíòèëëèîí',
- 171 => 'ñåêñêâèíêàãèíòèëëèîí',
- 174 => 'ñåïòåíêâèíêàãèíòèëëèîí',
- 177 => 'îêòîêâèíêàãèíòèëëèîí',
- 180 => 'íîâåìêâèíêàãèíòèëëèîí',
- 183 => 'ñåêñàãèíòèëëèîí',
- 186 => 'óíñåêñàãèíòèëëèîí',
- 189 => 'äóîñåêñàãèíòèëëèîí',
- 192 => 'òðåñåêñàãèíòèëëèîí',
- 195 => 'êâàòîðñåêñàãèíòèëëèîí',
- 198 => 'êâèíñåêñàãèíòèëëèîí',
- 201 => 'ñåêññåêñàãèíòèëëèîí',
- 204 => 'ñåïòåíñåêñàãèíòèëëèîí',
- 207 => 'îêòîñåêñàãèíòèëëèîí',
- 210 => 'íîâåìñåêñàãèíòèëëèîí',
- 213 => 'ñåïòàãèíòèëëèîí',
- 216 => 'óíñåïòàãèíòèëëèîí',
- 219 => 'äóîñåïòàãèíòèëëèîí',
- 222 => 'òðåñåïòàãèíòèëëèîí',
- 225 => 'êâàòîðñåïòàãèíòèëëèîí',
- 228 => 'êâèíñåïòàãèíòèëëèîí',
- 231 => 'ñåêññåïòàãèíòèëëèîí',
- 234 => 'ñåïòåíñåïòàãèíòèëëèîí',
- 237 => 'îêòîñåïòàãèíòèëëèîí',
- 240 => 'íîâåìñåïòàãèíòèëëèîí',
- 243 => 'îêòîãèíòèëëèîí',
- 246 => 'óíîêòîãèíòèëëèîí',
- 249 => 'äóîîêòîãèíòèëëèîí',
- 252 => 'òðåîêòîãèíòèëëèîí',
- 255 => 'êâàòîðîêòîãèíòèëëèîí',
- 258 => 'êâèíîêòîãèíòèëëèîí',
- 261 => 'ñåêñîêòîãèíòèëëèîí',
- 264 => 'ñåïòîêòîãèíòèëëèîí',
- 267 => 'îêòîîêòîãèíòèëëèîí',
- 270 => 'íîâåìîêòîãèíòèëëèîí',
- 273 => 'íîíàãèíòèëëèîí',
- 276 => 'óííîíàãèíòèëëèîí',
- 279 => 'äóîíîíàãèíòèëëèîí',
- 282 => 'òðåíîíàãèíòèëëèîí',
- 285 => 'êâàòîðíîíàãèíòèëëèîí',
- 288 => 'êâèííîíàãèíòèëëèîí',
- 291 => 'ñåêñíîíàãèíòèëëèîí',
- 294 => 'ñåïòåííîíàãèíòèëëèîí',
- 297 => 'îêòîíîíàãèíòèëëèîí',
- 300 => 'íîâåìíîíàãèíòèëëèîí',
- 303 => 'öåíòèëëèîí'
- );
-
- /**
- * The array containing the teens' :) names
- * @var array
- * @access private
- */
- var $_teens = array(
- 11=>'îäèííàäöàòü',
- 12=>'äâåíàäöàòü',
- 13=>'òðèíàäöàòü',
- 14=>'÷åòûðíàäöàòü',
- 15=>'ïÿòíàäöàòü',
- 16=>'øåñòíàäöàòü',
- 17=>'ñåìíàäöàòü',
- 18=>'âîñåìíàäöàòü',
- 19=>'äåâÿòíàäöàòü'
- );
-
- /**
- * The array containing the tens' names
- * @var array
- * @access private
- */
- var $_tens = array(
- 2=>'äâàäöàòü',
- 3=>'òðèäöàòü',
- 4=>'ñîðîê',
- 5=>'ïÿòüäåñÿò',
- 6=>'øåñòüäåñÿò',
- 7=>'ñåìüäåñÿò',
- 8=>'âîñåìüäåñÿò',
- 9=>'äåâÿíîñòî'
- );
-
- /**
- * The array containing the hundreds' names
- * @var array
- * @access private
- */
- var $_hundreds = array(
- 1=>'ñòî',
- 2=>'äâåñòè',
- 3=>'òðèñòà',
- 4=>'÷åûðåñòà',
- 5=>'ïÿòüñîò',
- 6=>'øåñòüñîò',
- 7=>'ñåìüñîò',
- 8=>'âîñåìüñîò',
- 9=>'äåâÿòüñîò'
- );
-
- /**
- * The array containing the digits
- * for neutral, male and female
- * @var array
- * @access private
- */
- var $_digits = array(
- array('íîëü', 'îäíî', 'äâà', 'òðè', '÷åòûðå','ïÿòü', 'øåñòü', 'ñåìü', 'âîñåìü', 'äåâÿòü'),
- array('íîëü', 'îäèí', 'äâà', 'òðè', '÷åòûðå','ïÿòü', 'øåñòü', 'ñåìü', 'âîñåìü', 'äåâÿòü'),
- array('íîëü', 'îäíà', 'äâå', 'òðè', '÷åòûðå','ïÿòü', 'øåñòü', 'ñåìü', 'âîñåìü', 'äåâÿòü')
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = ' ';
-
- /**
- * The currency names (based on the below links,
- * informations from central bank websites and on encyclopedias)
- *
- * @var array
- * @link http://www.jhall.demon.co.uk/currency/by_abbrev.html World currencies
- * @link http://www.rusimpex.ru/Content/Reference/Refinfo/valuta.htm Foreign currencies names
- * @link http://www.cofe.ru/Finance/money.asp Currencies names
- * @access private
- */
- var $_currency_names = array(
- 'ALL' => array(
- array(1,'ëåê','ëåêà','ëåêîâ'),
- array(2,'êèíäàðêà','êèíäàðêè','êèíäàðîê')
- ),
- 'AUD' => array(
- array(1,'àâñòðàëèéñêèé äîëëàð','àâñòðàëèéñêèõ äîëëàðà','àâñòðàëèéñêèõ äîëëàðîâ'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- ),
- 'BGN' => array(
- array(1,'ëåâ','ëåâà','ëåâîâ'),
- array(2,'ñòîòèíêà','ñòîòèíêè','ñòîòèíîê')
- ),
- 'BRL' => array(
- array(1,'áðàçèëüñêèé ðåàë','áðàçèëüñêèõ ðåàëà','áðàçèëüñêèõ ðåàëîâ'),
- array(1,'ñåíòàâî','ñåíòàâî','ñåíòàâî')
- ),
- 'BYR' => array(
- array(1,'áåëîðóññêèé ðóáëü','áåëîðóññêèõ ðóáëÿ','áåëîðóññêèõ ðóáëåé'),
- array(2,'êîïåéêà','êîïåéêè','êîïååê')
- ),
- 'CAD' => array(
- array(1,'êàíàäñêèé äîëëàð','êàíàäñêèõ äîëëàðà','êàíàäñêèõ äîëëàðîâ'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- ),
- 'CHF' => array(
- array(1,'øâåéöàðñêèé ôðàíê','øâåéöàðñêèõ ôðàíêà','øâåéöàðñêèõ ôðàíêîâ'),
- array(1,'ñàíòèì','ñàíòèìà','ñàíòèìîâ')
- ),
- 'CYP' => array(
- array(1,'êèïðñêèé ôóíò','êèïðñêèõ ôóíòà','êèïðñêèõ ôóíòîâ'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- ),
- 'CZK' => array(
- array(2,'÷åøñêàÿ êðîíà','÷åøñêèõ êðîíû','÷åøñêèõ êðîí'),
- array(1,'ãàëèðæ','ãàëèðæà','ãàëèðæåé')
- ),
- 'DKK' => array(
- array(2,'äàòñêàÿ êðîíà','äàòñêèõ êðîíû','äàòñêèõ êðîí'),
- array(1,'ýðå','ýðå','ýðå')
- ),
- 'EEK' => array(
- array(2,'ýñòîíñêàÿ êðîíà','ýñòîíñêèõ êðîíû','ýñòîíñêèõ êðîí'),
- array(1,'ñåíòè','ñåíòè','ñåíòè')
- ),
- 'EUR' => array(
- array(1,'åâðî','åâðî','åâðî'),
- array(1,'åâðîöåíò','åâðîöåíòà','åâðîöåíòîâ')
- ),
- 'CYP' => array(
- array(1,'ôóíò ñòåðëèíãîâ','ôóíòà ñòåðëèíãîâ','ôóíòîâ ñòåðëèíãîâ'),
- array(1,'ïåíñ','ïåíñà','ïåíñîâ')
- ),
- 'CAD' => array(
- array(1,'ãîíêîíãñêèé äîëëàð','ãîíêîíãñêèõ äîëëàðà','ãîíêîíãñêèõ äîëëàðîâ'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- ),
- 'HRK' => array(
- array(2,'õîðâàòñêàÿ êóíà','õîðâàòñêèõ êóíû','õîðâàòñêèõ êóí'),
- array(2,'ëèïà','ëèïû','ëèï')
- ),
- 'HUF' => array(
- array(1,'âåíãåðñêèé ôîðèíò','âåíãåðñêèõ ôîðèíòà','âåíãåðñêèõ ôîðèíòîâ'),
- array(1,'ôèëëåð','ôèëëåðà','ôèëëåðîâ')
- ),
- 'ISK' => array(
- array(2,'èñëàíäñêàÿ êðîíà','èñëàíäñêèõ êðîíû','èñëàíäñêèõ êðîí'),
- array(1,'ýðå','ýðå','ýðå')
- ),
- 'JPY' => array(
- array(2,'èåíà','èåíû','èåí'),
- array(2,'ñåíà','ñåíû','ñåí')
- ),
- 'LTL' => array(
- array(1,'ëèò','ëèòà','ëèòîâ'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- ),
- 'LVL' => array(
- array(1,'ëàò','ëàòà','ëàòîâ'),
- array(1,'ñåíòèì','ñåíòèìà','ñåíòèìîâ')
- ),
- 'MKD' => array(
- array(1,'ìàêåäîíñêèé äèíàð','ìàêåäîíñêèõ äèíàðà','ìàêåäîíñêèõ äèíàðîâ'),
- array(1,'äåíè','äåíè','äåíè')
- ),
- 'MTL' => array(
- array(2,'ìàëüòèéñêàÿ ëèðà','ìàëüòèéñêèõ ëèðû','ìàëüòèéñêèõ ëèð'),
- array(1,'ñåíòèì','ñåíòèìà','ñåíòèìîâ')
- ),
- 'NOK' => array(
- array(2,'íîðâåæñêàÿ êðîíà','íîðâåæñêèõ êðîíû','íîðâåæñêèõ êðîí'),
- array(0,'ýðå','ýðå','ýðå')
- ),
- 'PLN' => array(
- array(1,'çëîòûé','çëîòûõ','çëîòûõ'),
- array(1,'ãðîø','ãðîøà','ãðîøåé')
- ),
- 'ROL' => array(
- array(1,'ðóìûíñêèé ëåé','ðóìûíñêèõ ëåé','ðóìûíñêèõ ëåé'),
- array(1,'áàíè','áàíè','áàíè')
- ),
- // both RUR and RUR are used, I use RUB for shorter form
- 'RUB' => array(
- array(1,'ðóáëü','ðóáëÿ','ðóáëåé'),
- array(2,'êîïåéêà','êîïåéêè','êîïååê')
- ),
- 'RUR' => array(
- array(1,'ðîññèéñêèé ðóáëü','ðîññèéñêèõ ðóáëÿ','ðîññèéñêèõ ðóáëåé'),
- array(2,'êîïåéêà','êîïåéêè','êîïååê')
- ),
- 'SEK' => array(
- array(2,'øâåäñêàÿ êðîíà','øâåäñêèõ êðîíû','øâåäñêèõ êðîí'),
- array(1,'ýðå','ýðå','ýðå')
- ),
- 'SIT' => array(
- array(1,'ñëîâåíñêèé òîëàð','ñëîâåíñêèõ òîëàðà','ñëîâåíñêèõ òîëàðîâ'),
- array(2,'ñòîòèíà','ñòîòèíû','ñòîòèí')
- ),
- 'SKK' => array(
- array(2,'ñëîâàöêàÿ êðîíà','ñëîâàöêèõ êðîíû','ñëîâàöêèõ êðîí'),
- array(0,'','','')
- ),
- 'TRL' => array(
- array(2,'òóðåöêàÿ ëèðà','òóðåöêèõ ëèðû','òóðåöêèõ ëèð'),
- array(1,'ïèàñòð','ïèàñòðà','ïèàñòðîâ')
- ),
- 'UAH' => array(
- array(2,'ãðèâíà','ãðèâíû','ãðèâåí'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- ),
- 'USD' => array(
- array(1,'äîëëàð ÑØÀ','äîëëàðà ÑØÀ','äîëëàðîâ ÑØÀ'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- ),
- 'YUM' => array(
- array(1,'þãîñëàâñêèé äèíàð','þãîñëàâñêèõ äèíàðà','þãîñëàâñêèõ äèíàðîâ'),
- array(1,'ïàðà','ïàðà','ïàðà')
- ),
- 'ZAR' => array(
- array(1,'ðàíä','ðàíäà','ðàíäîâ'),
- array(1,'öåíò','öåíòà','öåíòîâ')
- )
- );
-
- /**
- * The default currency name
- * @var string
- * @access public
- */
- var $def_currency = 'RUB'; // Russian rouble
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in Russian language
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $gender Gender of string, 0=neutral, 1=male, 2=female.
- * Optional, defaults to 1.
- *
- * @return string The corresponding word representation
- *
- * @access private
- * @author Andrey Demenev
- */
- function toWords($num, $gender = 1)
- {
- return $this->_toWordsWithCase($num, $dummy, $gender);
- }
-
- /**
- * Converts a number to its word representation
- * in Russian language and determines the case of string.
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $case A variable passed by reference which is set to case
- * of the word associated with the number
- * @param integer $gender Gender of string, 0=neutral, 1=male, 2=female.
- * Optional, defaults to 1.
- *
- * @return string The corresponding word representation
- *
- * @access private
- * @author Andrey Demenev
- */
- function _toWordsWithCase($num, &$case, $gender = 1)
- {
- $ret = '';
- $case = 3;
-
- $num = trim($num);
-
- $sign = "";
- if (substr($num, 0, 1) == '-') {
- $sign = $this->_minus . $this->_sep;
- $num = substr($num, 1);
- }
-
- while (strlen($num) % 3) $num = '0' . $num;
- if ($num == 0 || $num == '') {
- $ret .= $this->_digits[$gender][0];
- }
-
- else {
- $power = 0;
- while ($power < strlen($num)) {
- if (!$power) {
- $groupgender = $gender;
- } elseif ($power == 3) {
- $groupgender = 2;
- } else {
- $groupgender = 1;
- }
- $group = $this->_groupToWords(substr($num,-$power-3,3),$groupgender,$_case);
- if (!$power) {
- $case = $_case;
- }
- if ($power == 3) {
- if ($_case == 1) {
- $group .= $this->_sep . 'òûñÿ÷à';
- } elseif ($_case == 2) {
- $group .= $this->_sep . 'òûñÿ÷è';
- } else {
- $group .= $this->_sep . 'òûñÿ÷';
- }
- } elseif ($group && $power>3 && isset($this->_exponent[$power])) {
- $group .= $this->_sep . $this->_exponent[$power];
- if ($_case == 2) {
- $group .= 'à';
- } elseif ($_case == 3) {
- $group .= 'îâ';
- }
- }
- if ($group) {
- $ret = $group . $this->_sep . $ret;
- }
- $power+=3;
- }
- }
-
- return $sign . $ret;
- }
-
- // }}}
- // {{{ _groupToWords()
-
- /**
- * Converts a group of 3 digits to its word representation
- * in Russian language.
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $gender Gender of string, 0=neutral, 1=male, 2=female.
- * @param integer $case A variable passed by reference which is set to case
- * of the word associated with the number
- *
- * @return string The corresponding word representation
- *
- * @access private
- * @author Andrey Demenev
- */
- function _groupToWords($num, $gender, &$case)
- {
- $ret = '';
- $case = 3;
- if ((int)$num == 0) {
- $ret = '';
- } elseif ($num < 10) {
- $ret = $this->_digits[$gender][(int)$num];
- if ($num == 1) $case = 1;
- elseif ($num < 5) $case = 2;
- else $case = 3;
- } else {
- $num = str_pad($num,3,'0',STR_PAD_LEFT);
- $hundreds = (int)$num{0};
- if ($hundreds) {
- $ret = $this->_hundreds[$hundreds];
- if (substr($num,1) != '00') {
- $ret .= $this->_sep;
- }
- $case = 3;
- }
- $tens=(int)$num{1};
- $ones=(int)$num{2};
- if ($tens || $ones) {
- if ($tens == 1 && $ones == 0) $ret .= 'äåñÿòü';
- elseif ($tens < 2) $ret .= $this->_teens[$ones+10];
- else {
- $ret .= $this->_tens[(int)$tens];
- if ($ones > 0) {
- $ret .= $this->_sep
- .$this->_digits[$gender][$ones];
- if ($ones == 1) {
- $case = 1;
- } elseif ($ones < 5) {
- $case = 2;
- } else {
- $case = 3;
- }
- }
- }
- }
- }
- return $ret;
- }
- // }}}
- // {{{ toCurrencyWords()
-
- /**
- * Converts a currency value to its word representation
- * (with monetary units) in Russian language
- *
- * @param integer $int_curr An international currency symbol
- * as defined by the ISO 4217 standard (three characters)
- * @param integer $decimal A money total amount without fraction part (e.g. amount of dollars)
- * @param integer $fraction Fractional part of the money amount (e.g. amount of cents)
- * Optional. Defaults to false.
- *
- * @return string The corresponding word representation for the currency
- *
- * @access public
- * @author Andrey Demenev
- */
- function toCurrencyWords($int_curr, $decimal, $fraction = false)
- {
- $int_curr = strtoupper($int_curr);
- if (!isset($this->_currency_names[$int_curr])) {
- $int_curr = $this->def_currency;
- }
- $curr_names = $this->_currency_names[$int_curr];
- $ret = trim($this->_toWordsWithCase($decimal, $case, 0, '', $curr_names[0][0]));
- $ret .= $this->_sep . $curr_names[0][$case];
-
- if ($fraction !== false) {
- $ret .= $this->_sep . trim($this->_toWordsWithCase($fraction, $case, 0, '', $curr_names[1][0]));
- $ret .= $this->_sep . $curr_names[1][$case];
- }
- return $ret;
- }
- // }}}
-
-}
-
-?>
diff --git a/thirdparty/pear/Numbers/Words/lang.sv.php b/thirdparty/pear/Numbers/Words/lang.sv.php
deleted file mode 100644
index ac8024805..000000000
--- a/thirdparty/pear/Numbers/Words/lang.sv.php
+++ /dev/null
@@ -1,310 +0,0 @@
- |
-// | Robin Ericsson |
-// +----------------------------------------------------------------------+
-//
-// $Id: lang.de.php,v 1.1.1.1 2004/03/10 10:33:10 makler Exp $
-//
-// Numbers_Words class extension to spell numbers in Swedish language.
-//
-
-/**
- *
- * Class for translating numbers into Swedish.
- * @author Robin Ericsson
- * @package Numbers_Words
- */
-
-/**
- * Include needed files
- */
-require_once("Numbers/Words.php");
-
-/**
- * Class for translating numbers into Swedish.
- *
- * @author Robin Ericsson
- * @package Numbers_Words
- */
-class Numbers_Words_sv extends Numbers_Words
-{
-
- // {{{ properties
-
- /**
- * Locale name
- * @var string
- * @access public
- */
- var $locale = 'sv';
-
- /**
- * Language name in English
- * @var string
- * @access public
- */
- var $lang = 'Swedish';
-
- /**
- * Native language name
- * @var string
- * @access public
- */
- var $lang_native = 'Svenska';
-
- /**
- * The word for the minus sign
- * @var string
- * @access private
- */
- var $_minus = 'Minus'; // minus sign
-
- /**
- * The sufixes for exponents (singular and plural)
- * @var array
- * @access private
- */
- var $_exponent = array(
- 0 => array(''),
- 3 => array('tusen', 'tusen'),
- 6 => array('miljon','miljoner'),
- 9 => array('miljard','miljarder'),
- 12 => array('biljon','biljoner'),
- 15 => array('biljard','biljarder'),
- 18 => array('triljon','triljoner'),
- 21 => array('triljard','triljarder'),
- 24 => array('kvadriljon','kvadriljoner'),
- 27 => array('kvadriljard','kvadriljarder'),
- 30 => array('kvintiljon','kvintiljoner'),
- 33 => array('kvintiljard','kvintiljarder'),
- 36 => array('sextiljon','sextiljoner'),
- 39 => array('sextiljard','sextiljarder'),
- 42 => array('septiljon','septiljoner'),
- 45 => array('septiljard','septiljarder'),
- 48 => array('oktiljon','oktiljoner'),
- 51 => array('oktiljard','oktiljarder'),
- 54 => array('noniljon','noniljoner'),
- 57 => array('noniljard','noniljarder'),
- 60 => array('dekiljon','dekiljoner'),
- 63 => array('dekiljard','dekiljarder'),
- 120 => array('vigintiljon','vigintiljoner'),
- 123 => array('vigintiljard','vigintiljarder'),
- 600 => array('centiljon','centiljoner'),
- 603 => array('centiljard','centiljarder')
- );
-
- /**
- * The array containing the digits (indexed by the digits themselves).
- * @var array
- * @access private
- */
- var $_digits = array(
- 0 => 'noll', 'ett', 'två', 'tre', 'fyra',
- 'fem', 'sex', 'sju', 'åtta', 'nio'
- );
-
- /**
- * The word separator
- * @var string
- * @access private
- */
- var $_sep = '';
-
- /**
- * The exponent word separator
- * @var string
- * @access private
- */
- var $_sep2 = ' ';
-
- // }}}
- // {{{ toWords()
-
- /**
- * Converts a number to its word representation
- * in Swedish language.
- *
- * @param integer $num An integer between -infinity and infinity inclusive :)
- * that need to be converted to words
- * @param integer $power The power of ten for the rest of the number to the right.
- * Optional, defaults to 0.
- * @param integer $powsuffix The power name to be added to the end of the return string.
- * Used internally. Optional, defaults to ''.
- *
- * @return string The corresponding word representation
- *
- * @access private
- * @author Piotr Klaban
- * @author Robin Ericsson
- * @since PHP 4.2.3
- */
- function toWords($num, $power = 0, $powsuffix = '') {
- $ret = '';
-
- // add a minus sign
- if (substr($num, 0, 1) == '-') {
- $ret = $this->_sep . $this->_minus;
- $num = substr($num, 1);
- }
-
- // strip excessive zero signs and spaces
- $num = trim($num);
- $num = preg_replace('/^0+/','',$num);
-
- if (strlen($num) > 3) {
- $maxp = strlen($num)-1;
- $curp = $maxp;
- for ($p = $maxp; $p > 0; --$p) { // power
-
- // check for highest power
- if (isset($this->_exponent[$p])) {
- // send substr from $curp to $p
- $snum = substr($num, $maxp - $curp, $curp - $p + 1);
- $snum = preg_replace('/^0+/','',$snum);
- if ($snum !== '') {
- $cursuffix = $this->_exponent[$power][count($this->_exponent[$power])-1];
- if ($powsuffix != '')
- $cursuffix .= $this->_sep . $powsuffix;
- $ret .= $this->toWords($snum, $p, $cursuffix);
- }
- $curp = $p - 1;
- continue;
- }
- }
- $num = substr($num, $maxp - $curp, $curp - $p + 1);
- if ($num == 0) {
- return $ret;
- }
- } elseif ($num == 0 || $num == '') {
- return $this->_sep . $this->_digits[0];
- }
-
- $h = $t = $d = 0;
-
- switch(strlen($num)) {
- case 3:
- $h = (int)substr($num,-3,1);
-
- case 2:
- $t = (int)substr($num,-2,1);
-
- case 1:
- $d = (int)substr($num,-1,1);
- break;
-
- case 0:
- return;
- break;
- }
-
- if ($h) {
- $ret .= $this->_sep . $this->_digits[$h] . $this->_sep . 'hundra';
- }
-
- // ten, twenty etc.
- switch ($t) {
- case 5:
- case 6:
- case 7:
- $ret .= $this->_sep . $this->_digits[$t] . 'tio';
- break;
-
- case 9:
- $ret .= $this->_sep . 'nittio';
- break;
-
- case 8:
- $ret .= $this->_sep . 'åttio';
- break;
-
- case 4:
- $ret .= $this->_sep . 'fyrtio';
- break;
-
- case 3:
- $ret .= $this->_sep . 'trettio';
- break;
-
- case 2:
- $ret .= $this->_sep . 'tjugo';
- break;
-
- case 1:
- switch ($d) {
- case 0:
- $ret .= $this->_sep . 'tio';
- break;
-
- case 1:
- $ret .= $this->_sep . 'elva';
- break;
-
- case 2:
- $ret .= $this->_sep . 'tolv';
- break;
-
- case 3:
- $ret .= $this->_sep . 'tretton';
- break;
-
- case 4:
- $ret .= $this->_sep . 'fjorton';
- break;
-
- case 5:
- case 6:
- $ret .= $this->_sep . $this->_digits[$d] . 'ton';
- break;
-
- case 7:
- $ret .= $this->_sep . 'sjutton';
- break;
-
- case 8:
- $ret .= $this->_sep . 'arton';
- break;
- case 9:
- $ret .= $this->_sep . 'nitton';
- }
- break;
- }
-
- if ($t != 1 && $d > 0) { // add digits only in <0>,<1,9> and <21,inf>
- // add minus sign between [2-9] and digit
- $ret .= $this->_sep . $this->_digits[$d];
- }
-
- if ($power > 0) {
- if (isset($this->_exponent[$power]))
- $lev = $this->_exponent[$power];
-
- if (!isset($lev) || !is_array($lev))
- return null;
-
- $ret .= $this->_sep . $lev[0];
- }
-
- if ($powsuffix != '')
- $ret .= $this->_sep . $powsuffix;
-
- return $ret;
- }
- // }}}
-}
-
-?>
diff --git a/thirdparty/pear/OLE/OLE.php b/thirdparty/pear/OLE/OLE.php
deleted file mode 100644
index ba05faa30..000000000
--- a/thirdparty/pear/OLE/OLE.php
+++ /dev/null
@@ -1,410 +0,0 @@
- |
-// | Based on OLE::Storage_Lite by Kawai, Takanori |
-// +----------------------------------------------------------------------+
-//
-// $Id: OLE.php,v 1.7 2003/08/21 15:15:40 xnoguer Exp $
-
-
-/**
-* Constants for OLE package
-*/
-define('OLE_PPS_TYPE_ROOT', 5);
-define('OLE_PPS_TYPE_DIR', 1);
-define('OLE_PPS_TYPE_FILE', 2);
-define('OLE_DATA_SIZE_SMALL', 0x1000);
-define('OLE_LONG_INT_SIZE', 4);
-define('OLE_PPS_SIZE', 0x80);
-
-require_once('PEAR.php');
-require_once 'OLE/PPS.php';
-
-/**
-* OLE package base class.
-*
-* @author Xavier Noguer
-* @category Structures
-* @package OLE
-*/
-class OLE extends PEAR
-{
- /**
- * The file handle for reading an OLE container
- * @var resource
- */
- var $_file_handle;
-
- /**
- * Array of PPS's found on the OLE container
- * @var array
- */
- var $_list;
-
- /**
- * Creates a new OLE object
- * Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();)
- * @access public
- */
- function OLE()
- {
- $this->_list = array();
- }
-
- /**
- * Reads an OLE container from the contents of the file given.
- *
- * @acces public
- * @param string $file
- * @return mixed true on success, PEAR_Error on failure
- */
- function read($file)
- {
- /* consider storing offsets as constants */
- $big_block_size_offset = 30;
- $iBdbCnt_offset = 44;
- $bd_start_offset = 68;
-
- $fh = @fopen($file, "r");
- if ($fh == false) {
- return $this->raiseError("Can't open file $file");
- }
- $this->_file_handle = $fh;
-
- /* begin reading OLE attributes */
- fseek($fh, 0);
- $signature = fread($fh, 8);
- if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) {
- return $this->raiseError("File doesn't seem to be an OLE container.");
- }
- fseek($fh, $big_block_size_offset);
- $packed_array = unpack("v", fread($fh, 2));
- $big_block_size = pow(2, $packed_array['']);
-
- $packed_array = unpack("v", fread($fh, 2));
- $small_block_size = pow(2, $packed_array['']);
- $i1stBdL = ($big_block_size - 0x4C) / OLE_LONG_INT_SIZE;
-
- fseek($fh, $iBdbCnt_offset);
- $packed_array = unpack("V", fread($fh, 4));
- $iBdbCnt = $packed_array[''];
-
- $packed_array = unpack("V", fread($fh, 4));
- $pps_wk_start = $packed_array[''];
-
- fseek($fh, $bd_start_offset);
- $packed_array = unpack("V", fread($fh, 4));
- $bd_start = $packed_array[''];
- $packed_array = unpack("V", fread($fh, 4));
- $bd_count = $packed_array[''];
- $packed_array = unpack("V", fread($fh, 4));
- $iAll = $packed_array['']; // this may be wrong
- /* create OLE_PPS objects from */
- $ret = $this->_readPpsWks($pps_wk_start, $big_block_size);
- if (PEAR::isError($ret)) {
- return $ret;
- }
- return true;
- }
-
- /**
- * Destructor (using PEAR)
- * Just closes the file handle on the OLE file.
- *
- * @access private
- */
- function _OLE()
- {
- fclose($this->_file_handle);
- }
-
- /**
- * Gets information about all PPS's on the OLE container from the PPS WK's
- * creates an OLE_PPS object for each one.
- *
- * @access private
- * @param integer $pps_wk_start Position inside the OLE file where PPS WK's start
- * @param integer $big_block_size Size of big blobks in the OLE file
- * @return mixed true on success, PEAR_Error on failure
- */
- function _readPpsWks($pps_wk_start, $big_block_size)
- {
- $pointer = ($pps_wk_start + 1) * $big_block_size;
- while (1)
- {
- fseek($this->_file_handle, $pointer);
- $pps_wk = fread($this->_file_handle, OLE_PPS_SIZE);
- if (strlen($pps_wk) != OLE_PPS_SIZE) {
- break; // Excel likes to add a trailing byte sometimes
- //return $this->raiseError("PPS at $pointer seems too short: ".strlen($pps_wk));
- }
- $name_length = unpack("c", substr($pps_wk, 64, 2)); // FIXME (2 bytes??)
- $name_length = $name_length[''] - 2;
- $name = substr($pps_wk, 0, $name_length);
- $type = unpack("c", substr($pps_wk, 66, 1));
- if (($type[''] != OLE_PPS_TYPE_ROOT) and
- ($type[''] != OLE_PPS_TYPE_DIR) and
- ($type[''] != OLE_PPS_TYPE_FILE))
- {
- return $this->raiseError("PPS at $pointer has unknown type: {$type['']}");
- }
- $prev = unpack("V", substr($pps_wk, 68, 4));
- $next = unpack("V", substr($pps_wk, 72, 4));
- $dir = unpack("V", substr($pps_wk, 76, 4));
- // there is no magic number, it can take different values.
- //$magic = unpack("V", strrev(substr($pps_wk, 92, 4)));
- $time_1st = substr($pps_wk, 100, 8);
- $time_2nd = substr($pps_wk, 108, 8);
- $start_block = unpack("V", substr($pps_wk, 116, 4));
- $size = unpack("V", substr($pps_wk, 120, 4));
- // _data member will point to position in file!!
- // OLE_PPS object is created with an empty children array!!
- $this->_list[] = new OLE_PPS(null, '', $type[''], $prev[''], $next[''],
- $dir[''], OLE::OLE2LocalDate($time_1st),
- OLE::OLE2LocalDate($time_2nd),
- ($start_block[''] + 1) * $big_block_size, array());
- // give it a size
- $this->_list[count($this->_list) - 1]->Size = $size[''];
- // check if the PPS tree (starting from root) is complete
- if ($this->_ppsTreeComplete(0)) {
- break;
- }
- $pointer += OLE_PPS_SIZE;
- }
- }
-
- /**
- * It checks whether the PPS tree is complete (all PPS's read)
- * starting with the given PPS (not necessarily root)
- *
- * @access private
- * @param integer $index The index of the PPS from which we are checking
- * @return boolean Whether the PPS tree for the given PPS is complete
- */
- function _ppsTreeComplete($index)
- {
- if ($this->_list[$index]->NextPps != -1) {
- if (!isset($this->_list[$this->_list[$index]->NextPps])) {
- return false;
- }
- else {
- return $this->_ppsTreeComplete($this->_list[$index]->NextPps);
- }
- }
- if ($this->_list[$index]->DirPps != -1) {
- if (!isset($this->_list[$this->_list[$index]->DirPps])) {
- return false;
- }
- else {
- return $this->_ppsTreeComplete($this->_list[$index]->DirPps);
- }
- }
- return true;
- }
-
- /**
- * Checks whether a PPS is a File PPS or not.
- * If there is no PPS for the index given, it will return false.
- *
- * @access public
- * @param integer $index The index for the PPS
- * @return bool true if it's a File PPS, false otherwise
- */
- function isFile($index)
- {
- if (isset($this->_list[$index])) {
- return ($this->_list[$index]->Type == OLE_PPS_TYPE_FILE);
- }
- return false;
- }
-
- /**
- * Checks whether a PPS is a Root PPS or not.
- * If there is no PPS for the index given, it will return false.
- *
- * @access public
- * @param integer $index The index for the PPS.
- * @return bool true if it's a Root PPS, false otherwise
- */
- function isRoot($index)
- {
- if (isset($this->_list[$index])) {
- return ($this->_list[$index]->Type == OLE_PPS_TYPE_ROOT);
- }
- return false;
- }
-
- /**
- * Gives the total number of PPS's found in the OLE container.
- *
- * @access public
- * @return integer The total number of PPS's found in the OLE container
- */
- function ppsTotal()
- {
- return count($this->_list);
- }
-
- /**
- * Gets data from a PPS
- * If there is no PPS for the index given, it will return an empty string.
- *
- * @access public
- * @param integer $index The index for the PPS
- * @param integer $position The position from which to start reading
- * (relative to the PPS)
- * @param integer $length The amount of bytes to read (at most)
- * @return string The binary string containing the data requested
- */
- function getData($index, $position, $length)
- {
- // if position is not valid return empty string
- if (!isset($this->_list[$index]) or ($position >= $this->_list[$index]->Size) or ($position < 0)) {
- return '';
- }
- // Beware!!! _data member is actually a position
- fseek($this->_file_handle, $this->_list[$index]->_data + $position);
- return fread($this->_file_handle, $length);
- }
-
- /**
- * Gets the data length from a PPS
- * If there is no PPS for the index given, it will return 0.
- *
- * @access public
- * @param integer $index The index for the PPS
- * @return integer The amount of bytes in data the PPS has
- */
- function getDataLength($index)
- {
- if (isset($this->_list[$index])) {
- return $this->_list[$index]->Size;
- }
- return 0;
- }
-
- /**
- * Utility function to transform ASCII text to Unicode
- *
- * @access public
- * @static
- * @param string $ascii The ASCII string to transform
- * @return string The string in Unicode
- */
- function Asc2Ucs($ascii)
- {
- $rawname = '';
- for ($i = 0; $i < strlen($ascii); $i++) {
- $rawname .= $ascii{$i}."\x00";
- }
- return $rawname;
- }
-
- /**
- * Utility function
- * Returns a string for the OLE container with the date given
- *
- * @access public
- * @static
- * @param integer $date A timestamp
- * @return string The string for the OLE container
- */
- function LocalDate2OLE($date = null)
- {
- if (!isset($date)) {
- return "\x00\x00\x00\x00\x00\x00\x00\x00";
- }
-
- // factor used for separating numbers into 4 bytes parts
- $factor = pow(2,32);
-
- // days from 1-1-1601 until the beggining of UNIX era
- $days = 134774;
- // calculate seconds
- $big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date),
- date("m",$date),date("d",$date),date("Y",$date));
- // multiply just to make MS happy
- $big_date *= 10000000;
-
- $high_part = floor($big_date/$factor);
- // lower 4 bytes
- $low_part = floor((($big_date/$factor) - $high_part)*$factor);
-
- // Make HEX string
- $res = '';
-
- for ($i=0; $i<4; $i++)
- {
- $hex = $low_part % 0x100;
- $res .= pack('c', $hex);
- $low_part /= 0x100;
- }
- for ($i=0; $i<4; $i++)
- {
- $hex = $high_part % 0x100;
- $res .= pack('c', $hex);
- $high_part /= 0x100;
- }
- return $res;
- }
-
- /**
- * Returns a timestamp from an OLE container's date
- *
- * @access public
- * @static
- * @param integer $string A binary string with the encoded date
- * @return string The timestamp corresponding to the string
- */
- function OLE2LocalDate($string)
- {
- if (strlen($string) != 8) {
- return new PEAR_Error("Expecting 8 byte string");
- }
-
- // factor used for separating numbers into 4 bytes parts
- $factor = pow(2,32);
- $high_part = 0;
- for ($i=0; $i<4; $i++)
- {
- $al = unpack('C', $string{(7 - $i)});
- $high_part += $al[''];
- if ($i < 3) {
- $high_part *= 0x100;
- }
- }
- $low_part = 0;
- for ($i=4; $i<8; $i++)
- {
- $al = unpack('C', $string{(7 - $i)});
- $low_part += $al[''];
- if ($i < 7) {
- $low_part *= 0x100;
- }
- }
- $big_date = ($high_part*$factor) + $low_part;
- // translate to seconds
- $big_date /= 10000000;
-
- // days from 1-1-1601 until the beggining of UNIX era
- $days = 134774;
-
- // translate to seconds from beggining of UNIX era
- $big_date -= $days*24*3600;
- return floor($big_date);
- }
-}
-?>
diff --git a/thirdparty/pear/OLE/PPS.php b/thirdparty/pear/OLE/PPS.php
deleted file mode 100644
index 9e0f9829c..000000000
--- a/thirdparty/pear/OLE/PPS.php
+++ /dev/null
@@ -1,219 +0,0 @@
- |
-// | Based on OLE::Storage_Lite by Kawai, Takanori |
-// +----------------------------------------------------------------------+
-//
-// $Id: PPS.php,v 1.5 2003/12/14 18:12:28 xnoguer Exp $
-
-
-require_once('PEAR.php');
-require_once('OLE.php');
-
-/**
-* Class for creating PPS's for OLE containers
-*
-* @author Xavier Noguer
-* @category Structures
-* @package OLE
-*/
-class OLE_PPS extends PEAR
-{
- /**
- * The PPS index
- * @var integer
- */
- var $No;
-
- /**
- * The PPS name (in Unicode)
- * @var string
- */
- var $Name;
-
- /**
- * The PPS type. Dir, Root or File
- * @var integer
- */
- var $Type;
-
- /**
- * The index of the previous PPS
- * @var integer
- */
- var $PrevPps;
-
- /**
- * The index of the next PPS
- * @var integer
- */
- var $NextPps;
-
- /**
- * The index of it's first child if this is a Dir or Root PPS
- * @var integer
- */
- var $DirPps;
-
- /**
- * A timestamp
- * @var integer
- */
- var $Time1st;
-
- /**
- * A timestamp
- * @var integer
- */
- var $Time2nd;
-
- /**
- * Starting block (small or big) for this PPS's data inside the container
- * @var integer
- */
- var $_StartBlock;
-
- /**
- * The size of the PPS's data (in bytes)
- * @var integer
- */
- var $Size;
-
- /**
- * The PPS's data (only used if it's not using a temporary file)
- * @var string
- */
- var $_data;
-
- /**
- * Array of child PPS's (only used by Root and Dir PPS's)
- * @var array
- */
- var $children = array();
-
- /**
- * The constructor
- *
- * @access public
- * @param integer $No The PPS index
- * @param string $name The PPS name (in Unicode)
- * @param integer $type The PPS type. Dir, Root or File
- * @param integer $prev The index of the previous PPS
- * @param integer $next The index of the next PPS
- * @param integer $dir The index of it's first child if this is a Dir or Root PPS
- * @param integer $time_1st A timestamp
- * @param integer $time_2nd A timestamp
- * @param array $children Array containing children PPS for this PPS
- */
- function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
- {
- $this->No = $No;
- $this->Name = $name;
- $this->Type = $type;
- $this->PrevPps = $prev;
- $this->NextPps = $next;
- $this->DirPps = $dir;
- $this->Time1st = $time_1st;
- $this->Time2nd = $time_2nd;
- $this->_data = $data;
- $this->children = $children;
- if ($data != '') {
- $this->Size = strlen($data);
- }
- else {
- $this->Size = 0;
- }
- }
-
- /**
- * Returns the amount of data saved for this PPS
- *
- * @access private
- * @return integer The amount of data (in bytes)
- */
- function _DataLen()
- {
- if (!isset($this->_data)) {
- return 0;
- }
- if (isset($this->_PPS_FILE))
- {
- fseek($this->_PPS_FILE, 0);
- $stats = fstat($this->_PPS_FILE);
- return $stats[7];
- }
- else {
- return strlen($this->_data);
- }
- }
-
- /**
- * Returns a string with the PPS's WK (What is a WK?)
- *
- * @access private
- * @return string The binary string
- */
- function _getPpsWk()
- {
- $ret = $this->Name;
- for ($i = 0; $i < (64 - strlen($this->Name)); $i++) {
- $ret .= "\x00";
- }
- $ret .= pack("v", strlen($this->Name) + 2) // 66
- . pack("c", $this->Type) // 67
- . pack("c", 0x00) //UK // 68
- . pack("V", $this->PrevPps) //Prev // 72
- . pack("V", $this->NextPps) //Next // 76
- . pack("V", $this->DirPps) //Dir // 80
- . "\x00\x09\x02\x00" // 84
- . "\x00\x00\x00\x00" // 88
- . "\xc0\x00\x00\x00" // 92
- . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
- . "\x00\x00\x00\x00" // 100
- . OLE::LocalDate2OLE($this->Time1st) // 108
- . OLE::LocalDate2OLE($this->Time2nd) // 116
- . pack("V", isset($this->_StartBlock)?
- $this->_StartBlock:0) // 120
- . pack("V", $this->Size) // 124
- . pack("V", 0); // 128
- return $ret;
- }
-
- /**
- * Updates index and pointers to previous, next and children PPS's for this
- * PPS. I don't think it'll work with Dir PPS's.
- *
- * @access private
- * @param array &$pps_array Reference to the array of PPS's for the whole OLE
- * container
- * @return integer The index for this PPS
- */
- function _savePpsSetPnt(&$pps_array)
- {
- $pps_array[count($pps_array)] = &$this;
- $this->No = count($pps_array) - 1;
- $this->PrevPps = 0xFFFFFFFF;
- $this->NextPps = 0xFFFFFFFF;
- if (count($this->children) > 0) {
- $this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array);
- }
- else {
- $this->DirPps = 0xFFFFFFFF;
- }
- return $this->No;
- }
-}
-?>
diff --git a/thirdparty/pear/OLE/PPS/File.php b/thirdparty/pear/OLE/PPS/File.php
deleted file mode 100644
index 1deb31f87..000000000
--- a/thirdparty/pear/OLE/PPS/File.php
+++ /dev/null
@@ -1,114 +0,0 @@
- |
-// | Based on OLE::Storage_Lite by Kawai, Takanori |
-// +----------------------------------------------------------------------+
-//
-// $Id: File.php,v 1.8 2003/12/12 21:10:10 xnoguer Exp $
-
-
-require_once ('OLE/PPS.php');
-
-/**
-* Class for creating File PPS's for OLE containers
-*
-* @author Xavier Noguer
-* @category Structures
-* @package OLE
-*/
-class OLE_PPS_File extends OLE_PPS
-{
- /**
- * The temporary dir for storing the OLE file
- * @var string
- */
- var $_tmp_dir;
-
- /**
- * The constructor
- *
- * @access public
- * @param string $name The name of the file (in Unicode)
- * @see OLE::Asc2Ucs()
- */
- function OLE_PPS_File($name)
- {
- $this->_tmp_dir = '';
- $this->OLE_PPS(
- null,
- $name,
- OLE_PPS_TYPE_FILE,
- null,
- null,
- null,
- null,
- null,
- '',
- array());
- }
-
- /**
- * Sets the temp dir used for storing the OLE file
- *
- * @access public
- * @param string $dir The dir to be used as temp dir
- * @return true if given dir is valid, false otherwise
- */
- function setTempDir($dir)
- {
- if (is_dir($dir)) {
- $this->_tmp_dir = $dir;
- return true;
- }
- return false;
- }
-
- /**
- * Initialization method. Has to be called right after OLE_PPS_File().
- *
- * @access public
- * @return mixed true on success. PEAR_Error on failure
- */
- function init()
- {
- $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File");
- $fh = @fopen($this->_tmp_filename, "w+b");
- if ($fh == false) {
- return $this->raiseError("Can't create temporary file");
- }
- $this->_PPS_FILE = $fh;
- if ($this->_PPS_FILE) {
- fseek($this->_PPS_FILE, 0);
- }
- }
-
- /**
- * Append data to PPS
- *
- * @access public
- * @param string $data The data to append
- */
- function append($data)
- {
- if ($this->_PPS_FILE) {
- fwrite($this->_PPS_FILE, $data);
- }
- else {
- $this->_data .= $data;
- }
- }
-}
-?>
diff --git a/thirdparty/pear/OLE/PPS/Root.php b/thirdparty/pear/OLE/PPS/Root.php
deleted file mode 100644
index 90166f03c..000000000
--- a/thirdparty/pear/OLE/PPS/Root.php
+++ /dev/null
@@ -1,519 +0,0 @@
- |
-// | Based on OLE::Storage_Lite by Kawai, Takanori |
-// +----------------------------------------------------------------------+
-//
-// $Id: Root.php,v 1.7 2003/12/12 21:10:10 xnoguer Exp $
-
-
-require_once ('OLE/PPS.php');
-
-/**
-* Class for creating Root PPS's for OLE containers
-*
-* @author Xavier Noguer
-* @category Structures
-* @package OLE
-*/
-class OLE_PPS_Root extends OLE_PPS
-{
- /**
- * The temporary dir for storing the OLE file
- * @var string
- */
- var $_tmp_dir;
-
- /**
- * Constructor
- *
- * @access public
- * @param integer $time_1st A timestamp
- * @param integer $time_2nd A timestamp
- */
- function OLE_PPS_Root($time_1st, $time_2nd, $raChild)
- {
- $this->_tmp_dir = '';
- $this->OLE_PPS(
- null,
- OLE::Asc2Ucs('Root Entry'),
- OLE_PPS_TYPE_ROOT,
- null,
- null,
- null,
- $time_1st,
- $time_2nd,
- null,
- $raChild);
- }
-
- /**
- * Sets the temp dir used for storing the OLE file
- *
- * @access public
- * @param string $dir The dir to be used as temp dir
- * @return true if given dir is valid, false otherwise
- */
- function setTempDir($dir)
- {
- if (is_dir($dir)) {
- $this->_tmp_dir = $dir;
- return true;
- }
- return false;
- }
-
- /**
- * Method for saving the whole OLE container (including files).
- * In fact, if called with an empty argument (or '-'), it saves to a
- * temporary file and then outputs it's contents to stdout.
- *
- * @param string $filename The name of the file where to save the OLE container
- * @access public
- * @return mixed true on success, PEAR_Error on failure
- */
- function save($filename)
- {
- // Initial Setting for saving
- $this->_BIG_BLOCK_SIZE = pow(2,
- ((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9));
- $this->_SMALL_BLOCK_SIZE= pow(2,
- ((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6));
-
- // Open temp file if we are sending output to stdout
- if (($filename == '-') or ($filename == ''))
- {
- $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
- $this->_FILEH_ = @fopen($this->_tmp_filename,"w+b");
- if ($this->_FILEH_ == false) {
- return $this->raiseError("Can't create temporary file.");
- }
- }
- else
- {
- $this->_FILEH_ = @fopen($filename, "wb");
- if ($this->_FILEH_ == false) {
- return $this->raiseError("Can't open $filename. It may be in use or protected.");
- }
- }
- // Make an array of PPS's (for Save)
- $aList = array();
- $this->_savePpsSetPnt($aList);
- // calculate values for header
- list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
- // Save Header
- $this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
-
- // Make Small Data string (write SBD)
- $this->_data = $this->_makeSmallData($aList);
-
- // Write BB
- $this->_saveBigData($iSBDcnt, $aList);
- // Write PPS
- $this->_savePps($aList);
- // Write Big Block Depot and BDList and Adding Header informations
- $this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
- // Close File, send it to stdout if necessary
- if(($filename == '-') or ($filename == ''))
- {
- fseek($this->_FILEH_, 0);
- fpassthru($this->_FILEH_);
- @fclose($this->_FILEH_);
- // Delete the temporary file.
- @unlink($this->_tmp_filename);
- }
- else {
- @fclose($this->_FILEH_);
- }
- return true;
- }
-
- /**
- * Calculate some numbers
- *
- * @access private
- * @param array $raList Reference to an array of PPS's
- * @return array The array of numbers
- */
- function _calcSize(&$raList)
- {
- // Calculate Basic Setting
- list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0);
- $iSmallLen = 0;
- $iSBcnt = 0;
- for ($i = 0; $i < count($raList); $i++) {
- if($raList[$i]->Type == OLE_PPS_TYPE_FILE) {
- $raList[$i]->Size = $raList[$i]->_DataLen();
- if($raList[$i]->Size < OLE_DATA_SIZE_SMALL) {
- $iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
- + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
- }
- else {
- $iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
- (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
- }
- }
- }
- $iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE;
- $iSlCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE);
- $iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0);
- $iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) +
- (( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0));
- $iCnt = count($raList);
- $iBdCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE;
- $iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt)? 1: 0));
-
- return array($iSBDcnt, $iBBcnt, $iPPScnt);
- }
-
- /**
- * Helper function for caculating a magic value for block sizes
- *
- * @access private
- * @param integer $i2 The argument
- * @see save()
- * @return integer
- */
- function _adjust2($i2)
- {
- $iWk = log($i2)/log(2);
- return ($iWk > floor($iWk))? floor($iWk)+1:$iWk;
- }
-
- /**
- * Save OLE header
- *
- * @access private
- * @param integer $iSBDcnt
- * @param integer $iBBcnt
- * @param integer $iPPScnt
- */
- function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt)
- {
- $FILE = $this->_FILEH_;
-
- // Calculate Basic Setting
- $iBlCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
- $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
-
- $iBdExL = 0;
- $iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
- $iAllW = $iAll;
- $iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
- $iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
-
- // Calculate BD count
- if ($iBdCnt >$i1stBdL)
- {
- while (1)
- {
- $iBdExL++;
- $iAllW++;
- $iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
- $iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
- if ($iBdCnt <= ($iBdExL*$iBlCnt+ $i1stBdL)) {
- break;
- }
- }
- }
-
- // Save Header
- fwrite($FILE,
- "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
- . "\x00\x00\x00\x00"
- . "\x00\x00\x00\x00"
- . "\x00\x00\x00\x00"
- . "\x00\x00\x00\x00"
- . pack("v", 0x3b)
- . pack("v", 0x03)
- . pack("v", -2)
- . pack("v", 9)
- . pack("v", 6)
- . pack("v", 0)
- . "\x00\x00\x00\x00"
- . "\x00\x00\x00\x00"
- . pack("V", $iBdCnt)
- . pack("V", $iBBcnt+$iSBDcnt) //ROOT START
- . pack("V", 0)
- . pack("V", 0x1000)
- . pack("V", 0) //Small Block Depot
- . pack("V", 1)
- );
- // Extra BDList Start, Count
- if ($iBdCnt < $i1stBdL)
- {
- fwrite($FILE,
- pack("V", -2). // Extra BDList Start
- pack("V", 0) // Extra BDList Count
- );
- }
- else
- {
- fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL));
- }
-
- // BDList
- for ($i=0; $i<$i1stBdL and $i < $iBdCnt; $i++) {
- fwrite($FILE, pack("V", $iAll+$i));
- }
- if ($i < $i1stBdL)
- {
- for ($j = 0; $j < ($i1stBdL-$i); $j++) {
- fwrite($FILE, (pack("V", -1)));
- }
- }
- }
-
- /**
- * Saving big data (PPS's with data bigger than OLE_DATA_SIZE_SMALL)
- *
- * @access private
- * @param integer $iStBlk
- * @param array &$raList Reference to array of PPS's
- */
- function _saveBigData($iStBlk, &$raList)
- {
- $FILE = $this->_FILEH_;
-
- // cycle through PPS's
- for ($i = 0; $i < count($raList); $i++)
- {
- if($raList[$i]->Type != OLE_PPS_TYPE_DIR)
- {
- $raList[$i]->Size = $raList[$i]->_DataLen();
- if(($raList[$i]->Size >= OLE_DATA_SIZE_SMALL) or
- (($raList[$i]->Type == OLE_PPS_TYPE_ROOT) and isset($raList[$i]->_data)))
- {
- // Write Data
- if(isset($raList[$i]->_PPS_FILE))
- {
- $iLen = 0;
- fseek($raList[$i]->_PPS_FILE, 0); // To The Top
- while($sBuff = fread($raList[$i]->_PPS_FILE, 4096))
- {
- $iLen += strlen($sBuff);
- fwrite($FILE, $sBuff);
- }
- }
- else {
- fwrite($FILE, $raList[$i]->_data);
- }
-
- if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)
- {
- for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); $j++) {
- fwrite($FILE, "\x00");
- }
- }
- // Set For PPS
- $raList[$i]->_StartBlock = $iStBlk;
- $iStBlk +=
- (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
- (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
- }
- // Close file for each PPS, and unlink it
- if (isset($raList[$i]->_PPS_FILE))
- {
- @fclose($raList[$i]->_PPS_FILE);
- $raList[$i]->_PPS_FILE = null;
- @unlink($raList[$i]->_tmp_filename);
- }
- }
- }
- }
-
- /**
- * get small data (PPS's with data smaller than OLE_DATA_SIZE_SMALL)
- *
- * @access private
- * @param array &$raList Reference to array of PPS's
- */
- function _makeSmallData(&$raList)
- {
- $sRes = '';
- $FILE = $this->_FILEH_;
- $iSmBlk = 0;
-
- for ($i = 0; $i < count($raList); $i++)
- {
- // Make SBD, small data string
- if ($raList[$i]->Type == OLE_PPS_TYPE_FILE)
- {
- if ($raList[$i]->Size <= 0) {
- continue;
- }
- if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL)
- {
- $iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
- + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
- // Add to SBD
- for ($j = 0; $j < ($iSmbCnt-1); $j++) {
- fwrite($FILE, pack("V", $j+$iSmBlk+1));
- }
- fwrite($FILE, pack("V", -2));
-
- // Add to Data String(this will be written for RootEntry)
- if ($raList[$i]->_PPS_FILE)
- {
- fseek($raList[$i]->_PPS_FILE, 0); // To The Top
- while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
- $sRes .= $sBuff;
- }
- }
- else {
- $sRes .= $raList[$i]->_data;
- }
- if($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)
- {
- for ($j = 0; $j < ($this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); $j++) {
- $sRes .= "\x00";
- }
- }
- // Set for PPS
- $raList[$i]->_StartBlock = $iSmBlk;
- $iSmBlk += $iSmbCnt;
- }
- }
- }
- $iSbCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE);
- if($iSmBlk % $iSbCnt)
- {
- for ($i = 0; $i < ($iSbCnt - ($iSmBlk % $iSbCnt)); $i++) {
- fwrite($FILE, pack("V", -1));
- }
- }
- return $sRes;
- }
-
- /**
- * Saves all the PPS's WKs
- *
- * @access private
- * @param array $raList Reference to an array with all PPS's
- */
- function _savePps(&$raList)
- {
- // Save each PPS WK
- for ($i = 0; $i < count($raList); $i++) {
- fwrite($this->_FILEH_, $raList[$i]->_getPpsWk());
- }
- // Adjust for Block
- $iCnt = count($raList);
- $iBCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE;
- if ($iCnt % $iBCnt)
- {
- for ($i = 0; $i < (($iBCnt - ($iCnt % $iBCnt)) * OLE_PPS_SIZE); $i++) {
- fwrite($this->_FILEH_, "\x00");
- }
- }
- }
-
- /**
- * Saving Big Block Depot
- *
- * @access private
- * @param integer $iSbdSize
- * @param integer $iBsize
- * @param integer $iPpsCnt
- */
- function _saveBbd($iSbdSize, $iBsize, $iPpsCnt)
- {
- $FILE = $this->_FILEH_;
- // Calculate Basic Setting
- $iBbCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
- $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
-
- $iBdExL = 0;
- $iAll = $iBsize + $iPpsCnt + $iSbdSize;
- $iAllW = $iAll;
- $iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
- $iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
- // Calculate BD count
- if ($iBdCnt >$i1stBdL)
- {
- while (1)
- {
- $iBdExL++;
- $iAllW++;
- $iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
- $iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
- if ($iBdCnt <= ($iBdExL*$iBbCnt+ $i1stBdL)) {
- break;
- }
- }
- }
-
- // Making BD
- // Set for SBD
- if ($iSbdSize > 0)
- {
- for ($i = 0; $i<($iSbdSize-1); $i++) {
- fwrite($FILE, pack("V", $i+1));
- }
- fwrite($FILE, pack("V", -2));
- }
- // Set for B
- for ($i = 0; $i<($iBsize-1); $i++) {
- fwrite($FILE, pack("V", $i+$iSbdSize+1));
- }
- fwrite($FILE, pack("V", -2));
-
- // Set for PPS
- for ($i = 0; $i<($iPpsCnt-1); $i++) {
- fwrite($FILE, pack("V", $i+$iSbdSize+$iBsize+1));
- }
- fwrite($FILE, pack("V", -2));
- // Set for BBD itself ( 0xFFFFFFFD : BBD)
- for ($i=0; $i<$iBdCnt;$i++) {
- fwrite($FILE, pack("V", 0xFFFFFFFD));
- }
- // Set for ExtraBDList
- for ($i=0; $i<$iBdExL;$i++) {
- fwrite($FILE, pack("V", 0xFFFFFFFC));
- }
- // Adjust for Block
- if (($iAllW + $iBdCnt) % $iBbCnt)
- {
- for ($i = 0; $i < ($iBbCnt - (($iAllW + $iBdCnt) % $iBbCnt)); $i++) {
- fwrite($FILE, pack("V", -1));
- }
- }
- // Extra BDList
- if ($iBdCnt > $i1stBdL)
- {
- $iN=0;
- $iNb=0;
- for ($i=$i1stBdL;$i<$iBdCnt; $i++, $iN++)
- {
- if ($iN>=($iBbCnt-1))
- {
- $iN = 0;
- $iNb++;
- fwrite($FILE, pack("V", $iAll+$iBdCnt+$iNb));
- }
- fwrite($FILE, pack("V", $iBsize+$iSbdSize+$iPpsCnt+$i));
- }
- if (($iBdCnt-$i1stBdL) % ($iBbCnt-1))
- {
- for ($i = 0; $i < (($iBbCnt-1) - (($iBdCnt-$i1stBdL) % ($iBbCnt-1))); $i++) {
- fwrite($FILE, pack("V", -1));
- }
- }
- fwrite($FILE, pack("V", -2));
- }
- }
-}
-?>
diff --git a/thirdparty/pear/README b/thirdparty/pear/README
deleted file mode 100644
index c953c26b1..000000000
--- a/thirdparty/pear/README
+++ /dev/null
@@ -1,18 +0,0 @@
- PEAR - PHP Extension and Application Repository
- ===============================================
- Dedicated to Malin Bakken, born 1999-11-21
-
-WHAT IS PEAR?
-
-PEAR is a code repository for PHP extensions and PHP library code
-similar to TeX's CTAN and Perl's CPAN.
-
-The intention behind PEAR is to provide a means for library code
-authors to organize their code in a defined way shared by other
-developers, and to give the PHP community a single source for such
-code.
-
-
-DOCUMENTATION
-
-Documentation for PEAR can be found at http://pear.php.net/manual/.
diff --git a/thirdparty/pear/SOAP/Base.php b/thirdparty/pear/SOAP/Base.php
deleted file mode 100644
index 938e63066..000000000
--- a/thirdparty/pear/SOAP/Base.php
+++ /dev/null
@@ -1,1116 +0,0 @@
- Original Author
- * @author Shane Caraveo Port to PEAR and more
- * @author Chuck Hagenbuch Maintenance
- * @author Jan Schneider Maintenance
- * @copyright 2003-2007 The PHP Group
- * @license http://www.php.net/license/2_02.txt PHP License 2.02
- * @link http://pear.php.net/package/SOAP
- */
-
-define('MAIL_MIMEPART_CRLF', "\r\n");
-require_once 'PEAR.php';
-
-if (!defined('INF')) {
- define('INF', 1.8e307);
-}
-if (!defined('NAN')) {
- define('NAN', 0.0);
-}
-
-define('SOAP_LIBRARY_VERSION', '0.11.0');
-define('SOAP_LIBRARY_NAME', 'PEAR-SOAP 0.11.0-beta');
-
-// Set schema version.
-define('SOAP_XML_SCHEMA_VERSION', 'http://www.w3.org/2001/XMLSchema');
-define('SOAP_XML_SCHEMA_INSTANCE', 'http://www.w3.org/2001/XMLSchema-instance');
-define('SOAP_XML_SCHEMA_1999', 'http://www.w3.org/1999/XMLSchema');
-define('SOAP_SCHEMA', 'http://schemas.xmlsoap.org/wsdl/soap/');
-define('SOAP_SCHEMA_ENCODING', 'http://schemas.xmlsoap.org/soap/encoding/');
-define('SOAP_ENVELOP', 'http://schemas.xmlsoap.org/soap/envelope/');
-
-define('SCHEMA_DISCO', 'http://schemas.xmlsoap.org/disco/');
-define('SCHEMA_DISCO_SCL', 'http://schemas.xmlsoap.org/disco/scl/');
-
-define('SCHEMA_SOAP', 'http://schemas.xmlsoap.org/wsdl/soap/');
-define('SCHEMA_SOAP12', 'http://schemas.xmlsoap.org/wsdl/soap12/');
-define('SCHEMA_SOAP_HTTP', 'http://schemas.xmlsoap.org/soap/http');
-define('SCHEMA_WSDL_HTTP', 'http://schemas.xmlsoap.org/wsdl/http/');
-define('SCHEMA_MIME', 'http://schemas.xmlsoap.org/wsdl/mime/');
-define('SCHEMA_WSDL', 'http://schemas.xmlsoap.org/wsdl/');
-define('SCHEMA_DIME', 'http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/');
-define('SCHEMA_CONTENT', 'http://schemas.xmlsoap.org/ws/2002/04/content-type/');
-define('SCHEMA_REF', 'http://schemas.xmlsoap.org/ws/2002/04/reference/');
-
-define('SOAP_DEFAULT_ENCODING', 'UTF-8');
-
-class SOAP_Base_Object extends PEAR
-{
-
- /**
- * Supported encodings, limited by XML extension.
- *
- * @var array $_encodings
- */
- var $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8');
-
- /**
- * Fault code.
- *
- * @var string $_myfaultcode
- */
- var $_myfaultcode = '';
-
- /**
- * Recent PEAR_Error object.
- *
- * @var PEAR_Error $fault
- */
- var $fault = null;
-
- /**
- * Constructor.
- *
- * @param string $faultcode Error code.
- */
- function SOAP_Base_Object($faultcode = 'Client')
- {
- $this->_myfaultcode = $faultcode;
- parent::PEAR('SOAP_Fault');
- }
-
- /**
- * Raises a SOAP error.
- *
- * Please refer to the SOAP definition for an impression of what a certain
- * parameter stands for.
- *
- * @param string|object $str Error message or object.
- * @param string $detail Detailed error message.
- * @param string $actorURI
- * @param mixed $code
- * @param mixed $mode
- * @param mixed $options
- * @param boolean $skipmsg
- */
- function &_raiseSoapFault($str, $detail = '', $actorURI = '', $code = null,
- $mode = null, $options = null, $skipmsg = false)
- {
- // Pass through previous faults.
- $is_instance = isset($this) && is_a($this, 'SOAP_Base_Object');
- if (is_object($str)) {
- $fault =& $str;
- } else {
- if (!$code) {
- $code = $is_instance ? $this->_myfaultcode : 'Client';
- }
- require_once 'SOAP/Fault.php';
- $fault = new SOAP_Fault($str,
- $code,
- $actorURI,
- $detail,
- $mode,
- $options);
- }
- if ($is_instance) {
- $this->fault =& $fault;
- }
-
- return $fault;
- }
-
- function _isfault()
- {
- return $this->fault != null;
- }
-
- function &_getfault()
- {
- return $this->fault;
- }
-
-}
-
-/**
- * Common base class of all SOAP classes.
- *
- * @access public
- * @package SOAP
- * @author Shane Caraveo Conversion to PEAR and updates
- */
-class SOAP_Base extends SOAP_Base_Object
-{
- var $_XMLSchema = array('http://www.w3.org/2001/XMLSchema',
- 'http://www.w3.org/1999/XMLSchema');
- var $_XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
-
- // load types into typemap array
- var $_typemap = array(
- 'http://www.w3.org/2001/XMLSchema' => array(
- 'string' => 'string',
- 'boolean' => 'boolean',
- 'float' => 'float',
- 'double' => 'float',
- 'decimal' => 'float',
- 'duration' => 'integer',
- 'dateTime' => 'string',
- 'time' => 'string',
- 'date' => 'string',
- 'gYearMonth' => 'integer',
- 'gYear' => 'integer',
- 'gMonthDay' => 'integer',
- 'gDay' => 'integer',
- 'gMonth' => 'integer',
- 'hexBinary' => 'string',
- 'base64Binary' => 'string',
- // derived datatypes
- 'normalizedString' => 'string',
- 'token' => 'string',
- 'language' => 'string',
- 'NMTOKEN' => 'string',
- 'NMTOKENS' => 'string',
- 'Name' => 'string',
- 'NCName' => 'string',
- 'ID' => 'string',
- 'IDREF' => 'string',
- 'IDREFS' => 'string',
- 'ENTITY' => 'string',
- 'ENTITIES' => 'string',
- 'integer' => 'integer',
- 'nonPositiveInteger' => 'integer',
- 'negativeInteger' => 'integer',
- // longs (64bit ints) are not supported cross-platform.
- 'long' => 'string',
- 'int' => 'integer',
- 'short' => 'integer',
- 'byte' => 'string',
- 'nonNegativeInteger' => 'integer',
- 'unsignedLong' => 'integer',
- 'unsignedInt' => 'integer',
- 'unsignedShort' => 'integer',
- 'unsignedByte' => 'integer',
- 'positiveInteger' => 'integer',
- 'anyType' => 'string',
- 'anyURI' => 'string',
- 'QName' => 'string'
- ),
- 'http://www.w3.org/1999/XMLSchema' => array(
- 'i4' => 'integer',
- 'int' => 'integer',
- 'boolean' => 'boolean',
- 'string' => 'string',
- 'double' => 'float',
- 'float' => 'float',
- 'dateTime' => 'string',
- 'timeInstant' => 'string',
- 'base64Binary' => 'string',
- 'base64' => 'string',
- 'ur-type' => 'string'
- ),
- 'http://schemas.xmlsoap.org/soap/encoding/' => array(
- 'base64' => 'string',
- 'array' => 'array',
- 'Array' => 'array',
- 'Struct' => 'array')
- );
-
- /**
- * Default class name to use for decoded response objects.
- *
- * @var string $_defaultObjectClassname
- */
- var $_defaultObjectClassname = 'stdClass';
-
- /**
- * Hash with used namespaces.
- *
- * @array
- */
- var $_namespaces;
-
- /**
- * The default namespace.
- *
- * @string
- */
- var $_namespace;
-
- var $_xmlEntities = array('&' => '&',
- '<' => '<',
- '>' => '>',
- "'" => ''',
- '"' => '"');
-
- var $_doconversion = false;
-
- var $_attachments = array();
-
- var $_wsdl = null;
-
- /**
- * True if we use section 5 encoding, or false if this is literal.
- *
- * @var boolean $_section5
- */
- var $_section5 = true;
-
- // Handle type to class mapping.
- var $_auto_translation = false;
- var $_type_translation = array();
-
- /**
- * Constructor.
- *
- * @param string $faultcode Error code.
- */
- function SOAP_Base($faultcode = 'Client')
- {
- parent::SOAP_Base_Object($faultcode);
- $this->_resetNamespaces();
- }
-
- /**
- * Sets the default namespace.
- *
- * @param string $namespace The default namespace.
- */
- function setDefaultNamespace($namespace)
- {
- $this->_namespace = $namespace;
- }
-
- function _resetNamespaces()
- {
- $this->_namespaces = array(
- 'http://schemas.xmlsoap.org/soap/envelope/' => 'SOAP-ENV',
- 'http://www.w3.org/2001/XMLSchema' => 'xsd',
- 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi',
- 'http://schemas.xmlsoap.org/soap/encoding/' => 'SOAP-ENC');
- }
-
- /**
- * Sets the schema version used in the SOAP message.
- *
- * @access private
- * @see $_XMLSchema
- *
- * @param string $schemaVersion The schema version.
- */
- function _setSchemaVersion($schemaVersion)
- {
- if (!in_array($schemaVersion, $this->_XMLSchema)) {
- return $this->_raiseSoapFault("unsuported XMLSchema $schemaVersion");
- }
- $this->_XMLSchemaVersion = $schemaVersion;
- $tmpNS = array_flip($this->_namespaces);
- $tmpNS['xsd'] = $this->_XMLSchemaVersion;
- $tmpNS['xsi'] = $this->_XMLSchemaVersion . '-instance';
- $this->_namespaces = array_flip($tmpNS);
- }
-
- function _getNamespacePrefix($ns)
- {
- if ($this->_namespace && $ns == $this->_namespace) {
- return '';
- }
- if (isset($this->_namespaces[$ns])) {
- return $this->_namespaces[$ns];
- }
- $prefix = 'ns' . count($this->_namespaces);
- $this->_namespaces[$ns] = $prefix;
- return $prefix;
- }
-
- function _getNamespaceForPrefix($prefix)
- {
- $flipped = array_flip($this->_namespaces);
- if (isset($flipped[$prefix])) {
- return $flipped[$prefix];
- }
- return null;
- }
-
- function _isSoapValue(&$value)
- {
- return is_a($value, 'SOAP_Value');
- }
-
- function _serializeValue(&$value, $name = '', $type = false,
- $elNamespace = null, $typeNamespace = null,
- $options = array(), $attributes = array(),
- $artype = '')
- {
- $namespaces = array();
- $arrayType = $array_depth = $xmlout_value = null;
- $typePrefix = $elPrefix = $xmlout_offset = $xmlout_arrayType = '';
- $xmlout_type = $xmlns = $ptype = $array_type_ns = '';
-
- if (!$name || is_numeric($name)) {
- $name = 'item';
- }
-
- if ($this->_wsdl) {
- list($ptype, $arrayType, $array_type_ns, $array_depth)
- = $this->_wsdl->getSchemaType($type, $name, $typeNamespace);
- }
-
- if (!$arrayType) {
- $arrayType = $artype;
- }
- if (!$ptype) {
- $ptype = $this->_getType($value);
- }
- if (!$type) {
- $type = $ptype;
- }
-
- if (strcasecmp($ptype, 'Struct') == 0 ||
- strcasecmp($type, 'Struct') == 0) {
- // Struct
- $vars = null;
- if (is_object($value)) {
- $vars = get_object_vars($value);
- } else {
- $vars = &$value;
- }
- if (is_array($vars)) {
- foreach (array_keys($vars) as $k) {
- // Hide private vars.
- if ($k[0] == '_') {
- continue;
- }
- if (is_object($vars[$k])) {
- if (is_a($vars[$k], 'SOAP_Value')) {
- $xmlout_value .= $vars[$k]->serialize($this);
- } else {
- // XXX get the members and serialize them instead
- // converting to an array is more overhead than we
- // should really do.
- $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5 ? null : $elNamespace);
- }
- } else {
- $xmlout_value .= $this->_serializeValue($vars[$k], $k, false, $this->_section5 ? null : $elNamespace);
- }
- }
- }
- } elseif (strcasecmp($ptype, 'Array') == 0 ||
- strcasecmp($type, 'Array') == 0) {
- // Array.
- $typeNamespace = SOAP_SCHEMA_ENCODING;
- $orig_type = $type;
- $type = 'Array';
- $numtypes = 0;
- $value = (array)$value;
- // XXX this will be slow on larger arrays. Basically, it flattens
- // arrays to allow us to serialize multi-dimensional arrays. We
- // only do this if arrayType is set, which will typically only
- // happen if we are using WSDL
- if (isset($options['flatten']) ||
- ($arrayType &&
- (strchr($arrayType, ',') || strstr($arrayType, '][')))) {
- $numtypes = $this->_multiArrayType($value, $arrayType,
- $ar_size, $xmlout_value);
- }
-
- $array_type = $array_type_prefix = '';
- if ($numtypes != 1) {
- $arrayTypeQName = new QName($arrayType);
- $arrayType = $arrayTypeQName->name;
- $array_types = array();
- $array_val = null;
-
- // Serialize each array element.
- $ar_size = count($value);
- foreach ($value as $array_val) {
- if ($this->_isSoapValue($array_val)) {
- $array_type = $array_val->type;
- $array_types[$array_type] = 1;
- $array_type_ns = $array_val->type_namespace;
- $xmlout_value .= $array_val->serialize($this);
- } else {
- $array_type = $this->_getType($array_val);
- $array_types[$array_type] = 1;
- $xmlout_value .= $this->_serializeValue($array_val, 'item', $array_type, $this->_section5 ? null : $elNamespace);
- }
- }
-
- $xmlout_offset = ' SOAP-ENC:offset="[0]"';
- if (!$arrayType) {
- $numtypes = count($array_types);
- if ($numtypes == 1) {
- $arrayType = $array_type;
- }
- // Using anyType is more interoperable.
- if ($array_type == 'Struct') {
- $array_type = '';
- } elseif ($array_type == 'Array') {
- $arrayType = 'anyType';
- $array_type_prefix = 'xsd';
- } else {
- if (!$arrayType) {
- $arrayType = $array_type;
- }
- }
- }
- }
- if (!$arrayType || $numtypes > 1) {
- // Should reference what schema we're using.
- $arrayType = 'xsd:anyType';
- } else {
- if ($array_type_ns) {
- $array_type_prefix = $this->_getNamespacePrefix($array_type_ns);
- } elseif (isset($this->_typemap[$this->_XMLSchemaVersion][$arrayType])) {
- $array_type_prefix = $this->_namespaces[$this->_XMLSchemaVersion];
- }
- if ($array_type_prefix) {
- $arrayType = $array_type_prefix . ':' . $arrayType;
- }
- }
-
- $xmlout_arrayType = ' SOAP-ENC:arrayType="' . $arrayType;
- if ($array_depth != null) {
- for ($i = 0; $i < $array_depth; $i++) {
- $xmlout_arrayType .= '[]';
- }
- }
- $xmlout_arrayType .= "[$ar_size]\"";
- } elseif ($this->_isSoapValue($value)) {
- $xmlout_value = $value->serialize($this);
- } elseif ($type == 'string') {
- $xmlout_value = htmlspecialchars($value);
- } elseif ($type == 'rawstring') {
- $xmlout_value =& $value;
- } elseif ($type == 'boolean') {
- $xmlout_value = $value ? 'true' : 'false';
- } else {
- $xmlout_value =& $value;
- }
-
- // Add namespaces.
- if ($elNamespace) {
- $elPrefix = $this->_getNamespacePrefix($elNamespace);
- if ($elPrefix) {
- $xmlout_name = "$elPrefix:$name";
- } else {
- $xmlout_name = $name;
- }
- } else {
- $xmlout_name = $name;
- }
-
- if ($typeNamespace) {
- $typePrefix = $this->_getNamespacePrefix($typeNamespace);
- if ($typePrefix) {
- $xmlout_type = "$typePrefix:$type";
- } else {
- $xmlout_type = $type;
- }
- } elseif ($type &&
- isset($this->_typemap[$this->_XMLSchemaVersion][$type])) {
- $typePrefix = $this->_namespaces[$this->_XMLSchemaVersion];
- if ($typePrefix) {
- $xmlout_type = "$typePrefix:$type";
- } else {
- $xmlout_type = $type;
- }
- }
-
- // Handle additional attributes.
- $xml_attr = '';
- if (count($attributes)) {
- foreach ($attributes as $k => $v) {
- $kqn = new QName($k);
- $vqn = new QName($v);
- $xml_attr .= ' ' . $kqn->fqn() . '="' . $vqn->fqn() . '"';
- }
- }
-
- // Store the attachment for mime encoding.
- if (isset($options['attachment']) &&
- !PEAR::isError($options['attachment'])) {
- $this->_attachments[] = $options['attachment'];
- }
-
- if ($this->_section5) {
- if ($xmlout_type) {
- $xmlout_type = " xsi:type=\"$xmlout_type\"";
- }
- if (is_null($xmlout_value)) {
- $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" .
- "$xml_attr xsi:nil=\"true\"/>";
- } else {
- $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" .
- "$xmlout_offset$xml_attr>$xmlout_value$xmlout_name>";
- }
- } else {
- if (is_null($xmlout_value)) {
- $xml = "\r\n<$xmlout_name$xmlns$xml_attr/>";
- } else {
- $xml = "\r\n<$xmlout_name$xmlns$xml_attr>" .
- $xmlout_value . "$xmlout_name>";
- }
- }
-
- return $xml;
- }
-
- /**
- * Converts a PHP type to a SOAP type.
- *
- * @access private
- *
- * @param string $value The value to inspect.
- *
- * @return string The value's SOAP type.
- */
- function _getType(&$value)
- {
- $type = gettype($value);
- switch ($type) {
- case 'object':
- if (is_a($value, 'soap_value')) {
- $type = $value->type;
- } else {
- $type = 'Struct';
- }
- break;
-
- case 'array':
- // Hashes are always handled as structs.
- if ($this->_isHash($value)) {
- $type = 'Struct';
- } else {
- $ar_size = count($value);
- reset($value);
- $key1 = key($value);
- if ($ar_size > 0 && is_a($key1, 'SOAP_Value')) {
- // FIXME: for non-wsdl structs that are all the same type
- $key2 = key($value);
- if ($ar_size > 1 &&
- $this->_isSoapValue($key1) &&
- $this->_isSoapValue($key2) &&
- $key1->name != $key2->name) {
- // This is a struct, not an array.
- $type = 'Struct';
- } else {
- $type = 'Array';
- }
- } else {
- $type = 'Array';
- }
- }
- break;
-
- case 'integer':
- case 'long':
- $type = 'int';
- break;
-
- case 'boolean':
- break;
-
- case 'double':
- // double is deprecated in PHP 4.2 and later.
- $type = 'float';
- break;
-
- case 'null':
- $type = '';
- break;
-
- case 'string':
- default:
- break;
- }
-
- return $type;
- }
-
- function _multiArrayType($value, &$type, &$size, &$xml)
- {
- if (is_array($value)) {
- // Seems we have a multi dimensional array, figure it out if we
- // do.
- for ($i = 0, $c = count($value); $i < $c; ++$i) {
- $this->_multiArrayType($value[$i], $type, $size, $xml);
- }
-
- $sz = count($value);
- if ($size) {
- $size = $sz . ',' . $size;
- } else {
- $size = $sz;
- }
- return 1;
- } elseif (is_object($value)) {
- $type = $value->type;
- $xml .= $value->serialize($this);
- } else {
- $type = $this->_getType($value);
- $xml .= $this->_serializeValue($value, 'item', $type);
- }
- $size = null;
-
- return 1;
- }
-
- /**
- * Returns whether a type is a base64 type.
- *
- * @param string $type A type name.
- *
- * @return boolean True if the type name is a base64 type.
- */
- function _isBase64Type($type)
- {
- return $type == 'base64' || $type == 'base64Binary';
- }
-
- /**
- * Returns whether an array is a hash.
- *
- * @param array $a An array to check.
- *
- * @return boolean True if the specified array is a hash.
- */
- function _isHash(&$a)
- {
- // I really dislike having to loop through this in PHP code, really
- // large arrays will be slow. We need a C function to do this.
- $it = 0;
- foreach ($a as $k => $v) {
- // Checking the type is faster than regexp.
- if (!is_int($k)) {
- return true;
- }
- // If someone has a large hash they should really be defining the
- // type.
- if ($it++ > 10) {
- $this->_raiseSoapFault('Large associative array passed where a SOAP_Value was expected');
- return false;
- }
- }
- return false;
- }
-
- function _un_htmlentities($string)
- {
- $trans_tbl = get_html_translation_table(HTML_ENTITIES);
- $trans_tbl = array_flip($trans_tbl);
- return strtr($string, $trans_tbl);
- }
-
- /**
- * Converts a SOAP_Value object into a StdClass PHP object
- */
- function &_decode(&$soapval)
- {
- if (!$this->_isSoapValue($soapval)) {
- return $soapval;
- } elseif (is_array($soapval->value)) {
- if ($soapval->type != 'Array') {
- $classname = $this->_defaultObjectClassname;
- if (isset($this->_type_translation[$soapval->tqn->fqn()])) {
- // This will force an error in PHP if the class does not
- // exist.
- $classname = $this->_type_translation[$soapval->tqn->fqn()];
- } elseif (isset($this->_type_translation[$soapval->type])) {
- // This will force an error in PHP if the class does not
- // exist.
- $classname = $this->_type_translation[$soapval->type];
- } elseif ($this->_auto_translation) {
- if (class_exists($soapval->type)) {
- $classname = $soapval->type;
- } elseif ($this->_wsdl) {
- $t = $this->_wsdl->getComplexTypeNameForElement($soapval->name, $soapval->namespace);
- if ($t && class_exists($t)) {
- $classname = $t;
- }
- }
- }
- $return = new $classname;
- } else {
- $return = array();
- }
-
- $counter = 1;
- $isstruct = !is_array($return);
- foreach ($soapval->value as $item) {
- if (is_object($return)) {
- if ($this->_wsdl) {
- // Get this child's WSDL information.
- // /$soapval->ns/$soapval->type/$item->ns/$item->name
- $child_type = $this->_wsdl->getComplexTypeChildType(
- $soapval->namespace,
- $soapval->name,
- $item->namespace,
- $item->name);
- if ($child_type) {
- $item->type = $child_type;
- }
- }
- if (!$isstruct || $item->type == 'Array') {
- if (isset($return->{$item->name}) &&
- is_object($return->{$item->name})) {
- $return->{$item->name} =& $this->_decode($item);
- } elseif (isset($return->{$item->name}) &&
- is_array($return->{$item->name})) {
- $return->{$item->name}[] = $this->_decode($item);
- } elseif (isset($return->{$item->name})) {
- $return->{$item->name} = array(
- $return->{$item->name},
- $this->_decode($item)
- );
- } elseif (is_array($return)) {
- $return[] =& $this->_decode($item);
- } else {
- $return->{$item->name} =& $this->_decode($item);
- }
- } elseif (isset($return->{$item->name})) {
- //$isstruct = false;
- if (count(get_object_vars($return)) == 1) {
- $d =& $this->_decode($item);
- $return = array($return->{$item->name}, $d);
- } else {
- $d =& $this->_decode($item);
- $return->{$item->name} = array($return->{$item->name}, $d);
- }
- } else {
- $return->{$item->name} =& $this->_decode($item);
- }
- // Set the attributes as members in the class.
- if (method_exists($return, '__set_attribute')) {
- foreach ($soapval->attributes as $key => $value) {
- call_user_func_array(array(&$return,
- '__set_attribute'),
- array($key, $value));
- }
- }
- } else {
- if ($soapval->arrayType && $this->_isSoapValue($item)) {
- if ($this->_isBase64Type($item->type) &&
- !$this->_isBase64Type($soapval->arrayType)) {
- // Decode the value if we're losing the base64
- // type information.
- $item->value = base64_decode($item->value);
- }
- $item->type = $soapval->arrayType;
- }
- if (!$isstruct) {
- $return[] = $this->_decode($item);
- } elseif (isset($return[$item->name])) {
- $isstruct = false;
- $d =& $this->_decode($item);
- $return = array($return[$item->name], $d);
- } else {
- $return[$item->name] = $this->_decode($item);
- }
- }
- }
-
- return $return;
- }
-
- if ($soapval->type == 'boolean') {
- if ($soapval->value != '0' &&
- strcasecmp($soapval->value, 'false') != 0) {
- $soapval->value = true;
- } else {
- $soapval->value = false;
- }
- } elseif ($soapval->type &&
- isset($this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type])) {
- // If we can, set variable type.
- settype($soapval->value,
- $this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type]);
- }
-
- return $soapval->value;
- }
-
- /**
- * Creates the SOAP envelope with the SOAP envelop data.
- *
- * @param mixed $method
- * @param array $headers
- * @param string $encoding
- * @param array $options
- *
- * @return string
- */
- function makeEnvelope(&$method, &$headers,
- $encoding = SOAP_DEFAULT_ENCODING,
- $options = array())
- {
- $smsg = $header_xml = $ns_string = '';
-
- if ($headers) {
- $c = count($headers);
- for ($i = 0; $i < $c; $i++) {
- $header_xml .= $headers[$i]->serialize($this);
- }
- $header_xml = "\r\n$header_xml\r\n\r\n";
- }
-
- if (!isset($options['input']) || $options['input'] == 'parse') {
- if (is_array($method)) {
- $c = count($method);
- for ($i = 0; $i < $c; $i++) {
- $smsg .= $method[$i]->serialize($this);
- }
- } else {
- $smsg = $method->serialize($this);
- }
- } else {
- $smsg = $method;
- }
- $body = "\r\n" . $smsg . "\r\n\r\n";
-
- foreach ($this->_namespaces as $k => $v) {
- $ns_string .= " xmlns:$v=\"$k\"\r\n";
- }
- if ($this->_namespace) {
- $ns_string .= " xmlns=\"{$this->_namespace}\"\r\n";
- }
-
- /* If 'use' == 'literal', we do not put in the encodingStyle. This is
- * denoted by $this->_section5 being false. 'use' can be defined at a
- * more granular level than we are dealing with here, so this does not
- * work for all services. */
- $xml = "\r\n\r\n".
- "_section5 ? ' SOAP-ENV:encodingStyle="' . SOAP_SCHEMA_ENCODING . '"' : '').
- ">\r\n".
- "$header_xml$body\r\n";
-
- return $xml;
- }
-
- function _makeMimeMessage($xml, $encoding = SOAP_DEFAULT_ENCODING)
- {
- if (!@include_once 'Mail/mimePart.php') {
- return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed');
- }
-
- // Encode any attachments. See http://www.w3.org/TR/SOAP-attachments
- // Now we have to mime encode the message.
- $params = array('content_type' => 'multipart/related; type="text/xml"');
- $msg = new Mail_mimePart('', $params);
-
- // Add the xml part.
- $params['content_type'] = 'text/xml';
- $params['charset'] = $encoding;
- $params['encoding'] = 'base64';
- $msg->addSubPart($xml, $params);
-
- // Add the attachements
- for ($i = 0, $c = count($this->_attachments); $i < $c; ++$i) {
- $msg->addSubPart($this->_attachments[$i]['body'],
- $this->_attachments[$i]);
- }
-
- return $msg->encode();
- }
-
- // TODO: this needs to be used from the Transport system.
- function _makeDIMEMessage($xml)
- {
- if (!@include_once 'Net/DIME.php') {
- return $this->_raiseSoapFault('DIME messages are unsupported, the Net_DIME package is not installed');
- }
-
- // Encode any attachments. See
- // http://search.ietf.org/internet-drafts/draft-nielsen-dime-soap-00.txt
- // Now we have to DIME encode the message
- $dime = new Net_DIME_Message();
- $msg = $dime->encodeData($xml, SOAP_ENVELOP, null, NET_DIME_TYPE_URI);
-
- // Add the attachments.
- $c = count($this->_attachments);
- for ($i = 0; $i < $c; $i++) {
- $msg .= $dime->encodeData($this->_attachments[$i]['body'],
- $this->_attachments[$i]['content_type'],
- $this->_attachments[$i]['cid'],
- NET_DIME_TYPE_MEDIA);
- }
- $msg .= $dime->endMessage();
-
- return $msg;
- }
-
- function _decodeMimeMessage(&$data, &$headers, &$attachments)
- {
- if (!@include_once 'Mail/mimeDecode.php') {
- return $this->_raiseSoapFault('MIME messages are unsupported, the Mail_Mime package is not installed');
- }
-
- $params['include_bodies'] = true;
- $params['decode_bodies'] = true;
- $params['decode_headers'] = true;
-
- // Lame thing to have to do for decoding.
- $decoder = new Mail_mimeDecode($data);
- $structure = $decoder->decode($params);
-
- if (isset($structure->body)) {
- $data = $structure->body;
- $headers = $structure->headers;
-
- return;
- } elseif (isset($structure->parts)) {
- $data = $structure->parts[0]->body;
- $headers = array_merge($structure->headers,
- $structure->parts[0]->headers);
- if (count($structure->parts) > 1) {
- $mime_parts = array_splice($structure->parts,1);
- // Prepare the parts for the SOAP parser.
-
- $c = count($mime_parts);
- for ($i = 0; $i < $c; $i++) {
- $p =& $mime_parts[$i];
- if (isset($p->headers['content-location'])) {
- // TODO: modify location per SwA note section 3
- // http://www.w3.org/TR/SOAP-attachments
- $attachments[$p->headers['content-location']] = $p->body;
- } else {
- $cid = 'cid:' . substr($p->headers['content-id'], 1, -1);
- $attachments[$cid] = $p->body;
- }
- }
- }
-
- return;
- }
-
- $this->_raiseSoapFault('Mime parsing error', '', '', 'Server');
- }
-
- function _decodeDIMEMessage(&$data, &$headers, &$attachments)
- {
- if (!@include_once 'Net/DIME.php') {
- return $this->_raiseSoapFault('DIME messages are unsupported, the Net_DIME package is not installed');
- }
-
- // This SHOULD be moved to the transport layer, e.g. PHP itself should
- // handle parsing DIME ;)
- $dime = new Net_DIME_Message();
- $err = $dime->decodeData($data);
- if (PEAR::isError($err)) {
- $this->_raiseSoapFault('Failed to decode the DIME message!', '', '', 'Server');
- return;
- }
- if (strcasecmp($dime->parts[0]['type'], SOAP_ENVELOP) != 0) {
- $this->_raiseSoapFault('DIME record 1 is not a SOAP envelop!', '', '', 'Server');
- return;
- }
-
- $data = $dime->parts[0]['data'];
- // Fake it for now.
- $headers['content-type'] = 'text/xml';
- $c = count($dime->parts);
- for ($i = 0; $i < $c; $i++) {
- $part =& $dime->parts[$i];
- // We need to handle URI's better.
- $id = strncmp($part['id'], 'cid:', 4)
- ? 'cid:' . $part['id']
- : $part['id'];
- $attachments[$id] = $part['data'];
- }
- }
-
- /**
- * @deprecated Use setTypeTranslation().
- */
- function __set_type_translation($type, $class = null)
- {
- $this->setTypeTranslation($type, $class);
- }
-
- /**
- * Explicitly sets the translation for a specific class.
- *
- * Auto translation works for all cases, but opens ANY class in the script
- * to be used as a data type, and may not be desireable.
- *
- * @param string $type A SOAP type.
- * @param string $class A PHP class name.
- */
- function setTypeTranslation($type, $class = null)
- {
- $tq = new QName($type);
- if (!$class) {
- $class = $tq->name;
- }
- $this->_type_translation[$type]=$class;
- }
-
-}
-
-/**
- * Class used to handle QNAME values in XML.
- *
- * @access public
- * @package SOAP
- * @author Shane Caraveo Conversion to PEAR and updates
- */
-class QName
-{
- var $name = '';
- var $ns = '';
- var $namespace='';
-
- function QName($name, $namespace = '')
- {
- if ($name && $name[0] == '{') {
- preg_match('/\{(.*?)\}(.*)/', $name, $m);
- $this->name = $m[2];
- $this->namespace = $m[1];
- } elseif (substr_count($name, ':') == 1) {
- $s = explode(':', $name);
- $s = array_reverse($s);
- $this->name = $s[0];
- $this->ns = $s[1];
- $this->namespace = $namespace;
- } else {
- $this->name = $name;
- $this->namespace = $namespace;
- }
-
- // A little more magic than should be in a qname.
- $p = strpos($this->name, '[');
- if ($p) {
- // TODO: Need to re-examine this logic later.
- // Chop off [].
- $this->arraySize = explode(',', substr($this->name, $p + 1, -$p - 2));
- $this->arrayInfo = substr($this->name, $p);
- $this->name = substr($this->name, 0, $p);
- }
- }
-
- function fqn()
- {
- if ($this->namespace) {
- return '{' . $this->namespace . '}' . $this->name;
- } elseif ($this->ns) {
- return $this->ns . ':' . $this->name;
- }
- return $this->name;
- }
-
-}
diff --git a/thirdparty/pear/SOAP/Client.php b/thirdparty/pear/SOAP/Client.php
deleted file mode 100644
index de66e8084..000000000
--- a/thirdparty/pear/SOAP/Client.php
+++ /dev/null
@@ -1,855 +0,0 @@
- Original Author
- * @author Shane Caraveo Port to PEAR and more
- * @author Chuck Hagenbuch Maintenance
- * @author Jan Schneider Maintenance
- * @copyright 2003-2005 The PHP Group
- * @license http://www.php.net/license/2_02.txt PHP License 2.02
- * @link http://pear.php.net/package/SOAP
- */
-
-require_once 'SOAP/Value.php';
-require_once 'SOAP/Base.php';
-require_once 'SOAP/Transport.php';
-require_once 'SOAP/WSDL.php';
-require_once 'SOAP/Fault.php';
-require_once 'SOAP/Parser.php';
-
-// Arnaud: the following code was taken from DataObject and adapted to suit
-
-// this will be horrifically slow!!!!
-// NOTE: Overload SEGFAULTS ON PHP4 + Zend Optimizer
-// these two are BC/FC handlers for call in PHP4/5
-
-if (!class_exists('SOAP_Client_Overload')) {
- if (substr(zend_version(), 0, 1) > 1) {
- class SOAP_Client_Overload extends SOAP_Base {
- function __call($method, $args)
- {
- $return = null;
- $this->_call($method, $args, $return);
- return $return;
- }
- }
- } else {
- if (!function_exists('clone')) {
- eval('function clone($t) { return $t; }');
- }
- eval('
- class SOAP_Client_Overload extends SOAP_Base {
- function __call($method, $args, &$return)
- {
- return $this->_call($method, $args, $return);
- }
- }');
- }
-}
-
-/**
- * SOAP Client Class
- *
- * This class is the main interface for making soap requests.
- *
- * basic usage:
- * $soapclient = new SOAP_Client( string path [ , boolean wsdl] );
- * echo $soapclient->call( string methodname [ , array parameters] );
- *
- * or, if using PHP 5+ or the overload extension:
- * $soapclient = new SOAP_Client( string path [ , boolean wsdl] );
- * echo $soapclient->methodname( [ array parameters] );
- *
- *
- * Originally based on SOAPx4 by Dietrich Ayala
- * http://dietrich.ganx4.com/soapx4
- *
- * @access public
- * @package SOAP
- * @author Shane Caraveo Conversion to PEAR and updates
- * @author Stig Bakken Conversion to PEAR
- * @author Dietrich Ayala Original Author
- */
-class SOAP_Client extends SOAP_Client_Overload
-{
- /**
- * Communication endpoint.
- *
- * Currently the following transport formats are supported:
- * - HTTP
- * - SMTP
- *
- * Example endpoints:
- * http://www.example.com/soap/server.php
- * https://www.example.com/soap/server.php
- * mailto:soap@example.com
- *
- * @see SOAP_Client()
- * @var string
- */
- var $_endpoint = '';
-
- /**
- * The SOAP PORT name that is used by the client.
- *
- * @var string
- */
- var $_portName = '';
-
- /**
- * Endpoint type e.g. 'wdsl'.
- *
- * @var string
- */
- var $_endpointType = '';
-
- /**
- * The received xml.
- *
- * @var string
- */
- var $xml;
-
- /**
- * The outgoing and incoming data stream for debugging.
- *
- * @var string
- */
- var $wire;
-
- /**
- * The outgoing data stream for debugging.
- *
- * @var string
- */
- var $_last_request = null;
-
- /**
- * The incoming data stream for debugging.
- *
- * @var string
- */
- var $_last_response = null;
-
- /**
- * Options.
- *
- * @var array
- */
- var $_options = array('trace' => false);
-
- /**
- * The character encoding used for XML parser, etc.
- *
- * @var string
- */
- var $_encoding = SOAP_DEFAULT_ENCODING;
-
- /**
- * The array of SOAP_Headers that we are sending.
- *
- * @var array
- */
- var $headersOut = null;
-
- /**
- * The headers we recieved back in the response.
- *
- * @var array
- */
- var $headersIn = null;
-
- /**
- * Options for the HTTP_Request class (see HTTP/Request.php).
- *
- * @var array
- */
- var $_proxy_params = array();
-
- /**
- * The SOAP_Transport instance.
- *
- * @var SOAP_Transport
- */
- var $_soap_transport = null;
-
- /**
- * Constructor.
- *
- * @access public
- *
- * @param string $endpoint An URL.
- * @param boolean $wsdl Whether the endpoint is a WSDL file.
- * @param string $portName The service's port name to use.
- * @param array $proxy_params Options for the HTTP_Request class
- * @see HTTP_Request
- * @param boolean|string $cache Use WSDL caching? The cache directory if
- * a string.
- */
- function SOAP_Client($endpoint, $wsdl = false, $portName = false,
- $proxy_params = array(), $cache = false)
- {
- parent::SOAP_Base('Client');
-
- $this->_endpoint = $endpoint;
- $this->_portName = $portName;
- $this->_proxy_params = $proxy_params;
-
- // This hack should perhaps be removed as it might cause unexpected
- // behaviour.
- $wsdl = $wsdl
- ? $wsdl
- : strtolower(substr($endpoint, -4)) == 'wsdl';
-
- // make values
- if ($wsdl) {
- $this->_endpointType = 'wsdl';
- // instantiate wsdl class
- $this->_wsdl = new SOAP_WSDL($this->_endpoint,
- $this->_proxy_params,
- $cache);
- if ($this->_wsdl->fault) {
- $this->_raiseSoapFault($this->_wsdl->fault);
- }
- }
- }
-
- function _reset()
- {
- $this->xml = null;
- $this->wire = null;
- $this->_last_request = null;
- $this->_last_response = null;
- $this->headersIn = null;
- $this->headersOut = null;
- }
-
- /**
- * Sets the character encoding.
- *
- * Limited to 'UTF-8', 'US_ASCII' and 'ISO-8859-1'.
- *
- * @access public
- *
- * @param string encoding
- *
- * @return mixed SOAP_Fault on error.
- */
- function setEncoding($encoding)
- {
- if (in_array($encoding, $this->_encodings)) {
- $this->_encoding = $encoding;
- return;
- }
- return $this->_raiseSoapFault('Invalid Encoding');
- }
-
- /**
- * Adds a header to the envelope.
- *
- * @access public
- *
- * @param SOAP_Header $soap_value A SOAP_Header or an array with the
- * elements 'name', 'namespace',
- * 'mustunderstand', and 'actor' to send
- * as a header.
- */
- function addHeader($soap_value)
- {
- // Add a new header to the message.
- if (is_a($soap_value, 'SOAP_Header')) {
- $this->headersOut[] = $soap_value;
- } elseif (is_array($soap_value)) {
- // name, value, namespace, mustunderstand, actor
- $this->headersOut[] = new SOAP_Header($soap_value[0],
- null,
- $soap_value[1],
- $soap_value[2],
- $soap_value[3]);
- } else {
- $this->_raiseSoapFault('Invalid parameter provided to addHeader(). Must be an array or a SOAP_Header.');
- }
- }
-
- /**
- * Calls a method on the SOAP endpoint.
- *
- * The namespace parameter is overloaded to accept an array of options
- * that can contain data necessary for various transports if it is used as
- * an array, it MAY contain a namespace value and a soapaction value. If
- * it is overloaded, the soapaction parameter is ignored and MUST be
- * placed in the options array. This is done to provide backwards
- * compatibility with current clients, but may be removed in the future.
- * The currently supported values are:
-Notes:
-Tests are done both "Direct" and with "WSDL". WSDL tests use the supplied interop WSDL
-to run the tests against. The Direct method uses an internal prebuilt list of methods and parameters
-for the test.
-
-Tests are also run against two methods of generating method parameters. The first, 'php', attempts
-to directly serialize PHP variables into soap values. The second method, 'soapval', uses a SOAP_Value
-class to define what the type of the value is. The second method is more interopable than the first
-by nature.
-
-
-
Interop Client Test Results
-
This is a database of the current test results using PEAR SOAP Clients against interop servers.
-
-More detail (wire) about errors (marked yellow or red) can be obtained by clicking on the
-link in the result box. If we have an HTTP error
-attempting to connect to the endpoint, we will mark all consecutive attempts as errors, and skip
-testing that endpoint. This reduces the time it takes to run the tests if a server is unavailable.
-WSDLCACHE errors mean we cannot retreive the WSDL file specified for the endpoint.
-