mattonit

freespace.php

Aug 30th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
  2. <head>
  3.   <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  4.   <title>Wskaźnik wolnej przestrzeni dla serwera <? echo $_SERVER["SERVER_ADDR"];?></title>
  5. </head>
  6. <body>
  7.     <?php
  8.     $df = disk_free_space("/var/www");
  9.     $dt = disk_total_space("/var/www");
  10.     $du = $dt - $df;
  11.     $dp = sprintf('%.2f',($du / $dt) * 100);
  12.     $df = formatSize($df);
  13.     $du = formatSize($du);
  14.     $dt = formatSize($dt);
  15.  
  16.     function formatSize( $bytes )
  17.     {
  18.             $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
  19.             for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
  20.                     return( round( $bytes, 2 ) . " " . $types[$i] );
  21.     }
  22.  
  23.     ?>
  24.  
  25.     <style type='text/css'>
  26.         h2 {
  27.         text-align: center;
  28.         }
  29.     .progress {
  30.             border: 2px solid #5E96E4;
  31.             height: 32px;
  32.             width: 540px;
  33.             margin: 30px auto;
  34.     }
  35.     .progress .prgbar {
  36.             background: #A7C6FF;
  37.             width: <?php echo $dp; ?>%;
  38.             position: relative;
  39.             height: 32px;
  40.             z-index: 999;
  41.     }
  42.     .progress .prgtext {
  43.             color: #286692;
  44.             text-align: center;
  45.             font-size: 13px;
  46.             padding: 9px 0 0;
  47.             width: 540px;
  48.             position: absolute;
  49.             z-index: 1000;
  50.     }
  51.     .progress .prginfo {
  52.             margin: 3px 0;
  53.     }
  54.  
  55.     </style>
  56. <h2>Wskaźnik wolnej przestrzeni dla serwera <? echo $_SERVER["SERVER_ADDR"];?></h2>
  57.     <div class='progress'>
  58.             <div class='prgtext'><?php echo $dp; ?>% zajętej przestrzeni dyskowej</div>
  59.             <div class='prgbar'></div>
  60.             <div class='prginfo'>
  61.                     <span style='float: left;'><?php echo "$du z $dt używanej przestrzeni"; ?></span>
  62.                     <span style='float: right;'><?php echo "$df z $dt wolnej przestrzeni"; ?></span>
  63.                     <span style='clear: both;'></span>
  64.             </div>
  65.     </div>
  66. </body>
  67. </html>
Add Comment
Please, Sign In to add comment