Quote (pu3ska @ Wed, Aug 12 2009, 12:25am)
can any1 tell me why the "Second(s) is not showing?"
I found the code on some random site.. seemed to work out
Here is the code i used
Code
<?php
Header ('Content-type: image/png');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');
/******************************************************
* BASICS *
******************************************************/
// create the image from a background jpg
$image = imagecreatefrompng('bg.png');
// set some colours for future use
$cool = imagecolorallocate($image, 81, 86, 96);
$red = imagecolorallocate($image, 255, 0, 0);
$yellow = imagecolorallocate($image, 255, 181, 53);
// set the font and print text
$font = '/avqest.ttf';
/******************************************************
* LOAD DATA *
******************************************************/
$class_name = array( -1 => 'None',
0 => 'Fighter',
1 => 'Barbarian',
2 => 'Rogue',
3 => 'Magician',
4 => 'Guardian',
5 => 'Samurai',
6 => 'Paladin',
7 => 'Monk',
8 => 'Ninja',
9 => 'Warlock',
10 => 'Headhunter',
11=> 'Alchemist');
// load xml data in vars
// This is where you load your own info from the xml d2jsp gives. This is a PHP5 only
command!
$data = simplexml_load_file('http://ladderslasher.d2jsp.org/xmlChar.php?i=155121');
$name = $data->name;
$class = $class_name[(int)$data->classid];
$lastaction = (int)$data->lastaction;
$time1 = time() - $lastaction;
$lastplayed = duration($time1);
/******************************************************
* TEXT PART *
******************************************************/
//Example; ImageTTFText ($image, textsize, angle, right indent, down indent, color,
font, "text");
//show name
ImageTTFText ($image, 9, 0, 122, 33, $yellow, $font, "Name: ");
ImageTTFText ($image, 9, 0, 160, 33, $red, $font, $name);
//show class
ImageTTFText ($image, 9, 0, 280, 33, $yellow, $font, "Class: ");
ImageTTFText ($image, 9, 0, 320, 33, $red, $font, $class);
// Last Played
ImageTTFText ($image, 9, 0, 122, 45, $yellow, $font, "Last Played: ");
ImageTTFText ($image, 9, 0, 190, 45, $red, $font, $lastplayed);
// output and destroy
imagepng($image);
imagedestroy($image);
/******************************************************
* FUNCTIONS *
******************************************************/
/***
* Calculate the last played time.
***/
function duration($secs)
{
$vals = array('w' => (int) ($secs / 86400 / 7),
'd' => $secs / 86400 % 7,
'h' => $secs / 3600 % 24,
'm' => $secs / 60 % 60,
's' => $secs % 60);
$ret = array();
$added = false;
foreach ($vals as $k => $v) {
if ($v > 0 || $added) {
$added = true;
$ret[] = $v . $k;
}
}
return join(' ', $ret);
}
?>
Quote (Konqk @ Wed, Aug 12 2009, 03:23am)
Helping via AIM.
This post was edited by GimmeCoffee on Aug 12 2009 01:46am