Вход Регистрация
Файл: inc/classes/anti_spam.php
Строк: 34
<?php
class anti_spam {
    public 
$msg,$status,$mod,$type;
    private 
$bol;
    
    public function 
__construct($msg,$status =1,$mod =1,$type =1) {
        
$this->msg = $msg;
        
$this->status = $status;
        
$this->mod = $mod;
        
$this->type = $type;
    }
    
    private function 
get_status() {
        if (
$this->status) {
            return 
true;
        } else return 
false;
    }
    
    public function 
check_msg() {
        if(
$this->get_status()) {
            switch(
$this->mod) {
                case 
1:
                    if (
preg_match('|https?://.?|i', $this->msg)) {
                        return 
true;
                    } else return 
false;
                break;
                
                case 
2:
                    if (
preg_match('|([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?.)+[a-zA-Z]{2,6}|i', $this->msg)) {
                        return 
true;
                    } else return 
false;
                break;
                
                default:
                    if (
preg_match('~\[url=(https?://.+?)\](.+?)\[/url\]|(https?://(www.)?[0-9a-z.-]+.[0-9a-z]{2,6}[0-9a-zA-Z/?.~&amp;_=/%-:#]*)~i', $this->msg)) {
                        return 
true;
                    } else return 
false;
            }
        } else return 
false;
            
    }
    
    public function 
print_protect() {
        return 
'Внимание ! Запрещено добавлять сообщения , содержащие ссылки на какие-либо ресурсы. В противном случае ваше сообщение будет заблокировано';
    }
    
    public function 
check_type() {
        if (
$this->check_msg()) {
            switch(
$this->type) {
                case 
2:
                    
$_SESSION['spam'] = 1;
                    return 
$_SESSION['spam'];
                break;
            
                case 
3:
                    
$ip = getip();
                    
$ip = ip2int($ip);
                    
$reason = 'Автоматическая блокировка.Запрещенно писать ссылки в сообщениях';
                    
mysql_query("INSERT INTO `ban_ip` SET
                            `ip`='" 
. mysql_real_escape_string($ip). "',
                            `type`='1',
                            `url`='',
                            `reason`='
$reason',
                            `date`='" 
. time() . "'") or die(mysql_error());
                    return 
true;
                break;
            
                default:
                    return 
true;
            }
        } else return 
false;
    }
}
?>
Онлайн: 4
Реклама