<?php
// header('Content-type: application/json');
include '../config/database.php';
function _command(){
	$conn = _connectDB();
	$sql = "SELECT * FROM monitor";
	$result = $conn->query($sql);
	$res = [];
	if ($result->num_rows > 0) {
	    while($row = $result->fetch_assoc()) {
			array_push($res,$row);
	    }
	}
	return $res;
}


$data = [];
foreach(_command() as $key => $val){
	array_push($data,$val);
	// $data = [];
	// $data['name'] = base64_decode($val['line_name']);
	// $data['product'] = $val['line_product'];
	// $data['person'] = base64_decode($val['line_person']);
}



function _getTime(){
	$current = date("Y-m-d H:i:s");  
	return $current;
}

// $now = date("Y-m-d H:i:s"); 
// if (_getTime() >= $now){
//  echo "true";
// }else{
//   echo "FAlse";
// }

// Array
// (
//     [Code] => HUAYLIKE
//     [Version] => V1
//     [Status] => RUN
//     [Timeout] => 2020-09-18 13:38:30
//     [Comment] => 
// )

echo json_encode($data);