예제 #1
0
/**
 * Called on the login user event
 * Checks for spammers
 * 
 * @param type $event
 * @param type $type
 * @param type $user
 * @return boolean
 */
function login_event($event, $type, $user)
{
    $check_login = elgg_get_plugin_setting('event_login', PLUGIN_ID);
    $ip = get_ip();
    $user->ip_address = $ip;
    if ($check_login != 'no' || !$user->last_login) {
        // do it by default
        if (!check_spammer($user->email, $ip, true) && !$user->isAdmin()) {
            register_error(elgg_echo('spam_login_filter:access_denied_mail_blacklist'));
            notify_admin($user->email, $ip, "Existing member identified as spammer has tried to login, check this account");
            return false;
        }
    }
    // check user metadata for banned words/phrases
    $banned = get_banned_strings();
    $metadata = get_metadata_names();
    if ($banned && $metadata) {
        foreach ($metadata as $m) {
            foreach ($banned as $str) {
                if (strpos($user->{$m}, $str) !== false) {
                    return false;
                }
            }
        }
    }
}
예제 #2
0
파일: added.php 프로젝트: kaz6120/P_BLOG
 $comment_field_name = md5($block_spam['comment_field_name']);
 $user_name = insert_safe($_POST['user_name']);
 $mail = insert_safe($_POST['user_email']);
 $title = insert_tag_safe($_POST['title']);
 $comment = insert_tag_safe($_POST[$comment_field_name]);
 $color = insert_safe($_POST['color']);
 $user_pass = insert_safe($_POST['user_pass']);
 $refer_id = insert_safe(intval($_POST['refer_id']));
 // Unicode conversion
 if ($cfg['enable_unicode'] == 'on') {
     mb_convert_variables($cfg['mysql_lang'], 'auto', $user_name, $title, $comment);
 }
 // If title is empty
 $title = $title == '' ? 'Untitled' : $title;
 // Block Spams
 if (isset($_POST['user_uri']) && substr_count($_POST['user_uri'], "@") > 0 || substr_count($comment, "http://") >= (int) $block_spam['uri_count'] || preg_match($block_spam['tags'], $_POST[$comment_field_name]) || preg_match($block_spam['keywords'], $_POST[$comment_field_name]) || $block_spam['deny_1byteonly'] == 'yes' && !preg_match('/.*[\\x80-\\xff]/', $_POST[$comment_field_name]) || preg_match($block_spam['tags'], $_POST['title']) || check_spammer() > 0) {
     // echo 'Hi, Spammer! :-p';
     header('Location: ' . $cd . '/forum/index.php');
     exit;
 }
 // Deny comment with same content
 $check_sql = 'SELECT COUNT(id) as num FROM ' . $forum_table . " WHERE comment = '{$comment}'";
 $check_res = mysql_query($check_sql);
 $check_row = mysql_fetch_array($check_res);
 if ($check_row['num'] > 1) {
     header('Location: ' . $cd . '/forum/index.php');
     exit;
 }
 // Matching a valid User password
 if (!preg_match('/^[0-9a-zA-Z]{4,16}$/i', $_POST['user_pass'])) {
     $contents = '<h2>' . $lang['invalid_pass'] . '</h2>' . '<p class="warning">' . $lang['invalid_pass_msg'] . '</p>';