Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1. <?php
  2.  
  3.     if ($_GET["server"] == "" ) {
  4.         if ($handle = opendir('/opt/usergraph')) {
  5.             while (false !== ($file = readdir($handle))) {
  6.                 if ( is_dir($file) && ! (preg_match("/^\./", $file)) ){
  7.                     print "<a href=\"cpu.php?server=$file\">$file</a><br/>";
  8.                 }
  9.             }
  10.         closedir($handle);
  11.         }
  12.     } else {
  13.         $server = $_GET["server"];
  14.         print "<h1>$server</h1>";
  15.         if ( is_dir("/opt/usergraph/$server") && ($handle = opendir("/opt/usergraph/$server")) ) {
  16.             print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";
  17.                 $usernames = array();
  18.             while (false !== ($file = readdir($handle))) {
  19.                 if ( is_file("/opt/usergraph/$server/$file") && (preg_match("/^\w+\.rrd/", $file)) ){
  20.                     $name = preg_split("/\.rrd/", $file);
  21.                     $usernames[] = $name[0];
  22.                 }
  23.             }
  24.                 sort($usernames);
  25.                 for ($i=0; $i<count($usernames); $i++ ) {
  26.                     $username = $usernames[$i];
  27.                     $time = time();
  28.                     print "<tr align=\"center\" bgcolor=\"#999999\">
  29.                   <td>".$username."</td>
  30.                   <td><a href=\"/cgi-bin/mkgraph.pl?username=".$username."&server=". $server. "&start=".($time - 24*60*60)."\">CPU usage за день</a></td>
  31.                   <td><a href=\"/cgi-bin/mkgraph.pl?username=".$username."&server=". $server. "&start=".($time - 24*60*60*7)."\">CPU usage за неделю</a></td>
  32.                   <td><a href=\"/cgi-bin/mkgraph.pl?username=".$username."&server=". $server. "&start=".($time - 24*60*60*30)."\">CPU usage за месяц</a></td>
  33.                   </tr>";
  34.                 }
  35.             print "</table>";
  36.             closedir($handle);
  37.         }
  38.     }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement