Advertisement
iSeven77

Untitled

Apr 7th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.60 KB | None | 0 0
  1. <?php
  2. //Title
  3. $title = 'Online Players</br>';
  4. //Amount of slots
  5. $serverslots = 20;
  6. //IP(local or external)- If running on a different port specify the port (ex. l27.0.0.1:1234)
  7. $ip = 'theserverIP';
  8. //Username (default is root - 'root')
  9. $username = 'yourMySQLusername';
  10. //password (default is none - '')
  11. $password = 'yourpassword';
  12. //database name
  13. $dbname = 'theMySQLdatabasename';
  14. //table name
  15. $tablename = 'online_players';
  16.  
  17. //ranks (Ranks are case sensitive. You can add more bu adding a comma and more quotes with rank title in the quotes)
  18. $ranks = array("Owner","User","New");  //these are your groups, the way u want to sort the table like Owner,Admin,Moderator,Builder,Default
  19. //number of ranks
  20. $numranks = 3;
  21.  
  22. //this is to refresh the page Refresh : 30 is to refresh page every 30 seconds
  23. $url=$_SERVER['REQUEST_URI'];
  24. header("Refresh: 30; URL=$url");
  25.  
  26. //Do not touch this code unlass you have the knowledge to change it
  27. //player_deaths player_kills
  28.   $con = mysql_connect($ip,$username,$password);
  29.   if (!$con)
  30.   {
  31.     die('Could not connect: ' . mysql_error());
  32.   }
  33.   mysql_select_db($dbname, $con);
  34.  
  35.   echo'
  36.  <head>
  37.  
  38.  
  39.  </head>
  40.  </body><center>
  41.  <table>
  42.  <caption><h3>'.$title.' <span style="color:green;">'.dcounter($tablename).'</span><b> / </b><span style="color:red;">'. $serverslots .'</span> </h3></caption>
  43.  <thead>
  44.    <tr style="color:darkblue;text-align:left;background-color:rgba(0,255,0,0.2);">
  45.       <th>Online</th>
  46.      <th>Player</th>
  47.      <th>Rank</th>
  48.       <th>Previous World</th>
  49.      <th>World</th>
  50.      <th>Kills</th>
  51.      <th>Deaths</th>
  52.      <th>Logged On</th>
  53.       <th>iP Address</th>
  54.    </tr>
  55.  </thead>
  56.   <tbody>';
  57.    
  58.   for ($i = 0; $i < $numranks; $i ++)
  59.   {
  60.     listorder($tablename, $ranks[$i]);
  61.     }
  62.  
  63.    
  64.  
  65.   mysql_close($con);
  66.  
  67.  
  68.                 echo "</tbody></table><br></body>";
  69. //functions
  70. function listorder($tablename,$permission) //listorder
  71. {
  72.   $result = mysql_query("SELECT * FROM ".$tablename);
  73.  
  74.   while($row = mysql_fetch_array($result))
  75.   {
  76.     if (($row['online'] == "1") && ($row['permission_group'] == $permission))
  77.     {
  78.       displayrow($row['online'],$row['player'],$row['permission_group'],$row['previous_world'],$row['current_world'],$row['player_deaths'],$row['player_kills'],date("l g:i:s a F d Y", $row['logon_time']),$row['ip_address']);
  79.     }
  80.         if (($row['online'] == "0") && ($row['permission_group'] == $permission))
  81.     {
  82.       displayrow($row['online'], $row['player'],$row['permission_group'],$row['previous_world'],$row['current_world'],$row['player_deaths'],$row['player_kills'],date("l g:i:s a F d Y", $row['logon_time']), $row['ip_address']);
  83.     }
  84.   }
  85. }//listorder
  86.  
  87. function dcounter($tablename)
  88. {
  89.   $result = mysql_query("SELECT * FROM ".$tablename);
  90.   $counter = 0;
  91.   while($row = mysql_fetch_array($result))
  92.   {
  93.     if ($row['online'] == "1")
  94.     {
  95.       $counter ++;
  96.     }    
  97.   }
  98.   return $counter;
  99. }
  100.  
  101.  
  102. function displayrow($dponline, $dpname, $dpermg, $dprevworld, $dcurrworld, $dpdeaths, $dpkills, $ddate, $dpip)
  103. {
  104.   if ($dpdeaths == null)
  105.     $dpdeaths=0;
  106.   if ($dpkills == null)
  107.     $dpkills=0;
  108.    if ($dponline == 0)
  109.     $dponline= '<span style="color:red;">OFF</span>';
  110.   else
  111.     $dponline='<span style="color:green;">ON</span>';
  112.   echo '<tr>';
  113.     echo '<td>'.$dponline.'</td>';
  114.     echo '<td>'.$dpname.'</td>';
  115.     echo '<td>'.$dpermg.'</td>';
  116.     echo '<td>'.$dprevworld.'</td>';
  117.     echo '<td>'.$dcurrworld.'</td>';
  118.     echo '<td>'.$dpkills.'</td>';
  119.     echo '<td>'.$dpdeaths.'</td>';
  120.     echo '<td>'.$ddate.'</td>';
  121.     echo '<td>'.$dpip.'</td>';
  122.   echo '</tr>';
  123. }
  124. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement