update wa official API
This commit is contained in:
+10
-3
@@ -17,10 +17,11 @@ if ($rows) {
|
||||
$result = [];
|
||||
foreach ($entries as $entry) {
|
||||
// Pecah setiap entry berdasarkan '_'
|
||||
list($akun, $ip_address) = explode('_', $entry);
|
||||
list($akun, $ip_address, $mac) = explode('_', $entry);
|
||||
$result[] = [
|
||||
'akun' => $akun,
|
||||
'ip_address' => $ip_address
|
||||
'ip_address' => $ip_address,
|
||||
'mac_address' => $mac
|
||||
];
|
||||
}
|
||||
// Ambil data akun dari database
|
||||
@@ -83,14 +84,16 @@ if ($rows) {
|
||||
// Rubah ke array
|
||||
$data = explode("_", $cari02);
|
||||
|
||||
if (count($data) === 2) {
|
||||
if (count($data) === 3) {
|
||||
$ipadd = $data[1];
|
||||
$macadd = $data[2];
|
||||
|
||||
// Siapkan data untuk update
|
||||
$updates[] = [
|
||||
'id' => $idakun,
|
||||
'status' => 'On',
|
||||
'ip_address' => $ipadd,
|
||||
'mac_address' => $macadd,
|
||||
'time' => $time,
|
||||
];
|
||||
}
|
||||
@@ -110,6 +113,10 @@ if ($rows) {
|
||||
foreach ($updates as $update) {
|
||||
$updateQuery .= "WHEN {$update['id']} THEN '{$update['ip_address']}' ";
|
||||
}
|
||||
$updateQuery .= "END, mac_address = CASE id ";
|
||||
foreach ($updates as $update) {
|
||||
$updateQuery .= "WHEN {$update['id']} THEN '{$update['mac_address']}' ";
|
||||
}
|
||||
$updateQuery .= "END, time_update = '{$time}' WHERE id IN (" . implode(',', array_column($updates, 'id')) . ")";
|
||||
$pdo->exec($updateQuery);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user