Profile Paket

Nama Profile Harus sama dengan yang ada di Mikrotik
Pilih Berulangkali jika user hotspot di tagihan setiap bulan
Isi jika menggunakan Aplikasi Agen Voucher
Contoh : 3H => 3 Jam , 1D => 1 Hari
prepare("SELECT * FROM setting_mikrotik WHERE id_data_server = :id_data_server"); $stmt->execute([':id_data_server' => $_POST['ids']]); $servers = $stmt->fetchAll(PDO::FETCH_ASSOC); $messages = []; // Array untuk menyimpan pesan foreach ($servers as $server) { $mikrotikName = $server['nama']; $API = new RouterosAPI(); $API->debug = false; // Koneksi ke MikroTik if ($API->connect2($server['ip_address'], $server['username'], $server['password'], $server['port_api'])) { $profileName = $_POST['profile']; if ($_POST['jenis'] == 'PPPOE') { // Cek profil PPPOE $profiles = $API->comm('/ppp/profile/print'); $found = false; foreach ($profiles as $profile) { if ($profile['name'] === $profileName) { $found = true; break; } } if (!$found) { $messages[] = "Profil PPPOE $profileName di $mikrotikName tidak ada."; } } else { // Cek profil Hotspot $profiles = $API->comm('/ip/hotspot/user/profile/print'); $found = false; foreach ($profiles as $profile) { if ($profile['name'] === $profileName) { $profileId = $profile['.id']; $found = true; break; } } if ($found) { // Jika status sama dengan 1 if ($status == 1) { // Pastikan intervalFormat() sudah terdefinisi $interval = intervalFormat($_POST['durasi']); // Skrip On Login yang akan dipasang $onLoginScript = ':local nama $user; :local tanggal [/system clock get date]; :local waktu [/system clock get time]; :if ([/ip hotspot user get [find name=$nama] comment] = "") do={/ip hotspot user set [find name=$nama] comment="Login.$tanggal $waktu"; :log warning ("User " . $nama . " berhasil login.")} else={:log warning ("User " . $nama . " berhasil melakukan login ulang.")}; :if ([/system schedule find name=$nama] = "") do={/system schedule add name=$nama interval='.$interval.' on-event="/ip hotspot active remove [find user=$nama]; /ip hotspot user remove [find name=$nama]; /system schedule remove [find name=$nama]" start-date=$tanggal start-time=$waktu;}'; // Update skrip On Login $API->comm('/ip/hotspot/user/profile/set', [ '.id' => $profileId, 'on-login' => $onLoginScript, ]); } else { $messages[] = "Gagal Upload Script: Profil Hotspot $profileName di $mikrotikName tidak aktif atau status tidak sesuai."; } } else { $messages[] = "Profil Hotspot $profileName di $mikrotikName tidak ada."; } } } else { $messages[] = "Gagal terhubung ke MikroTik $mikrotikName."; } } // Cek pesan sebelum menyimpan ke database if (empty($messages)) { $stmt = $pdo->prepare("UPDATE profile_paket SET id_data_server = :id_data_server, jenis_profile = :jenis_profile, nama_profile = :nama_profile, durasi = :durasi, nama = :nama, harga_paket = :harga_paket, vi_agen = :vi_agen, status = :status WHERE id = :id"); $stmt->bindParam(':id_data_server', $_POST['ids']); $stmt->bindParam(':jenis_profile', $_POST['jenis']); $stmt->bindParam(':nama_profile', $_POST['profile']); $stmt->bindParam(':durasi', $_POST['durasi']); $stmt->bindParam(':nama', $_POST['nama']); $stmt->bindParam(':harga_paket', $nominal); $stmt->bindParam(':vi_agen', $fee); $stmt->bindParam(':status', $status); $stmt->bindParam(':id', $page[1]); $stmt->execute(); sweetAlert("Profile Paket Telah di Ubah", "success", "?".encrypt_url('profile_paket')); } else { $message = implode("
", $messages); detailAlert($message, strpos($message, 'tidak ada') !== false || strpos($message, 'Gagal') !== false); } } catch (PDOException $e) { // Menangani kesalahan sweetAlert("Terjadi kesalahan: " . $e->getMessage(), "error"); } } ?>