-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrelease.php
227 lines (201 loc) · 10.1 KB
/
release.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
#include dit script als je de pagina alleen kunt zien als je ingelogd bent.
include('includes/security.php');
#Als je geen pokemon bij je hebt, terug naar index.
if($gebruiker['in_hand'] == 0) header('Location: index.php');
$page = 'release';
#Goeie taal erbij laden voor de page
include_once('language/language-pages.php');
if($gebruiker['item_over'] < 1){
echo '<div class="blue">'.$txt['alert_itemplace'].'</div>';
}
if(isset($_POST['submit'])){
$update = $db->prepare("SELECT wild_id, user_id, gehecht, gevongenmet FROM pokemon_speler WHERE id = :releaseId");
$update->bindValue(':releaseId', $_POST['release'], PDO::PARAM_INT);
$update->execute();
$update = $update->fetch(PDO::FETCH_ASSOC);
if(empty($_POST['release']))
echo '<div class="red">'.$txt['alert_no_pokemon_selected'].'</div>';
elseif($update['user_id'] != $_SESSION['id'])
echo' <div class="red">'.$txt['alert_not_your_pokemon'].'</div>';
elseif($update['gehecht'] == 1)
echo' <div class="red">'.$txt['alert_beginpokemon'].'</div>';
else{
#Ball teruggeven als er nog een itemplek over is
if($gebruiker['item_over'] > 0)
$giveBallBack = $db->prepare("UPDATE gebruikers_item SET `:pokeball`=`:pokeball`+'1' WHERE `user_id`=:uid");
$giveBallBack->bindValue(':pokeball', $update['gevongenmet'], PDO::PARAM_STR);
$giveBallBack->bindValue(':uid', $_SESSION['id'], PDO::PARAM_INT);
$giveBallBack->execute();
$getPokemon = $db->prepare("SELECT id FROM pokemon_speler WHERE wild_id='".$update['wild_id']."'");
$getPokemon->bindValue(':wildId', $update['wild_id'], PDO::PARAM_INT);
$getPokemon->execute();
if($getPokemon->fetchColumn() == 1)
update_pokedex($pokemon['wild_id'],'','release');
#Alles verwijderen
$deletePokemonSpeler = $db->prepare("DELETE FROM pokemon_speler WHERE id = :pokeId");
$deletePokemonSpeler->bindValue(':pokeId', $_POST['release'], PDO::PARAM_INT);
$deletePokemonSpeler->execute();
$deleteTransferlijst = $db->prepare("DELETE FROM transferlijst WHERE id = :pokeId");
$deleteTransferlijst->bindValue(':pokeId', $_POST['release'], PDO::PARAM_INT);
$deleteTransferlijst->execute();
$updatePokemonCount = $db->prepare("UPDATE `gebruikers` SET `aantalpokemon`=`aantalpokemon`-'1' WHERE `user_id` = :uid");
$updatePokemonCount->bindValue(':uid', $_SESSION['id'], PDO::PARAM_INT);
$updatePokemonCount->execute();
echo '<div class="green">'.$txt['success_release'].'</div>';
}
}
if(empty($_GET['subpage'])) $subpage = 1;
else $subpage = $_GET['subpage'];
#Max aantal leden per pagina
$max = 50;
$aantalSQL = $db->prepare("SELECT `id` FROM `pokemon_speler` WHERE `user_id`=:uid AND `opzak`='nee'");
$aantalSQL->bindValue(':uid', $_SESSION['id'], PDO::PARAM_INT);
$aantalSQL->execute();
$aantal = $aantalSQL->fetchColumn();
$aantal_paginas = ceil($aantal/$max);
if($aantal_paginas == 0) $aantal_paginas = 1;
$pagina = $subpage*$max-$max;
?>
<form method="post">
<center>
<?php echo $txt['title_text']; ?><br /><br />
<table width="390" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5"><center><strong><?php echo $txt['pokemon_team']; ?></strong></center><br /></td>
</tr>
<tr>
<td width="50" class="top_first_td"><?php echo $txt['#']; ?></td>
<td width="90" class="top_td"><?php echo $txt['pokemon']; ?></td>
<td width="120" class="top_td"><?php echo $txt['clamour_name']; ?></td>
<td width="60" class="top_td"><?php echo $txt['level']; ?></td>
<td width="70" class="top_td"><center><?php echo $txt['release']; ?></center></td>
</tr>
<?php
$tellerteam=0;
#Pokemon query ophalen
while($pokemon = $pokemon_sql->fetch(PDO::FETCH_ASSOC)){
$tellerteam++;
#Gegevens juist laden voor de pokemon
$pokemon = pokemonei($pokemon);
$pokemon['naam'] = pokemon_naam($pokemon['naam'],$pokemon['roepnaam']);
$popup = pokemon_popup($pokemon, $txt);
echo '<tr>
<td class="normal_first_td">'.$tellerteam.'.</td>
<td class="normal_td"><a href="#" class="tooltip" onMouseover="showhint(\''.$popup.'\', this)"><img src="'.$pokemon['animatie'].'" width=32 height=32></a></td>
<td class="normal_td">'.$pokemon['naam'].'</td>
<td class="normal_td">'.$pokemon['level'].'</td>
<td class="normal_td"><center><input type="radio" name="release" value="'.$pokemon['id'].'"></center></td>
</tr>';
}
if($tellerteam == 0)
echo '<tr>
<td colspan="5" class="normal_td">'.$txt['alert_no_pokemon_in_hand'].'</td>
</tr>';
?>
<tr>
<td colspan="9"><button type="submit" name="submit" class="button_mini" style="float:right;" ><?php echo $txt['button']; ?></button></td>
</tr>
</table>
<br /><br />
<table width="390" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5"><center><strong><?php echo $txt['pokemon_at_home']; ?></strong></center><br /></td>
</tr>
<tr>
<td width="50" class="top_first_td"><?php echo $txt['#']; ?></td>
<td width="90" class="top_td"><?php echo $txt['pokemon']; ?></td>
<td width="120" class="top_td"><?php echo $txt['clamour_name']; ?></td>
<td width="60" class="top_td"><?php echo $txt['level']; ?></td>
<td width="70" class="top_td"><center><?php echo $txt['release']; ?></center></td>
</tr>
<?
$poke = $db->prepare("SELECT pokemon_speler.*, `pokemon_wild`.`naam`, `pokemon_wild`.`type1`, `pokemon_wild`.`type2`
FROM `pokemon_speler`
INNER JOIN `pokemon_wild`
ON `pokemon_speler`.`wild_id` = `pokemon_wild`.`wild_id`
WHERE `pokemon_speler`.`user_id`=:uid AND `pokemon_speler`.`opzak`='nee' ORDER BY `pokemon_speler`.`wild_id` ASC LIMIT :page, :max");
$poke->bindParam(':uid', $_SESSION['id'], PDO::PARAM_INT);
$poke->bindValue(':page', $pagina, PDO::PARAM_INT);
$poke->bindValue(':max', $max, PDO::PARAM_INT);
$poke->execute();
#Teller op 0 zetten
$tellerhuis = 0;
for($j=$pagina+1; $pokemon = $poke->fetch(PDO::FETCH_ASSOC); $j++){
#Alle pokemons tellen
$tellerhuis++;
#Gegevens juist laden voor de pokemon
$pokemon = pokemonei($pokemon);
$pokemon['naam'] = pokemon_naam($pokemon['naam'],$pokemon['roepnaam']);
$popup = pokemon_popup($pokemon, $txt);
#Als pokemon geen baby is
echo '<tr>
<td class="normal_first_td">'.$tellerhuis.'.</td>
<td class="normal_td"><a href="#" class="tooltip" onMouseover="showhint(\''.$popup.'\', this)"><img src="'.$pokemon['animatie'].'" width=32 height=32></a></td>
<td class="normal_td">'.$pokemon['naam'].'</td>
<td class="normal_td">'.$pokemon['level'].'</td>
<td class="normal_td"><center><input type="radio" name="release" value="'.$pokemon['id'].'"></center></td>
</tr>';
}
if($tellerhuis == 0)
echo '<tr>
<td colspan="5" class="normal_td">'.$txt['alert_no_pokemon_at_home'].'</td>
</tr>';
?>
<tr>
<td colspan="9"><button type="submit" name="submit" class="button_mini" style="float:right;" ><?php echo $txt['button']; ?></button></td>
</tr>
<?
#Pagina systeem
$links = false;
$rechts = false;
echo '<tr><td colspan=5><center><br /><div class="sabrosus">';
if($subpage == 1)
echo '<span class="disabled"> < </span>';
else{
$back = $subpage-1;
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$_GET['page'].'&subpage='.$back.'"> < </a>';
}
for($i = 1; $i <= $aantal_paginas; $i++) {
if((2 >= $i) && ($subpage == $i))
echo '<span class="current">'.$i.'</span>';
elseif((2 >= $i) && ($subpage != $i))
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$_GET['page'].'&subpage='.$i.'">'.$i.'</a>';
elseif(($aantal_paginas-2 < $i) && ($subpage == $i))
echo '<span class="current">'.$i.'</span>';
elseif(($aantal_paginas-2 < $i) && ($subpage != $i))
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$_GET['page'].'&subpage='.$i.'">'.$i.'</a>';
else{
$max = $subpage+3;
$min = $subpage-3;
if($subpage == $i)
echo '<span class="current">'.$i.'</span>';
elseif(($min < $i) && ($max > $i))
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$_GET['page'].'&subpage='.$i.'">'.$i.'</a>';
else{
if($i < $subpage){
if(!$links){
echo '...';
$links = True;
}
}
else{
if(!$rechts){
echo '...';
$rechts = True;
}
}
}
}
}
if($aantal_paginas == $subpage)
echo '<span class="disabled"> > </span>';
else{
$next = $subpage+1;
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$_GET['page'].'&subpage='.$next.'"> > </a>';
}
echo "</div></center></td>";
?>
</table>
</center>
</form>