mirror of
https://github.com/gabrielkheisa/covid19_id.git
synced 2024-11-21 19:11:47 +07:00
Create index.php
This commit is contained in:
parent
c83d598326
commit
3c916e57e9
44
index.php
Normal file
44
index.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
|
$q = $_REQUEST["q"];
|
||||||
|
$key = "KEY";
|
||||||
|
|
||||||
|
if ($q == "")
|
||||||
|
{
|
||||||
|
$myfile = fopen("cache.txt", "r") or die("Unable to open file!");
|
||||||
|
$teks = fread($myfile, filesize("cache.txt"));
|
||||||
|
fclose($myfile);
|
||||||
|
|
||||||
|
$pieces = explode(",", $teks);
|
||||||
|
|
||||||
|
$marks = array(
|
||||||
|
"terkonfirmasi" => $pieces[0],
|
||||||
|
"perawatan" => $pieces[1],
|
||||||
|
"sembuh" => $pieces[2],
|
||||||
|
"meninggal" => $pieces[3],
|
||||||
|
"last_update" => $pieces[4],
|
||||||
|
"server_update" => $pieces[5]
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode($marks, JSON_PRETTY_PRINT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$txt = base64_decode($q);
|
||||||
|
|
||||||
|
$pieces = explode(",", $txt);
|
||||||
|
|
||||||
|
if (strcmp($pieces[6], $key) == 0)
|
||||||
|
{
|
||||||
|
$myfile = fopen("cache.txt", "w") or die("Unable to open file!");
|
||||||
|
fwrite($myfile, $txt);
|
||||||
|
fclose($myfile);
|
||||||
|
echo "Done!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
die("Key Invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user