query("DELETE FROM ip_timezones WHERE unix < {0} OR (unix < {1} AND country = '')", array(time() - 86400 * 60, time() - 86400)); $Exists = $MySql->query("SELECT * FROM ip_timezones WHERE ip = md5({0}) LIMIT 1", array($_GET["ip"]))->fetch(); $TimeZone = "Europe/Berlin"; $Country = "DE"; if (empty($Exists["ip"])) { //We can also use another service to trace the ip, if you wish so, change this code $TraceRequest = json_decode(HttpRequest("http://ip-api.com/json/".$_GET["ip"], "", 3), true); if ($TraceRequest["status"] == "success") { $TimeZone = $TraceRequest["timezone"]; $Country = $TraceRequest["countryCode"]; } $MySql->query("INSERT INTO ip_timezones (ip, timezone, country, unix)VALUES(md5({0}), {1}, {2}, {3})", array($_GET["ip"], $TimeZone, $Country, time())); } else { $TimeZone = $Exists["timezone"]; $Country = $Exists["country"]; } $Language = "DE"; $Exists = $MySql->query("SELECT * FROM countries_lang WHERE country = {0} LIMIT 1", array(strtolower($Country)))->fetch(); if (!empty($Exists["lang"])) {$Language = strtoupper($Exists["lang"]);} die(implode(",", array("OK", $Country, $TimeZone, $Language, $_GET["payload"]))); ?>