-
Notifications
You must be signed in to change notification settings - Fork 0
/
tab_favorites.php
312 lines (301 loc) · 13.4 KB
/
tab_favorites.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
include('simpleimage.php');
function imageResize($filename, $cleanFilename, $target)
{
if(!file_exists($cleanFilename))
{
$dims = getimagesize($filename);
$width = $dims[0];
$height = $dims[1];
//takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size image
if ($width > $height)
{
$percentage = ($target / $width);
}
else
{
$percentage = ($target / $height);
}
//gets the new value and applies the percentage, then rounds the value
$width = round($width * $percentage);
$height = round($height * $percentage);
$image = new SimpleImage();
$image->load($filename);
$image->resize($width, $height);
$image->save($cleanFilename);
$image = null;
}
//returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
return "src=\"$cleanFilename\"";
}
?>
<div>
<?php
if($user->favorites == "")
{
?>
<div style="text-align: center; width: 500px; padding: 15px; margin:30px auto; background-color: #eee; border: 1px solid #666;">
<h3><em>Whoops!</em> You haven't added any favorites yet.</h3>
<p>Consider visiting some games pages and favoriting some.</p>
</div>
<?php
}
else
{
$increment = "odd";
$counter = 0;
$favoritesArray = explode(",", $user->favorites);
?>
<div style="text-align: center; width: 800px; padding: 15px; margin:30px auto; background-color: #eee; border: 1px solid #666;">
<div>
<h2 class="arcade" style="float: left;"><?=$user->username?>'s Favorites</h2>
<div style="width: 80px; text-align: center; float: right;">
<a href="<?=$baseurl?>?tab=favorites&favoritesview=table"><img src="<?=$baseurl?>/images/common/icons/viewicons/table.png" alt="table"/></a>
<p style="margin-top: 2px;"><a href="<?=$baseurl?>?tab=favorites&favoritesview=table" style="color: #dd4400">Table</a></p>
</div>
<div style="width: 80px; text-align: center; float: right;">
<a href="<?=$baseurl?>?tab=favorites&favoritesview=banner"><img src="<?=$baseurl?>/images/common/icons/viewicons/banner.png" alt="banner"/></a>
<p style="margin-top: 2px;"><a href="<?=$baseurl?>?tab=favorites&favoritesview=banner" style="color: #dd4400">Banner</a></p>
</div>
<div style="width: 80px; text-align: center; float: right;">
<a href="<?=$baseurl?>?tab=favorites&favoritesview=boxart"><img src="<?=$baseurl?>/images/common/icons/viewicons/boxart.png" alt="boxart"/></a>
<p style="margin-top: 2px;"><a href="<?=$baseurl?>?tab=favorites&favoritesview=boxart" style="color: #dd4400">Boxart</a></p>
</div>
<div style="width: 80px; text-align: center; float: right;">
<a href="<?=$baseurl?>?tab=favorites&favoritesview=tile"><img src="<?=$baseurl?>/images/common/icons/viewicons/tile.png" alt="tile"/></a>
<p style="margin-top: 2px;"><a href="<?=$baseurl?>?tab=favorites&favoritesview=tile" style="color: #dd4400">Tile</a></p>
</div>
<div style="clear: both;"></div>
</div>
<?
if($favoritesview != "table")
{
foreach($favoritesArray as $favoriteID)
{
if($gameResult = mysql_query(" SELECT g.id, g.GameTitle, p.name, p.icon FROM games as g, platforms as p WHERE g.id = '$favoriteID' AND g.Platform = p.id"))
{
if($game = mysql_fetch_object($gameResult))
{
if($favoritesview == "tile")
{
if($boxartResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '$favoriteID' AND b.filename LIKE '%boxart%front%' LIMIT 1 "))
{
$boxart = mysql_fetch_object($boxartResult);
}
?>
<div style="width: 356px; height: 102px; float: left; padding: 10px; margin: 10px; border-radius: 16px; border: 2px solid #333; background-color: #fff;">
<div style="height: 102px; float:left">
<?php
if($boxart->filename != "")
{
?>
<img <?=imageResize("$baseurl/banners/$boxart->filename", "banners/_favcache/_tile-view/$boxart->filename", 100)?> alt="<?=$game->GameTitle?> Boxart" style="border: 1px solid #666;"/>
<?php
}
else
{
?>
<img src="<?=$baseurl?>/images/common/placeholders/boxart_blank.png" alt="<?=$game->GameTitle?> Boxart" style="width:70px; height: 100px; border: 1px solid #666;"/>
<?php
}
?>
</div>
<h3><a href="<?=$baseurl?>?tab=game&id=<?=$game->id?>" style="color: #000;"><?=$game->GameTitle?></a></h3>
<p><img src="<?=$baseurl?>/images/common/consoles/png24/<?=$game->icon?>" alt="<?=$game->name?>" style="vertical-align: -6px;" /> <?=$game->name?></p>
<?php
$platformIdQuery = mysql_query("SELECT * FROM platforms WHERE id = '$game->Platform' LIMIT 1");
$platformIdResult = mysql_fetch_object($platformIdQuery);
$boxartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$game->id' AND banners.filename LIKE '%front%' LIMIT 1");
$boxartResult = mysql_num_rows($boxartQuery);
$fanartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$game->id' AND keytype = 'fanart' LIMIT 1");
$fanartResult = mysql_num_rows($fanartQuery);
$bannerQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$game->id' AND keytype = 'series' LIMIT 1");
$bannerResult = mysql_num_rows($bannerQuery);
if($boxartResult != 0){ ?>Boxart: <img src="images/common/icons/tick_16.png" alt="Yes" /> | <?php } else{ ?>Boxart: <img src="images/common/icons/cross_16.png" alt="No" /> | <?php }
if($fanartResult != 0){ ?>Fanart: <img src="images/common/icons/tick_16.png" alt="Yes" /> | <?php } else{ ?>Fanart: <img src="images/common/icons/cross_16.png" alt="No" /> | <?php }
if($bannerResult != 0){ ?>Banner: <img src="images/common/icons/tick_16.png" alt="Yes" /><?php } else{ ?>Banner: <img src="images/common/icons/cross_16.png" alt="No" /><?php }?>
<div style="clear: both;"></div>
</div>
<?php
if($increment == "even")
{
?>
<div style="clear: both;"></div>
<?
}
}
elseif($favoritesview == "boxart")
{
if($boxartResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '$favoriteID' AND b.filename LIKE '%boxart%front%' LIMIT 1 "))
{
$boxart = mysql_fetch_object($boxartResult);
}
?>
<div style="width: 222px; min-height: 280px; float: left; padding: 10px; margin: 10px; border-radius: 16px; border: 2px solid #333; background-color: #fff;">
<div style="height: 200px;">
<?php
if($boxart->filename != "")
{
?>
<img <?=imageResize("$baseurl/banners/$boxart->filename", "banners/_favcache/_boxart-view/$boxart->filename", 200)?> alt="<?=$game->GameTitle?> Boxart" style="border: 1px solid #666;"/>
<?php
}
else
{
?>
<img src="<?=$baseurl?>/images/common/placeholders/boxart_blank.png" alt="<?=$game->GameTitle?> Boxart" style="width:140px; height: 200px; border: 1px solid #666;"/>
<?php
}
?>
</div>
<h3><a href="<?=$baseurl?>?tab=game&id=<?=$game->id?>" style="color: #000;"><?=$game->GameTitle?></a></h3>
<p><img src="<?=$baseurl?>/images/common/consoles/png24/<?=$game->icon?>" alt="<?=$game->name?>" style="vertical-align: -6px;" /> <?=$game->name?></p>
<div style="clear: both;"></div>
</div>
<?php
if($counter == 2)
{
$counter = 0;
?>
<div style="clear: both;"></div>
<?
}
else
{
$counter++;
}
}
elseif($favoritesview == "banner")
{
if($bannerResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '$favoriteID' AND b.keytype = 'series' LIMIT 1 "))
{
$banner = mysql_fetch_object($bannerResult);
}
?>
<div style="width: 222px; min-height: 80px; float: left; padding: 10px; margin: 10px; border-radius: 16px; border: 2px solid #333; background-color: #fff;">
<div style="height: 47px;">
<?php
if($banner->filename != "")
{
?>
<img <?=imageResize("$baseurl/banners/$banner->filename", "banners/_favcache/_banner-view/$banner->filename", 200)?> alt="<?=$game->GameTitle?> Boxart" style="border: 1px solid #666;"/>
<?php
}
else
{
?>
<img src="<?=$baseurl?>/images/common/placeholders/banner_blank.png" alt="<?=$game->GameTitle?> Boxart" style="width:200px; height: 47px; border: 1px solid #666;"/>
<?php
}
?>
</div>
<h3><a href="<?=$baseurl?>?tab=game&id=<?=$game->id?>" style="color: #000;"><?=$game->GameTitle?></a></h3>
<p><img src="<?=$baseurl?>/images/common/consoles/png24/<?=$game->icon?>" alt="<?=$game->name?>" style="vertical-align: -6px;" /> <?=$game->name?></p>
<div style="clear: both;"></div>
</div>
<?php
if($counter == 2)
{
$counter = 0;
?>
<div style="clear: both;"></div>
<?
}
else
{
$counter++;
}
}
if($increment == "odd")
{
$increment = "even";
}
else
{
$increment = "odd";
}
}
}
}
}
elseif($favoritesview == "table")
{
?>
<table width="100%" border="0" cellspacing="1" cellpadding="7" id="listtable">
<tr>
<td class="head arcade" align="center">ID</td>
<td class="head arcade">Game Title</td>
<td class="head arcade">P</td>
<td class="head arcade">Genre</td>
<td class="head arcade">ESRB</td>
<td class="head arcade">Boxart</td>
<td class="head arcade">Fanart</td>
<td class="head arcade">Banner</td>
</tr>
<?php
foreach($favoritesArray as $favoriteID)
{
if($gameResult = mysql_query(" SELECT g.id, g.GameTitle, g.Genre, g.Rating, p.name, p.icon FROM games as g, platforms as p WHERE g.id = '$favoriteID' AND g.Platform = p.id"))
{
if($game = mysql_fetch_object($gameResult))
{
$boxartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$game->id' AND banners.filename LIKE '%front%' LIMIT 1");
$boxartResult = mysql_num_rows($boxartQuery);
$fanartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$game->id' AND keytype = 'fanart' LIMIT 1");
$fanartResult = mysql_num_rows($fanartQuery);
$bannerQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$game->id' AND keytype = 'series' LIMIT 1");
$bannerResult = mysql_num_rows($bannerQuery);
if ($class == 'odd') { $class = 'even'; } else { $class = 'odd'; }
?>
<tr>
<td align="center" class="<?php echo $class; ?>"><?php echo $game->id; ?></td>
<td class="<?php echo $class; ?>"><a href="<?php echo $baseurl; ?>/?tab=game&id=<?php echo $game->id; ?>&lid=1"><?php echo $game->GameTitle; ?></a></td>
<td class="<?php echo $class; ?>"><img src="images/common/consoles/png16/<?php echo $game->icon; ?>" alt="<?php echo $game->name; ?>" style="vertical-align: middle;" /> <?php echo $platformIdResult->name; ?></td>
<td class="<?php echo $class; ?>">
<?php if(!empty($game->Genre))
{
$mainGenre = explode("|", $game->Genre);
if(!empty($stringGenres))
{
for($i = 0; $i <= count($mainGenre); $i++)
{
if($mainGenre[$i] == $stringGenres)
{
if(strlen($mainGenre[$i]) > 15)
{
$mainGenre[$i] = substr($mainGenre[$i], 0, 15) . "...";
}
echo $mainGenre[$i];
}
}
}
else
{
if(strlen($mainGenre[1]) > 15)
{
$mainGenre[1] = substr($mainGenre[1], 0, 15) . "...";
}
echo $mainGenre[1];
}
}
?>
</td>
<td class="<?php echo $class; ?>"><?php echo $game->Rating; ?></td>
<td align="center" class="<?php echo $class; ?>"><?php if($boxartResult != 0){ ?><img src="images/common/icons/tick_16.png" alt="Yes" /><?php } else{ ?><img src="images/common/icons/cross_16.png" alt="Yes" /><?php }?></td>
<td align="center" class="<?php echo $class; ?>"><?php if($fanartResult != 0){ ?><img src="images/common/icons/tick_16.png" alt="Yes" /><?php } else{ ?><img src="images/common/icons/cross_16.png" alt="Yes" /><?php }?></td>
<td align="center" class="<?php echo $class; ?>"><?php if($bannerResult != 0){ ?><img src="images/common/icons/tick_16.png" alt="Yes" /><?php } else{ ?><img src="images/common/icons/cross_16.png" alt="Yes" /><?php }?></td>
</tr>
<?php
}
}
}
?>
</table>
<?php
}
}
?>
<div style="clear: both;"></div>
<h3 class="arcade" style="color: #ff6600;">Total Favorites: <?=count($favoritesArray)?></h3>
</div>
</div>