query(" SELECT IF(publicaddress != '', publicaddress, concat(address, ':', port)) AS addr, name, publicaddress, act_map, kills, act_players, max_players, ct_wins, ts_wins, country, game FROM hlstats_Servers WHERE serverId='$server_id'"); $server_data = $db->fetch_array($result); //------------------------------------------------------------------------------------------------------------+ // THE MAGIC STARTS HERE // OUR BASIC BACKGROUND (YUP, WE SUPPORT GAMETYPE BASED IMAGES^^) $bgimg = IMAGE_PATH."/games/{$server_data['game']}/serverimage.png"; if (!file_exists($bgimg)){ $bgimg = IMAGE_PATH."/serverimage.png"; // If we have no gamebased background we use always the default } $im = imagecreatefrompng($bgimg); // MAP $mapimg = getImage("/games/{$server_data['game']}/maps/{$server_data['act_map']}"); if (!file_exists($mapimg['path'])) { $mapimg['path'] = IMAGE_PATH."/unknown.jpg"; } $im_map_info = getimagesize($mapimg['path']); if ($im_map_info[2] == 1) { $im_map = imagecreatefromgif($mapimg['path']); } if ($im_map_info[2] == 2) { $im_map = imagecreatefromjpeg($mapimg['path']); } if ($im_map_info[2] == 3) { $im_map = imagecreatefrompng($mapimg['path']); } // GAMEICON $gico = getImage("/games/{$server_data['game']}/game"); if (!file_exists($gico['path'])) { $gico['path'] = IMAGE_PATH."/server.gif"; } $im_icon_info = getimagesize($gico['path']); if ($im_icon_info[2] == 1) { $im_icon = imagecreatefromgif($gico['path']); } if ($im_icon_info[2] == 2) { $im_icon = imagecreatefromjpeg($gico['path']); } if ($im_icon_info[2] == 3) { $im_icon = imagecreatefrompng($gico['path']); } // COUNTRY FLAG $country = $server_data['country']; // Workarround to get the 2 digit Country code. $result = $db->query(" SELECT name, flag FROM hlstats_Countries WHERE name='$country'"); $country_data = $db->fetch_array($result); // $cimg = getImage("/flags/".strtolower($country_data['flag']).""); $cimage_info = getimagesize($cimg['path']); if ($cimage_info[2] == 1) { $cimage = imagecreatefromgif($cimg['path']); } if ($cimage_info[2] == 2) { $cimage = imagecreatefromjpeg($cimg['path']); } if ($cimage_info[2] == 3) { $cimage = imagecreatefrompng($cimg['path']); } // FONT COLOR $text_color0 = ImageColorAllocate($im,255,255,255); // GET TEXT $string0 = $server_data['name']; $string1 = $server_data['publicaddress']; $string2 = $server_data['act_map']; $string3 = "{$server_data['act_players']}/{$server_data['max_players']}"; $string4 = $server_data['kills']; $string5 = "{$server_data['ct_wins']}/{$server_data['ts_wins']}"; // MAP/GAMEIMAGE LOCATION ON BASE BACKGROUND $im_map_width = 130; $im_map_height = 120; $im_map_posx = 25; $im_map_posy = 112; $im_icon_width = 20; $im_icon_height = 20; $im_icon_posx = 26; $im_icon_posy = 113; // SPRINT TO THE FINISH LINE // Mapimage, Gameicon imagecopyresampled($im, $im_map, $im_map_posx, $im_map_posy, 0, 0, $im_map_width, $im_map_height, $im_map_info[0], $im_map_info[1]); imagecopyresampled($im, $im_icon, $im_icon_posx, $im_icon_posy, 0, 0, $im_icon_width, $im_icon_height, $im_icon_info[0], $im_icon_info[1]); imagecopyresampled($im, $cimage, $im_icon_posx + 111, $im_icon_posy + 3, 0, 0, 16, 11, $cimage_info[0], $cimage_info[1]); // Servername imagestring($im, 1, 6, 11, substr($string0,0,34), $text_color0); // IP:Port imagestring($im, 1, 6, 28, " IP:Port: {$string1}",$text_color0); // Map imagestring($im, 1, 6, 45, " Map: {$string2}",$text_color0); // Players imagestring($im, 1, 6, 60, " Players: {$string3}",$text_color0); // Kills imagestring($im, 1, 6, 76, " Kills: {$string4} (Total)",$text_color0); // CT/T Wins imagestring($im, 1, 6, 92, " CT/T Wins: {$string5} (Total)",$text_color0); // NOW LET THE MAGIC HAPPEN AND PULL ALL THAT SHIT INTO AN IMAGE imagepng($im); imagedestroy($im); //------------------------------------------------------------------------------------------------------------+ ?>