function isBannedEmail($email, $restriction, $error)
{
    global $txt, $smcFunc;
    // Can't ban an empty email
    if (empty($email) || trim($email) == '') {
        return;
    }
    // Let's start with the bans based on your IP/hostname/memberID...
    $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
    $ban_reason = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['reason'] : '';
    // ...and add to that the email address you're trying to register.
    $request = $smcFunc['db_query']('', '
		SELECT bi.id_ban, bg.' . $restriction . ', bg.cannot_access, bg.reason
		FROM {db_prefix}ban_items AS bi
			INNER JOIN {db_prefix}ban_groups AS bg ON (bg.id_ban_group = bi.id_ban_group)
		WHERE {string:email} LIKE bi.email_address
			AND (bg.' . $restriction . ' = {int:cannot_access} OR bg.cannot_access = {int:cannot_access})
			AND (bg.expire_time IS NULL OR bg.expire_time >= {int:now})', array('email' => $email, 'cannot_access' => 1, 'now' => time()));
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        if (!empty($row['cannot_access'])) {
            $_SESSION['ban']['cannot_access']['ids'][] = $row['id_ban'];
            $_SESSION['ban']['cannot_access']['reason'] = $row['reason'];
        }
        if (!empty($row[$restriction])) {
            $ban_ids[] = $row['id_ban'];
            $ban_reason = $row['reason'];
        }
    }
    $smcFunc['db_free_result']($request);
    // You're in biiig trouble.  Banned for the rest of this session!
    if (isset($_SESSION['ban']['cannot_access'])) {
        log_ban($_SESSION['ban']['cannot_access']['ids']);
        $_SESSION['ban']['last_checked'] = time();
        fatal_error(sprintf($txt['your_ban'], $txt['guest_title']) . $_SESSION['ban']['cannot_access']['reason'], false);
    }
    if (!empty($ban_ids)) {
        // Log this ban for future reference.
        log_ban($ban_ids, $email);
        fatal_error($error . $ban_reason, false);
    }
}
Beispiel #2
0
function isBannedEmail($email, $restriction, $error)
{
    global $db_prefix, $txt;
    // Can't ban an empty email
    if (empty($email) || trim($email) == '') {
        return;
    }
    // Let's start with the bans based on your IP/hostname/memberID...
    $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array();
    $ban_reason = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['reason'] : '';
    // ...and add to that the email address you're trying to register.
    $request = db_query("\n\t\tSELECT bi.ID_BAN, bg.{$restriction}, bg.cannot_access, bg.reason\n\t\tFROM ({$db_prefix}ban_items AS bi, {$db_prefix}ban_groups AS bg)\n\t\tWHERE bg.ID_BAN_GROUP = bi.ID_BAN_GROUP\n\t\t\tAND '{$email}' LIKE bi.email_address\n\t\t\tAND (bg.{$restriction} = 1 OR bg.cannot_access = 1)", __FILE__, __LINE__);
    while ($row = mysql_fetch_assoc($request)) {
        if (!empty($row['cannot_access'])) {
            $_SESSION['ban']['cannot_access']['ids'][] = $row['ID_BAN'];
            $_SESSION['ban']['cannot_access']['reason'] = $row['reason'];
        }
        if (!empty($row[$restriction])) {
            $ban_ids[] = $row['ID_BAN'];
            $ban_reason = $row['reason'];
        }
    }
    mysql_free_result($request);
    // You're in biiig trouble.  Banned for the rest of this session!
    if (isset($_SESSION['ban']['cannot_access'])) {
        log_ban($_SESSION['ban']['cannot_access']['ids']);
        $_SESSION['ban']['last_checked'] = time();
        fatal_error(sprintf($txt[430], $txt[28]) . $_SESSION['ban']['cannot_access']['reason'], false);
    }
    if (!empty($ban_ids)) {
        // Log this ban for future reference.
        log_ban($ban_ids, $email);
        fatal_error($error . $ban_reason, false);
    }
}