Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. /* settings */
  4. $ip = '0.0.0.0'; //mysql host
  5. $user = 'username'; //mysql user
  6. $pass = 'password'; //mysql pass
  7. $characters = 'oregon_char'; //char db
  8. $top = 100; //how many tops
  9.  
  10. /* code */
  11. $connect = mysql_pconnect($ip, $user, $pass)  or die ("Cant connect $ip");
  12.  
  13. function getTime($total)
  14. {
  15.   $dny = (int)($total/86400);
  16.   $total = $total - ($dny*86400);
  17.   $hodiny = (int)($total/3600);
  18.   $total = $total - ($hodiny*3600);
  19.   $minuty = (int)($total/60);
  20.  
  21.   $cas = $dny."d ".$hodiny."h ".$minuty."m";
  22.   return $cas;
  23. }
  24.  
  25. //Online checker
  26. function getOnline($online)
  27. {
  28.   if ($online == 1):
  29.     $status = "<font color=green>Online</font>";
  30.   else:
  31.     $status = "<font color=red>Offline</font>";
  32.   endif;
  33.  
  34.   return $status;
  35. }
  36.  
  37. //select db
  38. mysql_select_db($characters, $connect);
  39. //query
  40. $sql = "SELECT * FROM characters ORDER BY totaltime DESC LIMIT $top";
  41. $result = mysql_query($sql);
  42. $i=0;
  43. echo "<center><h1> TOP $top played time</H1>
  44.      <table>";
  45.      
  46. while ($vypis=mysql_fetch_array($result))
  47. {    
  48.   $i=$i+1;
  49.   echo "<tr><td>$i)<th>".$vypis['name']."</th>
  50.        <td>".getTime($vypis['totaltime'])."</td>
  51.        <td>".getOnline($vypis['online'])."</td></tr>";
  52.  
  53. }
  54.  
  55. echo "<center></table>";
  56. mysql_close();
  57.  
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement