- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 
                        public function passes($attribute, $hostname)
    {
        if (!mb_stripos($hostname, '.')) {
            return false;
        }
        $domain = explode('.', $hostname);
        $allowedChars = ['-'];
        $extenion = array_pop($domain);
        foreach ($domain as $value) {
            $fc = mb_substr($value, 0, 1);
            $lc = mb_substr($value, -1);
            if (
                hash_equals($value, '')
                || in_array($fc, $allowedChars)
                || in_array($lc, $allowedChars)
            ) {
                return false;
            }
            if (!ctype_alnum(str_replace($allowedChars, '', $value))) {
                return false;
            }
        }
        if (
            !ctype_alnum(str_replace($allowedChars, '', $extenion))
            || hash_equals($extenion, '')
        ) {
            return false;
        }
        if (filter_var($hostname, FILTER_VALIDATE_DOMAIN) === false) {
            return false;
        }
        return true;
    }
                                 
        
Комментарии (10) RSS
Добавить комментарий