/** * Initialize the app */ static function init() { // Initialize Composer autoloader require_once 'vendor/autoload.php'; // Initialize framework self::$_fw = Base::instance(); self::$_fw->mset(['AUTOLOAD' => 'app/', 'ESCAPE' => false, 'PREFIX' => 'dict.', 'PACKAGE' => 'svlt/front', 'UI' => 'app/view/', 'JAR.httponly' => false]); // Load configuration if (is_file('config.php')) { self::$_fw->mset(require 'config.php'); } else { throw new Exception('No config.php file found.'); } // Initialize routes require_once 'routes.php'; // Load user if any if ($token = self::$_fw->get('COOKIE.session_token')) { $user = \Helper\Api\User::get('me'); if (isset($user->id)) { self::$_fw->set('user', $user); } } // Run app self::$_fw->run(); }
/** * GET /u/@username * @param \Base $fw * @param array $params */ function base(\Base $fw, array $params) { $user = \Helper\Api\User::get($params['username']); if ($user->id) { $fw->set('title', $user->name); $fw->set('this_user', $user); $stream = \Helper\Api\Post::getPage($user->username); $fw->set('posts', $stream); $this->_render('user/single.html'); } else { $fw->error(404); } }