Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2.  
  3. //Connection string//
  4. $db_host = "localhost";
  5. $db_username = "";
  6. $db_pass = "";
  7. $db_name = "";
  8.  
  9. $myConnection = mysqli_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql");
  10.  
  11. //Define//
  12. define("servertimeout", 120);
  13.  
  14.  
  15. //Get server info//
  16. $sqlCommand1 = "SELECT * FROM server";
  17. $query1 = mysqli_query($myConnection,$sqlCommand1) or die("Error getting server data".mysqli_error());
  18. while($row = mysqli_fetch_array($query1)) {
  19.     //Set timeout//
  20.     $ServerTimeout = date("Y-m-d H:i:s", strtotime('-'.servertimeout.' second'));
  21.    
  22.     //Ensure server's last update is not past the timeout//
  23.     if($ServerTimeout > $row["last_update"])
  24.     {
  25.         echo $row["offline_name"] . "<br /><br />\n";  
  26.     } else {
  27.         $ServerName = $row["display_name"];
  28.         $ServerName = str_replace("{MAP}", $row["map"], $ServerName);
  29.         $ServerName = str_replace("{CURR}", $row["currplayers"], $ServerName);
  30.         $ServerName = str_replace("{MAX}", $row["maxplayers"], $ServerName);
  31.        
  32.         echo "<a href=\"steam://connect/" . $row["address"] . "\" title=\"Connect to this server\">" . $ServerName . "</a><br /><br />\n";
  33.     }
  34. }
  35. mysqli_free_result($query1);
  36.  
  37. mysqli_close($myConnection);
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement