<?
header("Content-type: image/png");
require("include/secrets.php");
MySQL_CONNECT($mysql_host, $mysql_user, $mysql_pass);
MySQL_SELECT_DB ($mysql_db);
$maxplayed = 0;
$userplayed = 0;
$result = MySQL_QUERY("SELECT * FROM flashscores GROUP BY user;");
while($flashuser = MySQL_FETCH_ARRAY($result))
{
$totalresult = MySQL_QUERY("SELECT COUNT(*) FROM flashscores WHERE user = '".$flashuser["user"]."';");
if($totaluser = MySQL_FETCH_ROW($totalresult))
{
if($totaluser[0]>$maxplayed)
{
$userplayed = $flashuser["user"];
$maxplayed = $totaluser[0];
}
}
}
$result = MySQL_QUERY("SELECT * FROM users WHERE id = ".$userplayed.";");
if($user = MySQL_FETCH_ARRAY($result))
{
$username = $user["username"];
$im = imagecreate(100,100);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$red = imagecolorallocate($im, 255, 0, 0);
$orange = imagecolorallocate($im, 255, 128, 0);
$yellow = imagecolorallocate($im, 255, 255, 0);
$greenish = imagecolorallocate($im, 128, 255, 0);
$green = imagecolorallocate($im, 0, 255, 0);
$greenblue = imagecolorallocate($im, 0, 255, 128);
$lightblue = imagecolorallocate($im, 0, 255, 255);
$blueish = imagecolorallocate($im, 0, 128, 255);
$blue = imagecolorallocate($im, 0, 0, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$bg = imagecreatefromgif("bitbucket/MostBoredAward.gif");
imagecopy ( $im, $bg, 0, 0, 0, 0, imagesx($bg), imagesy($bg));
imagestring($im, 3, 10, 80, $username, $black);
imagecolortransparent ( $im , $white);
imagepng($im);
imagedestroy($im);

}
?>