Scaper
2010-05-02 13:50:34
Ok how to i dispaly the user nam,e in my dynamic sig
see under the timerunningbox etc i shows as a 0 im wondering how to do i string in php
[php]
//DECLARE VARIABLES HERE
$timeran = $row['timeran'];
$exp = $row['natsmade'];
$natsmade = $row['experience'];
//CODE
function Sec2Time($time){
if(is_numeric($time)){
#
$value = array(
#
"years" => 0, "days" => 0, "hours" => 0,
#
"minutes" => 0, "seconds" => 0,
#
);
#
if($time >= 31556926){
#
$value["years"] = floor($time/31556926);
#
$time = ($time%31556926);
#
}
#
if($time >= 86400){
#
$value["days"] = leading_zeros(floor($time/86400), 2);
#
$time = ($time%86400);
#
}
#
if($time >= 3600){
#
$value["hours"] = leading_zeros(floor($time/3600), 2);
#
$time = ($time%3600);
#
}
#
if($time >= 60){
#
$value["minutes"] = leading_zeros(floor($time/60), 2);
#
$time = ($time%60);
#
}
#
$value["seconds"] = leading_zeros(floor($time), 2);
#
return (array) $value;
#
}else{
#
return (bool) FALSE;
#
}
#
}
#
#
function leading_zeros($value, $places){
#
// Function written by Marcus L. Griswold (vujsa)
#
// Can be found at http://www.handyphp.com
#
// Do not remove this header!
#
#
if(is_numeric($value)){
#
$leading = "";
#
for($x = 1; $x <= $places; $x++){
#
$ceiling = pow(10, $x);
#
if($value < $ceiling){
#
$zeros = $places - $x;
#
for($y = 1; $y <= $zeros; $y++){
#
$leading .= "0";
#
}
#
$x = $places + 1;
#
}
#
}
#
$output = $leading . $value;
#
}
#
else{
#
$output = $value;
#
}
#
return $output;
#
}
#
#
$timearray = Sec2Time($timeran);
#
$timestring = $timearray["days"] . ":" . $timearray["hours"] . ":" . $timearray["minutes"] . ":" . $timearray["seconds"];
#
#
header("Content-type: image/png");
#
$im = imagecreatefrompng("picture.png");
#
#
$textcolour = imagecolorallocate($im, 255, 255, 255);
#
putenv('GDFONTPATH=' . realpath('.'));
#
$font = 'font.ttf';
#
imagettftext($im, 12, 0, 170, 82, $textcolour, $font, $timestring);
#
imagettftext($im, 12, 0, 170, 110, $textcolour, $font, number_format($exp));
#
imagettftext($im, 12, 0, 170, 136, $textcolour, $font, number_format($natsmade));
#
imagettftext($im, 10, 0, 143, 167, $textcolour, $font, number_format($user));
#
#
imagepng($im);
#
imagedestroy($im);
#
?>[/php]
see under the timerunningbox etc i shows as a 0 im wondering how to do i string in php
[php]
//DECLARE VARIABLES HERE
$timeran = $row['timeran'];
$exp = $row['natsmade'];
$natsmade = $row['experience'];
//CODE
function Sec2Time($time){
if(is_numeric($time)){
#
$value = array(
#
"years" => 0, "days" => 0, "hours" => 0,
#
"minutes" => 0, "seconds" => 0,
#
);
#
if($time >= 31556926){
#
$value["years"] = floor($time/31556926);
#
$time = ($time%31556926);
#
}
#
if($time >= 86400){
#
$value["days"] = leading_zeros(floor($time/86400), 2);
#
$time = ($time%86400);
#
}
#
if($time >= 3600){
#
$value["hours"] = leading_zeros(floor($time/3600), 2);
#
$time = ($time%3600);
#
}
#
if($time >= 60){
#
$value["minutes"] = leading_zeros(floor($time/60), 2);
#
$time = ($time%60);
#
}
#
$value["seconds"] = leading_zeros(floor($time), 2);
#
return (array) $value;
#
}else{
#
return (bool) FALSE;
#
}
#
}
#
#
function leading_zeros($value, $places){
#
// Function written by Marcus L. Griswold (vujsa)
#
// Can be found at http://www.handyphp.com
#
// Do not remove this header!
#
#
if(is_numeric($value)){
#
$leading = "";
#
for($x = 1; $x <= $places; $x++){
#
$ceiling = pow(10, $x);
#
if($value < $ceiling){
#
$zeros = $places - $x;
#
for($y = 1; $y <= $zeros; $y++){
#
$leading .= "0";
#
}
#
$x = $places + 1;
#
}
#
}
#
$output = $leading . $value;
#
}
#
else{
#
$output = $value;
#
}
#
return $output;
#
}
#
#
$timearray = Sec2Time($timeran);
#
$timestring = $timearray["days"] . ":" . $timearray["hours"] . ":" . $timearray["minutes"] . ":" . $timearray["seconds"];
#
#
header("Content-type: image/png");
#
$im = imagecreatefrompng("picture.png");
#
#
$textcolour = imagecolorallocate($im, 255, 255, 255);
#
putenv('GDFONTPATH=' . realpath('.'));
#
$font = 'font.ttf';
#
imagettftext($im, 12, 0, 170, 82, $textcolour, $font, $timestring);
#
imagettftext($im, 12, 0, 170, 110, $textcolour, $font, number_format($exp));
#
imagettftext($im, 12, 0, 170, 136, $textcolour, $font, number_format($natsmade));
#
imagettftext($im, 10, 0, 143, 167, $textcolour, $font, number_format($user));
#
#
imagepng($im);
#
imagedestroy($im);
#
?>[/php]