}
if (!isset($argv[1])) {
- fwrite(STDERR, "Pass the path to a directory with game data json files\n");
+ fwrite(STDERR, "Pass the path to a \"folders\" file with game data json files folder names\n");
exit(1);
}
-$gamesDir = $argv[1];
-if (!is_dir($gamesDir)) {
- fwrite(STDERR, 'Given path is not a directory: ' . $gamesDir . "\n");
+
+$foldersFile = $argv[1];
+if (!is_file($foldersFile)) {
+ fwrite(STDERR, 'Given path is not a file: ' . $foldersFile . "\n");
exit(1);
}
+$baseDir = dirname($foldersFile);
+$gameFiles = [];
+foreach (file($foldersFile) as $line) {
+ $line = trim($line);
+ if (strlen($line)) {
+ if (strpos($line, '..') !== false) {
+ fwrite(STDERR, 'Path attack in ' . $folder . "\n");
+ }
+ $folder = $baseDir . '/' . $line;
+ if (!is_dir($folder)) {
+ fwrite(STDERR, 'Folder does not exist: ' . $folder . "\n");
+ }
+ $gameFiles = array_merge($gameFiles, glob($folder . '/*.json'));
+ }
+}
+
$appsCacheFile = $cacheDir . 'connect-apps.min.json';
$featuredAgesCacheFile = $cacheDir . 'connect-featured-ages.min.json';
-$games = loadGames($gamesDir);
+$games = loadGames($gameFiles);
loadConfigFeaturedFile();
loadConfigPopularTxtFile();
//make it "package name => number"