You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/05/08 01:48:22 UTC

svn commit: r654331 [6/6] - in /incubator/shindig/trunk/php: ./ src/common/Zend/ src/common/Zend/Feed/ src/common/Zend/Feed/Builder/ src/common/Zend/Feed/Builder/Header/ src/common/Zend/Feed/Entry/ src/common/Zend/Http/ src/common/Zend/Http/Client/ src...

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hex.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hex.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hex.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hex.php Wed May  7 16:48:15 2008
@@ -0,0 +1,74 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Hex.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hex extends Zend_Validate_Abstract
+{
+    /**
+     * Validation failure message key for when the value contains characters other than hexadecimal digits
+     */
+    const NOT_HEX = 'notHex';
+
+    /**
+     * Validation failure message template definitions
+     *
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::NOT_HEX => "'%value%' has not only hexadecimal digit characters"
+    );
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if $value contains only hexadecimal digit characters
+     *
+     * @param  string $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $valueString = (string) $value;
+
+        $this->_setValue($valueString);
+
+        if (!ctype_xdigit($valueString)) {
+            $this->_error();
+            return false;
+        }
+
+        return true;
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname.php Wed May  7 16:48:15 2008
@@ -0,0 +1,444 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Hostname.php 8986 2008-03-21 21:38:32Z matthew $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+/**
+ * @see Zend_Loader
+ */
+require_once 'Zend/Loader.php';
+
+/**
+ * @see Zend_Validate_Ip
+ */
+require_once 'Zend/Validate/Ip.php';
+
+/**
+ * Please note there are two standalone test scripts for testing IDN characters due to problems
+ * with file encoding.
+ *
+ * The first is tests/Zend/Validate/HostnameTestStandalone.php which is designed to be run on
+ * the command line.
+ *
+ * The second is tests/Zend/Validate/HostnameTestForm.php which is designed to be run via HTML
+ * to allow users to test entering UTF-8 characters in a form.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname extends Zend_Validate_Abstract
+{
+
+    const IP_ADDRESS_NOT_ALLOWED  = 'hostnameIpAddressNotAllowed';
+    const UNKNOWN_TLD             = 'hostnameUnknownTld';
+    const INVALID_DASH            = 'hostnameDashCharacter';
+    const INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema';
+    const UNDECIPHERABLE_TLD      = 'hostnameUndecipherableTld';
+    const INVALID_HOSTNAME        = 'hostnameInvalidHostname';
+    const INVALID_LOCAL_NAME      = 'hostnameInvalidLocalName';
+    const LOCAL_NAME_NOT_ALLOWED  = 'hostnameLocalNameNotAllowed';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::IP_ADDRESS_NOT_ALLOWED  => "'%value%' appears to be an IP address, but IP addresses are not allowed",
+        self::UNKNOWN_TLD             => "'%value%' appears to be a DNS hostname but cannot match TLD against known list",
+        self::INVALID_DASH            => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position",
+        self::INVALID_HOSTNAME_SCHEMA => "'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'",
+        self::UNDECIPHERABLE_TLD      => "'%value%' appears to be a DNS hostname but cannot extract TLD part",
+        self::INVALID_HOSTNAME        => "'%value%' does not match the expected structure for a DNS hostname",
+        self::INVALID_LOCAL_NAME      => "'%value%' does not appear to be a valid local network name",
+        self::LOCAL_NAME_NOT_ALLOWED  => "'%value%' appears to be a local network name but local network names are not allowed"
+    );
+
+    /**
+     * @var array
+     */
+    protected $_messageVariables = array(
+        'tld' => '_tld'
+    );
+
+    /**
+     * Allows Internet domain names (e.g., example.com)
+     */
+    const ALLOW_DNS   = 1;
+
+    /**
+     * Allows IP addresses
+     */
+    const ALLOW_IP    = 2;
+
+    /**
+     * Allows local network names (e.g., localhost, www.localdomain)
+     */
+    const ALLOW_LOCAL = 4;
+
+    /**
+     * Allows all types of hostnames
+     */
+    const ALLOW_ALL   = 7;
+
+    /**
+     * Whether IDN domains are validated
+     *
+     * @var boolean
+     */
+    private $_validateIdn = true;
+
+    /**
+     * Whether TLDs are validated against a known list
+     *
+     * @var boolean
+     */
+    private $_validateTld = true;
+
+    /**
+     * Bit field of ALLOW constants; determines which types of hostnames are allowed
+     *
+     * @var integer
+     */
+    protected $_allow;
+
+    /**
+     * Bit field of CHECK constants; determines what additional hostname checks to make
+     *
+     * @var unknown_type
+     */
+    // protected $_check;
+
+    /**
+     * Array of valid top-level-domains
+     *
+     * @var array
+     * @see ftp://data.iana.org/TLD/tlds-alpha-by-domain.txt  List of all TLDs by domain
+     */
+    protected $_validTlds = array(
+        'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao',
+        'aq', 'ar', 'arpa', 'as', 'asia', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb',
+        'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo',
+        'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cat', 'cc', 'cd',
+        'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'com', 'coop',
+        'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do',
+        'dz', 'ec', 'edu', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj',
+        'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh',
+        'gi', 'gl', 'gm', 'gn', 'gov', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu',
+        'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il',
+        'im', 'in', 'info', 'int', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm',
+        'jo', 'jobs', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw',
+        'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu',
+        'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mil', 'mk', 'ml', 'mm',
+        'mn', 'mo', 'mobi', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'museum', 'mv',
+        'mw', 'mx', 'my', 'mz', 'na', 'name', 'nc', 'ne', 'net', 'nf', 'ng',
+        'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'org', 'pa', 'pe',
+        'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'pro', 'ps', 'pt',
+        'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd',
+        'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr',
+        'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tel', 'tf', 'tg', 'th', 'tj',
+        'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'travel', 'tt', 'tv', 'tw',
+        'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've',
+        'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm',
+        'zw'
+        );
+
+    /**
+     * @var string
+     */
+    protected $_tld;
+
+    /**
+     * Sets validator options
+     *
+     * @param integer          $allow       OPTIONAL Set what types of hostname to allow (default ALLOW_DNS)
+     * @param boolean          $validateIdn OPTIONAL Set whether IDN domains are validated (default true)
+     * @param boolean          $validateTld OPTIONAL Set whether the TLD element of a hostname is validated (default true)
+     * @param Zend_Validate_Ip $ipValidator OPTIONAL
+     * @return void
+     * @see http://www.iana.org/cctld/specifications-policies-cctlds-01apr02.htm  Technical Specifications for ccTLDs
+     */
+    public function __construct($allow = self::ALLOW_DNS, $validateIdn = true, $validateTld = true, Zend_Validate_Ip $ipValidator = null)
+    {
+        // Set allow options
+        $this->setAllow($allow);
+
+        // Set validation options
+        $this->_validateIdn = $validateIdn;
+        $this->_validateTld = $validateTld;
+
+        $this->setIpValidator($ipValidator);
+    }
+
+    /**
+     * @param Zend_Validate_Ip $ipValidator OPTIONAL
+     * @return void;
+     */
+    public function setIpValidator(Zend_Validate_Ip $ipValidator = null)
+    {
+        if ($ipValidator === null) {
+            $ipValidator = new Zend_Validate_Ip();
+        }
+        $this->_ipValidator = $ipValidator;
+    }
+
+    /**
+     * Returns the allow option
+     *
+     * @return integer
+     */
+    public function getAllow()
+    {
+        return $this->_allow;
+    }
+
+    /**
+     * Sets the allow option
+     *
+     * @param  integer $allow
+     * @return Zend_Validate_Hostname Provides a fluent interface
+     */
+    public function setAllow($allow)
+    {
+        $this->_allow = $allow;
+        return $this;
+    }
+
+    /**
+     * Set whether IDN domains are validated
+     *
+     * This only applies when DNS hostnames are validated
+     *
+     * @param boolean $allowed Set allowed to true to validate IDNs, and false to not validate them
+     */
+    public function setValidateIdn ($allowed)
+    {
+        $this->_validateIdn = (bool) $allowed;
+    }
+
+    /**
+     * Set whether the TLD element of a hostname is validated
+     *
+     * This only applies when DNS hostnames are validated
+     *
+     * @param boolean $allowed Set allowed to true to validate TLDs, and false to not validate them
+     */
+    public function setValidateTld ($allowed)
+    {
+        $this->_validateTld = (bool) $allowed;
+    }
+
+    /**
+     * Sets the check option
+     *
+     * @param  integer $check
+     * @return Zend_Validate_Hostname Provides a fluent interface
+     */
+    /*
+    public function setCheck($check)
+    {
+        $this->_check = $check;
+        return $this;
+    }
+     */
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if the $value is a valid hostname with respect to the current allow option
+     *
+     * @param  string $value
+     * @throws Zend_Validate_Exception if a fatal error occurs for validation process
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $valueString = (string) $value;
+
+        $this->_setValue($valueString);
+
+        // Check input against IP address schema
+        if ($this->_ipValidator->setTranslator($this->getTranslator())->isValid($valueString)) {
+            if (!($this->_allow & self::ALLOW_IP)) {
+                $this->_error(self::IP_ADDRESS_NOT_ALLOWED);
+                return false;
+            } else{
+                return true;
+            }
+        }
+
+        // Check input against DNS hostname schema
+        $domainParts = explode('.', $valueString);
+        if ((count($domainParts) > 1) && (strlen($valueString) >= 4) && (strlen($valueString) <= 254)) {
+            $status = false;
+
+            do {
+                // First check TLD
+                if (preg_match('/([a-z]{2,10})$/i', end($domainParts), $matches)) {
+
+                    reset($domainParts);
+
+                    // Hostname characters are: *(label dot)(label dot label); max 254 chars
+                    // label: id-prefix [*ldh{61} id-prefix]; max 63 chars
+                    // id-prefix: alpha / digit
+                    // ldh: alpha / digit / dash
+
+                    // Match TLD against known list
+                    $this->_tld = strtolower($matches[1]);
+                    if ($this->_validateTld) {
+                        if (!in_array($this->_tld, $this->_validTlds)) {
+                            $this->_error(self::UNKNOWN_TLD);
+                            $status = false;
+                            break;
+                        }
+                    }
+
+                    /**
+                     * Match against IDN hostnames
+                     * @see Zend_Validate_Hostname_Interface
+                     */
+                    $labelChars = 'a-z0-9';
+                    $utf8 = false;
+                    $classFile = 'Zend/Validate/Hostname/' . ucfirst($this->_tld) . '.php';
+                    if ($this->_validateIdn) {
+                        if (Zend_Loader::isReadable($classFile)) {
+
+                            // Load additional characters
+                            $className = 'Zend_Validate_Hostname_' . ucfirst($this->_tld);
+                            Zend_Loader::loadClass($className);
+                            $labelChars .= call_user_func(array($className, 'getCharacters'));
+                            $utf8 = true;
+                        }
+                    }
+
+                    // Keep label regex short to avoid issues with long patterns when matching IDN hostnames
+                    $regexLabel = '/^[' . $labelChars . '\x2d]{1,63}$/i';
+                    if ($utf8) {
+                        $regexLabel .= 'u';
+                    }
+
+                    // Check each hostname part
+                    $valid = true;
+                    foreach ($domainParts as $domainPart) {
+
+                        // Check dash (-) does not start, end or appear in 3rd and 4th positions
+                        if (strpos($domainPart, '-') === 0 ||
+                        (strlen($domainPart) > 2 && strpos($domainPart, '-', 2) == 2 && strpos($domainPart, '-', 3) == 3) ||
+                        strrpos($domainPart, '-') === strlen($domainPart) - 1) {
+
+                            $this->_error(self::INVALID_DASH);
+                            $status = false;
+                            break 2;
+                        }
+
+                        // Check each domain part
+                        $status = @preg_match($regexLabel, $domainPart);
+                        if ($status === false) {
+                            /**
+                             * Regex error
+                             * @see Zend_Validate_Exception
+                             */
+                            require_once 'Zend/Validate/Exception.php';
+                            throw new Zend_Validate_Exception('Internal error: DNS validation failed');
+                        } elseif ($status === 0) {
+                            $valid = false;
+                        }
+                    }
+
+                    // If all labels didn't match, the hostname is invalid
+                    if (!$valid) {
+                        $this->_error(self::INVALID_HOSTNAME_SCHEMA);
+                        $status = false;
+                    }
+
+                } else {
+                    // Hostname not long enough
+                    $this->_error(self::UNDECIPHERABLE_TLD);
+                    $status = false;
+                }
+            } while (false);
+
+            // If the input passes as an Internet domain name, and domain names are allowed, then the hostname
+            // passes validation
+            if ($status && ($this->_allow & self::ALLOW_DNS)) {
+                return true;
+            }
+        } else {
+            $this->_error(self::INVALID_HOSTNAME);
+        }
+
+        // Check input against local network name schema; last chance to pass validation
+        $regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}){1,254}$/';
+        $status = @preg_match($regexLocal, $valueString);
+        if (false === $status) {
+            /**
+             * Regex error
+             * @see Zend_Validate_Exception
+             */
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception('Internal error: local network name validation failed');
+        }
+
+        // If the input passes as a local network name, and local network names are allowed, then the
+        // hostname passes validation
+        $allowLocal = $this->_allow & self::ALLOW_LOCAL;
+        if ($status && $allowLocal) {
+            return true;
+        }
+
+        // If the input does not pass as a local network name, add a message
+        if (!$status) {
+            $this->_error(self::INVALID_LOCAL_NAME);
+        }
+
+        // If local network names are not allowed, add a message
+        if (!$allowLocal) {
+            $this->_error(self::LOCAL_NAME_NOT_ALLOWED);
+        }
+
+        return false;
+    }
+
+    /**
+     * Throws an exception if a regex for $type does not exist
+     *
+     * @param  string $type
+     * @throws Zend_Validate_Exception
+     * @return Zend_Validate_Hostname Provides a fluent interface
+     */
+    /*
+    protected function _checkRegexType($type)
+    {
+        if (!isset($this->_regex[$type])) {
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception("'$type' must be one of ('" . implode(', ', array_keys($this->_regex))
+                                            . "')");
+        }
+        return $this;
+    }
+     */
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/At.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/At.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/At.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/At.php Wed May  7 16:48:15 2008
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: At.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_At implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see http://www.nic.at/en/service/technical_information/idn/charset_converter/ Austria (.AT)
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return '\x{00EO}-\x{00F6}\x{00F8}-\x{00FF}\x{0153}\x{0161}\x{017E}';
+    }
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Ch.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Ch.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Ch.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Ch.php Wed May  7 16:48:15 2008
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Ch.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_Ch implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see https://nic.switch.ch/reg/ocView.action?res=EF6GW2JBPVTG67DLNIQXU234MN6SC33JNQQGI7L6#anhang1 Switzerland (.CH)
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return '\x{00EO}-\x{00F6}\x{00F8}-\x{00FF}\x{0153}';
+    }
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/De.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/De.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/De.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/De.php Wed May  7 16:48:15 2008
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: De.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_De implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see http://www.denic.de/en/domains/idns/liste.html Germany (.DE) alllowed characters
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return  '\x{00E1}\x{00E0}\x{0103}\x{00E2}\x{00E5}\x{00E4}\x{00E3}\x{0105}\x{0101}\x{00E6}\x{0107}' .
+                '\x{0109}\x{010D}\x{010B}\x{00E7}\x{010F}\x{0111}\x{00E9}\x{00E8}\x{0115}\x{00EA}\x{011B}' .
+                '\x{00EB}\x{0117}\x{0119}\x{0113}\x{011F}\x{011D}\x{0121}\x{0123}\x{0125}\x{0127}\x{00ED}' .
+                '\x{00EC}\x{012D}\x{00EE}\x{00EF}\x{0129}\x{012F}\x{012B}\x{0131}\x{0135}\x{0137}\x{013A}' .
+                '\x{013E}\x{013C}\x{0142}\x{0144}\x{0148}\x{00F1}\x{0146}\x{014B}\x{00F3}\x{00F2}\x{014F}' .
+                '\x{00F4}\x{00F6}\x{0151}\x{00F5}\x{00F8}\x{014D}\x{0153}\x{0138}\x{0155}\x{0159}\x{0157}' .
+                '\x{015B}\x{015D}\x{0161}\x{015F}\x{0165}\x{0163}\x{0167}\x{00FA}\x{00F9}\x{016D}\x{00FB}' .
+                '\x{016F}\x{00FC}\x{0171}\x{0169}\x{0173}\x{016B}\x{0175}\x{00FD}\x{0177}\x{00FF}\x{017A}' .
+                '\x{017E}\x{017C}\x{00F0}\x{00FE}';
+    }
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Fi.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Fi.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Fi.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Fi.php Wed May  7 16:48:15 2008
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Fi.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_Fi implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see http://www.ficora.fi/en/index/palvelut/fiverkkotunnukset/aakkostenkaytto.html Finland (.FI)
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return '\x{00E5}\x{00E4}\x{00F6}';
+    }
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Hu.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Hu.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Hu.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Hu.php Wed May  7 16:48:15 2008
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Hu.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_Hu implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see http://www.domain.hu/domain/English/szabalyzat.html Hungary (.HU)
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return '\x{00E1}\x{00E9}\x{00ED}\x{00F3}\x{00F6}\x{0151}\x{00FA}\x{00FC}\x{0171}';
+    }
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Interface.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Interface.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Interface.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Interface.php Wed May  7 16:48:15 2008
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Interface.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+interface Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * UTF-8 characters should be written as four character hex codes \x{XXXX}
+     * For example é (lowercase e with acute) is represented by the hex code \x{00E9}
+     *
+     * You only need to include lower-case equivalents of characters since the hostname
+     * check is case-insensitive
+     *
+     * Please document the supported TLDs in the documentation file at:
+     * manual/en/module_specs/Zend_Validate-Hostname.xml
+     *
+     * @see http://en.wikipedia.org/wiki/Internationalized_domain_name
+     * @see http://www.iana.org/cctld/ Country-Code Top-Level Domains (TLDs)
+     * @see http://www.columbia.edu/kermit/utf8-t1.html UTF-8 characters
+     * @return string
+     */
+    static function getCharacters();
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Li.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Li.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Li.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Li.php Wed May  7 16:48:15 2008
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Li.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_Li implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see https://nic.switch.ch/reg/ocView.action?res=EF6GW2JBPVTG67DLNIQXU234MN6SC33JNQQGI7L6#anhang1 Liechtenstein (.LI)
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return '\x{00EO}-\x{00F6}\x{00F8}-\x{00FF}\x{0153}';
+    }
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/No.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/No.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/No.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/No.php Wed May  7 16:48:15 2008
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: No.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_No implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see http://www.norid.no/domeneregistrering/idn/idn_nyetegn.en.html Norway (.NO)
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return  '\x00E1\x00E0\x00E4\x010D\x00E7\x0111\x00E9\x00E8\x00EA\x\x014B' .
+                '\x0144\x00F1\x00F3\x00F2\x00F4\x00F6\x0161\x0167\x00FC\x017E\x00E6' .
+                '\x00F8\x00E5';
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Se.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Se.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Se.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Hostname/Se.php Wed May  7 16:48:15 2008
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Se.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Hostname_Interface
+ */
+require_once 'Zend/Validate/Hostname/Interface.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Hostname_Se implements Zend_Validate_Hostname_Interface
+{
+
+    /**
+     * Returns UTF-8 characters allowed in DNS hostnames for the specified Top-Level-Domain
+     *
+     * @see http://www.iis.se/english/IDN_campaignsite.shtml?lang=en Sweden (.SE)
+     * @return string
+     */
+    static function getCharacters()
+    {
+        return '\x{00E5}\x{00E4}\x{00F6}\x{00FC}\x{00E9}';
+    }
+
+}
\ No newline at end of file

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Identical.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Identical.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Identical.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Identical.php Wed May  7 16:48:15 2008
@@ -0,0 +1,117 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Identical.php 8118 2008-02-18 16:10:32Z matthew $
+ */
+
+/** Zend_Validate_Abstract */
+require_once 'Zend/Validate/Abstract.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Identical extends Zend_Validate_Abstract
+{
+    /**#@+
+     * Error codes
+     * @const string
+     */
+    const NOT_SAME      = 'notSame';
+    const MISSING_TOKEN = 'missingToken';
+    /**#@-*/
+
+    /**
+     * Error messages
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::NOT_SAME      => 'Tokens do not match',
+        self::MISSING_TOKEN => 'No token was provided to match against',
+    );
+
+    /**
+     * Original token against which to validate
+     * @var string
+     */
+    protected $_token;
+
+    /**
+     * Sets validator options
+     *
+     * @param  string $token
+     * @return void
+     */
+    public function __construct($token = null)
+    {
+        if (null !== $token) {
+            $this->setToken($token);
+        }
+    }
+
+    /**
+     * Set token against which to compare
+     * 
+     * @param  string $token 
+     * @return Zend_Validate_Identical
+     */
+    public function setToken($token)
+    {
+        $this->_token = (string) $token;
+        return $this;
+    }
+
+    /**
+     * Retrieve token
+     * 
+     * @return string
+     */
+    public function getToken()
+    {
+        return $this->_token;
+    }
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if a token has been set and the provided value 
+     * matches that token.
+     *
+     * @param  string $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $this->_setValue($value);
+        $token = $this->getToken();
+
+        if (empty($token)) {
+            $this->_error(self::MISSING_TOKEN);
+            return false;
+        }
+
+        if ($value !== $token)  {
+            $this->_error(self::NOT_SAME);
+            return false;
+        }
+
+        return true;
+    }
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/InArray.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/InArray.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/InArray.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/InArray.php Wed May  7 16:48:15 2008
@@ -0,0 +1,138 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: InArray.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_InArray extends Zend_Validate_Abstract
+{
+
+    const NOT_IN_ARRAY = 'notInArray';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::NOT_IN_ARRAY => "'%value%' was not found in the haystack"
+    );
+
+    /**
+     * Haystack of possible values
+     *
+     * @var array
+     */
+    protected $_haystack;
+
+    /**
+     * Whether a strict in_array() invocation is used
+     *
+     * @var boolean
+     */
+    protected $_strict;
+
+    /**
+     * Sets validator options
+     *
+     * @param  array   $haystack
+     * @param  boolean $strict
+     * @return void
+     */
+    public function __construct(array $haystack, $strict = false)
+    {
+        $this->setHaystack($haystack)
+             ->setStrict($strict);
+    }
+
+    /**
+     * Returns the haystack option
+     *
+     * @return mixed
+     */
+    public function getHaystack()
+    {
+        return $this->_haystack;
+    }
+
+    /**
+     * Sets the haystack option
+     *
+     * @param  mixed $haystack
+     * @return Zend_Validate_InArray Provides a fluent interface
+     */
+    public function setHaystack(array $haystack)
+    {
+        $this->_haystack = $haystack;
+        return $this;
+    }
+
+    /**
+     * Returns the strict option
+     *
+     * @return boolean
+     */
+    public function getStrict()
+    {
+        return $this->_strict;
+    }
+
+    /**
+     * Sets the strict option
+     *
+     * @param  boolean $strict
+     * @return Zend_Validate_InArray Provides a fluent interface
+     */
+    public function setStrict($strict)
+    {
+        $this->_strict = $strict;
+        return $this;
+    }
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if $value is contained in the haystack option. If the strict
+     * option is true, then the type of $value is also checked.
+     *
+     * @param  mixed $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $this->_setValue($value);
+        if (!in_array($value, $this->_haystack, $this->_strict)) {
+            $this->_error();
+            return false;
+        }
+        return true;
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Int.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Int.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Int.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Int.php Wed May  7 16:48:15 2008
@@ -0,0 +1,75 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Int.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Int extends Zend_Validate_Abstract
+{
+
+    const NOT_INT = 'notInt';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::NOT_INT => "'%value%' does not appear to be an integer"
+    );
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if $value is a valid integer
+     *
+     * @param  string $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $valueString = (string) $value;
+
+        $this->_setValue($valueString);
+
+        $locale = localeconv();
+
+        $valueFiltered = str_replace($locale['decimal_point'], '.', $valueString);
+        $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered);
+
+        if (strval(intval($valueFiltered)) != $valueFiltered) {
+            $this->_error();
+            return false;
+        }
+
+        return true;
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Interface.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Interface.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Interface.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Interface.php Wed May  7 16:48:15 2008
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Interface.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+interface Zend_Validate_Interface
+{
+    /**
+     * Returns true if and only if $value meets the validation requirements
+     *
+     * If $value fails validation, then this method returns false, and
+     * getMessages() will return an array of messages that explain why the
+     * validation failed.
+     *
+     * @param  mixed $value
+     * @return boolean
+     * @throws Zend_Valid_Exception If validation of $value is impossible
+     */
+    public function isValid($value);
+
+    /**
+     * Returns an array of messages that explain why the most recent isValid()
+     * call returned false. The array keys are validation failure message identifiers,
+     * and the array values are the corresponding human-readable message strings.
+     *
+     * If isValid() was never called or if the most recent isValid() call
+     * returned true, then this method returns an empty array.
+     *
+     * @return array
+     */
+    public function getMessages();
+
+    /**
+     * Returns an array of message codes that explain why a previous isValid() call
+     * returned false.
+     *
+     * If isValid() was never called or if the most recent isValid() call
+     * returned true, then this method returns an empty array.
+     *
+     * This is now the same as calling array_keys() on the return value from getMessages().
+     *
+     * @return array
+     * @deprecated Since 1.5.0
+     */
+    public function getErrors();
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Ip.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Ip.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Ip.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Ip.php Wed May  7 16:48:15 2008
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Ip.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Ip extends Zend_Validate_Abstract
+{
+
+    const NOT_IP_ADDRESS = 'notIpAddress';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::NOT_IP_ADDRESS => "'%value%' does not appear to be a valid IP address"
+    );
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if $value is a valid IP address
+     *
+     * @param  mixed $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $valueString = (string) $value;
+
+        $this->_setValue($valueString);
+
+        if (ip2long($valueString) === false) {
+            $this->_error();
+            return false;
+        }
+
+        return true;
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/LessThan.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/LessThan.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/LessThan.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/LessThan.php Wed May  7 16:48:15 2008
@@ -0,0 +1,113 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: LessThan.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_LessThan extends Zend_Validate_Abstract
+{
+
+    const NOT_LESS = 'notLessThan';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::NOT_LESS => "'%value%' is not less than '%max%'"
+    );
+
+    /**
+     * @var array
+     */
+    protected $_messageVariables = array(
+        'max' => '_max'
+    );
+
+    /**
+     * Maximum value
+     *
+     * @var mixed
+     */
+    protected $_max;
+
+    /**
+     * Sets validator options
+     *
+     * @param  mixed $max
+     * @return void
+     */
+    public function __construct($max)
+    {
+        $this->setMax($max);
+    }
+
+    /**
+     * Returns the max option
+     *
+     * @return mixed
+     */
+    public function getMax()
+    {
+        return $this->_max;
+    }
+
+    /**
+     * Sets the max option
+     *
+     * @param  mixed $max
+     * @return Zend_Validate_LessThan Provides a fluent interface
+     */
+    public function setMax($max)
+    {
+        $this->_max = $max;
+        return $this;
+    }
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if $value is less than max option
+     *
+     * @param  mixed $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $this->_setValue($value);
+        if ($this->_max <= $value) {
+            $this->_error();
+            return false;
+        }
+        return true;
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/NotEmpty.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/NotEmpty.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/NotEmpty.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/NotEmpty.php Wed May  7 16:48:15 2008
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: NotEmpty.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_NotEmpty extends Zend_Validate_Abstract
+{
+
+    const IS_EMPTY = 'isEmpty';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::IS_EMPTY => "Value is empty, but a non-empty value is required"
+    );
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if $value is not an empty value.
+     *
+     * @param  string $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $valueString = (string) $value;
+
+        $this->_setValue($valueString);
+
+        if (empty($value)) {
+            $this->_error();
+            return false;
+        }
+
+        return true;
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/Regex.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/Regex.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/Regex.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/Regex.php Wed May  7 16:48:15 2008
@@ -0,0 +1,125 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: Regex.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_Regex extends Zend_Validate_Abstract
+{
+
+    const NOT_MATCH = 'regexNotMatch';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'"
+    );
+
+    /**
+     * @var array
+     */
+    protected $_messageVariables = array(
+        'pattern' => '_pattern'
+    );
+
+    /**
+     * Regular expression pattern
+     *
+     * @var string
+     */
+    protected $_pattern;
+
+    /**
+     * Sets validator options
+     *
+     * @param  string $pattern
+     * @return void
+     */
+    public function __construct($pattern)
+    {
+        $this->setPattern($pattern);
+    }
+
+    /**
+     * Returns the pattern option
+     *
+     * @return string
+     */
+    public function getPattern()
+    {
+        return $this->_pattern;
+    }
+
+    /**
+     * Sets the pattern option
+     *
+     * @param  string $pattern
+     * @return Zend_Validate_Regex Provides a fluent interface
+     */
+    public function setPattern($pattern)
+    {
+        $this->_pattern = (string) $pattern;
+        return $this;
+    }
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if $value matches against the pattern option
+     *
+     * @param  string $value
+     * @throws Zend_Validate_Exception if there is a fatal error in pattern matching
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $valueString = (string) $value;
+
+        $this->_setValue($valueString);
+
+        $status = @preg_match($this->_pattern, $valueString);
+        if (false === $status) {
+            /**
+             * @see Zend_Validate_Exception
+             */
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$valueString'");
+        }
+        if (!$status) {
+            $this->_error();
+            return false;
+        }
+        return true;
+    }
+
+}

Added: incubator/shindig/trunk/php/src/common/Zend/Validate/StringLength.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/Zend/Validate/StringLength.php?rev=654331&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/common/Zend/Validate/StringLength.php (added)
+++ incubator/shindig/trunk/php/src/common/Zend/Validate/StringLength.php Wed May  7 16:48:15 2008
@@ -0,0 +1,180 @@
+<?php
+
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id: StringLength.php 8064 2008-02-16 10:58:39Z thomas $
+ */
+
+
+/**
+ * @see Zend_Validate_Abstract
+ */
+require_once 'Zend/Validate/Abstract.php';
+
+
+/**
+ * @category   Zend
+ * @package    Zend_Validate
+ * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Validate_StringLength extends Zend_Validate_Abstract
+{
+
+    const TOO_SHORT = 'stringLengthTooShort';
+    const TOO_LONG  = 'stringLengthTooLong';
+
+    /**
+     * @var array
+     */
+    protected $_messageTemplates = array(
+        self::TOO_SHORT => "'%value%' is less than %min% characters long",
+        self::TOO_LONG  => "'%value%' is greater than %max% characters long"
+    );
+
+    /**
+     * @var array
+     */
+    protected $_messageVariables = array(
+        'min' => '_min',
+        'max' => '_max'
+    );
+
+    /**
+     * Minimum length
+     *
+     * @var integer
+     */
+    protected $_min;
+
+    /**
+     * Maximum length
+     *
+     * If null, there is no maximum length
+     *
+     * @var integer|null
+     */
+    protected $_max;
+
+    /**
+     * Sets validator options
+     *
+     * @param  integer $min
+     * @param  integer $max
+     * @return void
+     */
+    public function __construct($min = 0, $max = null)
+    {
+        $this->setMin($min);
+        $this->setMax($max);
+    }
+
+    /**
+     * Returns the min option
+     *
+     * @return integer
+     */
+    public function getMin()
+    {
+        return $this->_min;
+    }
+
+    /**
+     * Sets the min option
+     *
+     * @param  integer $min
+     * @throws Zend_Validate_Exception
+     * @return Zend_Validate_StringLength Provides a fluent interface
+     */
+    public function setMin($min)
+    {
+        if (null !== $this->_max && $min > $this->_max) {
+            /**
+             * @see Zend_Validate_Exception
+             */
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum length, but $min >"
+                                            . " $this->_max");
+        }
+        $this->_min = max(0, (integer) $min);
+        return $this;
+    }
+
+    /**
+     * Returns the max option
+     *
+     * @return integer|null
+     */
+    public function getMax()
+    {
+        return $this->_max;
+    }
+
+    /**
+     * Sets the max option
+     *
+     * @param  integer|null $max
+     * @throws Zend_Validate_Exception
+     * @return Zend_Validate_StringLength Provides a fluent interface
+     */
+    public function setMax($max)
+    {
+        if (null === $max) {
+            $this->_max = null;
+        } else if ($max < $this->_min) {
+            /**
+             * @see Zend_Validate_Exception
+             */
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum length, but "
+                                            . "$max < $this->_min");
+        } else {
+            $this->_max = (integer) $max;
+        }
+
+        return $this;
+    }
+
+    /**
+     * Defined by Zend_Validate_Interface
+     *
+     * Returns true if and only if the string length of $value is at least the min option and
+     * no greater than the max option (when the max option is not null).
+     *
+     * @param  string $value
+     * @return boolean
+     */
+    public function isValid($value)
+    {
+        $valueString = (string) $value;
+        $this->_setValue($valueString);
+        $length = iconv_strlen($valueString);
+        if ($length < $this->_min) {
+            $this->_error(self::TOO_SHORT);
+        }
+        if (null !== $this->_max && $this->_max < $length) {
+            $this->_error(self::TOO_LONG);
+        }
+        if (count($this->_messages)) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+}

Modified: incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php?rev=654331&r1=654330&r2=654331&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php Wed May  7 16:48:15 2008
@@ -60,7 +60,93 @@
 		//header("HTTP/1.1 $status", true);
 		if ($status == 200) {
 			$output = '';
-			$json = array($url => array('body' => $result->getResponseContent(), 'rc' => $status));
+			if ($_GET['contentType'] == 'FEED') {
+				// We are including this library manually because the autoload doesnt work with 
+				// this, its filename doesnt match with the class name.
+				require 'src/common/Zend/Feed.php';
+				$numEntries = $_GET['numEntries'];
+				$getSummaries = $_GET['getSummaries'];
+				$channel = array();
+				//TODO fix the hack below by updating content fetcher..
+				// we cheat a litle here, we want a different caching time for feed's
+				// but atm the content fetcher doesn't allow this to be configured
+				$originalCacheTime = Config::get('cache_time');
+				$newTime = isset($_GET['refresh']) ? $_GET['refresh'] : 5 * 60;
+				Config::set('cache_time', $newTime);
+				$request = new RemoteContentRequest($url);
+				$request = $this->context->getHttpFetcher()->fetch($request, $this->context);
+				// Restore original caching time
+				Config::set('cache_time', $originalCacheTime);
+				if ((int)$result->getHttpCode() == 200) {
+					$content = $result->getResponseContent();
+					try {
+						$feed = Zend_Feed::importString($content);
+						if ($feed instanceof Zend_Feed_Rss) {
+							$channel = array(
+							    'title'       	=> $feed->title(),
+							    'link'        	=> $feed->link(),
+							    'description' 	=> $feed->description(),
+							 	'pubDate' 		=> $feed->pubDate(),
+							 	'language' 		=> $feed->language(),
+							 	'category' 		=> $feed->category(),
+							    'items'       	=> array()
+							);
+							// Loop over each channel item and store relevant data
+							$counter = 0;
+							foreach ($feed as $item) {
+								if ($counter >= $numEntries) {
+									break;
+								}
+								$counter++;
+							    $channel['items'][] = array(
+							        'title'			=> $item->title(),
+							        'link'			=> $item->link(),
+							    	'author'		=> $item->author(),
+							    	'description'	=> $getSummaries ? $item->description() : '',
+							    	'category'		=> $item->category(),
+							    	'comments'		=> $item->comments(),
+							    	'pubDate'		=> $item->pubDate()
+							    );
+							}
+						} elseif ($feed instanceof Zend_Feed_Atom) {
+							$channel = array(
+								'title'			=> $feed->title(),
+								'link'        	=> $feed->link(),
+								'id'        	=> $feed->id(),
+							    'subtitle' 		=> $feed->subtitle(),
+								'items'       	=> array()
+							);
+							$counter = 0;
+							foreach ($feed as $entry) {
+								if ($counter >= $numEntries) {
+									break;
+								}
+								$channel['items'][] = array(
+									'id' 		=> $entry->id(),
+									'title' 	=> $entry->title(),
+									'link' 		=> $entry->link(),
+									'summary' 	=> $entry->summary(),
+									'content' 	=> $entry->content(),
+									'author' 	=> $entry->author(),
+									'published' => $entry->published(),
+									'updated' 	=> $entry->updated()
+								);
+							}
+						} else {
+							throw new Exception('Invalid feed type');
+						}
+						$resp = json_encode($channel);
+					} catch (Zend_Feed_Exception $e) {
+						$resp = 'Error parsing feed: '.$e->getMessage();
+					}
+				} else {
+				    // feed import failed
+				    $resp = "Error fetching feed, response code: ".$result->getHttpCode();
+				}
+			} else {
+				$resp = $result->getResponseContent();
+			}
+			$json = array($url => array('body' => $resp, 'rc' => $status));
 			$json = json_encode($json);
 			$output = UNPARSEABLE_CRUFT . $json;
 			$this->setCachingHeaders();
@@ -73,7 +159,7 @@
 		}
 		die();
 	}
-	
+
 	/**
 	 * Fetches the content and returns it as-is using the headers as returned
 	 * by the remote host.
@@ -131,7 +217,6 @@
 	private function fetchContent($signedUrl, $method)
 	{
 		//TODO get actual character encoding from the request
-		
 
 		// Extract the request headers from the $_SERVER super-global (this -does- unfortunatly mean that any header that php doesn't understand won't be proxied thru though)
 		// if this turns out to be a problem we could add support for HTTP_RAW_HEADERS, but this depends on a php.ini setting, so i'd rather prevent that from being required

Modified: incubator/shindig/trunk/php/src/gadgets/http/ProxyServlet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/http/ProxyServlet.php?rev=654331&r1=654330&r2=654331&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/http/ProxyServlet.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/http/ProxyServlet.php Wed May  7 16:48:15 2008
@@ -19,7 +19,7 @@
  */
 
 class ProxyServlet extends HttpServlet {
-	
+
 	public function doGet()
 	{
 		$this->noHeaders = true;
@@ -48,9 +48,9 @@
 			$proxyHandler->fetch($url, $gadgetSigner, $method);
 		}
 	}
-	
+
 	public function doPost()
 	{
 		$this->doGet();
 	}
-}
\ No newline at end of file
+}