* licensed under AGPLv3-or-later; see LICENSE.md for more information */ header('Content-Type: application/json; charset=UTF-8'); try { $pdo = new PDO("mysql:host=127.0.0.1;dbname=hitlerclicker", "root", "aA1234Aa"); } catch(PDOException $e) { die('{ "status": "database offline" }'); }; $wrkarr = []; $ifarr = [ "token" ]; $postjson = json_decode(file_get_contents('php://input'), true); foreach ($ifarr as $i): if (isset($postjson[$i])): $newarr = [ "$i" => "$postjson[$i]", ]; $wrkarr = array_merge($wrkarr, $newarr); endif; endforeach; if (!isset($wrkarr["token"]) || trim($wrkarr["token"]) == ""): die('{ "status": "token was not provided.\ncould not return information." }'); else: $query = $pdo->prepare("SELECT name, team, clicks FROM users WHERE token LIKE ?"); $query -> execute([$wrkarr["token"]]); $found = $query->fetch(PDO::FETCH_ASSOC); if ($found): die("{ \"status\": \"success\", \"name\": \"$found[name]\", \"team\": \"$found[team]\", \"clicks\": \"$found[clicks]\" }"); else: die('{ "status": "token does not exist in the database." }'); endif; endif; echo '{ "status": "online" }'; ?>