-
Notifications
You must be signed in to change notification settings - Fork 0
/
ladder.php
96 lines (80 loc) · 3.19 KB
/
ladder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
require_once("common.php");
$ladderID = get("ladder");
checkLadder($ladderID);
$html = "";
$ladder = db()->stdGet("ladders", array("ladderID"=>$ladderID), array("name", "summary", "message"));
$ladderMessageHtml = "<p>" . nl2br(htmlentities($ladder["message"])) . "</p>";
if (!isLoggedIn() || !db()->stdExists("ladderPlayers", array("ladderID"=>$ladderID, "userID"=>currentUserID()))) {
$ladderOperationHtml = <<<HTML
<p><a href="joinladder.php?ladder={$ladderID}" class="btn btn-lg btn-primary">Join this ladder</a></p>
HTML;
} else if(isMod($ladderID)) {
$ladderOperationHtml = <<<HTML
<p><a href="modladder.php?ladder={$ladderID}" class="btn btn-default">Change ladder settings</a></p>
HTML;
} else {
$ladderOperationHtml = "";
}
if ($ladderOperationHtml != "") {
$ladderMessageHtml = "<div class=\"row\"><div class=\"col-md-10\">$ladderMessageHtml</div><div class=\"col-md-2\">$ladderOperationHtml</div></div>";
}
$topRankingHtml = renderRanking($ladderID, "Top players", "There don't seem to be any players on this ladder.", null, 0, 10);
$recentGamesHtml = renderGames(null, $ladderID, "Recent games", "No games have been played on this ladder yet.", 0, 10);
if(isLoggedIn() && db()->stdExists("ladderPlayers", array("ladderID"=>$ladderID, "userID"=>currentUserID()))) {
$player = db()->stdGet("ladderPlayers", array("ladderID"=>$ladderID, "userID"=>currentUserID()), array("rank", "joinStatus"));
$myRankingHtml = renderRanking($ladderID, "Your rank", "There don't seem to be any players on this ladder.", currentUserID(), max($player["rank"] - 6, 0), 10);
$myRecentGamesHtml = renderGames(currentUserID(), $ladderID, "Your recent games", "You have not played any games on this ladder yet.", 0, 10);
if ($player["joinStatus"] == "SIGNEDUP") {
$html .= <<<HTML
<div class="alert alert-warning">
<p>You must be approved by a ladder moderator before you can participate on this ladder.</p>
</div>
HTML;
}
$html .= <<<HTML
<div class="row">
<div class="col-md-6">
$topRankingHtml
</div>
<div class="col-md-6">
$myRankingHtml
</div>
</div>
<div class="row">
<div class="col-md-6">
$recentGamesHtml
</div>
<div class="col-md-6">
$myRecentGamesHtml
</div>
</div>
HTML;
} else {
$html .= $topRankingHtml . $recentGamesHtml;
}
$html .= <<<HTML
<div class="panel panel-default chat">
<div class="panel-heading"><h3>Ladder Chat</h3></div>
<table class="table table-condensed" id="chatLines"></table>
<div class="panel-footer enterChat">
<form id="chatForm"><table><tr>
HTML;
if(isLoggedIn()) {
$html .= <<<HTML
<td class="stretch newChatLinetd"><input type="text" name="newChatLine" id="newChatLine" class="form-control"></td>
<td><input type="submit" name="newChatLineSubmit" id="newChatLineSubmit" class="btn btn-default" value="Send"></td>
<td><input type="button" name="chatShowAll" id="chatShowAll" class="btn" value="Show all"></td>
HTML;
} else {
$html .= <<<HTML
<td><div class="show-all"><input type="button" name="chatShowAll" id="chatShowAll" class="btn" value="Show all"></div></td>
HTML;
}
$html .= <<<HTML
</tr></table></form>
</div>
</div>
<script>new LadderChat($ladderID);</script>
HTML;
page($html, "ladder", $ladder["name"], htmlentities($ladder["summary"]), $ladderMessageHtml);