<?php
//include("push.php");
$versions["rg"]="5.0";
$versions["rfyl"]="3.0";
$versions["insect"]="4.0";

$versions["robious"]="3.0";
$versions["hammer"]="2.0";
$versions["rfyl8"]="1.0";
$versions["bomber"]="2.5";
$versions["road"]="3.0";
$versions["thief"]="2.0";
$versions["cars"]="6.0";
$versions["cube"]="1.0";
$versions["beatpro"]="5.0";
$versions["qtap"]="2.0";
$versions["ftb"]="2.0";
$versions["beat"]="6.2";
$versions["td"]="3.0";
if(!$_GET['id']) {
die("-1");
}
if(!$_GET['lang']) {
die("-1");
}
$id=$_GET['id'];
$lang=$_GET['lang'];
$count=0;
$file=fopen("txt/".$id.".txt","r");
if ($file) {
$count=fgets($file);
fclose($file);
}
$file=fopen("txt/".$id.".txt","w+");
flock($file, LOCK_EX);
if (!$file) {
flock($file, LOCK_UN);
die("-1");
}
$count=$count+1;
fputs($file,$count);
flock($file, LOCK_UN);
$err=fclose($file);

$url="http://ip-api.com/json/".$_SERVER[REMOTE_ADDR];
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
$ipinfo=json_decode($result, true);
$sound="score";
if ($id=="rg") $sound="harp";
$title=$id." counter ".$count." in ".($_GET['lang']==1?'English':'Spanish').", from ".$ipinfo["city"].", ".$ipinfo["regionName"].", ".$ipinfo[country];
$m="test";
//push($title,$m,$sound);
//lang
$tcount=0;
$file=fopen("txt/total".$lang.".txt","r");
if ($file) {
$tcount=fgets($file);
fclose($file);
}
$file=fopen("txt/total".$lang.".txt","w+");
flock($file, LOCK_EX);
if (!$file) {
flock($file, LOCK_UN);
die("-1");
}
$tcount=$tcount+1;
fputs($file,$tcount);
flock($file, LOCK_UN);
$err=fclose($file);

echo $count."\n";
if(!$versions[$id]) { die("-1\n"); }
echo $versions[$id]."\n";
echo filesize("motd".$lang.".ogg")."\n";
?>