Code:
<?php
/**
* @author Dynamite
* @copyright 2011
*/
$urlbase = "http://localhost/game_stats/";
putenv("GDFONTPATH=".realpath("."));
$script_name = $_SERVER["SCRIPT_NAME"];
$script_name = explode('/', $script_name);
$script_name = $script_name[count($script_name) - 1];
If (isset($_GET['js']))
{
?>
var link_to_script = 'http://stats.durp.me/';
$(document).ready(function () {
$('#imgbox').hide()
});
function GetData() {
data = new Array();
$('#select :selected').each(function (i, selected) {
data[i] = $(selected).text().replace(/ /g, '_');
});
return data;
}
function FetchImage(uid, data) {
var request = '?img&uid=' + uid + '&vars=';
$.each(data, function (key, val) {
var substr = val.split(',');
request += '"' + substr[0] + '",'
});
request = request.substring(0, request.length - 1);
$('#img').attr('src', '<?php echo $script_name;?>' + request);
$('#imgbox').show(0);
$('#link').html(link_to_script + (encodeURI(request)));
}
<?php
die();
}
if(isset($_GET['vars'])){
$strArr = stripslashes($_GET['vars']);
$strArr = str_replace('_', ' ', $strArr);
$strArr = str_replace('"', '', $strArr);
$varArr = explode(',', $strArr);
}
If (isset($_GET['img']))
{
Foreach ($_GET as $key => $value)
{
If ($key != 'img')
{
$$key = $value;
}
}
header("Content-type: image/png");
$image = imagecreatefrompng('image3.png');
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
$i = 0;
$b = 1;
$c = 0;
$u;
$t;
$r;
$pair = array(2,4,6,8,10,12,14,16,18,20);
$impair = array(1,3,5,7,9,11,13,15,17,19);
$data = @file_get_contents("http://stats.villavu.com/api/user/".$_GET['uid']);
$data = @json_decode($data);
foreach($data as $key => $value){
//print($key.': '.$value.' | ');
if($key == 'rank'){
$r = $value;
}else if($key == 'user'){
$u = $value;
}else if($key == 'time'){
$t = $value;
}
for($j = 0; $j < count($varArr); $j++){
for($k = 0; $k < count($value); $k++){
if(is_array($value)){
if($value[$k][1] == $varArr[$j]){
$i = $i == 0 ? 25 : $i + 15;
$print = $value[$k][1].': '.$value[$k][0].' ';
If ($b > 10)
{
$c = $c == 0 ? 25 : $c + 16;
imagestring($image, 3, 250, $c, $print, $black);
}else{
imagestring($image, 3, 6, $i, $print, $black);
}
$i++;
$b++;
}
}
}
}
}
imagestring($image, 5, 10, 5, "Username: ".$u." Time: ".$t." Rank: ".$r, $white);
imagepng($image);
imagedestroy($images);
}
If (isset($_GET['uid']))
{
$id = intval($_GET['uid']);
$page = '
<html>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="'.$script_name.'?js"></script>
</head>
<body>
<ins></ins>
<b>Username:</b> {$user} <br/>
<b>Rank:</b> {$rank} <br/>
<b>Time:</b> {$time} <br/>
<br/>
{$select}
<br/> <br/>
<div id="imgbox">
<img id="img" src=\''.$script_name.'\' border="0"></img>
<br><br/>
<div id="link"></div>
<br/>
</div>
<button onclick="FetchImage(\'{$uid}\', GetData());">Generate Signature</button>
</body>
</html>
';
$data = @file_get_contents("http://stats.villavu.com/api/user/".$id);
If (!$data)
{
Die ("Couldn't fetch data from the site");
}
$data = @json_decode($data);
If (!$data)
{
Die ("Invalid data");
}
foreach ($data as $key => $value)
{
$$key = $value;
}
$select = '<select multiple="true" style="height: 150px" id="select">';
foreach ($vars as $var)
{
$select .= "<option value=\"{$var[0]}\">{$var[1]}</option>";
}
$select .= '</select>';
eval("\$page = \"".str_replace("\\'", "'", addslashes($page))."\";");
Echo $page;
}else{
$form = '<form method="get" action=""><input type="text" name="uid"/> <input type="submit" value="Search UID"/></form>';
Echo $form;
}
?>