This repository has been archived by the owner on May 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaplist.php
200 lines (197 loc) · 8.41 KB
/
maplist.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?php
require_once 'includes/haut-global.php';
$titre = "Parkour maps";
$metaDescription = "List of parkour maps created and shared with the CreativeParkour Bukkit plugin.";
$canonical = "https://creativeparkour.net/maplist.php";
require_once 'includes/haut-html.php';
define ( "MAPS_PAR_PAGE", 10 );
?>
<section class="listeMaps">
<h1><?php echo htmlspecialchars($titre); ?></h1>
<p class="margeGauche">
Here is the list of all the parkour maps created by the
CreativeParkour community. You can play them by typing the indicated
command on a server that has the CreativeParkour Bukkit plugin. <a
href="doc/play.php">Click here</a> for details.
</p>
<?php
$diffMin = - 1;
$diffMax = 5;
if ($_GET ["diffMin"])
$diffMin = ( float ) $_GET ["diffMin"];
if ($_GET ["diffMax"])
$diffMax = ( float ) $_GET ["diffMax"];
if ($diffMax == 5)
$diffMax = 999; // Pour que les maps à 5 s'affichent
$verMax = 999; // On veut toutes les versions au départ
if ($_GET ["verMax"])
$verMax = ( int ) $_GET ["verMax"];
// Recherche du nombre de maps
$reponse = $bdd->prepare ( "SELECT COUNT(*) nombre FROM maps WHERE etat = 'disponible' AND difficulte >= :diffMin AND difficulte < :diffMax AND verConversion <= :verMax" );
$reponse->bindParam ( ':diffMin', $diffMin, PDO::PARAM_INT );
$reponse->bindParam ( ':diffMax', $diffMax, PDO::PARAM_INT );
$reponse->bindParam ( ':verMax', $verMax, PDO::PARAM_INT );
$reponse->execute () or die ( "SQL error 34" );
$nbMaps = $reponse->fetch () ["nombre"];
$reponse->closeCursor ();
$tri = "m.points";
$sens = "DESC";
if ($_GET ["s"]) {
$sens = "ASC";
if ($_GET ["s"] == "date")
$tri = "m.dateAjout";
else if ($_GET ["s"] == "difficulty")
$tri = "m.difficulte";
else if ($_GET ["s"] == "quality")
$tri = "m.qualite";
else if ($_GET ["s"] == "name")
$tri = "m.nom";
}
if ($_GET ["o"] == "desc")
$sens = "DESC";
elseif ($_GET ["o"])
$sens = "ASC";
$borneInf = 0;
$page = 1;
$nbPages = ceil ( htmlspecialchars ( $nbMaps / MAPS_PAR_PAGE ) );
if ($_GET ["p"]) {
$page = ( int ) htmlspecialchars ( $_GET ["p"] );
}
if ($page > $nbPages || $page < 1)
$page = 1;
else
$borneInf = ($page - 1) * MAPS_PAR_PAGE;
function navigation() {
global $page, $nbPages, $nbMaps;
$pagePreced = $page - 1;
$pageSuiv = $page + 1;
$url = "maplist.php?" . "o=" . htmlspecialchars ( $_GET ["o"] ) . "&s=" . htmlspecialchars ( $_GET ["s"] );
$urlDiff = "diffMin=" . htmlspecialchars ( $_GET ["diffMin"] ) . "&diffMax=" . htmlspecialchars ( $_GET ["diffMax"] );
$urlVer = "verMax=" . htmlspecialchars ( $_GET ["verMax"] );
?>
<div class="navigation">
Page <?php
echo htmlspecialchars ( $page . "/" . $nbPages . " (" . $nbMaps . " maps)" ) . " — ";
if ($pagePreced >= 1) {
echo '<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . $pagePreced . '">Previous</a> · ';
}
if ($page - 4 > 1) {
echo '<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=1">1</a>·';
}
if ($page - 5 > 1) {
echo '…·';
}
if ($page - 4 >= 1) {
echo '<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page - 4) . '">' . ($page - 4) . '</a>·';
}
if ($page - 3 >= 1) {
echo '<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page - 3) . '">' . ($page - 3) . '</a>·';
}
if ($page - 2 >= 1) {
echo '<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page - 2) . '">' . ($page - 2) . '</a>·';
}
if ($page - 1 >= 1) {
echo '<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page - 1) . '">' . ($page - 1) . '</a>·';
}
echo '<strong>' . $page . '</strong>';
if ($page + 1 <= $nbPages) {
echo '·<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page + 1) . '">' . ($page + 1) . '</a>';
}
if ($page + 2 <= $nbPages) {
echo '·<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page + 2) . '">' . ($page + 2) . '</a>';
}
if ($page + 3 <= $nbPages) {
echo '·<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page + 3) . '">' . ($page + 3) . '</a>';
}
if ($page + 4 <= $nbPages) {
echo '·<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . ($page + 4) . '">' . ($page + 4) . '</a>';
}
if ($page + 5 < $nbPages) {
echo '·…';
}
if ($page + 4 < $nbPages) {
echo '·<a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . $nbPages . '">' . $nbPages . '</a>';
}
if ($pageSuiv <= $nbPages) {
echo ' · <a rel="nofollow" href="' . $url . "&" . $urlDiff . "&" . $urlVer . '&p=' . $pageSuiv . '">Next</a>';
}
?>
<br /> Sort by : <a rel="nofollow"
href="maplist.php?s=difficulty&<?php echo htmlspecialchars($urlDiff . "&" . $urlVer); ?>">difficulty</a>
· <a rel="nofollow"
href="maplist.php?s=quality&o=desc&<?php echo htmlspecialchars($urlDiff . "&" . $urlVer); ?>">quality</a>
· <a rel="nofollow"
href="maplist.php?s=name&<?php echo htmlspecialchars($urlDiff . "&" . $urlVer); ?>">name</a>
· <a rel="nofollow"
href="maplist.php?s=date&<?php echo htmlspecialchars($urlDiff . "&" . $urlVer); ?>">date</a>
<?php
// Pas de lien pour l'ordre décroissant si tri par défaut (points)
if ($_GET ["s"]) {
echo "(";
if ($_GET ["o"] == "desc")
echo '<a rel="nofollow" href="maplist.php?o=asc&s=' . htmlspecialchars ( $_GET ["s"] . "&" . $urlDiff . "&" . $urlVer ) . '">ascending order</a>';
else
echo '<a rel="nofollow" href="maplist.php?o=desc&s=' . htmlspecialchars ( $_GET ["s"] . "&" . $urlDiff . "&" . $urlVer ) . '">descending order</a>';
echo ")";
}
?>
<br /> Search by difficulty: <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlVer); ?>&diffMin=1&diffMax=1.5">very
easy</a> · <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlVer); ?>&diffMin=1.5&diffMax=2.5">easy</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlVer); ?>&diffMin=2.5&diffMax=3.5">medium</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlVer); ?>&diffMin=3.5&diffMax=4.5">hard</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlVer); ?>&diffMin=4.5&diffMax=5">extreme</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlVer); ?>">all</a>
<br /> Minecraft version compatibility: <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlDiff); ?>&verMax=8">1.8</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlDiff); ?>&verMax=9">1.9</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlDiff); ?>&verMax=10">1.10</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlDiff); ?>&verMax=11">1.11</a>
· <a rel="nofollow"
href="<?php echo htmlspecialchars($url . "&" . $urlDiff); ?>&verMax=12">1.12</a>
</div>
<?php
}
navigation ();
if ($nbMaps < 1) {
?>
<div class="avertissement">
0 maps to display with your criteria (<a href="maplist.php">reset</a>).
</div>
<?php
}
?>
<table>
<?php
$reponse = $bdd->prepare ( "
SELECT m.id idMap, m.nom nomMap, s.id idServ, s.nom nomServ, s.etat etatServ, m.createur createurMap, m.contributeurs contributeursMap, m.image imageMap, m.difficulte difficulte, m.qualite qualite, m.versionMin versionMin, m.verConversion verConversion
FROM maps m
INNER JOIN serveurs s ON m.idServOrigine = s.id
WHERE m.etat = 'disponible' AND difficulte >= :diffMin AND difficulte < :diffMax AND verConversion <= :verMax
ORDER BY " . $tri . " " . $sens . ", m.points DESC, m.id DESC LIMIT :borneInf, " . MAPS_PAR_PAGE . "
" );
$reponse->bindParam ( ':diffMin', $diffMin, PDO::PARAM_INT );
$reponse->bindParam ( ':diffMax', $diffMax, PDO::PARAM_INT );
$reponse->bindParam ( ':verMax', $verMax, PDO::PARAM_INT );
$reponse->bindParam ( ':borneInf', $borneInf, PDO::PARAM_INT );
$reponse->execute () or die ( "SQL error 186" );
while ( $donnees = $reponse->fetch () ) {
afficherLigneMap ( $donnees );
}
$reponse->closeCursor ();
?>
<tr class="ligneSupplementaire">
<td colspan="3"><a href="doc/add-map.php">Add my parkour map</a></td>
</tr>
</table>
<?php navigation(); ?>
</section>
<?php include_once 'includes/bas.php'; ?>