<?php
//CA IGN
$caign = "ingamename";
//Base Image for sig
$baseimage = "bgs/bg.png";
//Fonts to display in
$namefont = "fonts/ill.skillz.[fontvir.us].ttf";
$killfont = "fonts/arial.ttf";
$deathfont = "fonts/arial.ttf";
$fragfont = "fonts/arial.ttf";
$headfont = "fonts/arial.ttf";
$winfont = "fonts/arial.ttf";
$lossfont = "fonts/arial.ttf";
$streakfont = "fonts/arial.ttf";
$multifont = "fonts/arial.ttf";
$ultrafont = "fonts/arial.ttf";
//Font sizes
$namefontsize = "15";
//Font angles
$nameangle = "0";
//Font coordinates
$namex = "5";
$namey = "15";
//Font rgb colors
$namer = "255";
$nameg = "0";
$nameb = "0";
//Stat title definitions
$cakillname = "Kills:";
$cadeathname = "Deaths:";
$cafragname = "KDR:";
$caheadname = "HS:";
$cawinname = "Wins:";
$calossname = "Loss:";
$castreakname = "Streak:";
$camultiname = "Multis:";
$caultraname = "Ultras:";
//Pull the stats
$castats = file("http://combatarms.nexon.net/Community/Profile.aspx?user=$caign");
foreach($castats as $linenum => $line){}
//Base Image
$image = imagecreatefrompng("$baseimage");
//Fix to remove code and extra characters
$old_pattern = array("/[^a-zA-Z0-9]/", "/_+/", "/_$/");
$new_pattern = array("", "", "");
//Fix to check if line #s are correct
$canamecheck = strip_tags($castats[116]);
$canamecheck = preg_replace($old_pattern, $new_pattern , $canamecheck);
$nameline = "138";
$killline = "167";
$deathline = "171";
$headline = "175";
$winline = "183";
$lossline = "187";
$streakline = "203";
$multiline = "338";
$ultraline = "342";
/*
if($canamecheck == "$caign"){
//Content Line #s
$nameline = "116";
$killline = "138";
$deathline = "142";
$headline = "146";
$winline = "154";
$lossline = "158";
$streakline = "174";
$multiline = "309";
$ultraline = "313";
}
else{
$nameline = "124";
$killline = "153";
$deathline = "157";
$headline = "161";
$winline = "169";
$lossline = "173";
$streakline = "189";
$multiline = "324";
$ultraline = "328";
}
*/
//CA Name
$caname = strip_tags($castats[$nameline]);
$caname = preg_replace($old_pattern, $new_pattern , $caname);
$canamecolor = ImageColorAllocate ($image, $namer, $nameg, $nameb);
imagettftext($image, $namefontsize, $nameangle, $namex, $namey, $canamecolor, $namefont, $caname);
//CA Kills
$cakills = strip_tags($castats[$killline]);
$cakills = preg_replace($old_pattern, $new_pattern , $cakills);
$cakillscolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 5, 30, $cakillscolor, $killfont, $cakillname);
imagettftext($image, 10, 0, 35, 30, $cakillscolor, $killfont, $cakills);
//CA Deaths
$cadeaths = strip_tags($castats[$deathline]);
$cadeaths = preg_replace($old_pattern, $new_pattern , $cadeaths);
$cadeathscolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 5, 45, $cadeathscolor, $deathfont, $cadeathname);
imagettftext($image, 10, 0, 53, 45, $cadeathscolor, $deathfont, $cadeaths);
//CA Frag
//if(($cakills > "0") AND ($cadeaths > "0")){
$cafrag = $cakills / $cadeaths;
$decimalcheck = substr_count($cafrag, '.');
if($decimalcheck > "0"){
$cafrag = round($cafrag, 2);
}else{$cafrag = $cafrag;}
$cafragcolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 5, 60, $cafragcolor, $fragfont, $cafragname);
imagettftext($image, 10, 0, 37, 60, $cafragcolor, $fragfont, $cafrag);
//}
//CA Head
$cahead = strip_tags($castats[$headline]);
$cahead = preg_replace($old_pattern, $new_pattern , $cahead);
$caheadcolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 5, 75, $caheadcolor, $headfont, $caheadname);
imagettftext($image, 10, 0, 28, 75, $caheadcolor, $headfont, $cahead);
//CA Wins
$cawins = strip_tags($castats[$winline]);
$cawins = preg_replace($old_pattern, $new_pattern , $cawins);
$cawinscolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 5, 90, $cawinscolor, $winfont, $cawinname);
imagettftext($image, 10, 0, 38, 90, $cawinscolor, $winfont, $cawins);
//CA Loss
$caloss = strip_tags($castats[$lossline]);
$caloss = preg_replace($old_pattern, $new_pattern , $caloss);
$calosscolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 5, 105, $calosscolor, $lossfont, $calossname);
imagettftext($image, 10, 0, 38, 105, $calosscolor, $lossfont, $caloss);
//CA Streak
$castreak = strip_tags($castats[$streakline]);
$castreak = preg_replace($old_pattern, $new_pattern , $castreak);
$castreakcolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 5, 120, $castreakcolor, $streakfont, $castreakname);
imagettftext($image, 10, 0, 48, 120, $castreakcolor, $streakfont, $castreak);
//CA Multi Kills
$camulti = strip_tags($castats[$multiline]);
$camulti = preg_replace($old_pattern, $new_pattern , $camulti);
$camulticolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 100, 60, $camulticolor, $multifont, $camultiname);
imagettftext($image, 10, 0, 140, 60, $camulticolor, $multifont, $camulti);
//CA Ultra Kills
$caultra = strip_tags($castats[$ultraline]);
$caultra = preg_replace($old_pattern, $new_pattern , $caultra);
$caultracolor = ImageColorAllocate ($image, 255, 255, 255);
imagettftext($image, 10, 0, 100, 75, $caultracolor, $ultrafont, $caultraname);
imagettftext($image, 10, 0, 140, 75, $caultracolor, $ultrafont, $caultra);
header("Content-type: image/png");
imagepng($image);
imagedestroy($image);
?>