Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Shared :: "Classes/queryClass.php"
- class queryClass {
- public $gamesByRelease = [];
- public $Blacklist = [];
- public $queryRelease = "";
- public $queryGame = "";
- public function __construct() {
- $type = 'type';
- $this->Blacklist[$type] = explode("\r\n", file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/Shared/scripts/csv/blacklists/{$type}.csv"));
- foreach($this->Blacklist['type'] as $type) {
- // Load blacklist from CSV
- $this->Blacklist[$type] = explode("\r\n", file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/Shared/scripts/csv/blacklists/{$type}.csv"));
- }
- $this->queryRelease = $_GET['release'] ?? false;
- $this->queryGame = $_GET['game'] ?? false;
- }
- public function query() {
- $this->gamesByRelease = [];
- $releases = array_filter(
- array_map('basename', glob("{$_SERVER['DOCUMENT_ROOT']}/*", GLOB_ONLYDIR)),
- fn($file) => !in_array($file, $this->Blacklist['release'])
- );
- natcasesort($releases);
- foreach ($releases as $release) {
- $this->gamesByRelease[$release] = [];
- $games = array_values(array_filter(
- array_map('basename', glob("{$_SERVER['DOCUMENT_ROOT']}/{$release}/*", GLOB_ONLYDIR)),
- fn($file) => !in_array($file, $this->Blacklist['game'])
- ));
- natcasesort($games);
- $this->gamesByRelease[$release] = $games;
- }
- print_r($this->gamesByRelease);
- $requestedRelease = $_GET['release'] ?? false;
- $requestedGame = $_GET['game'] ?? false;
- if (!isset($this->gamesByRelease[$requestedRelease][$requestedGame])) {
- $this->queryRelease = false;
- $this->queryGame = false;
- } else {
- $this->queryRelease = $requestedRelease;
- $this->queryGame = $requestedGame;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement