<?php


/* -------------------------------------------------------------------------------------- */
if ($mode=="error") {/* ERROR MODE ------------------------------------------ */
/* -------------------------------------------------------------------------------------- */
	$image_get = "themes/".$theme."/simple.png";
	$image_src = imagecreatefrompng($image_get);
	$image_out = imagecreatetruecolor(325, 21);
	imagecopyresampled($image_out, $image_src, 0, 0, 0, 0, 325, 21, 325, 21);
	imagedestroy($image_src);
	$color = imagecolorallocate($image_out,255,255,255);
	$font = 'arial.ttf';
	$text='Тест';
	imagestring($image_out, 5, 10, 4, "Error: ".$error, $color);
/* -------------------------------------------------------------------------------------- */
} else if ($mode=="normal") {/* NORMAL SIGNATURE MODE ----------------------------------- */
/* -------------------------------------------------------------------------------------- */

	$image_get = "themes/".$theme."/normal.png";//this is the path to the png image it uses for the background
	$image_out = imagecreatefrompng($image_get);
require('param.php');
// $scores='Очки:';


	
	/*****************
	  COLOR SETTINGS
	*****************/
	$black = imagecolorallocate($image_out,0,0,0);
	$white = imagecolorallocate($image_out,255,255,255);
	$red = imagecolorallocate($image_out,255,0,0);
	$orange = imagecolorallocate($image_out,255,153,0);
	$yellow = imagecolorallocate($image_out,255,255,0);
	$green = imagecolorallocate($image_out,0,255,0);
	$blue  = imagecolorallocate($image_out,0,0,255);
	$purple = imagecolorallocate($image_out,153,51,255);
	/*****************
	END COLOR SETTINGS
	*****************/
	
	/***************
	DISPLAY SETTINGS
	***************/
	//show the image for the rank; set to false to hide or true to show
	$show_rank_image = true;
	//the X coordinate on the image for where to put the rank image
	$rank_x = 8;
	//the Y coordiante on the image for where to put the rank image
	$rank_y = 3;
	//The width you want the rank image to be
	$rank_width = 35;
	//The height you want the rank image to be
	$rank_height = 35;
	
	//show the gold silver and bronze medals and how many there are; set to false to hide or true to show
	$show_gld_slvr_brnze = true;
	//The width you want the gold silver and bronze medals images to be
	$gsb_width = 20;
	//The height you want the gold silver and bronze medal images to be
	$gsb_height = 20;
	//the X coordinate on the image for where to start the display of gold silver bronze medals
	$gsb_x = 250;
	//the Y coordinate on the image for where to start the display of gold silver bronze medals
	$gsb_y = 20;
	//Color you want the text for the award numbers to be (use a color that is in the colors settings section)
	$gsb_text_color = $white;
	
	//show the country flag; set to false to hide or true to show
	$show_flag = false;
	//the X coordinate on the image for where to put the flag
	$flag_x = 348;
	//the Y coordiante on the image for where to put the flag
	$flag_y = 3;
	
	//progress bar settings
	//Wether to show the progress bar or not; set to false to hide or true to show
	$show_progress_bar = true;
	//set the width you want for the progress bar here
	$prgwidth = 200;
	//the X coordinate on the image for where to start the progress bar
	$prg_x = 45;
	//the Y coordiante on the image for where to start the progress bar
	$prg_y = 23;
	//Test size for the Progress Bar
	$prg_text_size = 2;
	//Center the Text Onto the Progress Bar (both vertically and horizontally)
	$prg_text_center = true;
	//Color you want the text for the progress bar to be (use a color that is in the colors settings section)
	$prg_text_color = $white;
	//This only works if $prg_text_center = false. the X coordinate on the image for where to start the Percent Text.
	$prg_text_x = 130;
	//This only works if $prg_text_center = false. the Y coordinate on the image for where to start the Percent Text
	$prg_text_y = 24;
	//Number of decimal places to show in the percentage
	$prg_decimal = 1;
		
	//below is settings for the awards display
	//Wether to show the awards box or not; set to false to hide or true to show
	$show_awards_box = true;
	//The width you want each award to be
	$award_width = 20;
	//The height you want each award to be
	$award_height = 20;
	//the X coordinate on the image for where to start the awards display
	$award_x = 10;
	//the Y coordiante on the image for where to start the awards display
	//TIP: the box will make new lines when it runs out of space horizontally, so remember to leave enough space below for the extra lines.
	$award_y = 112;
	//The width of the "box" the awards show in. 
	//NOTE: Default "imagesx($image_out) - 20" is the width of the image minus 20 (for a border on the edge), if you want to change it to just a # change "imagesx($image_out) - 20" to whatever # you want
	$award_box = imagesx($image_out) - 20;
	
	//Set to true to split ribbons and awards into seperate boxes or false to have them all in the awards box
	$split_ribbons_box = false;
	
	//below is settings for the ribbons display
	//IMPOTANT YOU ONLY NEED TO SET THIS IF you are splitting the ribbons and awards into the 2 seperate boxes
	//The width you want each ribbon to be
	$ribbons_width = 20;
	//The height you want each ribbon to be
	$ribbons_height = 20;
	//the X coordinate on the image for where to start the ribbons display
	$ribbons_x = 10;
	//the Y coordiante on the image for where to start the ribbons display
	//TIP: the box will make new lines when it runs out of space horizontally, so remember to leave enough space below for the extra lines.
	$ribbons_y = 132;
	//The width of the "box" the ribbon show in. 
	//NOTE: Default "imagesx($image_out) - 20" is the width of the image minus 20 (for a border on the edge), if you want to change it to just a # change "imagesx($image_out) - 20" to whatever # you want
	$ribbons_box = imagesx($image_out) - 20;
	
	//below is settings for the awards display
	//Wether to show the awards box or not; set to false to hide or true to show
	$show_unlocks_box = false;
	//The width you want each award to be
	$unlock_width = 45;
	//The height you want each award to be
	$unlock_height = 15;
	//the X coordinate on the image for where to start the awards display
	$unlock_x = 10;
	//the Y coordiante on the image for where to start the awards display
	//TIP: the box will make new lines when it runs out of space horizontally, so remember to leave enough space below for the extra lines.
	$unlock_y = 152;
	//The width of the "box" the awards show in. 
	//NOTE: Default "imagesx($image_out) - 20" is the width of the image minus 20 (for a border on the edge), if you want to change it to just a # change "imagesx($image_out) - 20" to whatever # you want
	$unlock_box = imagesx($image_out) - 20;
	
	
	/**********************
	END OF DISPLAY SETTINGS
	**********************/
	
	/****************************************
	THIS PART BELOW IS WHERE TO CHANGE/CONTROL WHAT STATS AND THE LAYOUT/COLOR OF THE STATS!!!
	****************************************/
	
	//heres how to use it: imagestringcentered($image_out,font size, x offset (use 0 for no offest),y coordinate for text,text you want it to say,$white)	
	//explanation for x offset: i used 40 for offset since there is the badge before the name and i dont want it centered to the whole image, just centered
	//from where the badge ends to where the right edge. using 0 would make it centered from the left edge to the right edge.
//	imagestringcentered($image_out, 4, 40, 4, $rank." ".$namedstats['nick'], $white);//see three lines above for how to use this function
	imagettftext($image_out, 12, 0, 47, 17, $white, 'arial', $rank .$namedstats['nick']);
	imagettftext($image_out, 6, 0, 10, 52, $white, 'KLMNFP2005', $scores .$namedstats['scor']);
//	imagestring($image_out, 2, 10, 40, "Scores: ".$namedstats['scor'], $white);//score
	imagettftext($image_out, 6, 0, 10, 64, $white, 'KLMNFP2005', $death .$namedstats['deth']);
//	imagestring($image_out, 2, 10, 52, "Kills (Streak): ".$namedstats['kill']."(".$namedstats['bksk'].")", $white);
	imagettftext($image_out, 6, 0, 10, 76, $white, 'KLMNFP2005', $kills .$namedstats['kill']);
	
//	imagestring($image_out, 2, 10, 64, "Deaths(Streak): ".$namedstats['deth']."(".$namedstats['wdsk'].")", $white);
	imagettftext($image_out, 6, 0, 10, 88, $white, 'KLMNFP2005', $captures .$namedstats['cpcp']);

//	imagestring($image_out, 2, 10, 76, "Captures(Assists): ".$namedstats['cpcp']."(".$namedstats['cacp'].")", $white);
	imagettftext($image_out, 6, 0, 10, 100, $white, 'KLMNFP2005', $revivess .$namedstats['rviv']);

//	imagestring($image_out, 2, 10, 88, "Revives(Heals): ".$namedstats['rviv']."(".$namedstats['heal'].")", $white);
	imagettftext($image_out, 6, 0, 10, 112, $white, 'KLMNFP2005', $tiplay .$playtime);
//	imagestring($image_out, 2, 10, 100, "Time Played: ".$playtime, $white);

	imagettftext($image_out, 6, 0, 180, 52, $white, 'KLMNFP2005', $bestrnd .$namedstats['bbrs']);
//	imagestring($image_out, 2, 200, 40, "Knife Kills: ".$namedstats['wkl-9'], $white);
	imagettftext($image_out, 6, 0, 180, 64, $white, 'KLMNFP2005', $tvictim .$namedstats['mvns']);
//	imagestring($image_out, 2, 200, 52, "Defibrillator Kills: ".$namedstats['wkl-10'], $white);
	imagettftext($image_out, 6, 0, 180, 76, $white, 'KLMNFP2005', $topp .$namedstats['vmns']);
//	imagestring($image_out, 2, 200, 76, "Best Round: ".$namedstats['bbrs'], $white);
	imagettftext($image_out, 6, 0, 180, 88, $white, 'KLMNFP2005', $favmap .mapconverter($namedstats['fmap']));
//	imagestring($image_out, 2, 180, 76, "Fav. Map: ".mapconverter($namedstats['fmap']), $white);

	imagettftext($image_out, 6, 0, 180, 100, $white, 'KLMNFP2005', $favweap .weaponconverter($namedstats['fwea']));
//	imagestring($image_out, 2, 180, 88, "Fav. Weapon: ".weaponconverter($namedstats['fwea']), $white);
	imagettftext($image_out, 6, 0, 180, 112, $white, 'KLMNFP2005', $favveh .vehicleconverter($namedstats['fveh']));
//	imagestring($image_out, 2, 180, 100, "Fav. Vehicle: ".vehicleconverter($namedstats['fveh']), $white);
	
	//Here are some example lines for other stats that will work when you uncomment them and change the infotoget variable in config.php to make it get 
	//the info (the letters inside the [''] ) first though. and also delete the files in the statsxml folder on your server.
	//you will probably also want to move thier location (x,y) in this they are all at an x location of 10 and a y location of 64
	//imagestring($image_out, 2, 10, 64, "Team Score: ".$namedstats['twsc'], $white);
	//imagestring($image_out, 2, 10, 64, "Combat Score: ".$namedstats['cmsc'], $white);
	//imagestring($image_out, 2, 10, 64, "Commander Score: ".$namedstats['cdsc'], $white);
		
	//the line below is how to show your kill to death ratio just uncomment it and it will work, you will probably want to move it. Change the 1 to however many decimal points you want.
	//imagestring($image_out, 2, 10, 64, "KDR: ".round($namedstats['kill']/$namedstats['deth'], 1), $white);
	
	//this line shows the last time you were on a ranked server	
	//imagestring($image_out, 2, 10, 64, "Last Seen: ".$LastBattle, $white);
	
	/****************************************
	END OF WHERE TO CONTROL LAYOUT/COLOR ECT.
	****************************************/

	
	
	If ($show_progress_bar == true) {
		//create progress bar images
		$bg       = @imagecreatefrompng("themes/".$theme."/progress/bg.png");
		$fill     = @imagecreatefrompng("themes/".$theme."/progress/fill.png");
		$bg_cap   = @imagecreatefrompng("themes/".$theme."/progress/cap.png");
		$fill_cap = @imagecreatefrompng("themes/".$theme."/progress/fill_cap.png");
        //do calculations for the bar
		include("progress.php");
		//place the progressbar on the image
		imagecopy($image_out, $progressbar, $prg_x, $prg_y, 0, 0, imagesx($progressbar), imagesy($progressbar));
		imagedestroy($bg);
		imagedestroy($fill);
		imagedestroy($bg_cap);
		imagedestroy($fill_cap);
		//show percent ontop of the progress bar
		If ($prg_text_center == true) {
		imagestring($image_out, $prg_text_size, $prgwidth / 2 - strlen($rankpercent) * imagefontwidth($prg_text_size) / 2 + $prg_x, imagesy($progressbar) / 2 - imagefontheight($prg_text_size) / 2 + $prg_y, $rankpercent, $prg_text_color);
		} else {
		imagestring($image_out, $prg_text_size, $prg_text_x, $prg_text_y, $rankpercent, $prg_text_color);
		}
		imagedestroy($progressbar);
	}
	
	If ($show_rank_image == true) {
		//create the rank image
		$image_rank = @imagecreatefrompng("themes/".$theme."/rank/".$namedstats['rank'].".png");
		//This part does the rank image
		imagecopyresampled($image_out, $image_rank, $rank_x, $rank_y, 0, 0, $rank_width, $rank_height, imagesx($image_rank), imagesy($image_rank));
		imagedestroy($image_rank);
	}
	
	If ($show_gld_slvr_brnze == true) {
		//create the gold/silver/bronze medals images
		$image_gold = @imagecreatefrompng("themes/".$theme."/awards/2051907.png");
		$image_silver = @imagecreatefrompng("themes/".$theme."/awards/2051919.png");
		$image_bronze = @imagecreatefrompng("themes/".$theme."/awards/2051902.png");
		//placement of gold/silver/bronze medals
		imagecopyresampled($image_out, $image_gold, $gsb_x, $gsb_y, 0, 0, $gsb_width, $gsb_height, imagesx($image_gold), imagesy($image_gold));
		imagecopyresampled($image_out, $image_silver, $gsb_x + 40, $gsb_y, 0, 0, $gsb_width, $gsb_height, imagesx($image_silver), imagesy($image_silver));
		imagecopyresampled($image_out, $image_bronze, $gsb_x + 80, $gsb_y, 0, 0, $gsb_width, $gsb_height, imagesx($image_bronze), imagesy($image_bronze));
		imagedestroy($image_gold);
		imagedestroy($image_silver);
		imagedestroy($image_bronze);
		//medals numbers part
		//gold
		imagestring($image_out, 2,  $gsb_x + 18, $gsb_y + 4, "x".$namedawards[2051907], $gsb_text_color);
		//silver
		imagestring($image_out, 2,  $gsb_x + 58, $gsb_y + 4, "x".$namedawards[2051919], $gsb_text_color);
		//bronze
		imagestring($image_out, 2, $gsb_x + 98, $gsb_y + 4, "x".$namedawards[2051902], $gsb_text_color);
	}
	
	//heres for the country flag
	If ($show_flag == true) {
		$image_flag = @imagecreatefrompng("themes/".$theme."/flags/".strtolower($namedleader['countrycode']).".png");
		imagecopy($image_out, $image_flag, $flag_x, $flag_y, 0, 0, imagesx($image_flag), imagesy($image_flag));
		imagedestroy($image_flag);
	}
	
	//include code for the award/ribbon boxes
	include("awardbox.php");
		
	/* -------------------------------------------------------------------------------------- */
} else {
	$image_get = "themes/".$theme."/simple.png";
	$image_src = imagecreatefrompng($image_get);
	$image_out = imagecreatetruecolor(325, 21);
	imagecopyresampled($image_out, $image_src, 0, 0, 0, 0, 325, 21, 325, 21);
	imagedestroy($image_src);
	$color = imagecolorallocate($image_out,255,255,255);
	imagestring($image_out, 3, 10, 4, "Error: Mode Specified Doesn't Exist", $color);
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-type: image/png");
imagepng($image_out);
imagedestroy($image_out);
?>
