-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
32 lines (30 loc) · 656 Bytes
/
api.php
File metadata and controls
32 lines (30 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/*
* Author: Max Base
* Name: ISSABEL simple API Restful JSON
* Date: 15 May, 2022
*/
date_default_timezone_set('Asia/Tehran');
header("Content-type: application/json");
$json_file = "cache.json";
if (!file_exists($json_file)) {
print json_encode([
"status" => 0,
]);
}
else {
$data = file_get_contents($json_file);
$obj = json_decode($data, true);
if($obj === null || $obj === [] || $data === "" || $data === null) {
print json_encode([
"status" => 0,
]);
}
else {
print json_encode([
"status" => 1,
"data" => $obj,
"lastupdate" => date("F d Y H:i:s", filemtime($json_file))
]);
}
}