일회용 이메일 차단

[code]
<?php
if (!defined('_GNUBOARD_')) exit;
 
// --- 자동 업데이트 조건 추가 (관리자 페이지 접속 시 48시간마다) ---
if (defined('G5_IS_ADMIN') && isset($is_admin) && $is_admin == 'super') {
    $now_time = time();
    $interval_seconds = 48 * 3600; // 48시간
 
    // 마지막 실행 시간 확인
    $sql_check = " select cf_optimize_date from {$g5['config_table']} ";
    $cfg_check = sql_fetch($sql_check);
    $last_update_time = is_numeric($cfg_check['cf_optimize_date']) ? (int)$cfg_check['cf_optimize_date'] : strtotime($cfg_check['cf_optimize_date']);
 
    // 48시간이 지났다면 수동 버튼을 누른 것과 같은 효과를 냄
    if ($now_time > ($last_update_time + $interval_seconds)) {
        $_GET['update_disposable'] = '1';
        $is_auto_update = true; // 자동 실행임을 표시
    }
}
 
// 1. 업데이트 로직 (수동 클릭 및 위의 자동 조건 충족 시 실행)
if (isset($is_admin) && $is_admin == 'super' && isset($_GET['update_disposable']) && $_GET['update_disposable'] == '1') {
     
    $target_url = "<a href="https://disposable.github.io/disposable-email-domains/domains.txt";" target="_blank" rel="nofollow">https://disposable.github.io/disposable-email-domains/domains.txt";</a>
     
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $target_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    $content = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
 
    if ($http_code == 200 && $content) {
        $content = str_replace(array("rn", "r"), "n", trim($content));
        $new_domains = explode("n", $content);
         
        $sql = " select cf_prohibit_email from " . $g5['config_table'];
        $cfg = sql_fetch($sql);
         
        $current_raw = str_replace(array("rn", "r"), "n", trim($cfg['cf_prohibit_email']));
        $current_domains = explode("n", $current_raw);
         
        $total_domains = array_unique(array_merge($current_domains, $new_domains));
        $clean_domains = array();
        foreach($total_domains as $domain) {
            $d = trim($domain);
            if($d) $clean_domains[] = $d;
        }
         
        $final_list = implode("n", $clean_domains);
        // 리스트 업데이트와 동시에 날짜(타임스탬프) 기록
        sql_query(" update " . $g5['config_table'] . " set cf_prohibit_email = '" . addslashes($final_list) . "', cf_optimize_date = '" . time() . "' ");
 
        // 수동으로 버튼을 눌렀을 때만 알림창을 띄움 (자동일 때는 조용히 업데이트)
        if (!isset($is_auto_update)) {
            echo "<script>alert('최신 리스트로 업데이트 완료!'); location.replace('" . G5_ADMIN_URL . "');</script>";
            exit;
        }
    }
}
 
// 2. 관리자 페이지 헤더 변수에 스크립트 추가
if (isset($is_admin) && $is_admin == 'super' && defined('G5_IS_ADMIN')) {
    if (!isset($admin_head)) $admin_head = "";
    $update_url = G5_ADMIN_URL . "/?update_disposable=1";
    $admin_head .= "
    <script>
    jQuery(function($){
        var btn_html = "<li><a href='{$update_url}' style='color:#ff5500; font-weight:bold;'>[이메일차단 갱신]</a></li>";
        if($('.tnb_community').length) {
            $('.tnb_community').append(btn_html);
        }
    });
    </script>
    ";
}
[/code]

위 내용으로 disposable_email_updater.php 파일을 만들어 /extend 에 업로드 하시고

그누보드 기본 입력 금지 메일 내용이 입력될  (cf_prohibit_email) 필드 문자열 데이터 타입을 
MEDIUMTEXT 나 LONGTEXT 로 변경해줘야 합니다.

ALTER TABLE g5_config
    MODIFY cf_prohibit_email MEDIUMTEXT NOT NULL,
    MODIFY cf_optimize_date date NOT NULL DEFAULT '1970-01-01';


mysql에서 위 명령 실행 시키세요

https://github.com/disposable/disposable-email-domains  이 팁의 
https://disposable.github.io/disposable-email-domains/domains.txt 일회용 이메일 내용을

입력 금지 메일 (cf_prohibit_email) 필드에 넣어서 저장해주는 방법입니다.
업데이트후 48시간 이후 다시 관리자 페이지 접속할때 자동 갱신해주는 로직입니다.

|

댓글 1개

  • $interval_seconds = 24 * 3600; // 하루(24시간)로 변경 시

  • $interval_seconds = 7 * 24 * 3600; // 일주일로 변경 시

댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
3년 전 조회 5,040
10시간 전 조회 11
17시간 전 조회 25
어제 조회 78
4일 전 조회 142
2주 전 조회 346
2주 전 조회 301
2주 전 조회 273
4주 전 조회 590
1개월 전 조회 515
1개월 전 조회 505
1개월 전 조회 550
1개월 전 조회 645
1개월 전 조회 634
1개월 전 조회 633
1개월 전 조회 610
1개월 전 조회 806
1개월 전 조회 772
1개월 전 조회 678
1개월 전 조회 646
2개월 전 조회 819
2개월 전 조회 776
2개월 전 조회 616
2개월 전 조회 870
2개월 전 조회 846
2개월 전 조회 755
2개월 전 조회 754
2개월 전 조회 875
2개월 전 조회 728
2개월 전 조회 759
3개월 전 조회 908