-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCatalog.php
448 lines (394 loc) · 18 KB
/
Catalog.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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
<?php
require_once 'api/web/config.php';
include 'api/web/header.php';
if (isset($_REQUEST['m'])) {
$m= $_REQUEST['m'];
switch ($m){
case "TopFavorites":
$mthing = "Top Favorites";
$mthing3 = "TopFavorites";
break;
case "BestSelling":
$mthing = "Best Selling";
$mthing3 = "BestSelling";
break;
case "RecentlyUpdated":
$mthing = "Recently Updated";
$mthing3 = "RecentlyUpdated";
$bthing2 = 0;
break;
case "ForSale":
$mthing = "For Sale";
$mthing3 = "ForSale";
break;
default:
$mthing = "Top Favorites";
$mthing3 = "TopFavorites";
$bthing2 = 0;
break;
}
} else {
$mthing = "Top Favorites";
$mthing3 = "TopFavorites";
$bthing2 = 0;
$m= null;
}
if (isset($_REQUEST['c'])) {
$c= (int)$_REQUEST['c'];
switch($c){
case 7:
$tthing = "Heads";
$bthing = "7";
break;
case 8:
$tthing = "Faces";
$bthing = "8";
break;
case 1:
$tthing = "Hats";
$bthing = "1";
break;
case 2:
$tthing = "T-Shirts";
$bthing = "2";
break;
case 5:
$tthing = "Shirts";
$bthing = "5";
break;
case 6:
$tthing = "Pants";
$bthing = "6";
break;
case 4:
$tthing = "Decals";
$bthing = "4";
break;
case 3:
$tthing = "Models";
$bthing = "3";
break;
case 20:
$tthing = "Places";
$bthing = "20";
break;
case 20:
$tthing = "Places";
$bthing = "9";
break;
default:
$tthing = "Hats";
$bthing = "1";
break;
}
} else {
$tthing = "Hats";
$bthing = "1";
$c =null;
}
$type2 = null;
if (isset($tthing)) {
switch ($tthing) {
case "Heads":
$type2 = "head";
break;
case "Faces":
$type2 = "face";
break;
case "Hats":
$type2 = "hat";
break;
case "T-Shirts":
$type2 = "tshirt";
break;
case "Shirts":
$type2 = "shirt";
break;
case "Pants":
$type2 = "pants";
break;
case "Decals":
$type2 = "decal";
break;
case "Models":
$type2 = "model";
break;
case "Places":
$type2 = "place";
break;
default:
$type2 = "hat";
break;
}
}
$sqlthing = "SELECT * FROM catalog WHERE `type` = :type2";
$params = ['type2' => $type2];
if (isset($_GET['m'])) {
switch ($m) {
case "ForSale":
$sqlthing .= " AND isoffsale = 0";
break;
} }
if(!empty($_REQUEST['q'])) {
$search = htmlspecialchars(strtolower($_REQUEST['q']), ENT_QUOTES, 'UTF-8');
$search2isuck = htmlspecialchars(($_REQUEST['q']), ENT_QUOTES, 'UTF-8');
}
if (!empty($search)) {
$sqlthing .= " AND (LOWER(name) LIKE :search)";
$params['search'] = '%' . $search . '%';
}
$stmt = $con->prepare($sqlthing);
$stmt->execute($params);
$results = $stmt->fetchAll();
$resultsperpage = 20;
$usercount = count($results);
$numberofpages = ceil($usercount / $resultsperpage);
$page = isset($_GET['p']) ? (int)$_GET['p'] : 1;
$page = max(min($page, $numberofpages), 1);
$offset = ($page - 1) * $resultsperpage;
$currentResults = array_slice($results, $offset, $resultsperpage);
?>
<div id="CatalogContainer" style="margin-top: 10px;">
<form action="" method="POST">
<div id="SearchBar" class="SearchBar">
<span class="SearchBox">
<input name="q" type="text" maxlength="100" id="ctl00_cphGoldblox_SearchTextBox" class="TextBox" value="<?php if(!empty($search)) { ?><?= $search2isuck;?><?php } ?>">
</span>
<span class="SearchButton">
<input type="submit" name="ctl00$cphGoldblox$SearchButton" value="Search" id="ctl00_cphGoldblox_SearchButton">
</span>
<span class="SearchLinks">
<sup><a id="ctl00_cphGoldblox_ResetSearchButton" href="/Browse.aspx">Reset</a> | </sup>
<a href="#" class="tips"><sup>Tips</sup>
<span>
Exact Phrase: "red brick"<br>
Find ALL Terms: red and brick =OR= red + brick<br>
Find ANY Term: red or brick =OR= red | brick<br>
Wildcard Suffix: tel* (Finds teleport, telamon, telephone, etc.)<br>
Terms Near each other: red near brick =OR= red ~ brick<br>
Excluding Terms: red and not brick =OR= red - brick<br>
Grouping operations: brick and (red or blue) =OR= brick + (red | blue)<br>
Combinations: "red brick" and not (tele* or tower) =OR= "red brick" - (tele* | tower)<br>
Wildcard Prefix is NOT supported: *port will not find teleport, airport, etc.
</span>
</a>
</span>
</div>
</form>
<div class="pt-3"></div>
<div class="DisplayFilters">
<h2>Catalog</h2>
<title>GOLDBLOX - Catalog</title>
<div id="BrowseMode">
<h4><a id="ctl00_cphGoldblox_rbxCatalog_CafePressHyperLink" href="#">Buy GOLDBLOX Stuff!</a></h4>
<h4><a id="ctl00_cphGoldblox_rbxCatalog_CafePressHyperLink" href="#">Buy GOLDBUX!</a></h4>
<h4><a id="ctl00_cphGoldblox_rbxCatalog_CafePressHyperLink" href="/Marketplace/TradeCurrency.aspx">Trade Currency!</a></h4>
<h4>Browse</h4>
<?php $sel = '<img id="ctl00_cphGoldblox_rbxGames_MostPopularBullet" class="GamesBullet" src="/images/games_bullet.png" border="0"/>'; ?>
<ul>
<li><?php if($mthing == "Top Favorites"){ echo $sel; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=TopFavorites&c=<?=( $bthing);?>"><?php if($mthing == "Top Favorites"){?><b><?}?>Top Favorites<?php if($mthing == "Top Favorites"){?></b><?}?></a></li>
<li><?php if($mthing == "Best Selling"){ echo $sel; }?><a id="ctl00_cphGoldblox_rbxGames_hlTopFavorites" href="Catalog.aspx?m=BestSelling&c=<?=( $bthing);?>"><?php if($mthing == "Best Selling"){?><b><?}?>Best Selling<?php if($mthing == "Best Selling"){?></b><?}?></a></li>
<li><?php if($mthing == "Recently Updated"){ echo $sel; }?><a id="ctl00_cphGoldblox_rbxGames_hlRecentlyUpdated" href="Catalog.aspx?m=RecentlyUpdated&c=<?=($bthing);?>"><?php if($mthing == "Recently Updated"){?><b><?}?>Recently Updated<?php if($mthing == "Recently Updated"){?></b><?}?></a></li>
<li><?php if($mthing == "For Sale"){ echo $sel; }?><a id="ctl00_cphGoldblox_rbxGames_hlRecentlyUpdated" href="Catalog.aspx?m=ForSale&c=<?=($bthing);?>"><?php if($mthing == "For Sale"){?><b><?}?>For Sale<?php if($mthing == "For Sale"){?></b><?}?></a></li>
<li><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="#">Public Domain</a></li>
</ul>
</div>
<div id="Category">
<h4>Category</h4>
<?php $sel2 = '<img id="ctl00_cphGoldblox_rbxGames_TimespanNowBullet" class="GamesBullet" src="/images/games_bullet.png" border="0"/>'; ?>
<ul>
<li><?php if($tthing == "Heads"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?=($mthing3);?>&c=7"><?php if($tthing == "Heads"){?><b><?}?>Heads<?php if($tthing == "Heads"){?></b><?}?></a></li>
<li><?php if($tthing == "Faces"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?=($mthing3);?>&c=8"><?php if($tthing == "Faces"){?><b><?}?>Faces<?php if($tthing == "Faces"){?></b><?}?></a></li>
<li><?php if($tthing == "Hats"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?=($mthing3);?>&c=1"><?php if($tthing == "Hats"){?><b><?}?>Hats<?php if($tthing == "Hats"){?></b><?}?></a></li>
<li><?php if($tthing == "T-Shirts"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?=($mthing3);?>&c=2"><?php if($tthing == "T-Shirts"){?><b><?}?>T-Shirts<?php if($tthing == "T-Shirts"){?></b><?}?></a></li>
<li><?php if($tthing == "Shirts"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?=($mthing3);?>&c=5"><?php if($tthing == "Shirts"){?><b><?}?>Shirts<?php if($tthing == "Shirts"){?></b><?}?></a></li>
<li><?php if($tthing == "Pants"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?=($mthing3);?>&c=6"><?php if($tthing == "Pants"){?><b><?}?>Pants<?php if($tthing == "Pants"){?></b><?}?></a></li>
<li><?php if($tthing == "Decals"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?= str_replace(' ', '', $mthing); ?>&c=4"><?php if($tthing == "Decals"){?><b><?}?>Decals<?php if($tthing == "Decals"){?></b><?}?></a></li>
<li><?php if($tthing == "Places"){ echo $sel2; }?><a id="ctl00_cphGoldblox_rbxGames_hlMostPopular" href="Catalog.aspx?m=<?= str_replace(' ', '', $mthing); ?>&c=20"><?php if($tthing == "Places"){?><b><?}?>Places<?php if($tthing == "Places"){?></b><?}?></a></li>
</ul>
</div>
</div>
<?php if($usercount == 0) { ?>
<?php
if ($m === 'TopFavorites' || !$m) {
echo '<span id="ctl00_cphGoldblox_rbxCatalog_AssetsDisplaySetLabel" class="AssetsDisplaySet">';
echo 'Favorite ' . htmlspecialchars($tthing);
echo '</span>';
} elseif (!$m) {
echo '<span id="ctl00_cphGoldblox_rbxCatalog_AssetsDisplaySetLabel" class="AssetsDisplaySet">';
echo 'Favorite ' . htmlspecialchars($tthing);
echo '</span>';
} elseif ($m === 'ForSale') {
echo '<span id="ctl00_cphGoldblox_rbxCatalog_AssetsDisplaySetLabel" class="AssetsDisplaySet">';
echo htmlspecialchars($tthing) . ' ' . htmlspecialchars($mthing);
echo '</span>';
} else {
echo '<span id="ctl00_cphGoldblox_rbxCatalog_AssetsDisplaySetLabel" class="AssetsDisplaySet">';
echo htmlspecialchars($mthing) . ' ' . htmlspecialchars($tthing);
echo '</span>';
}
?><br><br>
No results found.
<?php }else{ ?>
<div class="Assets">
<?php
if ($m === 'TopFavorites' || !$m) {
echo '<span id="ctl00_cphGoldblox_rbxCatalog_AssetsDisplaySetLabel" class="AssetsDisplaySet">';
echo 'Favorite ' . htmlspecialchars($tthing);
echo '</span>';
} elseif ($m === 'ForSale') {
echo '<span id="ctl00_cphGoldblox_rbxCatalog_AssetsDisplaySetLabel" class="AssetsDisplaySet">';
echo htmlspecialchars($tthing) . ' ' . htmlspecialchars($mthing);
echo '</span>';
} else {
echo '<span id="ctl00_cphGoldblox_rbxCatalog_AssetsDisplaySetLabel" class="AssetsDisplaySet">';
echo htmlspecialchars($mthing) . ' ' . htmlspecialchars($tthing);
echo '</span>';
}
?>
<div id="ctl00_cphGoldblox_rbxCatalog_HeaderPagerPanel" class="HeaderPager">
<?php if($page > 1){if($numberofpages > 0){?><a id="ctl00_cphGoldblox_rbxGames_hlHeaderPager_Next" href="Catalog.aspx?m=<?=($mthing3);?>&c=<?=($bthing);?>&p=<?=$page -1;?>"><span class="NavigationIndicators"><<</span> Previous</a><?}}?>
<span id="ctl00_cphGoldblox_rbxGames_HeaderPagerLabel">Page <?=$page;?> of <?=$numberofpages;?>:</span>
<?php if($page < $numberofpages){?><a id="ctl00_cphGoldblox_rbxGames_hlHeaderPager_Next" href="Catalog.aspx?m=<?=($mthing3);?>&c=<?=($bthing);?>&p=<?=$page +1;?>">Next <span class="NavigationIndicators">>></span></a><?}?>
</div>
<table id="ctl00_cphGoldblox_rbxCatalog_AssetsDataList" cellspacing="0" align="Center" border="0" width="610">
<?php
$page = isset($page) ? (int)$page : 1;
$resultsperpage = isset($resultsperpage) ? (int)$resultsperpage : 10;
$thispagefirstresult = ($page - 1) * $resultsperpage;
$type2 = isset($type2) ? $type2 : '';
switch ($m) {
case "ForSale":
$sql = "SELECT * FROM catalog WHERE `type` = :type2 AND isoffsale = 0";
if (!empty($search)) $sql .= " AND LOWER(name) LIKE :search";
$sql .= " ORDER BY id DESC , catalog.id DESC LIMIT :start, :limit";
break;
case "BestSelling":
$sql = "SELECT catalog.*, COUNT(owned_items.itemid) AS owned
FROM catalog
LEFT JOIN owned_items ON catalog.id = owned_items.itemid
WHERE catalog.`type` = :type2";
if (!empty($search)) $sql .= " AND LOWER(catalog.name) LIKE :search";
$sql .= " GROUP BY catalog.id ORDER BY owned DESC, catalog.id DESC LIMIT :start, :limit";
break;
case "RecentlyUpdated":
$sql = "SELECT * FROM catalog WHERE `type` = :type2";
if (!empty($search)) $sql .= " AND LOWER(name) LIKE :search";
$sql .= " ORDER BY creation_date DESC, catalog.id DESC LIMIT :start, :limit";
break;
default:
$sql = "SELECT catalog.*, COUNT(favorites.itemid) AS favorites
FROM catalog
LEFT JOIN favorites ON catalog.id = favorites.itemid
WHERE catalog.`type` = :type2";
if (!empty($search)) $sql .= " AND LOWER(catalog.name) LIKE :search";
$sql .= " GROUP BY catalog.id ORDER BY favorites DESC, catalog.id DESC LIMIT :start, :limit";
break;
}
$stmt = $con->prepare($sql);
$stmt->bindParam(':type2', $type2, PDO::PARAM_STR);
if (!empty($search)) {
$searchParam = "%$search%";
$stmt->bindParam(':search', $searchParam, PDO::PARAM_STR);
}
$stmt->bindParam(':start', $thispagefirstresult, PDO::PARAM_INT);
$stmt->bindParam(':limit', $resultsperpage, PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($result) > 0) {
$count = 0;
echo '<tr>';
foreach ($result as $row) {
if ($count % 4 == 0 && $count != 0) {
echo '</tr><tr>';
}
$creators = $con->prepare("SELECT * FROM users WHERE id = :creatorid");
$creators->bindParam(':creatorid', $row['creatorid'], PDO::PARAM_INT);
$creators->execute();
$creator = $creators->fetch(PDO::FETCH_ASSOC);
$count++;
?>
<td valign="top">
<div class="Asset">
<div class="AssetThumbnail">
<a id="AssetThumbnailHyperLink" title="<?= $row['name']; ?>" href="/Item.aspx?ID=<?= $row['id']; ?>"
style="display:inline-block; cursor:pointer; width: 110px; height: 110px; overflow: hidden;">
<img src="/Thumbs/Asset.ashx?assetId=<?= $row['id']; ?>&isSmall" id="img" alt="<?= $row['name']; ?>"
style="width: 110px; height: 110px; object-fit: cover; object-position: center center; border: 0;">
</a>
</div>
<div class="AssetDetails">
<strong><a id="ctl00_cphGoldblox_rbxUserAssetsPane_UserAssetsDataList_ctl06_AssetNameHyperLink" href="/Item.aspx?ID=<?= $row['id']; ?>"><?= $row['name']; ?></a></strong>
<div class="AssetLastUpdate"><span class="Label">Updated:</span> <span class="Detail">
<?php
$updated = context::updated($row['creation_date']);
?>
<?php echo $updated ?>
</span></div>
<div class="AssetCreator"><span class="Label">Creator:</span> <span class="Detail"><a id="ctl00_cphGoldblox_rbxCatalog_AssetsDataList_ctl00_GameCreatorHyperLink" href="/User.aspx?ID=<?= $creator['id']; ?>"><?= htmlspecialchars($creator['username']); ?></a></span></div>
<?php
$ownedq = "SELECT * FROM owned_items WHERE itemid = :itemid";
$owneds = $con->prepare($ownedq);
$owneds->execute([':itemid' => $row['id']]);
$ownedc = $owneds->rowCount();
?>
<div class="AssetsSold"><span class="Label">Number Owned:</span> <span class="Detail"><?= htmlspecialchars($ownedc); ?></span></div>
<?php
$favoritesq = "SELECT * FROM favorites WHERE itemid = :itemid";
$favoritese = $con->prepare($favoritesq);
$favoritese->execute([':itemid' => $row['id']]);
$favorites = $favoritese->rowCount();
?>
<div class="AssetFavorites"><span class="Label">Favorited:</span> <span class="Detail"><?= htmlspecialchars($favorites); ?> time<?php if ($favorites != 1) {
echo "s";
} ?></span></div>
<?php if ($row['isoffsale'] == 0 && $row['type'] != 'place') { ?>
<?php if ($row['price'] > 0 || $row['price2'] > 0) { ?>
<?php if ($row['buywith2'] == "GOLDBUX") { ?>
<div class="AssetPrice" style="width:120px;height:11px">
<span class="PriceInGOLDBUX">G$: <?= number_format($row['price2']) ?></span>
</div>
<?php } ?>
<?php if ($row['buywith'] == "tix") { ?>
<div class="AssetPrice" style="width:120px;height:11px">
<span class="PriceInTickets">Tx: <?= number_format($row['price']) ?></span>
</div>
<?php } ?>
<?php } else { ?>
<div class="AssetPrice" style="width:120px;height:11px">
<span class="PriceForFree">Free</span>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
</td>
<?php
}
if ($count < 4) {
$pisscock = 4 - $count;
for ($i = 0; $i < $pisscock; $i++) {
?>
<td valign="top">
<div class="Asset">
</div>
</td>
<?php
}
}
echo '</tr>';
}
?>
</table>
<div id="ctl00_cphGoldblox_rbxCatalog_FooterPagerPanel" class="FooterPager">
<?php if($page > 1){if($numberofpages > 0){?><a id="ctl00_cphGoldblox_rbxGames_hlHeaderPager_Next" href="Catalog.aspx?m=<?=($mthing3);?>&c=<?=($bthing);?>&p=<?=$page -1;?>"><span class="NavigationIndicators"><<</span> Previous</a><?}}?>
<span id="ctl00_cphGoldblox_rbxGames_HeaderPagerLabel">Page <?=$page;?> of <?=$numberofpages;?>:</span>
<?php if($page < $numberofpages){?><a id="ctl00_cphGoldblox_rbxGames_hlHeaderPager_Next" href="Catalog.aspx?m=<?=($mthing3);?>&c=<?=($bthing);?>&p=<?=$page +1;?>">Next <span class="NavigationIndicators">>></span></a><?}?>
</div><?php } ?>
</div>
<div id="AdvertisingSkyscraper">
</div>
<div style="clear: both;"/>
</div>
</div>
<? include 'api/web/footer.php'; ?>