<?php
if(isset($_POST['scam']))
{
    $tim = check_string($_POST['scam']);
    $dvr = $DVR->query("SELECT * FROM `tocaoscam` WHERE (`stk` like '%$tim%') OR (`sdt` like '%$tim%') AND `status` = 'scam'");

    if ($dvr) {
        $thay = mysqli_num_rows($dvr);
    } else {
        $thay = 0;
    }
}
else
{
    die('<script type="text/javascript">if(!alert("Không tồn tại!")){window.history.back().location.reload();}</script>');
}

$title = ' Hệ Thống Tìm Kiếm Scamer ';
$body['header'] = '';
$body['footer'] = '';
require_once __DIR__ . '/header.php';
require_once __DIR__ . '/nav.php';
//CheckLogin();
?>
<div id="main" class="main">
    <div class="section-gap section-intro">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="section-heading">
                        <div class="title">
                            KIỂM TRA THÔNG TIN & TỐ CÁO SCAMMER
                        </div>
                        <div class="line"></div>
                        <div class="desc">
                            <b><p>Kiểm Tra&nbsp;<strong><font color="red"> "SĐT, STK Ngân Hàng , Tên ..."</font> </strong>&nbsp;Trước Khi Giao Dịch Bằng Cách Nhập Thông Tin Vào&nbsp;<strong>" Thanh Tìm Kiếm "</strong> Bên Dưới</p></b>
                        </div>
                    </div>
                </div>
                <div class="col-12">
                    <div class="row align-items-center">
                        <div class="col-lg-6">
                            <form method="POST" action="/search/scam">
                                <div class="form-group position-relative">
                                    <input type="text" class="form-control" name="scam" placeholder="Nhập Sđt Ngân Hàng & Kiểm Tra ">
                                    <button type="submit">
                                        <i class="fa-solid fa-magnifying-glass" style="color: var(--primary-color)"></i>
                                    </button>
                                </div>
                                <a href="/scam/create" class="btn-theme btn-theme_primary" style="color: white">
                                    <b>Tố Cáo Lừa Đảo</b>
                                    <span></span>
                                </a>
                                <a href="/trust-services" class="btn-theme btn-theme_success" style="color: white">
                                    <b>Check Uy Tín</b>
                                    <span></span>
                                </a>
                            </form>
                        </div>
                        <div class="col-lg-6">
                            <div class="intro-image">
                                <img src="/storage/userfiles/images/bg-scam.png" class="w-100 img-fluid h-auto" alt="" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-12">
                    <div class="section-heading mt-4">
                        <div class="desc">
                            <h4>Tìm thấy <?=$thay;?> thông tin lừa đảo liên quan đến: "<?=$tim;?>"</h4>
                        </div>
                    </div>
                    <?php
                    if ($dvr && $thay > 0) {
                        foreach($dvr as $row) { 
                    ?>
                    <div class="scam-item d-flex align-items-center py-3 px-4 border bg-white" style="border-radius: 17px; margin-bottom: 9px">
                            <div class="scam-title" style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                                <span class="scam-title_icon">
                                    <iconify-icon icon="twemoji:warning" width="16" height="16"></iconify-icon>
                                </span>
                                <a href="/scams/<?=$row['code']; ?>.html" class="scam-title_link" style="color: black; margin-right: 1px;">
                                    <?=$row['username']; ?>
                                </a>
                                <span class="scam-title_icon ml-2">

                                 </span>
                            </div>
                            <div class="scam-info ml-auto">
                                <span class="scam-info_time">
                                    <iconify-icon icon="fluent-emoji:calendar" width="16" height="16"></iconify-icon>
                                    <?=$row['ngay']; ?>
                                </span>
                                <span class="scam-info_phone">
                                   <iconify-icon icon="twemoji:bank" width="16" height="16"></iconify-icon>
                                    <?=$row['ngan_hang']; ?>: <?=$row['stk']; ?>
                                </span>
                                <span class="scam-info_eye">
                                   <iconify-icon icon="carbon:view-filled" width="16" height="16"></iconify-icon>
                                    <?=$row['view']; ?>
                                </span>
                            </div>
                        </div>
                    <?php 
                        }
                    } else {
                        echo "<p>Không có thông tin lừa đảo nào được tìm thấy.</p>";
                    } 
                    ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php require_once __DIR__ . '/footer.php'; ?>
