2022-10-29 20:59:32 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
|
|
|
|
$q = $_REQUEST["q"];
|
|
|
|
$key = "API_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);
|
|
|
|
|
2022-11-03 08:51:41 +07:00
|
|
|
$marks = array("price"=>$pieces[0], "price_change"=>$pieces[1], "change"=>$pieces[2], "last_update"=>$pieces[3],"server_update"=>$pieces[4], "symbol"=>$pieces[5], "color"=>$pieces[6]);
|
2022-10-29 20:59:32 +07:00
|
|
|
|
|
|
|
echo json_encode($marks, JSON_PRETTY_PRINT);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$txt = base64_decode($q);
|
|
|
|
|
|
|
|
$pieces = explode("=", $txt);
|
|
|
|
|
2022-11-03 08:51:41 +07:00
|
|
|
if(strcmp($pieces[7], $key) == 0) {
|
2022-10-29 20:59:32 +07:00
|
|
|
$myfile = fopen("cache.txt", "w") or die("Unable to open file!");
|
|
|
|
fwrite($myfile, $txt);
|
|
|
|
fclose($myfile);
|
|
|
|
echo "Done!";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "Key Invalid";
|
|
|
|
fclose($myfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|