Last active
September 18, 2016 10:16
-
-
Save chaseoes/4490794 to your computer and use it in GitHub Desktop.
Display stats provided by the TF2 Bukkit plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// MySQL Information | |
$database_hostname = 'localhost'; | |
$database_username = 'username'; | |
$database_password = 'password'; | |
$database_name = 'my_database'; | |
$database_port = '3306'; | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- Meta --> | |
<title>TF2 Stats</title> | |
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> | |
<meta name="author" content="chaseoes"> | |
<!-- Styles --> | |
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet"> | |
<style type="text/css"> | |
body { | |
margin: 150px; | |
margin-top: 80px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>TF2 Stats</h1> | |
<?php | |
$sortby = 'kills'; | |
$limit = '50'; | |
$order = 'DESC'; | |
if (isset($_GET["sort"])) { | |
$sortby = $_GET["sort"]; | |
} | |
if (isset($_GET["limit"])) { | |
$limit = $_GET["limit"]; | |
} | |
if (isset($_GET["order"])) { | |
$order = $_GET["order"]; | |
} | |
$con = mysql_connect($database_hostname . ":" . $database_port, $database_username, $database_password); | |
if (!$con) { | |
die('Could not connect to database.'); | |
} | |
echo "Stats page automatically generated for the <a href='http://dev.bukkit.org/server-mods/team-fortress-2'>TF2</a> plugin, currently sorted by " . $sortby . ". <hr />"; | |
mysql_select_db($database_name, mysql_connect($database_hostname . ":" . $database_port, $database_username, $database_password)); | |
$result = mysql_query("SELECT * FROM players ORDER BY CONVERT(" . $sortby . ", UNSIGNED INTEGER) " . $order . " LIMIT " . $limit); | |
echo "<table class='table table-hover table-bordered'> | |
<tr> | |
<th>Username</th> | |
<th>Kills</th> | |
<th>Highest Killstreak</th> | |
<th>Points Captured</th> | |
<th>Games Played</th> | |
<th>Red Team Count</th> | |
<th>Blue Team Count</th> | |
<th>Time Ingame</th> | |
<th>Games Won</th> | |
<th>Arrows Fired</th> | |
<th>Deaths</th> | |
</tr>"; | |
while($row = mysql_fetch_array($result)) { | |
echo "<tr>"; | |
echo "<td>" . $row['username'] . "</td>"; | |
echo "<td>" . $row['kills'] . "</td>"; | |
echo "<td>" . $row['highest_killstreak'] . "</td>"; | |
echo "<td>" . $row['points_captured'] . "</td>"; | |
echo "<td>" . $row['games_played'] . "</td>"; | |
echo "<td>" . $row['red_team_count'] . "</td>"; | |
echo "<td>" . $row['blue_team_count'] . "</td>"; | |
echo "<td>" . $row['time_ingame'] . "</td>"; | |
echo "<td>" . $row['games_won'] . "</td>"; | |
echo "<td>" . $row['arrows_fired'] . "</td>"; | |
echo "<td>" . $row['deaths'] . "</td>"; | |
echo "</tr>"; | |
} | |
echo "</table>"; | |
mysql_close($con); | |
?> | |
<p style="float: left;"><hr /><span class="muted">TF2 stats page created by <a href="http://github.com/chaseoes">chaseoes</a> for the <a href="http://dev.bukkit.org/server-mods/team-fortress-2/">TF2</a> plugin.</p> | |
</body> | |
</html> |
wait so is this broken
lol, someone code use sql injection easy on this code... should of done preg_match so then if it does not match numbers to die().
Thanks! ^_^
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oops! You forgot to escape input by users.