forked from TheGamesDB/TheGamesDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tab_recentgames.php
208 lines (185 loc) · 11 KB
/
tab_recentgames.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
<?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=\"$baseurl/$cleanFilename\"";
}
?>
<div id="gameHead">
<?php if($errormessage): ?>
<div class="error"><?= $errormessage ?></div>
<?php endif; ?>
<?php if($message): ?>
<div class="message"><?= $message ?></div>
<?php endif; ?>
<?php
//Google AdSense - Right of Main Content Skyscraper
include_once("adverts/adsense-leaderboard_content-top.php");
?>
<h1>Recently Updated Games</h1>
<?php
$recentResult = mysql_query(" SELECT g.*, p.name, p.icon, p.alias AS PlatformAlias FROM games AS g, platforms AS p WHERE g.Platform = p.id ORDER BY lastupdated DESC LIMIT 50 ");
$count = 1;
$recent = mysql_fetch_object($recentResult)
//echo "$recent->id, $recent->GameTitle, $recent->lastupdated <br />";
?>
<div style=" width: 90%; padding: 16px; margin: 10px auto 20px auto; border-radius: 4px; border: 1px solid #4f4f4f; background-color: #333;">
<?php
if($boxartResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '$recent->id' AND b.filename LIKE '%boxart%front%' LIMIT 1 "))
{
$boxart = mysql_fetch_object($boxartResult);
}
?>
<div style="height: 200px; float: left; padding-right: 12px; width: 202px; text-align: center;">
<?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>
<h2><?= $count ?>: <a style="color: orange; text-decoration: none;" href="<?= $baseurl ?>/game/<?= $recent->id ?>/"><?= $recent->GameTitle ?></a></h2>
<p><img src="<?=$baseurl?>/images/common/consoles/png24/<?=$recent->icon?>" alt="<?=$recent->name?>" style="vertical-align: -6px;" /> <a style="font-size: 14px; color: #fff;" href="<?= $baseurl; ?>/platform/<?php if(!empty($recent->PlatformAlias)) { echo $recent->PlatformAlias; } else { echo $recent->Platform; } ?>/"><?=$recent->name?></a>
<span style=" float: right; background-color: #333; padding: 6px; border-radius: 6px;">
<?php
$ratingquery = "SELECT AVG(rating) AS average, count(*) AS count FROM ratings WHERE itemtype='game' AND itemid=$recent->id";
$ratingresult = mysql_query($ratingquery) or die('Query failed: ' . mysql_error());
$rating = mysql_fetch_object($ratingresult);
for ($i = 2; $i <= 10; $i = $i + 2) {
if ($i <= $rating->average) {
print "<img src=\"$baseurl/images/game/star_on.png\" width=15 height=15 border=0 />";
}
else if ($rating->average > $i - 2 && $rating->average < $i) {
print "<img src=\"$baseurl/images/game/star_half.png\" width=15 height=15 border=0 />";
}
else {
print "<img src=\"$baseurl/images/game/star_off.png\" width=15 height=15 border=0 />";
}
}
?>
</span></p>
<p style="text-align: justify;"><?php if ($recent->Overview != "") { echo substr($recent->Overview, 0, 410) . "..."; } else { echo "<br />No Overview Available...<br /><br />"; } ?></p>
<div>
<p>
<?php
$boxartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND banners.filename LIKE '%front%' LIMIT 1");
$boxartResult = mysql_num_rows($boxartQuery);
$fanartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'fanart' LIMIT 1");
$fanartResult = mysql_num_rows($fanartQuery);
$bannerQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'series' LIMIT 1");
$bannerResult = mysql_num_rows($bannerQuery);
$screenQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'screenshot' LIMIT 1");
$screenResult = mysql_num_rows($screenQuery);
?>
<?php if($recent->Rating != ""){ ?>ESRB: <?php echo "<b style=\"color: orange;\">$recent->Rating</b> | "; } else{ ?>ESRB: <b style="color: orange;">N/A</b> | <?php }
if($boxartResult != 0){ ?>Boxart: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Boxart: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($fanartResult != 0){ ?>Fanart: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Fanart: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($bannerResult != 0){ ?>Banner: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Banner: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($screenResult != 0){ ?>Screens: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Screens: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($recent->Youtube != ""){ ?>Trailer: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /><?php } else{ ?>Trailer: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /><?php }?>
</p>
</div>
<div style="clear: both;"></div>
</div>
<?php
$count++;
## Tile Items Display
while($recent = mysql_fetch_object($recentResult))
{
if($boxartResult = mysql_query(" SELECT b.filename FROM banners as b WHERE b.keyvalue = '$recent->id' AND b.filename LIKE '%boxart%front%' LIMIT 1 "))
{
$boxart = mysql_fetch_object($boxartResult);
}
?>
<div style="width: 440px; min-height: 150px; float: left; padding: 6px; margin: 10px 13px; border-radius: 4px; border: 1px solid #4f4f4f; background-color: #333;">
<div style="height: 102px; width: 106px; text-align: center; float:left">
<?php
if($boxart->filename != "")
{
?>
<img <?=imageResize("$baseurl/banners/$boxart->filename", "banners/_favcache/_tile-view/$boxart->filename", 100)?> alt="<?=$recent->GameTitle?> Boxart" style="border: 1px solid #666;"/>
<?php
}
else
{
?>
<img src="<?=$baseurl?>/images/common/placeholders/boxart_blank.png" alt="<?=$recent->GameTitle?> Boxart" style="width:70px; height: 100px; border: 1px solid #666;"/>
<?php
}
?>
</div>
<h3 style="margin: 0px; padding: 0px 10px 10px 10px;"><?= $count; ?>: <a href="<?=$baseurl?>/game/<?=$recent->id?>/" style="color: orange;"><?=$recent->GameTitle?></a></h3>
<p style="margin: 0px; padding: 0px 10px 10px 10px;"><img src="<?=$baseurl?>/images/common/consoles/png24/<?=$recent->icon?>" alt="<?=$recent->name?>" style="vertical-align: -6px;" /> <a style="color: #fff;" href="<?= $baseurl; ?>/platform/<?php if(!empty($recent->PlatformAlias)) { echo $recent->PlatformAlias; } else { echo $recent->Platform; } ?>/"><?=$recent->name?></a></p>
<p style="margin: 0px; padding: 0px 10px 10px 10px; text-align: justify;"><?php if ($recent->Overview != "") { echo substr($recent->Overview, 0, 140) . "..."; } else { echo "No Overview Available..."; } ?></p>
<?php
$boxartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND banners.filename LIKE '%front%' LIMIT 1");
$boxartResult = mysql_num_rows($boxartQuery);
$fanartQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'fanart' LIMIT 1");
$fanartResult = mysql_num_rows($fanartQuery);
$bannerQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'series' LIMIT 1");
$bannerResult = mysql_num_rows($bannerQuery);
$screenQuery = mysql_query("SELECT keyvalue FROM banners WHERE banners.keyvalue = '$recent->id' AND keytype = 'screenshot' LIMIT 1");
$screenResult = mysql_num_rows($screenQuery);
?>
<div style="clear: both; padding-top: 10px; text-align: center;">
<?php
if($boxartResult != 0){ ?>Boxart: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" /> | <?php } else{ ?>Boxart: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" /> | <?php }
if($fanartResult != 0){ ?>Fanart: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" /> | <?php } else{ ?>Fanart: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" /> | <?php }
if($bannerResult != 0){ ?>Banner: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" /> | <?php } else{ ?>Banner: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" /> | <?php }
if($screenResult != 0){ ?>Screens: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /> | <?php } else{ ?>Screens: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /> | <?php }
if($recent->Youtube != ""){ ?>Trailer: <img src="<?= $baseurl ?>/images/common/icons/tick_16.png" alt="Yes" style="vertical-align: -3px;" /><?php } else{ ?>Trailer: <img src="<?= $baseurl ?>/images/common/icons/cross_16.png" alt="No" style="vertical-align: -3px;" /><?php }?>
</div>
<div style="clear: both;"></div>
</div>
<?php
if($increment == "odd")
{
$increment = "even";
}
else
{
$increment = "odd";
}
if($increment == "even")
{
?>
<div style="clear: both;"></div>
<?
}
$count++;
}
?>
<div style="clear: both;"></div>
</div>