require_once 'vendor/autoload.php'; require_once 'helpers/mods.php'; require_once 'data/config.php'; $klein = new \Klein\Klein(); /* * Attach the layout to the site and generate/check for cached mod list data. * TODO: incl. manual settings for no longer supported */ $klein->respond(function ($request, $response, $service, $app) use($klein) { $klein->onError(function ($klein, $err_msg) { $klein->service()->flash($err_msg); if ($err_msg === 'robot') { //TODO: Log and blacklist spambot IPs } if ($err_msg === 'submission') { $klein->response()->redirect('/submit/incomplete'); } if ($err_msg !== 'api' && $err_msg !== 'submission') { $klein->service()->back(); } }); $modlist_mtime = filemtime('data/modlist.json'); $modlist_fsize = filesize('data/modlist.json'); $modlist_cache = "data/cache/{$modlist_mtime}-{$modlist_fsize}.json"; if (!file_exists($modlist_cache)) { //Clear cache folder $obsolete = glob('data/cache/*'); array_map('unlink', $obsolete); //Start saving new cache $mod_list = json_decode(file_get_contents('data/modlist.json'), 1); $versions = array();