Cara membuat web host manager sendiri V12 Sistem Penghapusan Akun Otomatis setelah 30 Hari Disuspend

Me Nime Id
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

 Oke! Kita tambahkan fitur Sistem Penghapusan Akun Otomatis setelah 30 Hari Disuspend di WHM Custom.

Fitur yang Akan Dibuat:

  • Akun yang sudah disuspend selama 30 hari akan otomatis dihapus.
  • User akan mendapatkan email peringatan sebelum akunnya dihapus.
  • Admin bisa melihat daftar akun yang akan segera dihapus.
  • Gunakan Cron Job agar proses penghapusan berjalan otomatis setiap hari.

1️⃣ Buat Cron Job untuk Cek Akun yang Akan Dihapus

📌 File cron/delete_suspended.php

<?php
include '../includes/config.php';
include '../includes/mail_config.php';

// Ambil akun yang disuspend lebih dari 30 hari
$date = date('Y-m-d', strtotime('-30 days'));
$stmt = $conn->prepare("SELECT id, username, email FROM accounts WHERE status = 'suspended' AND expired_date < ?");
$stmt->bind_param("s", $date);
$stmt->execute();
$result = $stmt->get_result();

while ($row = $result->fetch_assoc()) {
    $account_id = $row['id'];
    $username = $row['username'];
    $email = $row['email'];

    // Kirim email peringatan sebelum akun dihapus
    $subject = "Peringatan: Akun Anda Akan Dihapus Permanen!";
    $message = "
        <h2>Halo, $username</h2>
        <p>Akun hosting Anda telah disuspend selama lebih dari 30 hari.</p>
        <p>Jika tidak diperpanjang dalam waktu 7 hari, akun Anda akan dihapus secara permanen.</p>
        <p><a href='https://yourdomain.com/renew.php'>Perpanjang Sekarang</a></p>
        <p>Terima kasih telah menggunakan layanan kami.</p>
        <p><b>Tim Hosting</b></p>
    ";

    sendEmail($email, $subject, $message);
}

echo "Email peringatan akun yang akan dihapus berhasil dikirim!";
?>

📌 Script ini akan mengirim email peringatan ke user sebelum akun mereka dihapus.


2️⃣ Buat Cron Job untuk Menghapus Akun Setelah 37 Hari

📌 File cron/delete_account.php

<?php
include '../includes/config.php';

// Ambil akun yang disuspend lebih dari 37 hari
$date = date('Y-m-d', strtotime('-37 days'));
$stmt = $conn->prepare("SELECT id, username, email FROM accounts WHERE status = 'suspended' AND expired_date < ?");
$stmt->bind_param("s", $date);
$stmt->execute();
$result = $stmt->get_result();

while ($row = $result->fetch_assoc()) {
    $account_id = $row['id'];
    $username = $row['username'];

    // Hapus akun dari database
    $stmt = $conn->prepare("DELETE FROM accounts WHERE id = ?");
    $stmt->bind_param("i", $account_id);
    $stmt->execute();

    echo "Akun $username telah dihapus permanen.\n";
}

echo "Proses penghapusan akun expired selesai!";
?>

📌 Script ini akan menghapus akun yang disuspend lebih dari 37 hari dari database.


3️⃣ Tambahkan Cron Job di Server

📌 Jalankan perintah ini di terminal (jika menggunakan VPS):

crontab -e

📌 Tambahkan baris berikut untuk menjalankan script setiap hari pukul 00:00

0 0 * * * /usr/bin/php /path/to/cron/delete_suspended.php
0 0 * * * /usr/bin/php /path/to/cron/delete_account.php

📌 Pastikan /path/to/cron/ sesuai dengan lokasi file di server Anda.


4️⃣ Buat Halaman Admin untuk Melihat Akun yang Akan Dihapus

📌 File admin/accounts_to_delete.php

<?php
include '../includes/config.php';

// Ambil akun yang akan dihapus dalam 7 hari
$date = date('Y-m-d', strtotime('-30 days'));
$result = $conn->query("SELECT id, username, email, expired_date FROM accounts WHERE status='suspended' AND expired_date < '$date'");

?>
<h2>Akun yang Akan Dihapus</h2>
<table border="1">
    <tr>
        <th>Username</th>
        <th>Email</th>
        <th>Expired Date</th>
        <th>Aksi</th>
    </tr>
    <?php while ($row = $result->fetch_assoc()) { ?>
    <tr>
        <td><?php echo $row['username']; ?></td>
        <td><?php echo $row['email']; ?></td>
        <td><?php echo $row['expired_date']; ?></td>
        <td>
            <a href="renew_account.php?id=<?php echo $row['id']; ?>">Perpanjang</a>
        </td>
    </tr>
    <?php } ?>
</table>

📌 Admin bisa melihat daftar akun yang akan dihapus & memperpanjangnya sebelum dihapus permanen.


🔥 Sekarang WHM Custom Bisa Menghapus Akun Expired Otomatis!

User akan mendapatkan email peringatan sebelum akunnya dihapus.
Akun yang disuspend lebih dari 37 hari otomatis dihapus.
Admin bisa melihat daftar akun yang akan dihapus & memperpanjangnya.
Cron job berjalan otomatis setiap hari.

Posting Komentar

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.