* ALBUM DOWNLOAD **/ $app->get('/redeem/:album/:code', function ($album, $code) use($app, $dl) { // Validate the code entered $validCode = $dl->validate_code($album, $code); if ($validCode !== 200) { if ($validCode == 400) { $app->flash('error', 'Your code does not have any more downloads'); $app->redirect($app->urlFor('home')); } else { $app->flash('error', 'Your code was not valid'); $app->redirect($app->urlFor('home')); } } else { $albumInfo = $dl->get_album_info($album); $tracks = $dl->get_tracks($album); $app->render('redeem.twig', array('album' => $album, 'code' => $code, 'artist' => $albumInfo['artist'], 'album_title' => $albumInfo['title'], 'image_name' => $albumInfo['thumbnail'], 'tracks' => $tracks, 'email' => $app->getCookie('email'), 'remaining_dl' => $dl->remaining_downloads($code, $album))); } })->name('redeem'); /** * LEGACY REDIRECT **/ $app->get('/redeem/redeem.php?c=:code&p=:album', function ($album, $code) use($app) { $app->redirect('./redeem/' . $album . '/' . $code); }); /** * Album Download page **/ $app->get('/download/:album/:code', function ($album, $code) use($app, $dl) { $download = $dl->file_download($album, $code); $dl->use_code($code, $album);