Image saying how long I've been browsing this week
Moderator: General Moderators
Image saying how long I've been browsing this week
I've seen these kind of things generated by XFIRE but I want a image that updates itself that can say how many hours I've been on the browsing this week. I've decided to write a vb program to tell how long I've been on, but need to know how to make php read a file (named time.php) that contains this: "2:12" and say "I've been online 2 days and 12 hours this week!"
- tecktalkcm0391
- DevNet Resident
- Posts: 1030
- Joined: Fri May 26, 2006 9:25 am
- Location: Florida
Just do:
Code: Select all
<?php
include("time.php");
/*
// Make sure in your php page time.php that it contains something like
$time = 2:12;
// or have it be like
$days = 2 ;
$hours = 12;
*/
// This is only needed if you don't have them seperated into two variables
$splitdata = explode(':', $time);
$days = $splitdata[0];
$hours = $splitdata[1];
// Make sure that there is at least 1 hours
if($hours>=1){
// If yes print:
$message = 'I\'ve been online '. $days . 'days and '. $hours . 'hours this week!';
print("$message");
} else {
print("I've not been online over an hour this week.");
}- aerodromoi
- Forum Contributor
- Posts: 230
- Joined: Sun May 07, 2006 5:21 am
By using the GD library and imagestring.m0u53m4t wrote:Thats good, but I need it to put that as text over an image for a sig image. How could I do that?
Greetings,
Marc
Ok. So this is my code now:
How can I make the background transparent? Or put an image in the background?
Code: Select all
<?php
$nums = file_get_contents("time.php");
$time = explode(':', $nums);
$text = "I've been online for $time[0] days and $time[1] hours this week!";
$extralength = 3;
$length = (strlen($text)) * 9 + $extralength;
$im = imagecreate($length, 19);
// white background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 000, 000, 000);
// write the string at the top left
imagestring($im, 7, $extralength, 0, $text, $textcolor);
// output the image
header("Content-type: image/png");
imagepng($im);
?>Right above....
Put...
pif
Code: Select all
imagestring($im, 7, $extralength, 0, $text, $textcolor);Put...
Code: Select all
imagecolortransparent ( $im, $bg );