All pastes #515134 Raw Edit

Miscellany

public text v1 · immutable
#515134 ·published 2007-05-28 02:05 UTC
rendered paste body
<?PHP
$nav = $_SERVER["REQUEST_URI"];
$script = $_SERVER["SCRIPT_NAME"];
$nav = ereg_replace("^$script", "", $nav);
$nav = str_replace("%20"," ",$nav);
$vars = explode("/", $nav);
$per = substr($vars[2],0,strpos($vars[2],"."));
$backg = strtolower($vars[1]);
$per = ucfirst(strtolower($per));
$handle = fopen("http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=".$per,"r"); 
if($handle){ 
   while (!feof($handle)) { 
   $contents .= fread($handle, 8192);} 
fclose($handle);}
function GetLvl($skill)
{	$str1 = strstr($GLOBALS['contents'], '>'.chr(10).$skill.chr(10).'<');
	if(strpos($str1, 'd co')<30) return '--';
	$pos1 = strpos($str1, 't"',strpos($str1, 't"')+1)+3;
	return substr($str1, $pos1, strpos($str1,'<',$pos1)-$pos1);}		
function GetXP($skill)
{	$str1 = strstr($GLOBALS['contents'], '>'.chr(10).$skill.chr(10).'<');
	if(strpos($str1, 'd co')<30) return '--';
	$pos1 = strpos($str1, 't"',strpos($str1, 't"',strpos($str1, 't"')+1)+1)+3; 
	return substr($str1, $pos1, strpos($str1,'<',$pos1)-$pos1);}
function GetRank($skill)	
{	$str1 = strstr($GLOBALS['contents'], '>'.chr(10).$skill.chr(10).'<');
	if(strpos($str1, 'd co')<30) return '--';
	$pos1 = strpos($str1, 't"')+3; 
	return substr($str1, $pos1, strpos($str1,'<',$pos1)-$pos1);} 
function parse($skill){return GetLvl($skill);}

$font="./images/font1.ttf";
$font2="./images/font2.ttf";
$font3="./images/font3.ttf";
$imgfile = "./images/".$backg.".png";
$im_size = getimagesize($imgfile);
$image_width = $im_size[0];
$image_height = $im_size[1];
$im = imagecreatetruecolor($image_width, $image_height);
$color = imagecolorallocate($im, 255, 255, 255);
$color2 = imagecolorallocate($im, 0, 0, 0);
$im2 = imagecreatefrompng($imgfile);
imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);
imagedestroy($im2);
imagettftext($im, 10, 0, 199, 21, $color2, $font3, $per);
imagettftext($im, 10, 0, 198, 20, $color, $font3, $per);
imagettftext($im, 12, 0, 221, 93, $color2, $font2, "Jazz.CNET");
imagettftext($im, 12, 0, 220, 92, $color, $font2, "Jazz.CNET");

//Black First
imagettftext($im, 8, 0, 201, 34, $color2, $font, "Overall: " . parse(Overall));
imagettftext($im, 8, 0, 201, 46, $color2, $font, "Rank: " . GetRank(Overall));
imagettftext($im, 8, 0, 201, 58, $color2, $font, "XP: " . GetXP(Overall));

imagettftext($im, 10, 0, 23, 16, $color2, $font, parse(Attack));
imagettftext($im, 10, 0, 23, 36, $color2, $font, parse(Defence));
imagettftext($im, 10, 0, 23, 54, $color2, $font, parse(Strength));
imagettftext($im, 10, 0, 23, 73, $color2, $font, parse(Hitpoints));
imagettftext($im, 10, 0, 23, 92, $color2, $font, parse(Ranged));
imagettftext($im, 10, 0, 62, 16, $color2, $font, parse(Prayer));
imagettftext($im, 10, 0, 62, 35, $color2, $font, parse(Magic));
imagettftext($im, 10, 0, 62, 54, $color2, $font, parse(Cooking));
imagettftext($im, 10, 0, 62, 73, $color2, $font, parse(Woodcutting));
imagettftext($im, 10, 0, 62, 92, $color2, $font, parse(Fletching));
imagettftext($im, 10, 0, 101, 16, $color2, $font, parse(Fishing));
imagettftext($im, 10, 0, 101, 35, $color2, $font, parse(Firemaking));
imagettftext($im, 10, 0, 101, 54, $color2, $font, parse(Crafting));
imagettftext($im, 10, 0, 101, 73, $color2, $font, parse(Smithing));
imagettftext($im, 10, 0, 101, 92, $color2, $font, parse(Mining));
imagettftext($im, 10, 0, 141, 16, $color2, $font, parse(Herblore));
imagettftext($im, 10, 0, 141, 35, $color2, $font, parse(Agility));
imagettftext($im, 10, 0, 141, 54, $color2, $font, parse(Thieving));
imagettftext($im, 10, 0, 141, 73, $color2, $font, parse(Runecraft));
imagettftext($im, 10, 0, 141, 92, $color2, $font, parse(Slayer));
imagettftext($im, 10, 0, 181, 16, $color2, $font, parse(Farming));
imagettftext($im, 10, 0, 181, 54, $color2, $font, parse(Hunter));

//Now white overlay
imagettftext($im, 8, 0, 200, 33, $color, $font, "Overall: " . parse(Overall));
imagettftext($im, 8, 0, 200, 45, $color, $font, "Rank: " . GetRank(Overall));
imagettftext($im, 8, 0, 200, 57, $color, $font, "XP: " . GetXP(Overall));

imagettftext($im, 10, 0, 22, 15, $color, $font, parse(Attack));
imagettftext($im, 10, 0, 22, 34, $color, $font, parse(Defence));
imagettftext($im, 10, 0, 22, 53, $color, $font, parse(Strength));
imagettftext($im, 10, 0, 22, 72, $color, $font, parse(Hitpoints));
imagettftext($im, 10, 0, 22, 91, $color, $font, parse(Ranged));
imagettftext($im, 10, 0, 61, 15, $color, $font, parse(Prayer));
imagettftext($im, 10, 0, 61, 34, $color, $font, parse(Magic));
imagettftext($im, 10, 0, 61, 53, $color, $font, parse(Cooking));
imagettftext($im, 10, 0, 61, 72, $color, $font, parse(Woodcutting));
imagettftext($im, 10, 0, 61, 91, $color, $font, parse(Fletching));
imagettftext($im, 10, 0, 100, 15, $color, $font, parse(Fishing));
imagettftext($im, 10, 0, 100, 34, $color, $font, parse(Firemaking));
imagettftext($im, 10, 0, 100, 53, $color, $font, parse(Crafting));
imagettftext($im, 10, 0, 100, 72, $color, $font, parse(Smithing));
imagettftext($im, 10, 0, 100, 91, $color, $font, parse(Mining));
imagettftext($im, 10, 0, 140, 15, $color, $font, parse(Herblore));
imagettftext($im, 10, 0, 140, 34, $color, $font, parse(Agility));
imagettftext($im, 10, 0, 140, 53, $color, $font, parse(Thieving));
imagettftext($im, 10, 0, 140, 72, $color, $font, parse(Runecraft));
imagettftext($im, 10, 0, 140, 91, $color, $font, parse(Slayer));
imagettftext($im, 10, 0, 180, 15, $color, $font, parse(Farming));
imagettftext($im, 10, 0, 180, 53, $color, $font, parse(Hunter));

//Combat area
//imgttftext format ($im, font size, angle keep at 0, X, Y, $color, $font, text string 

//Combat Formula begins below
$cbraw = ("0.32707" * parse(Attack)) + ("0.249" * parse(Defence)) + ("0.324" * parse(Strength)) + ("0.25" * parse(Hitpoints)) + ("0.124" * parse(Prayer)); //Colculates the combat level
$cbfull = explode(".",$cbraw); //takes the combt level for example 95.234234 into 95 ( ROUNDED )

//Now for displaying on the picture
imagettftext($im, 10, 0, 180, 34, $color, $font, $cbfull);
//Edit the X and Y ( 180 and 34 ) until u figure out where you want em on the picture


$pos = strrpos(parse(Construction), "n");
if ($pos === false) { 
imagettftext($im, 10, 0, 181, 35, $color2, $font, parse(Construction));
imagettftext($im, 10, 0, 180, 34, $color, $font, parse(Construction));
}
header("Content-type: image/gif");
imagepng($im);
imagedestroy($im);
?>