Example #1
0
 /**
  * Returns value if it is a valid hostname, FALSE otherwise.
  * Depending upon the value of $allow, Internet domain names, IP
  * addresses, and/or local network names are considered valid.
  * The default is HOST_ALLOW_ALL, which considers all of the
  * above to be valid.
  *
  * @param mixed $key
  * @param integer $allow bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
  * @return mixed
  */
 public function testHostname($key, $allow = Zend_Filter::HOST_ALLOW_ALL)
 {
     if (!$this->keyExists($key)) {
         return false;
     }
     if (Zend_Filter::isHostname($this->_source[$key], $allow)) {
         return $this->_source[$key];
     }
     return FALSE;
 }
Example #2
0
 /**
  * Returns true if and only if the host string passes validation. If no host is passed,
  * then the host contained in the instance variable is used.
  *
  * @param string $host
  * @return boolean
  * @uses Zend_Filter
  */
 public function validateHost($host = null)
 {
     if ($host === null) {
         $host = $this->_host;
     }
     /**
      * If the host is empty, then it is considered invalid
      */
     if (strlen($host) == 0) {
         return false;
     }
     /**
      * Check the host against the allowed values; delegated to Zend_Filter. As a feature, this only
      * validates Internet domain names and local network names; IP addresses are considered invalid.
      *
      * @link http://www.faqs.org/rfcs/rfc2396.html
      */
     $allow = Zend_Filter::HOST_ALLOW_DNS | Zend_Filter::HOST_ALLOW_LOCAL;
     return Zend_Filter::isHostname($host, $allow) !== FALSE;
 }
Example #3
0
 /**
  * Returns value if it is a valid hostname, FALSE otherwise.
  * Depending upon the value of $allow, Internet domain names, IP
  * addresses, and/or local network names are considered valid.
  * The default is HOST_ALLOW_ALL, which considers all of the
  * above to be valid.
  *
  * @param mixed $key
  * @param integer $allow bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
  * @throws Zend_Filter_Exception
  * @return mixed
  */
 public function isHostname($key, $allow = Zend_Filter::HOST_ALLOW_ALL)
 {
     return Zend_Filter::isHostname($this->_source[$key], $allow);
 }
 /**
  * Returns true if and only if the host string passes validation. If no host is passed,
  * then the host contained in the instance variable is used.
  *
  * @param string $host
  * @return boolean
  * @uses Zend_Filter
  */
 public function validateHost($host = null)
 {
     if ($host === null) {
         $host = $this->_host;
     }
     /**
      * If the host is empty, then it is considered invalid
      */
     if (strlen($host) == 0) {
         return false;
     }
     /**
      * Check the host against the allowed values; delegated to Zend_Filter.
      */
     return Zend_Filter::isHostname($host) !== FALSE;
 }
Example #5
0
 /**
  * Returns value if it is a valid hostname, FALSE otherwise.
  * Depending upon the value of $allow, Internet domain names, IP
  * addresses, and/or local network names are considered valid.
  * The default is HOST_ALLOW_ALL, which considers all of the
  * above to be valid.
  *
  * @param mixed $key
  * @param integer $allow bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
  * @return mixed
  */
 public function testHostname($key = null, $allow = Zend_Filter::HOST_ALLOW_ALL)
 {
     if (!($value = $this->keyExists($key))) {
         return false;
     }
     if (Zend_Filter::isHostname($value, $allow)) {
         return $value;
     }
     return FALSE;
 }