정

임시 이메일 자동 차단

· 2026-11-02 (월) 09:07:34 · 20
# guerrillamailblock.com
# guerrillamail.com
# guerrillamail.net
# guerrillamail.org

위와 같은.... 자꾸 임시 생성한 메일 가입자가 늘어서 만들었습니다.
bbs / register_form_update.php 열어서 아래 내용을 복사해  "광고성 이메일 수신(동의)" 아래 부분 정도... 적당한곳 찾아서 넣어 주세요.



/* ==========================================
 * 임시 이메일 자동 차단
 * 24시간 캐시 + 자동 업데이트
 * GNUBOARD5
 * ========================================== */

$block_url = 'https://disposable.github.io/disposable-email-domains/domains.txt';

$cache_dir  = G5_DATA_PATH . '/email_block';
$cache_file = $cache_dir . '/domains.txt';
$lock_file  = $cache_dir . '/update.lock';

$cache_time = 86400; // 24시간
$retry_time = 3600;  // 실패 시 1시간 후 재시도

// 캐시 디렉터리 생성
if (!is_dir($cache_dir)) {
    @mkdir($cache_dir, 0755, true);
}

// 이메일 도메인 추출
$email_parts = explode('@', strtolower(trim($mb_email)));
$email_domain = count($email_parts) === 2
    ? $email_parts[1] : '';

// 캐시 상태 확인
$cache_valid = is_file($cache_file)
    && filesize($cache_file) > 10000;

$need_update = !$cache_valid
    || time() - filemtime($cache_file) >= $cache_time;

// 자동 업데이트
if ($need_update && is_dir($cache_dir)) {

    $lock = @fopen($lock_file, 'c');

    if ($lock && flock($lock, LOCK_EX | LOCK_NB)) {

        $retry_file = $cache_dir . '/last_attempt';

        $can_retry = !is_file($retry_file)
            || time() - filemtime($retry_file) >= $retry_time;

        if ($can_retry) {

            @touch($retry_file);

            $context = stream_context_create(array(
                'http' => array(
                    'timeout' => 5,
                    'follow_location' => 1
                )
            ));

            $data = @file_get_contents(
                $block_url,
                false,
                $context
            );

            if ($data !== false && strlen($data) > 10000) {

                $lines = preg_split('/\r\n|\r|\n/', trim($data));
                $valid = count($lines) >= 1000;

                // 다운로드 내용의 기본 형식 검증
                if ($valid) {
                    foreach ($lines as $line) {
                        if (!preg_match(
                            '/^[a-z0-9.-]+$/i',
                            trim($line)
                        )) {
                            $valid = false;
                            break;
                        }
                    }
                }

                if ($valid) {
                    $tmp_file = tempnam($cache_dir, 'email_');

                    if ($tmp_file !== false) {
                        $written = @file_put_contents(
                            $tmp_file,
                            $data,
                            LOCK_EX
                        );

                        if ($written === strlen($data)) {
                            @chmod($tmp_file, 0644);
                            @rename($tmp_file, $cache_file);
                        }

                        if (is_file($tmp_file)) {
                            @unlink($tmp_file);
                        }
                    }
                }
            }
        }

        flock($lock, LOCK_UN);
        fclose($lock);
    } elseif ($lock) {
        fclose($lock);
    }
}

// 캐시 목록으로 검사
if ($email_domain !== '' && is_readable($cache_file)) {

    $handle = @fopen($cache_file, 'r');

    if ($handle) {
        while (($line = fgets($handle)) !== false) {

            $blocked_domain = strtolower(trim($line));

            if ($email_domain === $blocked_domain) {
                fclose($handle);
                alert('임시 이메일 주소로는 회원가입을 하실 수 없습니다.');
            }
        }

        fclose($handle);
    }
}

/* ===== 임시 이메일 차단 종료 ===== */
 
|
댓글을 작성하시려면 로그인이 필요합니다.
+
제목 글쓴이 날짜 조회
22-06-20 조회 1만
11-02 조회 54
11-02 조회 21
10-18 조회 86
10-16 조회 97
09-11 조회 2,019
09-04 조회 3,154
08-09 조회 3,805
08-05 조회 5,077
07-30 조회 3,798
07-30 조회 3,677
07-15 조회 4,972
07-01 조회 5,140
06-30 조회 5,181
06-22 조회 5,842
06-17 조회 5,025
06-14 조회 3,782
05-29 조회 3,871
05-16 조회 3,852
05-04 조회 5,321
04-29 조회 5,477
04-28 조회 5,276
04-27 조회 5,279
04-25 조회 4,259
04-24 조회 6,019
04-23 조회 5,468
04-14 조회 4,497
04-08 조회 5,278
04-01 조회 6,928
03-31 조회 5,978
03-16 조회 6,148