Update dari aaPanel
This commit is contained in:
+135
-73
@@ -2,127 +2,189 @@
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// =======================
|
||||
// Include necessary files
|
||||
// =======================
|
||||
include "/www/wwwroot/bilspro/config/connect.php";
|
||||
include "/www/wwwroot/bilspro/config/routeros_api.class.php";
|
||||
|
||||
// include "../config/connect.php";
|
||||
// include "../config/routeros_api.class.php";
|
||||
// ============================
|
||||
// Get parameters from CLI args
|
||||
// ============================
|
||||
$m_ip = $argv[1]; // IP address
|
||||
$m_user = $argv[2]; // Username
|
||||
$m_pass = $argv[3]; // Password
|
||||
$m_port = $argv[4]; // Port
|
||||
$idsm = $argv[5]; // Mikrotik setting ID
|
||||
$nama = $argv[6]; // Nama Mikrotik
|
||||
|
||||
// Get parameters from command line arguments
|
||||
$m_ip = $argv[1]; // IP address
|
||||
$m_user = $argv[2]; // Username
|
||||
$m_pass = $argv[3]; // Password
|
||||
$m_port = $argv[4]; // Port
|
||||
$idsm = $argv[5]; // Mikrotik setting ID
|
||||
// ====================
|
||||
// Log file location
|
||||
// ====================
|
||||
$logFile = "/www/wwwroot/bilspro/load/logs/voucher_{$nama}_log.txt";
|
||||
|
||||
// Create new RouterosAPI instance
|
||||
// ================================
|
||||
// Function: Write to log file
|
||||
// ================================
|
||||
function writeLog($message)
|
||||
{
|
||||
global $logFile;
|
||||
$date = date("Y-m-d H:i:s");
|
||||
$newLine = "[$date] $message\n";
|
||||
|
||||
// Append new log
|
||||
file_put_contents($logFile, $newLine, FILE_APPEND);
|
||||
|
||||
// Keep log file max 1000 lines
|
||||
$lines = file($logFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
$totalLines = count($lines);
|
||||
if ($totalLines > 1000) {
|
||||
$lines = array_slice($lines, -1000); // Keep only last 1000
|
||||
file_put_contents($logFile, implode("\n", $lines) . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================
|
||||
// Create RouterOS API object
|
||||
// ==========================
|
||||
$API = new RouterosAPI();
|
||||
$API->debug = false;
|
||||
|
||||
// Connect to the router API
|
||||
// =======================
|
||||
// Connect to RouterOS API
|
||||
// =======================
|
||||
if ($API->connect2($m_ip, $m_user, $m_pass, $m_port)) {
|
||||
echo "\n<b>Connected to Router: {$m_ip}</b>\n";
|
||||
echo "✅ Berhasil terhubung ke Router: {$m_ip}\n";
|
||||
writeLog("[✅] Berhasil terhubung ke Router: {$m_ip}");
|
||||
|
||||
// Query vouchers that need to be checked
|
||||
$ambilv1 = $pdo->prepare("SELECT id, create_time, voucher, durasi FROM v_load_cek_voucher WHERE id_setting_mikrotik = :idsm AND status_cek IS NULL LIMIT 75");
|
||||
$ambilv1->execute([':idsm' => $idsm]);
|
||||
$batchSize = 200; // Batasi 200 voucher per batch
|
||||
$offset = 0;
|
||||
|
||||
while ($cekv1 = $ambilv1->fetch(PDO::FETCH_ASSOC)) {
|
||||
$iddatav1 = $cekv1['id'];
|
||||
$datav1 = $cekv1['voucher'];
|
||||
$durasi = $cekv1['durasi'];
|
||||
do {
|
||||
$ambilv1 = $pdo->prepare("
|
||||
SELECT id, create_time, voucher, durasi
|
||||
FROM v_load_cek_voucher
|
||||
WHERE id_setting_mikrotik = :idsm
|
||||
LIMIT :limit OFFSET :offset
|
||||
");
|
||||
$ambilv1->bindValue(':idsm', $idsm, PDO::PARAM_INT);
|
||||
$ambilv1->bindValue(':limit', $batchSize, PDO::PARAM_INT);
|
||||
$ambilv1->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$ambilv1->execute();
|
||||
|
||||
// Convert the 'durasi' to a valid DateInterval format
|
||||
$inter = convertDurationToInterval($durasi);
|
||||
if (!$inter) {
|
||||
echo "Invalid duration format: $durasi.\n";
|
||||
continue; // Skip this voucher if the duration is invalid
|
||||
}
|
||||
$rows = $ambilv1->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (!$rows) break;
|
||||
|
||||
// Check if the voucher exists in the hotspot users
|
||||
$cek = $API->comm('/ip/hotspot/user/print', ["?name" => $datav1]);
|
||||
foreach ($rows as $cekv1) {
|
||||
$iddatav1 = $cekv1['id'];
|
||||
$datav1 = $cekv1['voucher'];
|
||||
$durasi = $cekv1['durasi'];
|
||||
|
||||
if ($cek) {
|
||||
// If voucher exists, check the comment
|
||||
if (isset($cek[0]['comment']) && $cek[0]['comment'] != '') {
|
||||
$activetime = processCommentDate($cek[0]['comment']);
|
||||
$Tgl = new DateTime($activetime);
|
||||
// ================================
|
||||
// Convert duration to DateInterval
|
||||
// ================================
|
||||
$inter = convertDurationToInterval($durasi);
|
||||
if (!$inter) {
|
||||
$status = "Durasi tidak valid ($durasi)";
|
||||
echo "{$datav1} => $status\n";
|
||||
writeLog("[⛔] {$datav1} => $status");
|
||||
continue;
|
||||
}
|
||||
|
||||
// =====================================
|
||||
// Check if voucher exists on Hotspot
|
||||
// =====================================
|
||||
$cek = $API->comm('/ip/hotspot/user/print', ["?name" => $datav1]);
|
||||
|
||||
if ($cek) {
|
||||
// If voucher exists and has comment
|
||||
if (!empty($cek[0]['comment'])) {
|
||||
$activetime = processCommentDate($cek[0]['comment']);
|
||||
$Tgl = new DateTime($activetime);
|
||||
$Tgl->add($inter);
|
||||
$exp = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
updateVoucher($pdo, $iddatav1, $activetime, $exp);
|
||||
$status = "Voucher aktif & diperbarui. Expired: $exp";
|
||||
echo "{$datav1} => $status\n";
|
||||
writeLog("[✅] {$datav1} => $status");
|
||||
} else {
|
||||
markVoucherChecked($pdo, $iddatav1);
|
||||
$status = "Voucher ditemukan tanpa komentar, ditandai sudah dicek";
|
||||
echo "{$datav1} => $status\n";
|
||||
writeLog("[ℹ️] {$datav1} => $status");
|
||||
}
|
||||
} else {
|
||||
// If voucher does not exist
|
||||
$aktif = $cekv1['create_time'];
|
||||
$Tgl = new DateTime($aktif);
|
||||
$Tgl->add($inter);
|
||||
$exp = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
echo "{$datav1} comment->{$cek[0]['comment']} active->{$activetime} exp->{$exp} => Exists\n";
|
||||
|
||||
// Update the database with active and expired time
|
||||
updateVoucher($pdo, $iddatav1, $activetime, $exp);
|
||||
} else {
|
||||
// Mark the voucher as checked
|
||||
markVoucherChecked($pdo, $iddatav1);
|
||||
updateVoucher($pdo, $iddatav1, $aktif, $exp);
|
||||
$status = "Voucher tidak ditemukan, dianggap aktif sejak $aktif, expired: $exp";
|
||||
echo "{$datav1} => $status\n";
|
||||
writeLog("[⚠️] {$datav1} => $status");
|
||||
}
|
||||
} else {
|
||||
// If voucher does not exist, calculate expiration time based on creation date
|
||||
$aktif = $cekv1['create_time'];
|
||||
$Tgl = new DateTime($aktif);
|
||||
$Tgl->add($inter);
|
||||
$exp = $Tgl->format('Y-m-d H:i:s');
|
||||
|
||||
echo "{$datav1} active->{$aktif} exp->{$exp} => Does not exist\n";
|
||||
|
||||
// Update the database with active and expired time
|
||||
updateVoucher($pdo, $iddatav1, $aktif, $exp);
|
||||
}
|
||||
|
||||
echo "{$cekv1['voucher']}\n";
|
||||
}
|
||||
$offset += $batchSize;
|
||||
} while (count($rows) == $batchSize);
|
||||
|
||||
echo "✅ Selesai memproses semua voucher untuk Router {$m_ip}\n";
|
||||
writeLog("[✅] Selesai memproses semua voucher untuk Router {$m_ip}");
|
||||
} else {
|
||||
echo "Unable to connect to router: {$m_ip}\n";
|
||||
$msg = "Gagal terhubung ke Router: {$m_ip}";
|
||||
echo "❌ $msg\n";
|
||||
writeLog("[❌] $msg");
|
||||
}
|
||||
|
||||
// Disconnect the API session
|
||||
// =======================
|
||||
// Disconnect API session
|
||||
// =======================
|
||||
$API->disconnect();
|
||||
|
||||
// Function to convert duration string to DateInterval
|
||||
function convertDurationToInterval($durasi) {
|
||||
|
||||
// ============================================
|
||||
// Helper Functions
|
||||
// ============================================
|
||||
function convertDurationToInterval($durasi)
|
||||
{
|
||||
if (substr($durasi, -1) == 'H') {
|
||||
return new DateInterval("PT" . rtrim($durasi, 'H') . "H"); // For hours
|
||||
return new DateInterval("PT" . rtrim($durasi, 'H') . "H");
|
||||
} elseif (substr($durasi, -1) == 'D') {
|
||||
return new DateInterval("P" . rtrim($durasi, 'D') . "D"); // For days
|
||||
return new DateInterval("P" . rtrim($durasi, 'D') . "D");
|
||||
} elseif (substr($durasi, -1) == 'M') {
|
||||
return new DateInterval("PT" . rtrim($durasi, 'M') . "M"); // For minutes
|
||||
return new DateInterval("PT" . rtrim($durasi, 'M') . "M");
|
||||
} else {
|
||||
return false; // Invalid duration format
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to process the comment and extract valid activation time
|
||||
function processCommentDate($comment) {
|
||||
function processCommentDate($comment)
|
||||
{
|
||||
$modifiedDateTime = substr($comment, 6);
|
||||
if (substr($modifiedDateTime, 0, 4) == date('Y')) {
|
||||
return $modifiedDateTime;
|
||||
} else {
|
||||
$date = date_create_from_format("M/d/Y H:i:s", $modifiedDateTime);
|
||||
if ($date !== false) {
|
||||
return date_format($date, "Y-m-d H:i:s");
|
||||
} else {
|
||||
echo "Invalid date format: {$modifiedDateTime}\n";
|
||||
return null;
|
||||
}
|
||||
return $date ? date_format($date, "Y-m-d H:i:s") : null;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to update the voucher in the database
|
||||
function updateVoucher($pdo, $iddatav1, $activetime, $exp) {
|
||||
function updateVoucher($pdo, $iddatav1, $activetime, $exp)
|
||||
{
|
||||
$updateQuery = "UPDATE ganerate_voucher SET active_time = :activetime, expaired_time = :exp WHERE id = :id";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
$stmt->execute([
|
||||
':activetime' => $activetime,
|
||||
':exp' => $exp,
|
||||
':id' => $iddatav1
|
||||
':exp' => $exp,
|
||||
':id' => $iddatav1
|
||||
]);
|
||||
}
|
||||
|
||||
// Function to mark voucher as checked in the database
|
||||
function markVoucherChecked($pdo, $iddatav1) {
|
||||
function markVoucherChecked($pdo, $iddatav1)
|
||||
{
|
||||
$updateQuery = "UPDATE ganerate_voucher SET status_cek = '1' WHERE id = :id";
|
||||
$stmt = $pdo->prepare($updateQuery);
|
||||
$stmt->execute([':id' => $iddatav1]);
|
||||
|
||||
+16
-16
@@ -1,23 +1,23 @@
|
||||
SV_Cikembar_Utama Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01SV_BojongKerta Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01SV_Permata_Sampora Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01SV_Kingnet_Cibadak Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01SV_CC-Net_Cipicung Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01SV_Nusaina_Cibadak Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01SV_Diamond Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-07-14 23:47:01SV_BojongKerta Data pelanggan tidak ada
|
||||
2025-07-14 23:47:01SV_Permata_Sampora Data pelanggan tidak ada
|
||||
2025-07-14 23:47:01SV_Kingnet_Cibadak Data pelanggan tidak ada
|
||||
2025-07-14 23:47:01SV_CC-Net_Cipicung Data pelanggan tidak ada
|
||||
2025-07-14 23:47:01SV_Nusaina_Cibadak Data pelanggan tidak ada
|
||||
2025-07-14 23:47:01SV_Diamond Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_22P Net Cibadak Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01SV_Nettizen_Segaranten Data pelanggan tidak ada
|
||||
2025-07-05 15:51:01SV-DNY-Net-1 Data pelanggan tidak ada
|
||||
2025-07-05 16:31:01SV_NTA_2_Pasawahan Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-07-14 23:47:01SV_Nettizen_Segaranten Data pelanggan tidak ada
|
||||
2025-07-14 23:17:02SV-DNY-Net-1 Data pelanggan tidak ada
|
||||
2025-07-14 23:57:02SV_NTA_2_Pasawahan Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_NTA_1 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV-Cicukang Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO-Bumdes-Mekarmanah Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO-Pak-Kholiq Data pelanggan tidak ada
|
||||
2025-07-05 16:36:01RO-Dendrit-Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-07-15 00:02:02RO-Dendrit-Net Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
LJN.NS.CSR.NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
IVVINET-CBD Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01QONNET Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01Mikrotik_X86 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-07-14 23:47:02QONNET Data pelanggan tidak ada
|
||||
2025-07-14 23:47:02Mikrotik_X86 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Mikrotik_BSW_1 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Mikrotik_Alea Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
STANG Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
@@ -25,7 +25,7 @@ UNIX-NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
BTR CIEMAS Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV_NTA_2_TBL Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
MULYANAJAYA Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
PERWASIM.NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
PERWASIM-NETWORK Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_MELDINA Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_LIPPY Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO_Asep Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
@@ -37,14 +37,14 @@ RO_Wargasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
LJN_AGUNG Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RNET-CMS Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
DCN-GB-CCR Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01coba Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-07-14 23:47:02coba Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
412NET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
brf Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
BMSNET Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
purabaya Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
DCN-CO-GX4 Data pelanggan tidak ada
|
||||
2025-07-05 16:21:01MIKROTIK GX4 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-07-14 23:47:02MIKROTIK GX4 Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
RO - Netborhood Wifi Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
Neglasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
SV-DNY-Net-2 Data pelanggan tidak ada
|
||||
2025-07-05 16:31:01DNY-Neglasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
2025-07-14 23:57:02DNY-Neglasari Status koneksi tidak aktif atau interval tidak tersedia.
|
||||
|
||||
@@ -1 +1 @@
|
||||
Update ALL to NULL successful
|
||||
Successfully started background process for IP: tunnel.manjapro.net SV-DNY-Net-1<br>Successfully started background process for IP: nsn.my.id SV_22P Net Cibadak<br>Successfully started background process for IP: nsn.my.id RO-Bumdes-Mekarmanah<br>Successfully started background process for IP: 103.242.104.69 RO-Dendrit-Net<br>Successfully started background process for IP: 103.26.176.93 LJN.NS.CSR.NET<br>Successfully started background process for IP: 103.155.198.109 RO_Asep<br>Successfully started background process for IP: 103.155.199.191 PERWASIM-NETWORK<br>Successfully started background process for IP: tunnel.manjapro.net SV_NTA_2_Pasawahan<br>Successfully started background process for IP: tunnel.manjapro.net SV-Cicukang<br>Successfully started background process for IP: tunnel.manjapro.net SV_NTA_1<br>Successfully started background process for IP: 103.94.10.112 STANG<br>Successfully started background process for IP: 157.20.128.231 QONNET<br>Successfully started background process for IP: 114.141.51.12 BMSNET<br>Successfully started background process for IP: 114.141.51.12 purabaya<br>Successfully started background process for IP: nsn.my.id SV_Cikembar_Utama<br>Successfully started background process for IP: tunnel.bilspro.com RO_Sukasari<br>Successfully started background process for IP: tunnel.bilspro.com Mikrotik_X86<br>Successfully started background process for IP: 103.155.196.145 UNIX-NET<br>Successfully started background process for IP: nsn.my.id SV_Diamond Net<br>Successfully started background process for IP: 103.26.176.81 SV_CC-Net_Cipicung<br>Successfully started background process for IP: 103.242.105.199 SV-DNY-Net-2<br>Started parallel processes for checking vouchers. => 2025-07-15 00:00:01
|
||||
@@ -19,6 +19,7 @@ if ($set1->rowCount() > 0) {
|
||||
|
||||
while ($pset = $set1->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Get connection details for the router
|
||||
$nama = $pset['nama'];
|
||||
$m_ip = $pset['ip_address'];
|
||||
$m_user = $pset['username'];
|
||||
$m_pass = $pset['password'];
|
||||
@@ -26,16 +27,16 @@ if ($set1->rowCount() > 0) {
|
||||
$idsm = $pset['id_setting_mikrotik'];
|
||||
|
||||
// Prepare the command for each router
|
||||
$command = "php /www/wwwroot/bilspro/load/check_voucher.php {$m_ip} {$m_user} {$m_pass} {$m_port} {$idsm} > /dev/null 2>&1 &";
|
||||
$command = "php /www/wwwroot/bilspro/load/check_voucher.php {$m_ip} {$m_user} {$m_pass} {$m_port} {$idsm} {$nama} > /dev/null 2>&1 &";
|
||||
|
||||
// Execute the command in background
|
||||
exec($command, $output, $return_var);
|
||||
|
||||
// Check if there was an issue with exec
|
||||
if ($return_var !== 0) {
|
||||
echo "Error executing command for IP: {$m_ip}\n";
|
||||
echo "Error executing command for IP: {$m_ip}<br>";
|
||||
} else {
|
||||
echo "Successfully started background process for IP: {$m_ip}\n";
|
||||
echo "Successfully started background process for IP: {$m_ip} {$nama}<br>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -319,7 +319,7 @@ try {
|
||||
|
||||
// Kirim Pesan WhatsApp
|
||||
$nomor = explode(',', $tagihan['nomor_whatsapp']);
|
||||
$Url = 'http://bilspro.com/invoice/' . $invoice;
|
||||
$Url = 'https://manjapro.net/invoice/' . $invoice;
|
||||
|
||||
$APIwa = new PesanWA();
|
||||
$APIwa->Create_Pesan($tagihan['id_data_server'], $idtag, 'pesan_melunasi_tagihan', 'tag');
|
||||
|
||||
@@ -24,7 +24,7 @@ STANG =><br>
|
||||
UNIX-NET =><br>
|
||||
SV_NTA_2_TBL =><br>
|
||||
MULYANAJAYA =><br>
|
||||
PERWASIM.NET =><br>
|
||||
PERWASIM-NETWORK =><br>
|
||||
RO_MELDINA =><br>
|
||||
RO_LIPPY =><br>
|
||||
RO_Asep =><br>
|
||||
|
||||
@@ -1 +1 @@
|
||||
Tidak perlu update untuk ID: 2 Rp.200,000<br>Harga khusus untuk ID: 3 Rp.250,000<br>Tidak perlu update untuk ID: 4 Rp.300,000<br>Tidak perlu update untuk ID: 5 Rp.300,000<br>Tidak perlu update untuk ID: 6 Rp.200,000<br>Harga khusus untuk ID: 7 Rp.200,000<br>Tidak perlu update untuk ID: 8 Rp.200,000<br>Tidak perlu update untuk ID: 9 Rp.200,000<br>Tidak perlu update untuk ID: 10 Rp.200,000<br>Harga harus diupdate untuk ID Data Server: 12 Rp.750,000<br>Tidak perlu update untuk ID: 13 Rp.750,000<br>Tidak perlu update untuk ID: 14 Rp.450,000<br>Tidak perlu update untuk ID: 15 Rp.450,000<br>Tidak perlu update untuk ID: 16 Rp.300,000<br>Harga khusus untuk ID: 17 Rp.300,000<br>Tidak perlu update untuk ID: 18 Rp.300,000<br>Tidak perlu update untuk ID: 19 Rp.450,000<br>Tidak perlu update untuk ID: 20 Rp.200,000<br>Tidak perlu update untuk ID: 21 Rp.300,000<br>Tidak perlu update untuk ID: 22 Rp.300,000<br>Tidak perlu update untuk ID: 23 Rp.450,000<br>Tidak perlu update untuk ID: 24 Rp.200,000<br>Tidak perlu update untuk ID: 25 Rp.250,000<br>Tidak perlu update untuk ID: 26 Rp.200,000<br>Tidak perlu update untuk ID: 28 Rp.200,000<br>Tidak perlu update untuk ID: 29 Rp.300,000<br>Tidak perlu update untuk ID: 30 Rp.200,000<br>Tidak perlu update untuk ID: 31 Rp.200,000<br>Tidak perlu update untuk ID: 32 Rp.200,000<br>Tidak perlu update untuk ID: 33 Rp.200,000<br>Tidak perlu update untuk ID: 34 Rp.200,000<br>Tidak perlu update untuk ID: 35 Rp.200,000<br>Tidak perlu update untuk ID: 36 Rp.200,000<br>Tidak perlu update untuk ID: 37 Rp.300,000<br>Tidak perlu update untuk ID: 38 Rp.200,000<br>Tidak perlu update untuk ID: 39 Rp.200,000<br>Harga khusus untuk ID: 40 Rp.1,000,000<br>Tidak perlu update untuk ID: 41 Rp.200,000<br>Tidak perlu update untuk ID: 42 Rp.200,000<br>Harga khusus untuk ID: 43 Rp.100,000<br>Tidak perlu update untuk ID: 44 Rp.200,000<br>Tidak perlu update untuk ID: 45 Rp.300,000<br>Tidak perlu update untuk ID: 46 Rp.200,000<br>Tidak perlu update untuk ID: 47 Rp.200,000<br>Tidak perlu update untuk ID: 48 Rp.200,000<br>Tidak perlu update untuk ID: 49 Rp.200,000<br>Tidak perlu update untuk ID: 50 Rp.200,000<br>Tidak perlu update untuk ID: 51 Rp.200,000<br>Tidak perlu update untuk ID: 52 Rp.1,000,000<br>Tidak perlu update untuk ID: 53 Rp.200,000<br>Tidak perlu update untuk ID: 54 Rp.200,000<br>Tidak perlu update untuk ID: 55 Rp.200,000<br>Tidak perlu update untuk ID: 56 Rp.200,000<br>Tidak perlu update untuk ID: 57 Rp.200,000<br>Tidak perlu update untuk ID: 58 Rp.200,000<br>Tidak perlu update untuk ID: 59 Rp.200,000<br>Tidak perlu update untuk ID: 60 Rp.200,000<br>Tidak perlu update untuk ID: 61 Rp.300,000<br>Tidak perlu update untuk ID: 62 Rp.200,000<br>Tidak perlu update untuk ID: 63 Rp.200,000<br>Tidak perlu update untuk ID: 64 Rp.200,000<br>Tidak perlu update untuk ID: 65 Rp.200,000<br>Tidak perlu update untuk ID: 66 Rp.200,000<br>Tidak perlu update untuk ID: 67 Rp.200,000<br>Harga khusus untuk ID: 68 Rp.200,000<br>Harga khusus untuk ID: 69 Rp.200,000<br>Tidak perlu update untuk ID: 70 Rp.200,000<br>Tidak perlu update untuk ID: 71 Rp.200,000<br>Tidak perlu update untuk ID: 72 Rp.200,000<br>Tidak perlu update untuk ID: 73 Rp.200,000<br>
|
||||
Tidak perlu update untuk ID: 2 Rp.200,000<br>Harga khusus untuk ID: 3 Rp.250,000<br>Tidak perlu update untuk ID: 4 Rp.300,000<br>Tidak perlu update untuk ID: 5 Rp.300,000<br>Tidak perlu update untuk ID: 6 Rp.200,000<br>Harga khusus untuk ID: 7 Rp.200,000<br>Tidak perlu update untuk ID: 8 Rp.200,000<br>Tidak perlu update untuk ID: 9 Rp.200,000<br>Tidak perlu update untuk ID: 10 Rp.200,000<br>Tidak perlu update untuk ID: 12 Rp.750,000<br>Tidak perlu update untuk ID: 13 Rp.750,000<br>Tidak perlu update untuk ID: 14 Rp.450,000<br>Tidak perlu update untuk ID: 15 Rp.450,000<br>Tidak perlu update untuk ID: 16 Rp.300,000<br>Harga khusus untuk ID: 17 Rp.300,000<br>Tidak perlu update untuk ID: 18 Rp.300,000<br>Tidak perlu update untuk ID: 19 Rp.450,000<br>Tidak perlu update untuk ID: 20 Rp.200,000<br>Tidak perlu update untuk ID: 21 Rp.300,000<br>Tidak perlu update untuk ID: 22 Rp.300,000<br>Tidak perlu update untuk ID: 23 Rp.450,000<br>Tidak perlu update untuk ID: 24 Rp.200,000<br>Tidak perlu update untuk ID: 25 Rp.250,000<br>Tidak perlu update untuk ID: 26 Rp.200,000<br>Tidak perlu update untuk ID: 28 Rp.200,000<br>Tidak perlu update untuk ID: 29 Rp.300,000<br>Tidak perlu update untuk ID: 30 Rp.200,000<br>Tidak perlu update untuk ID: 31 Rp.200,000<br>Tidak perlu update untuk ID: 32 Rp.200,000<br>Tidak perlu update untuk ID: 33 Rp.200,000<br>Tidak perlu update untuk ID: 34 Rp.200,000<br>Tidak perlu update untuk ID: 35 Rp.200,000<br>Tidak perlu update untuk ID: 36 Rp.200,000<br>Tidak perlu update untuk ID: 37 Rp.300,000<br>Tidak perlu update untuk ID: 38 Rp.200,000<br>Tidak perlu update untuk ID: 39 Rp.200,000<br>Harga khusus untuk ID: 40 Rp.1,000,000<br>Tidak perlu update untuk ID: 41 Rp.200,000<br>Tidak perlu update untuk ID: 42 Rp.200,000<br>Harga khusus untuk ID: 43 Rp.100,000<br>Tidak perlu update untuk ID: 44 Rp.200,000<br>Tidak perlu update untuk ID: 45 Rp.300,000<br>Tidak perlu update untuk ID: 46 Rp.200,000<br>Tidak perlu update untuk ID: 47 Rp.200,000<br>Tidak perlu update untuk ID: 48 Rp.200,000<br>Tidak perlu update untuk ID: 49 Rp.200,000<br>Tidak perlu update untuk ID: 50 Rp.200,000<br>Tidak perlu update untuk ID: 51 Rp.200,000<br>Tidak perlu update untuk ID: 52 Rp.1,000,000<br>Tidak perlu update untuk ID: 53 Rp.200,000<br>Tidak perlu update untuk ID: 54 Rp.200,000<br>Tidak perlu update untuk ID: 55 Rp.200,000<br>Tidak perlu update untuk ID: 56 Rp.200,000<br>Tidak perlu update untuk ID: 57 Rp.200,000<br>Tidak perlu update untuk ID: 58 Rp.200,000<br>Tidak perlu update untuk ID: 59 Rp.200,000<br>Tidak perlu update untuk ID: 60 Rp.200,000<br>Tidak perlu update untuk ID: 61 Rp.300,000<br>Tidak perlu update untuk ID: 62 Rp.200,000<br>Tidak perlu update untuk ID: 63 Rp.200,000<br>Tidak perlu update untuk ID: 64 Rp.200,000<br>Tidak perlu update untuk ID: 65 Rp.200,000<br>Tidak perlu update untuk ID: 66 Rp.200,000<br>Tidak perlu update untuk ID: 67 Rp.200,000<br>Harga khusus untuk ID: 68 Rp.200,000<br>Harga khusus untuk ID: 69 Rp.200,000<br>Tidak perlu update untuk ID: 70 Rp.200,000<br>Tidak perlu update untuk ID: 71 Rp.200,000<br>Tidak perlu update untuk ID: 72 Rp.200,000<br>Tidak perlu update untuk ID: 73 Rp.200,000<br>2399 data pesan sebelum 3 hari terakhir berhasil dihapus.<br>
|
||||
@@ -55,6 +55,24 @@ try {
|
||||
echo "Harga khusus untuk ID: " . $data['id'] . " Rp." . number_format($data['harga_sewa']) . "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
$sekarang = date('Y-m-d H:i:s');
|
||||
$harilalu = date('Y-m-d H:i:s', strtotime("$sekarang -3 days"));
|
||||
|
||||
// Hitung jumlah data yang akan dihapus
|
||||
$sqlCount = "SELECT COUNT(id) AS jumid FROM master_pesan WHERE waktu <= :harilalu";
|
||||
$stmtCount = $pdo->prepare($sqlCount);
|
||||
$stmtCount->execute(['harilalu' => $harilalu]);
|
||||
$pp = $stmtCount->fetch(PDO::FETCH_ASSOC);
|
||||
$jumlahHapus = $pp['jumid'] ?? 0;
|
||||
|
||||
// Hapus data
|
||||
$sqlDelete = "DELETE FROM master_pesan WHERE waktu <= :harilalu";
|
||||
$stmtDelete = $pdo->prepare($sqlDelete);
|
||||
$stmtDelete->execute(['harilalu' => $harilalu]);
|
||||
|
||||
echo $jumlahHapus . " data pesan sebelum 3 hari terakhir berhasil dihapus.<br>";
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// Tangani kesalahan koneksi atau query
|
||||
echo "Terjadi kesalahan: " . $e->getMessage();
|
||||
|
||||
Reference in New Issue
Block a user