Cara membuat web host manager sendiri V11 Sistem Auto-Suspend untuk Akun yang Sudah Expired

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 Auto-Suspend untuk Akun yang Sudah Expired di WHM Custom.

Fitur yang Akan Dibuat:

  • Akun hosting yang expired otomatis disuspend.
  • User mendapatkan email pemberitahuan setelah akun disuspend.
  • Admin bisa melihat daftar akun yang disuspend karena expired.
  • Gunakan Cron Job agar proses suspend berjalan otomatis setiap hari.

1️⃣ Buat Cron Job untuk Auto-Suspend Akun Expired

📌 File cron/auto_suspend.php

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

// Ambil akun yang sudah expired
$date = date('Y-m-d');
$stmt = $conn->prepare("SELECT id, username, email FROM accounts WHERE expired_date < ? AND status = 'active'");
$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'];

    // Update status akun menjadi suspended
    $stmt = $conn->prepare("UPDATE accounts SET status='suspended' WHERE id=?");
    $stmt->bind_param("i", $account_id);
    $stmt->execute();

    // Kirim email notifikasi
    $subject = "Akun Hosting Anda Telah Disuspend!";
    $message = "
        <h2>Halo, $username</h2>
        <p>Akun hosting Anda telah disuspend karena masa aktifnya telah habis.</p>
        <p>Segera lakukan perpanjangan untuk mengaktifkan kembali akun Anda.</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 "Akun expired berhasil disuspend & email notifikasi telah dikirim!";
?>

📌 Script ini akan mencari akun yang expired dan otomatis mengubah statusnya menjadi suspended serta mengirimkan email ke user.


2️⃣ 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/auto_suspend.php

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


3️⃣ Buat Halaman Admin untuk Melihat Akun yang Disuspend karena Expired

📌 File admin/suspended_expired_accounts.php

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

// Ambil akun yang disuspend karena expired
$result = $conn->query("SELECT id, username, email, expired_date FROM accounts WHERE status='suspended'");

?>
<h2>Akun yang Disuspend karena Expired</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 disuspend karena expired & memperpanjangnya.


4️⃣ Buat Halaman untuk Mengaktifkan Kembali Akun yang Sudah Disuspend

📌 File renew_account.php

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

if (isset($_GET['id'])) {
    $account_id = $_GET['id'];

    // Perpanjang expired date 1 bulan
    $stmt = $conn->prepare("UPDATE accounts SET expired_date = DATE_ADD(expired_date, INTERVAL 1 MONTH), status='active' WHERE id=?");
    $stmt->bind_param("i", $account_id);
    $stmt->execute();

    // Ambil informasi akun
    $stmt = $conn->prepare("SELECT username, email FROM accounts WHERE id=?");
    $stmt->bind_param("i", $account_id);
    $stmt->execute();
    $stmt->store_result();

    if ($stmt->num_rows > 0) {
        $stmt->bind_result($username, $email);
        $stmt->fetch();

        // Kirim email pemberitahuan
        $subject = "Akun Hosting Anda Telah Diaktifkan Kembali";
        $message = "
            <h2>Halo, $username</h2>
            <p>Akun hosting Anda telah diaktifkan kembali setelah diperpanjang.</p>
            <p>Terima kasih telah menggunakan layanan kami.</p>
            <p><b>Tim Hosting</b></p>
        ";

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

        echo "Akun berhasil diperpanjang & email notifikasi telah dikirim!";
    } else {
        echo "Akun tidak ditemukan!";
    }
}
?>

📌 Admin bisa memperpanjang akun yang disuspend & user akan mendapatkan email pemberitahuan.


🔥 Sekarang WHM Custom Bisa Auto-Suspend Akun Expired!

Akun expired otomatis disuspend.
User mendapatkan email notifikasi saat akun disuspend.
Admin bisa melihat daftar akun yang disuspend karena expired.
Admin bisa memperpanjang akun yang disuspend & user akan mendapatkan email notifikasi.

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.