Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Title
- $title = 'Online Players</br>';
- //Amount of slots
- $serverslots = 20;
- //IP(local or external)- If running on a different port specify the port (ex. l27.0.0.1:1234)
- $ip = 'theserverIP';
- //Username (default is root - 'root')
- $username = 'yourMySQLusername';
- //password (default is none - '')
- $password = 'yourpassword';
- //database name
- $dbname = 'theMySQLdatabasename';
- //table name
- $tablename = 'online_players';
- //ranks (Ranks are case sensitive. You can add more bu adding a comma and more quotes with rank title in the quotes)
- $ranks = array("Owner","User","New"); //these are your groups, the way u want to sort the table like Owner,Admin,Moderator,Builder,Default
- //number of ranks
- $numranks = 3;
- //this is to refresh the page Refresh : 30 is to refresh page every 30 seconds
- $url=$_SERVER['REQUEST_URI'];
- header("Refresh: 30; URL=$url");
- //Do not touch this code unlass you have the knowledge to change it
- //player_deaths player_kills
- $con = mysql_connect($ip,$username,$password);
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($dbname, $con);
- echo'
- <head>
- </head>
- </body><center>
- <table>
- <caption><h3>'.$title.' <span style="color:green;">'.dcounter($tablename).'</span><b> / </b><span style="color:red;">'. $serverslots .'</span> </h3></caption>
- <thead>
- <tr style="color:darkblue;text-align:left;background-color:rgba(0,255,0,0.2);">
- <th>Online</th>
- <th>Player</th>
- <th>Rank</th>
- <th>Previous World</th>
- <th>World</th>
- <th>Kills</th>
- <th>Deaths</th>
- <th>Logged On</th>
- <th>iP Address</th>
- </tr>
- </thead>
- <tbody>';
- for ($i = 0; $i < $numranks; $i ++)
- {
- listorder($tablename, $ranks[$i]);
- }
- mysql_close($con);
- echo "</tbody></table><br></body>";
- //functions
- function listorder($tablename,$permission) //listorder
- {
- $result = mysql_query("SELECT * FROM ".$tablename);
- while($row = mysql_fetch_array($result))
- {
- if (($row['online'] == "1") && ($row['permission_group'] == $permission))
- {
- 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']);
- }
- if (($row['online'] == "0") && ($row['permission_group'] == $permission))
- {
- 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']);
- }
- }
- }//listorder
- function dcounter($tablename)
- {
- $result = mysql_query("SELECT * FROM ".$tablename);
- $counter = 0;
- while($row = mysql_fetch_array($result))
- {
- if ($row['online'] == "1")
- {
- $counter ++;
- }
- }
- return $counter;
- }
- function displayrow($dponline, $dpname, $dpermg, $dprevworld, $dcurrworld, $dpdeaths, $dpkills, $ddate, $dpip)
- {
- if ($dpdeaths == null)
- $dpdeaths=0;
- if ($dpkills == null)
- $dpkills=0;
- if ($dponline == 0)
- $dponline= '<span style="color:red;">OFF</span>';
- else
- $dponline='<span style="color:green;">ON</span>';
- echo '<tr>';
- echo '<td>'.$dponline.'</td>';
- echo '<td>'.$dpname.'</td>';
- echo '<td>'.$dpermg.'</td>';
- echo '<td>'.$dprevworld.'</td>';
- echo '<td>'.$dcurrworld.'</td>';
- echo '<td>'.$dpkills.'</td>';
- echo '<td>'.$dpdeaths.'</td>';
- echo '<td>'.$ddate.'</td>';
- echo '<td>'.$dpip.'</td>';
- echo '</tr>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement