Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* settings */
- $ip = '0.0.0.0'; //mysql host
- $user = 'username'; //mysql user
- $pass = 'password'; //mysql pass
- $characters = 'oregon_char'; //char db
- $top = 100; //how many tops
- /* code */
- $connect = mysql_pconnect($ip, $user, $pass) or die ("Cant connect $ip");
- function getTime($total)
- {
- $dny = (int)($total/86400);
- $total = $total - ($dny*86400);
- $hodiny = (int)($total/3600);
- $total = $total - ($hodiny*3600);
- $minuty = (int)($total/60);
- $cas = $dny."d ".$hodiny."h ".$minuty."m";
- return $cas;
- }
- //Online checker
- function getOnline($online)
- {
- if ($online == 1):
- $status = "<font color=green>Online</font>";
- else:
- $status = "<font color=red>Offline</font>";
- endif;
- return $status;
- }
- //select db
- mysql_select_db($characters, $connect);
- //query
- $sql = "SELECT * FROM characters ORDER BY totaltime DESC LIMIT $top";
- $result = mysql_query($sql);
- $i=0;
- echo "<center><h1> TOP $top played time</H1>
- <table>";
- while ($vypis=mysql_fetch_array($result))
- {
- $i=$i+1;
- echo "<tr><td>$i)<th>".$vypis['name']."</th>
- <td>".getTime($vypis['totaltime'])."</td>
- <td>".getOnline($vypis['online'])."</td></tr>";
- }
- echo "<center></table>";
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement