View::render($viewTemplate, $viewParameters + ['fullPage' => true]) ]); } catch (StopException $e) { } } public static function execute($uri) { switch($uri) { case '/': return ContentActions::executeHome(); case '/fund': return CreditActions::executeFund(); case '/get': return ContentActions::executeGet(); case '/postcommit': return OpsActions::executePostCommit(); case '/log-upload': return OpsActions::executeLogUpload(); case '/list-subscribe': return MailActions::executeListSubscribe(); case '/LBRY-deck.pdf': return static::redirect('https://s3.amazonaws.com/files.lbry.io/LBRY-deck.pdf', 307); case '/dl/lbry_setup.sh': return static::redirect('https://raw.githubusercontent.com/lbryio/lbry-setup/master/lbry_setup.sh', 307); case '/lbry-osx-latest.dmg': return static::redirect('https://s3.amazonaws.com/files.lbry.io/osx/lbry.0.2.0.dmg', 307); default: $noSlashUri = ltrim($uri, '/'); if (View::exists('page/' . $noSlashUri)) { return ['page/' . $noSlashUri, []]; } else { return ['page/404', []]; } } } public static function redirect($url, $statusCode = 302) { if (empty($url)) { throw new InvalidArgumentException('Cannot redirect to an empty URL.'); } $url = str_replace('&', '&', $url); if ($statusCode == 201 || ($statusCode >= 300 && $statusCode < 400)) { header('Location: ' . $url, true, $statusCode); } else { echo sprintf('', htmlspecialchars($url, ENT_QUOTES)); } throw new StopException('Time to redirect'); } }