daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <header>
  3. <style>
  4. table{
  5.     background-color: #222222;
  6.     width: 600px;
  7.     border-style: solid;
  8.     border-width: 1px;
  9.     border-color: #000;
  10.     border-spacing: 0px;
  11.     padding: 5px 5px 5px 5px;
  12.     border-radius: 8px;
  13.     -webkit-border-radius: 8px;
  14.     -moz-border-radius: 8px;
  15. }
  16.  
  17. tr, td {
  18.     background-color: #222222;
  19.     width: 600px;
  20.     border-style: solid;
  21.     border-width: 1px;
  22.     border-color: #000;
  23.     border-spacing: 0px;
  24.     padding: 5px 5px 5px 5px;
  25.     margin: 2px 2px 2px 2px;
  26. }
  27. </style>
  28. </header>
  29. </html>
  30.  
  31. <?php
  32.  
  33.  
  34. $dbhost = 'localhost';
  35. $dbuser = 'root';
  36. $dbpass = '';
  37. $dbname = 'test';
  38.  
  39.  
  40.  
  41. $conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('I cannot connect to the database because: ' . mysql_error());
  42. mysql_select_db ($dbname) or die('Could not select the database ' . $dbname . '!');
  43.  
  44. $query  = "SELECT rp_name_first, cash, bank, time_played FROM perp_users";
  45.  
  46. $result = mysql_query($query);
  47.  
  48. print "<center><SPAN STYLE='font-size: 16pt; font-family: arial'><b>Server Stats</span>";
  49.  
  50.  
  51. while($row = mysql_fetch_array($result, MYSQL_ASSOC))
  52. {
  53.  
  54. $money += $row['cash'] + $row['bank'];
  55.  
  56. $formattedTime = "0 Seconds";
  57. $timePlayed = $row['time_played'];
  58. $totalTime += $row['time_played'];
  59.  
  60.  
  61. $numMonths = floor($totalTime / (60 * 60 *24 * 31));
  62. $numWeeks = floor($totalTime / (60 * 60 *24 * 7));
  63. $numDays = floor($totalTime / (60 * 60 *24));
  64. $numHours = floor($totalTime / (60 * 60));
  65. $numMinutes = floor($totalTime / 60);
  66. $numSeconds = floor($totalTime);
  67.  
  68.     if (numMonths != 0)
  69.     {
  70.     $formattedTime = $numMonths." "."Month";
  71.         if ($numMonths > 1)
  72.             {
  73.             $formattedTime = $formattedTime."s";
  74.             }
  75.     }
  76.     elseif ($numWeeks != 0)
  77.         {
  78.         $formattedTime = $numWeeks." "."Week";
  79.             if ($numWeeks > 1)
  80.             {
  81.             $formattedTime = $formattedTime."s";
  82.             }
  83.         }
  84.     elseif ($numDays != 0)
  85.         {
  86.         $formattedTime = $numDays." "."Day";
  87.             if ($numDays > 1)
  88.             {
  89.             $formattedTime = $formattedTime."s";
  90.             }
  91.         }
  92.     elseif ($numHours != 0)
  93.         {
  94.         $formattedTime = $numHours." "."Hour";
  95.             if ($numHours > 1)
  96.             {
  97.             $formattedTime = $formattedTime."s";
  98.             }
  99.         }
  100.     elseif ($numMinutes != 0)
  101.         {
  102.         $formattedTime = $numMinutes." "."Minute";
  103.             if ($numMinutes > 1)
  104.             {
  105.             $formattedTime = $formattedTime."s";
  106.             }
  107.         }
  108.     else
  109.         {
  110.         $formattedTime = $numSeconds." "."Second";
  111.             if ($numDays > 1)
  112.             {
  113.             $formattedTime = $formattedTime."s";
  114.             }
  115.         }
  116.        
  117. }
  118. $totalmoney = number_format($money);
  119.  
  120. echo "
  121. <table>
  122.  
  123.     <tr>
  124.         <td><b>Total Money</b></td>
  125.        
  126.         <td><b>Total Time</b></td>
  127.        
  128.     </tr>
  129.    
  130.     <tr>
  131.         <td><b>$" . $totalmoney . "</b></td>
  132.        
  133.         <td><b>{$formattedTime}</b></td>
  134.        
  135.     </tr>
  136.    
  137. </table>";
  138.  
  139. $query  = "SELECT rp_name_first, rp_name_last, TIME_PLAYED, cash, bank FROM perp_users";
  140. $result = mysql_query($query);
  141.  
  142. echo "<br><br> <SPAN STYLE='font-size: 16pt; font-family: arial'><b>Player Stats</span>
  143.         <table>
  144.             <tr>
  145.                 <td><b>Name</b></td>
  146.                 <td><b>Playtime</b></td>
  147.                 <td><b>Money</b></td>
  148.             </tr>
  149.      ";
  150.  
  151. while($row = mysql_fetch_array($result, MYSQL_ASSOC))
  152. {
  153.  
  154.  
  155.  
  156. $formattedTime = "0 Seconds";
  157. $timePlayed = $row['TIME_PLAYED'];
  158.  
  159. $numMonths = floor($timePlayed / (60 * 60 *24 * 31));
  160. $numWeeks = floor($timePlayed / (60 * 60 *24 * 7));
  161. $numDays = floor($timePlayed / (60 * 60 *24));
  162. $numHours = floor($timePlayed / (60 * 60));
  163. $numMinutes = floor($timePlayed / 60);
  164. $numSeconds = floor($timePlayed);
  165.  
  166.     if (numMonths != 0)
  167.     {
  168.     $formattedTime = $numMonths." "."Month";
  169.         if ($numMonths > 1)
  170.             {
  171.             $formattedTime = $formattedTime."s";
  172.             }
  173.     }
  174.     elseif ($numWeeks != 0)
  175.         {
  176.         $formattedTime = $numWeeks." "."Week";
  177.             if ($numWeeks > 1)
  178.             {
  179.             $formattedTime = $formattedTime."s";
  180.             }
  181.         }
  182.     elseif ($numDays != 0)
  183.         {
  184.         $formattedTime = $numDays." "."Day";
  185.             if ($numDays > 1)
  186.             {
  187.             $formattedTime = $formattedTime."s";
  188.             }
  189.         }
  190.     elseif ($numHours != 0)
  191.         {
  192.         $formattedTime = $numHours." "."Hour";
  193.             if ($numHours > 1)
  194.             {
  195.             $formattedTime = $formattedTime."s";
  196.             }
  197.         }
  198.     elseif ($numMinutes != 0)
  199.         {
  200.         $formattedTime = $numMinutes." "."Minute";
  201.             if ($numMinutes > 1)
  202.             {
  203.             $formattedTime = $formattedTime."s";
  204.             }
  205.         }
  206.     else
  207.         {
  208.         $formattedTime = $numSeconds." "."Second";
  209.             if ($numDays > 1)
  210.             {
  211.             $formattedTime = $formattedTime."s";
  212.             }
  213.         }
  214.        
  215.     $formattedMoney = $row['cash'] + $row['bank'];
  216.  
  217. echo "
  218.         <tr>
  219.             <td>{$row['rp_name_first']} {$row['rp_name_last']}</td>
  220.             <td>{$formattedTime}</td>
  221.             <td>$" . $formattedMoney . "</td>
  222.         </tr>
  223.     </table>
  224.      ";
  225. }
  226.  
  227. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top