flash.moe/public/collection/index.php

79 lines
2.5 KiB
PHP
Raw Normal View History

2020-08-20 00:02:37 +00:00
<?php
require_once '_inc.php';
$getSystems = $pdo->prepare('
SELECT s.*, (
SELECT COUNT(`game_id`)
FROM `col_games`
WHERE `sys_id` = s.`sys_id`
) AS `sys_games`,
(
SELECT COUNT(`game_id`)
FROM `col_games_ownership`
WHERE `game_id` IN (
SELECT `game_id`
FROM `col_games`
WHERE `sys_id` = s.`sys_id`
)
) AS `sys_games_owned`
FROM `col_systems` AS s
ORDER BY `sys_games_owned` DESC
');
$getSystems->execute();
$systems = $getSystems->fetchAll(PDO::FETCH_OBJ);
$systems = [
-1 => (object)[
'sys_id' => 0,
'sys_short' => 'all',
'sys_name' => 'All Games',
'sys_link' => 'games.php',
],
] + $systems;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Game Collection</title>
<link href="assets/style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
var _paq = window._paq || [];
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
_paq.push(['setTrackerUrl', '//uiharu.railgun.sh/mtm']);
_paq.push(['setSiteId', 'w4PqjBGmOL5l']);
var g = document.createElement('script');
g.type = 'text/javascript'; g.async = true;
g.defer = true; g.src = '//uiharu.railgun.sh/mtm.js';
document.head.appendChild(g);
})();
</script>
</head>
<body>
<div class="wrapper">
<h1><a href="./">Game Collection</a></h1>
<div class="syscont">
<?php
foreach($systems as $system):
if(isset($system->sys_games) && $system->sys_games < 1)
continue;
?>
<div class="sysbox">
<img src="<?=sprintf('assets/systems/%s.jpg', $system->sys_short);?>" alt="" class="sysbox-bg"/>
<a class="sysbox-link" href="<?=($system->sys_link ?? sprintf('games.php?sys=%d', $system->sys_id));?>"></a>
<div class="sysbox-cont">
<h2><?=$system->sys_name;?></h2>
<?php if(isset($system->sys_games)): ?>
<p><?=number_format($system->sys_games_owned);?> of <?=number_format($system->sys_games);?> game<?=($system->sys_games !== 1 ? 's' : '');?></p>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</body>
</html>