Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.10 KB | None | 0 0
  1. <html lang="en"> </html>
  2. <head>
  3.   <style>
  4.       body { font-family:courier,serif  }
  5.   </style>
  6. </head>
  7.  
  8. <?php
  9.  
  10. function seconds_to_string($seconds) {
  11.     $hours = floor($seconds / 3600);
  12.     $mins = floor($seconds / 60 % 60);
  13.     $secs = floor($seconds % 60);
  14.  
  15.     return sprintf('%02d:%02d:%02d', $hours, $mins, $secs);
  16. }
  17.  
  18. $conn = new mysqli('localhost', 'root', '', 'smelter');
  19. if ($conn->connect_error) {
  20.     die('DB ERROR');
  21. }
  22.  
  23. $ips = $_GET['ip'];
  24. $where = '';
  25.  
  26. if ($ips != 'master') {
  27.     foreach (explode(',', $ips) as $ip) {
  28.         $where .= " or ip = '" . $ip . "'";
  29.     }
  30.    $where = ' where ' . trim($where, ' or');
  31. }
  32.  
  33. $sql = 'SELECT * FROM reports ' . $where;
  34. $query = $conn->query($sql);
  35.  
  36. if (($query) && ($query->num_rows > 0)) {
  37.  
  38.     $total_arr = array();
  39.     $xp_arr = array();
  40.    
  41.     while($row = $query->fetch_assoc()) {
  42.          $item = $row['ITEM_NAME'];
  43.          $count = round($row['TOTAL_XP'] / $row['ITEM_XP']);
  44.          $xp = $row['TOTAL_XP'];
  45.  
  46.          if ($item == 'CANNONBALL') {
  47.              $count *= 4;
  48.          }
  49.  
  50.          if (array_key_exists($item, $total_arr)) {
  51.              $total_arr[$item] += $count;
  52.          } else {
  53.              $total_arr[$item] = $count;
  54.         }
  55.  
  56.         if (array_key_exists($item, $xp_arr)) {
  57.              $xp_arr[$item] += $xp;
  58.          } else {
  59.              $xp_arr[$item] = $xp;
  60.         }
  61.     }
  62.    
  63.     echo '<h1>Total</h1>';
  64.     echo '<hr>';
  65.  
  66.     echo '<table>';
  67.     echo '<style>';
  68.     echo 'td {';
  69.     echo '  padding: 8px;';
  70.     echo '  text-align: left;';
  71.     echo '  border-bottom: 1px solid #ddd;';
  72.     echo '}';
  73.     echo '</style>';
  74.     echo '<tr>';
  75.     echo '  <th>Item</th>';
  76.     echo '  <th>Amount</th>';
  77.     echo '  <th>XP</th>';
  78.     echo '</tr>';
  79.  
  80.     while ($item= current($total_arr)) {
  81.         echo '<tr>';
  82.         echo '<td>' . key($total_arr) . '</td>';
  83.         echo '<td>' . number_format(current($total_arr)) . ' </td>';
  84.         echo '<td>' . number_format(current($xp_arr)) . ' </td>';
  85.         echo '</tr>';
  86.  
  87.         next($total_arr);
  88.         next($xp_arr);
  89.     }
  90.  
  91.   echo '</table>';
  92. }
  93.  
  94. $sql = 'SELECT * FROM sessions ' . $where;
  95. $query = $conn->query($sql);
  96.  
  97. if (($query) && ($query->num_rows > 0)) {
  98.    
  99.     echo '<h1>Scripts Running</h1>';
  100.     echo '<hr>';
  101.  
  102.     echo '<table>';
  103.     echo '<style>';
  104.     echo 'td {';
  105.     echo '  padding: 8px;';
  106.     echo '  text-align: left;';
  107.     echo '  border-bottom: 1px solid #ddd;';
  108.     echo '}';
  109.     echo '</style>';
  110.     echo '<tr>';
  111.     echo '  <th>Tag</th>';
  112.     echo '  <th>IP</th>';
  113.     echo '  <th>Time</th>';
  114.     echo '  <th>Item</th>';
  115.     echo '</tr>';
  116.    
  117.     while($row = $query->fetch_assoc()) {
  118.         $runtime = $row['PING'] - $row['START_TIME'];
  119.  
  120.         echo '<tr>';
  121.         echo '<td>' . $row['TAG'] . '</td>';
  122.         echo '<td>' . $row['IP'] . '</td>';
  123.         echo '<td>' . seconds_to_string($runtime) . ' </td>';
  124.         echo '<td>' . $row['ITEM_NAME'] . ' </td>';
  125.         echo '</tr>';
  126.     }
  127.  
  128.     echo '</table>';
  129. } else {
  130.     echo '<h1>No Scripts Running</h1>';
  131.     echo '<hr>';
  132. }
  133.  
  134. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement