Zend_Validate_Hostname example

return $this->_options['hostname'];
    }

    /** * @param Zend_Validate_Hostname $hostnameValidator OPTIONAL * @param int $allow OPTIONAL * @return void */
    public function setHostnameValidator(Zend_Validate_Hostname $hostnameValidator = null, $allow = Zend_Validate_Hostname::ALLOW_DNS)
    {
        if (!$hostnameValidator) {
            $hostnameValidator = new Zend_Validate_Hostname($allow);
        }

        $this->_options['hostname'] = $hostnameValidator;
        $this->_options['allow']    = $allow;
        return $this;
    }

    /** * Whether MX checking via getmxrr is supported or not * * This currently only works on UNIX systems * * @return boolean */

        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.         $validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);

        return $validate->isValid($host);
    }

    /** * Sets the host for the current URI, and returns the old host * * @param string $host The HTTP host * @throws Zend_Uri_Exception When $host is nota valid HTTP host * @return string */
    
/** * Constructor. * * @param string $host OPTIONAL Hostname of remote connection (default: 127.0.0.1) * @param integer $port OPTIONAL Port number (default: null) * @throws Zend_Mail_Protocol_Exception * @return void */
    public function __construct($host = '127.0.0.1', $port = null)
    {
        $this->_validHost = new Zend_Validate();
        $this->_validHost->addValidator(new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL));

        if (!$this->_validHost->isValid($host)) {
            /** * @see Zend_Mail_Protocol_Exception */
            throw new Zend_Mail_Protocol_Exception(join(', ', $this->_validHost->getMessages()));
        }

        $this->_host = $host;
        $this->_port = $port;
    }


    
Home | Imprint | This part of the site doesn't use cookies.