Untitled

[{"id":"1","lastseen":1679247455,"online":false},{"id":"2","lastseen":1679244623,"online":false},{"id":"5","lastseen":1677149304,"online":false},{"id":"4","lastseen":1678051744,"online":false}]
 avatar
Esbjerg82
php
2 years ago
679 B
18
Indexable
<?php
// Connect to the database
define('DB_SERVER', 'localhost');
define('DB_USERNAME', '');
define('DB_PASSWORD', '!');
define('DB_NAME', '');

$dm = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);


// Get online status of each admin

$sql = "SELECT id, lastseen, online FROM `dm_admins`";
$result = mysqli_query($dm, $sql);
$data = array();
while ($row = mysqli_fetch_array($result)) {
  $data[] = array(
    'id' => $row['id'],
    'lastseen' => strtotime($row['lastseen']),
    'online' => (bool) $row['online']
  );
}

// Return online status data as JSON
header('Content-Type: application/json');
echo json_encode($data);
exit;
?>
Editor is loading...