[php]
<?php
header("Content-type: image/jpeg");
$width = 60;
$height = 60;
$font="/home/lid/erikje/public_html/verdana.ttf";
//create new image
$image = imagecreate($width, $height);
//Allocate colors
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$yellow = ImageColorAllocate($image, 0, 255, 0);
$green = ImageColorAllocate($image, 0, 255, 255);
$red = ImageColorAllocate($image, 255, 100, 100);
$blue = ImageColorAllocate($image, 0, 0, 255);
$icon=rand(1,2);
/*
if(!isset($icon))
{
$icon=rand(1,4);
}
*/
if ($icon==1) //Let's do the Load Icon

{
imagefilledrectangle($image, 0, 0, 60, 60, $black);
ImageString($image, 1, 5, 15, "Load:", $white);
$load=exec("cat /proc/loadavg|cut -f 1 -d ' '");
ImageString($image, 5, 5, 40, $load, $yellow);
}
if ($icon==2) //Let's do the time Icon

{
imagefilledrectangle($image, 0, 0, 60, 60, $black);
imagestring($image, 0, 5, 15, "Time:", $yellow);
$time = exec("date +%H:%M.%S");
imagestring($image, 0, 3, 40, $time, $red);
}
if ($icon==3) //Let's do the no of users icon

{
imagefilledrectangle($image, 0, 0, 60, 60, $black);
imagettftext($image, 12, 0, 5, 15, $yellow, $font, "Users");
imagettftext($image, 9, 0, 5, 30, $green, $font, "logged");
imagettftext($image, 9, 0, 5, 45, $yellow, $font, "in:");
$users = exec("who -q|grep '#'|cut -f 2 -d '='");
imagettftext($image, 12, 0, 35, 49, $white, $font, $users);
}
if ($icon==4) //Let's do the users icon

{
imagefilledrectangle($image, 0, 0, 60, 60, $black);
imagettftext($image, 8, 0, 3, 15, $white, $font, "Users online");
$users = exec("who -q|grep '#'|cut -f 2 -d '='");
$base_x=3;
$base_y=25;
for($x = 1; $x < $users+1; $x++)
{
$user=exec("who|cut -f 1 -d' '|head -n $x|tail -n $no_of_users-$x");
imagettftext($image, 9, 0, $base_x, $base_y, $yellow, $font, $user);
$base_y=$base_y+10;
}
}
imagejpeg($image);
imagedestroy($image);
?>
Als ImageString niet bestaat is lib_gd niet geladen...