Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Connection string//
- $db_host = "localhost";
- $db_username = "";
- $db_pass = "";
- $db_name = "";
- $myConnection = mysqli_connect("$db_host","$db_username","$db_pass", "$db_name") or die ("could not connect to mysql");
- //Define//
- define("servertimeout", 120);
- //Get server info//
- $sqlCommand1 = "SELECT * FROM server";
- $query1 = mysqli_query($myConnection,$sqlCommand1) or die("Error getting server data".mysqli_error());
- while($row = mysqli_fetch_array($query1)) {
- //Set timeout//
- $ServerTimeout = date("Y-m-d H:i:s", strtotime('-'.servertimeout.' second'));
- //Ensure server's last update is not past the timeout//
- if($ServerTimeout > $row["last_update"])
- {
- echo $row["offline_name"] . "<br /><br />\n";
- } else {
- $ServerName = $row["display_name"];
- $ServerName = str_replace("{MAP}", $row["map"], $ServerName);
- $ServerName = str_replace("{CURR}", $row["currplayers"], $ServerName);
- $ServerName = str_replace("{MAX}", $row["maxplayers"], $ServerName);
- echo "<a href=\"steam://connect/" . $row["address"] . "\" title=\"Connect to this server\">" . $ServerName . "</a><br /><br />\n";
- }
- }
- mysqli_free_result($query1);
- mysqli_close($myConnection);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement