<?php
require_once "maincore.php";
$id=$_GET['id'];
$q = dbquery("SELECT * FROM ".DB_SERVERS." WHERE server_id = ".$id."");
$serv=dbarray_fetch($q);
$status="Ofline";
if($serv['server_status']==1)$status="Online";
header ("Content-type: image/png");
$img = imagecreatetruecolor(500, 90);
$server_full=floor(($serv['server_players'] / $serv['server_maxplayers']) * 100);
$data=htmlcolor($img,"CC9900");
$z=htmlcolor($img,"339900");
$ip=htmlcolor($img,"FFCC33");
$text_color=htmlcolor($img,"F68E56");
$green=htmlcolor($img,"00FF00");
imagestring($img, 4, 5, 4,  "Name:", $z);
imagestring($img, 2, 9, 19,  $serv['server_name'], $data);
imagestring($img, 4, 10, 57,  "IP:", $z);
imagestring($img, 20, 420, 10,  $status, $green);
imagestring($img, 2, 40, 60,  $serv['server_ip'], $data);
imagestring($img, 3, 220, 50,  "Map", $z);
imagestring($img, 2, 220, 60,  $serv['server_map'], $data);
imagestring($img, 3, 350, 47,  "Players", $z);
imagestring($img, 2, 360, 60,  $serv['server_players']."/".$serv['server_maxplayers'], $data);
imagestring($img, 2, 400, 70,  "Server Full ".$server_full. "%", $data);
imagepng($img);
imagedestroy($img);

//функция для перевода из HEX кода в RBG
function htmlcolor($img,$color) {
    sscanf($color, "%2x%2x%2x", $red, $green, $blue);
    return ImageColorAllocate($img,$red,$green,$blue);
    return($c);
    }
	
//функция для русского текста
function iso2uni ($isoline)
{
   $isoline = convert_cyr_string($isoline, "w", "k");
   $isoline = convert_cyr_string($isoline, "k", "i");
   for ($i=0; $i < strlen($isoline); $i++)
   {
      $thischar=substr($isoline,$i,1);
      $charcode=ord($thischar);
      $uniline.=($charcode>175) ? "&#".(1040+($charcode-176)). ";" : $thischar;
   }
   return $uniline;
}
?>