Just though i'd post this script up, it's one of my first scripts that uses gd so it isn't exactly 'pretty' at the minute
Example image

Last edited by Jamatu on Tue May 02, 2006 10:49 am; edited 1 time in total
| Code: |
| <?php
//Jamatu's Dynamic Server status signature script v0.1b header("Content-type: image/png"); //load the page as an image header("Expires: " . gmdate("D, d M Y H:i:s") . " GMT"); //expires when created header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //modified every script execution header("Cache-Control: no-store, no-cache, must-revalidate"); //HTTP/1.1 no-cache header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); //HTTP/1.0 no-cache $uptime = shell_exec("cut -d. -f1 /proc/uptime"); //Get the current uptime from the virtual file $udays = floor($uptime/60/60/24); $uhours = $uptime/60/60%24; $umins = $uptime/60%60; $usecs = $uptime%60; $sqlinf = mysql_stat(); //get mysql runtime information $output = explode(' ',$sqlinf); $mdays = floor($output[1]/60/60/24); $mhours = $output[1]/60/60%24; $mmins = $output[1]/60%60; $msecs = $output[1]%60; //set some variables to be drawn $title = 'Website name'; $uptime = "Server uptime: $udays days, $uhours hours, $umins minutes and $usecs seconds"; $sqluptime = "mySQL uptime: $mdays days, $mhours hours, $mmins minutes and $msecs seconds"; $queries = 'Queries: '.$output[7]; $qps = 'Queries per second: '.$output[28]; $image = imagecreate(400, 80); //create a blank image $bgColor = imagecolorallocate($image, 255, 255, 255); //set the background color as white $textColor = imagecolorallocate($image, 0, 0, 0); //set the text color as black imagestring($image, 5, 150, 5, $title, $textColor); //draw the text imagestring($image, 2, 5, 22, $uptime, $textColor); imagestring($image, 2, 5, 36, $sqluptime, $textColor); imagestring($image, 2, 5, 50, $queries, $textColor); imagestring($image, 2, 5, 64, $qps, $textColor); imagepng($image); //create the image imagedestroy($image); //destroy the image ?> |
Example image

Last edited by Jamatu on Tue May 02, 2006 10:49 am; edited 1 time in total
