All pastes #543280 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-06 01:30 UTC
rendered paste body
<?php 
header("Content-type: image/png");

$stat = $_GET['skill'];
$pgoal = $_GET['target'];

$per = $_GET['user'];
$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 getExperience($exp, $goal){
    $goal--;
    for($i = 1; $i <= $goal; $i++){
      $e += intval($i + 300 * pow(2, $i / 7));
    }
    return intval($e / 4) - $exp;
}
function getPercent($exp, $goal){
    $goal--;
    for($i = 1; $i <= $goal; $i++){
      $e += intval($i + 300 * pow(2, $i / 7));
    }   
    return round(($exp / intval($e / 4)) * 100 ,0);
}

$font=""; //Font file string

if ($stat == 'runecrafting' ) {
$lvl =  GetLvl(Runecraft);
$xp  =  GetXP(Runecraft);
} else {
$lvl =  GetLvl(ucfirst(strtolower($stat)));
$xp  =  GetXP(ucfirst(strtolower($stat)));
}

$xp =   str_replace(",","",$xp);  

$temp = getExperience($xp, $pgoal); 
if ($temp < 0 ) { 
$imgfile = './images/100.png';
$imgfile2 = './images/'.$stat.'.png';
$im_size = getimagesize($imgfile);
$image_width = $im_size[0];
$image_height = $im_size[1];
$im = imagecreatetruecolor($image_width, $image_height);
$im2 = imagecreatefrompng($imgfile);
$im3 = imagecreatefrompng($imgfile2);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);
imagedestroy($im2); 
imagettftext($im, 8, 0, 180, 20, $black, $font, ucfirst(strtolower($stat)).' lvl: '.$lvl.' / '.$pgoal);
imagettftext($im, 8, 0, 179, 19, $white, $font, ucfirst(strtolower($stat)).' lvl: '.$lvl.' / '.$pgoal);
imagettftext($im, 8, 0, 60, 20, $black, $font, 'Goal Achieved!');
imagettftext($im, 8, 0, 60, 19, $white, $font, 'Goal Achieved!');

} else { 

$imgfile = './images/main.png';
$imgfile2 = './images/'.$stat.'.png';
$bar = './images/bar.png';
$im_size = getimagesize($imgfile);
$image_width = $im_size[0];
$image_height = $im_size[1];
$im = imagecreatetruecolor($image_width, $image_height);
$im2 = imagecreatefrompng($imgfile);
$im3 = imagecreatefrompng($imgfile2);
$im4 = imagecreatefrompng($bar);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagecopy($im, $im2, 0, 0, 0, 0, $image_width, $image_height);
imagedestroy($im2);

$percent = getPercent($xp, $pgoal);

if ( $percent > 99) { $percent = 99; }
if ( $percent < 0)  { $percent = 0; }

imagecopy($im, $im4, 31, 8, 0, 0, (0.444444*$percent)+$percent, 14);
imagedestroy($im4);

imagettftext($im, 7, 0, 180, 13, $black, $font, ucfirst(strtolower($stat)).' Level: '.$lvl.' / '.$pgoal);
imagettftext($im, 7, 0, 179, 12, $white, $font, ucfirst(strtolower($stat)).' Level: '.$lvl.' / '.$pgoal);
imagettftext($im, 7, 0, 180, 25, $black, $font, 'XP Remaining: '.number_format($temp));
imagettftext($im, 7, 0, 179, 24, $white, $font, 'XP Remaining: '.number_format($temp));
imagettftext($im, 8, 0, 63, 20, $black, $font, $percent.'% Complete');
imagettftext($im, 8, 0, 63, 19, $white, $font, $percent.'% Complete');

}

//Display the Image..
imagecopy($im, $im3, 0,0, 0, 0, 31, 29);
imagedestroy($im3);

imagepng($im);
imagedestroy($im);

?>