Created
November 2, 2016 23:57
-
-
Save rodel77/a96335676fc63baa29684e9fffc9bf93 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<title>MiniBoardGames Web-Stats</title> | |
<meta charset="utf-8"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<div class="panel panel-default"> | |
<?php | |
##CONFIGURABLE START | |
#DBConfig | |
$sql_host = ""; | |
$sql_username = ""; | |
$sql_password = ""; | |
$sql_dbname = ""; | |
#Strings | |
$select_game = "Select Game"; | |
$stat = "{game} stats!"; | |
$selectdisplay = "Select a Game to display stats!"; | |
#Strings-Games | |
$games = array(); | |
$games["connect4"] = "Connect4"; | |
$games["fabulousfred"] = "FabolousFred"; | |
$games["hearthstone"] = "HearthStone"; | |
$games["mastermind"] = "MasterMind"; | |
$games["rockpaperscissors"] = "RockPaperScissors"; | |
$games["tictactoe"] = "TicTacToe"; | |
$games["uno"] = "UNO"; | |
$games["whackamole"] = "WhackAMole"; | |
$columns = array(); | |
$columns["discsPlaced"] = "Discs Placed"; | |
$columns["purplePlaced"] = "Purple Placed"; | |
$columns["minionsDamage"] = "Minions Damage"; | |
$columns["lose"] = "Lose"; | |
$columns["GhastPlaced"] = "Ghast Placed"; | |
$columns["SilverfishPlaced"] = "Silverfish Placed"; | |
$columns["mobsSmashed"] = "Mobs Smashed"; | |
$columns["VillagerPlaced"] = "Villager Placed"; | |
$columns["WitherBossPlaced"] = "Wither Boss Placed"; | |
$columns["horizontalWins"] = "Horizontal Wins"; | |
$columns["rock"] = "Rock"; | |
$columns["coins"] = "Coins"; | |
$columns["timesPlayed"] = "Times Played"; | |
$columns["diagonalWins"] = "Diagonal Wins"; | |
$columns["CreeperPlaced"] = "Creeper Placed"; | |
$columns["songs"] = "Songs"; | |
$columns["bluePlaced"] = "Blue Placed"; | |
$columns["ZombieVillagerPlaced"] = "Zombie Villager Placed"; | |
$columns["linesCompleted"] = "Lines Completed"; | |
$columns["EnderDragonPlaced"] = "Ender Dragon Placed"; | |
$columns["paper"] = "Paper"; | |
$columns["IronGolemPlaced"] = "Iron Golem Placed"; | |
$columns["SnowmanPlaced"] = "Snowman Placed"; | |
$columns["EndermanPlaced"] = "Enderman Placed"; | |
$columns["ChickenPlaced"] = "Chicken Placed"; | |
$columns["SpiderPlaced"] = "Spider Placed"; | |
$columns["greenPlaced"] = "Green Placed"; | |
$columns["wins"] = "Wins"; | |
$columns["verticalWins"] = "Vertical Wins"; | |
$columns["SquidPlaced"] = "Squid Placed"; | |
$columns["skullsPlaced"] = "Skulls Placed"; | |
$columns["redPlaced"] = "Red Placed"; | |
$columns["player"] = "Player"; | |
$columns["green"] = "Green"; | |
$columns["totalDamage"] = "Total Damage"; | |
$columns["SkeletonPlaced"] = "Skeleton Placed"; | |
$columns["GuardianPlaced"] = "Guardian Placed"; | |
$columns["scissors"] = "Scissors"; | |
$columns["blue"] = "Blue"; | |
$columns["yellow"] = "Yellow"; | |
$columns["red"] = "Red"; | |
$columns["fails"] = "Fails"; | |
$columns["goodNotes"] = "Good Notes"; | |
$columns["playersDamage"] = "Players Damage"; | |
$columns["cardsPlaced"] = "Cards Placed"; | |
$columns["BlazePlaced"] = "Blaze Placed"; | |
$columns["yellowPlaced"] = "Yellow Placed"; | |
##CONFIGURABLE END | |
$game = null; | |
$order = "timesPlayed"; | |
if(isset($_GET["game"])){ | |
$game = $_GET["game"]; | |
} | |
if(isset($_GET["order"])){ | |
$order = $_GET["order"]; | |
} | |
$conn = mysql_connect($sql_host, $sql_username, $sql_password); | |
if(!$conn){ | |
die("Error connection to db: ".mysql_error()); | |
} | |
$db = mysql_select_db($sql_dbname); | |
if(!$db){ | |
die("Error connecting to table: ".mysql_error()); | |
} | |
$result = mysql_list_tables($sql_dbname); | |
if(!$result){ | |
echo "Error getting all tables: ".mysql_error(); | |
exit; | |
} | |
echo '<div class="panel-heading">'; | |
if($game!=null){ | |
$dn = $game; | |
if(!empty($games[$game])){ | |
$dn = $games[$game]; | |
} | |
echo "<p>".str_replace("{game}", $dn, $stat)."</p>"; | |
}else{ | |
echo $selectdisplay; | |
} | |
echo '</div>'; | |
echo '<div class="panel-body">'; | |
echo '<div class="btn-group" style="margin:10px;"> | |
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
'.$select_game.' <span class="caret"></span> | |
</button> | |
<ul class="dropdown-menu">'; | |
while ($row = mysql_fetch_row($result)) { | |
$displayName = $row[0]; | |
foreach ($games as $key => $value) { | |
if($key==$row[0]){ | |
$displayName = $value; | |
} | |
} | |
echo '<li><a href="?game='.$row[0].'">'.$displayName.'</a></li>'; | |
} | |
echo '</ul> | |
</div>'; | |
if($game!=null && !empty($games[$game])){ | |
echo '<table class="table table-striped table-bordered"> | |
<thead> | |
<tr><th>#</th>'; | |
$cc = mysql_query("SHOW COLUMNS FROM ".$sql_dbname.".".$game); | |
while($c = mysql_fetch_row($cc)){ | |
$dn = $c[0]; | |
if(!empty($columns[$c[0]])){ | |
$dn = $columns[$c[0]]; | |
} | |
echo '<th><a href="?game='.$game.'&order='.$c[0].'">'.$dn.'</a></th>'; | |
} | |
echo '</tr> | |
</thead> | |
<tbody> | |
<tr> | |
'; | |
$cc2 = mysql_query("SHOW COLUMNS FROM ".$sql_dbname.".".$game); | |
$top = mysql_query("SELECT * FROM `".$game."` ORDER BY `".$game."`.`".$order."` DESC"); | |
$increment = 1; | |
while($p = mysql_fetch_array($top)){ | |
echo "<tr>"; | |
echo "<td>".$increment."</td>"; | |
for ($i=0; $i < mysql_num_fields($top); $i++) { | |
if($i==0){ | |
echo '<td><img src="http://cravatar.eu/avatar/'.$p[$i].'/32.png"> '.json_decode(file_get_contents(str_replace("-", "", "https://api.mojang.com/user/profiles/".$p[$i]."/names")),true)[0]["name"].'</td>'; | |
}else{ | |
echo "<td>".$p[$i]."</td>"; | |
} | |
} | |
echo "</tr>"; | |
$increment+=1; | |
} | |
echo ' | |
</tr> | |
</tbody> | |
</table>'; | |
} | |
mysql_close(); | |
?> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment