connect_error) { $mysql = false; } } catch(Exception $e) { $mysql = false; } $data = shell_exec('uptime'); $uptime = explode(' up ', $data); $uptime = explode(',', $uptime[1]); $uptime = $uptime[0].', '.$uptime[1]; if($mysql){ $data = [ 'success' => true, 'uptime' => $uptime]; header('Content-Type: application/json; charset=utf-8'); echo json_encode($data); }else{ $data = [ 'success' => false, 'uptime' => $uptime]; header('HTTP/1.1 500 Internal Server Error'); header('Content-Type: application/json; charset=utf-8'); echo json_encode($data); }