<?php
// Aktifkan laporan kesalahan
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Koneksi ke database
$servername = "localhost";
$username = "zonb9946_weliington";
$password = "#Bismillah16";
$dbname = "zonb9946_email";

// Membuat koneksi
$conn = new mysqli($servername, $username, $password, $dbname);

// Cek koneksi
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Ambil email_id dari URL
if (isset($_GET['email_id'])) {
    $email_id = $_GET['email_id'];

    // Query pembaruan log open email
    $update_sql = "UPDATE tbl_securitymail SET LOG_OPENWEB = NOW() WHERE NIK = ?";
    $stmt = $conn->prepare($update_sql);
    if ($stmt) {
        $stmt->bind_param("s", $email_id); // Menghindari SQL injection
        if ($stmt->execute()) {
            //echo "Email read log updated for $email_id.";
             echo"<script language='javascript'>location.href='hacked.php?email_id=$email_id';</script>";
            
        } else {
            echo "Error updating log: " . $stmt->error;
        }
        $stmt->close();
    } else {
        echo "Error preparing statement: " . $conn->error;
    }
}

// Mengirim 1x1 px image sebagai response
//header("Content-Type: image/gif");
//echo base64_decode("R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==");

// Tutup koneksi
$conn->close();
?>
