Exemple #1
0
function is_access_denied()
{
    $dbr = Database::$content->query("SELECT name, list FROM " . Database::$db_settings['banlists_table'] . " WHERE name='ips' OR name='user_agents'");
    while ($data = $dbr->fetch()) {
        if ($data['name'] == 'ips') {
            $ips = $data['list'];
        }
        if ($data['name'] == 'user_agents') {
            $user_agents = $data['list'];
        }
    }
    if (isset($ips) && trim($ips) != '') {
        $banned_ips = explode("\n", $ips);
        if (is_ip_banned($_SERVER['REMOTE_ADDR'], $banned_ips)) {
            return true;
        }
    }
    if (isset($user_agents) && trim($user_agents) != '') {
        $banned_user_agents = explode("\n", $user_agents);
        if (is_user_agent_banned($_SERVER['HTTP_USER_AGENT'], $banned_user_agents)) {
            return true;
        }
    }
    return false;
}
     if (is_ip_banned($_SERVER['REMOTE_ADDR'], $banned_ips_array_checked)) {
         $errors[] = 'error_own_ip_banned';
     }
 } else {
     $banned_ips = '';
 }
 if (isset($_POST['banned_user_agents']) && trim($_POST['banned_user_agents']) != '') {
     $banned_user_agents_array = preg_split('/\\015\\012|\\015|\\012/', $_POST['banned_user_agents']);
     foreach ($banned_user_agents_array as $banned_user_agent) {
         if (trim($banned_user_agent) != '') {
             $banned_user_agents_array_checked[] = trim($banned_user_agent);
         }
     }
     natcasesort($banned_user_agents_array_checked);
     $banned_user_agents = implode("\n", $banned_user_agents_array_checked);
     if (is_user_agent_banned($_SERVER['HTTP_USER_AGENT'], $banned_user_agents_array_checked)) {
         $errors[] = 'error_own_user_agent_banned';
     }
 } else {
     $banned_user_agents = '';
 }
 if (isset($_POST['not_accepted_words']) && trim($_POST['not_accepted_words']) != '') {
     $not_accepted_words_array = preg_split('/\\015\\012|\\015|\\012/', $_POST['not_accepted_words']);
     foreach ($not_accepted_words_array as $not_accepted_word) {
         if (trim($not_accepted_word) != '') {
             $not_accepted_words_array_checked[] = trim($not_accepted_word);
         }
     }
     natcasesort($not_accepted_words_array_checked);
     $not_accepted_words = implode("\n", $not_accepted_words_array_checked);
 } else {