|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<?php $maxwidth = 200; $maxusers = 75; $onlineusers = 70; $percent = 100 / $maxusers * $onlineusers; $loadwidth = $maxwidth - ($percent / 100) * $maxwidth; $buffer = " <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html> <head> <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"> <title>Speicherplatzbelegung</title> <style type=\"text/css\"> .speicher { background-color: green; width: ".$maxwidth."px; height: 15px; overflow: hidden; padding: 0; } .balken { top: 0; width: ".$maxwidth."px; height: 15px; background-color: red; } </style> </head> <body> $onlineusers von $maxusers online! <div class=\"speicher\"> <div class=\"balken\" style=\"position: relative; left: -".$loadwidth."px;\"></div> </div> </body> </html>"; echo $buffer; ?> |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<?php // copied from the PHP manual: // http://us3.php.net/manual/en/function.imagefilledrectangle.php //this needs to reside in its own php page //you can include that php page in your html as you would an image: //<IMG SRC="makebar.php?rating=25.2&width=200&height=20" border="0"> // rating is a percentage from 0 to 100. function drawRating($rating) { $width = $_GET['width']; $height = $_GET['height']; if ($width == 0) { $width = 300; } if ($height == 0) { $height = 15; } $rating = $_GET['rating']; $ratingbar = (($rating/100)*$width)-2; $image = imagecreate($width,$height); //colors $fill = ImageColorAllocate($image,0,255,0); //grün if ($rating > 49) { $fill = ImageColorAllocate($image,255,255,0); } //gelb if ($rating > 74) { $fill = ImageColorAllocate($image,255,128,0); } //orange if ($rating > 89) { $fill = ImageColorAllocate($image,255,0,0); } //rot $back = ImageColorAllocate($image,255,255,255); $border = ImageColorAllocate($image,0,0,0); ImageFilledRectangle($image,0,0,$width-1,$height-1,$back); ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill); ImageRectangle($image,0,0,$width-1,$height-1,$border); imagePNG($image); imagedestroy($image); } Header("Content-type: image/png"); drawRating($rating); ?> |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<? function ZahlenFormatieren($Wert) { if($Wert > 1099511627776) { $Wert = number_format($Wert/1099511627776, 2, ",", ".")." TB"; } elseif($Wert > 1073741824) { $Wert = number_format($Wert/1073741824, 2, ",", ".")." GB"; } elseif($Wert > 1048576) { $Wert = number_format($Wert/1048576, 2, ",", ".")." MB"; } elseif($Wert > 1024) { $Wert = number_format($Wert/1024, 2, ",", ".")." kB"; } else { $Wert = number_format($Wert, 2, ",", ".")." Bytes"; } return $Wert; } $frei = disk_free_space("./"); $insgesamt = disk_total_space("./"); $belegt = $insgesamt-$frei; $prozent_belegt = 100*$belegt/$insgesamt; ?> </td><td> <table width=340 border=0 cellspacing=1 cellpadding=3 bgcolor=#C0C0C0> <tr><td bgcolor=#F4F4F4><? echo $lang[diskspace];?></td><td bgcolor=#F4F4F4><?=ZahlenFormatieren($insgesamt);?></td></tr> <tr><td bgcolor=#F4F4F4><? echo $lang[in_use];?></td><td bgcolor=#F4F4F4><?=ZahlenFormatieren($belegt);?> (<?=round($prozent_belegt,"2");?> %)</td></tr> <tr><td colspan=2 bgcolor=#F4F4F4 align=center><center><img src="ratingbar.php?rating=<?=round($prozent_belegt,"2");?>" border="0"></td></tr> <tr><td bgcolor=#F4F4F4><? echo $lang[free];?></td><td bgcolor=#F4F4F4><?=ZahlenFormatieren($frei);?> </td></tr></table> |