/** * Default action of the hello controller. */ public function doIndex() { RPG::view()->setContent('blah, index action'); }
/** * Logs the user out of the system. * * GET Parameters * - hash: string * - returnto: string */ public function doLogout() { $user = RPG::user(); $hash = RPG::input()->get('hash', 'string'); if ($hash === sha1($user->id . sha1($user->salt) . sha1($user->name) . sha1(RPG::config('cookieSalt')))) { $user->clearAutoLogin(); RPG::session()->regenerateId(); RPG::session()->loggedIn = false; RPG::session()->userId = 0; $user->setupGuest(); RPG::session()->setFlash('frontend_message', 'Logged out successfully.'); } else { RPG::session()->setFlash('frontend_error', 'Invalid logout hash.'); } $returnTo = urldecode(RPG::input()->get('returnto', 'string')); $query = array(); if (strpos($returnTo, '?') !== false) { list($path, $queryString) = explode('?', $returnTo); parse_str($queryString, $query); } else { $path = $returnTo; } RPG::view()->redirect($path, $query); }
// try { // Initialize the system RPG::setConfig($config); RPG_Template::setPath($config['viewPath']); RPG_Model::setPath($config['modelPath']); RPG::session(); RPG::user(RPG::model('user')); // add this now, so controllers can include CSS that overrides defaults RPG::view()->addStyleSheet('media/styles/light.css'); // Process the request RPG::router($config['controllerPath'])->processRequest(); // stop the timer - needs to be here so it can get rendered via templates RPG::debug('Execution Time (pre-render): ' . round(microtime(true) - RPG::get('__debug_time'), 4)); // Render the output - TODO: handle styles differently later RPG::view()->render(); } catch (RPG_Exception $ex) { // Basic error page echo '<html> <head> <title>Application Error</title> <style type="text/css"> body { font-family: sans-serif; } </style> </head> <body> <h1>Application Error</h1>', "\n"; if (isset($config['debug']) and $config['debug'] === true) { echo $ex; } else { echo "There has been an internal error within Crindigan.\n";
/** * Exchange money with an external system. */ public function doMoney() { RPG::view()->setNavCurrent('user', 'user/money')->setTitle('Exchange Money'); }
public function doIndex() { // just go to HomeController RPG::view()->redirect('home'); }
/** * Displays more news articles and a navigable archive. */ public function doNews() { RPG::view()->setNavCurrent('home', 'home/news')->setTitle('News'); }
/** * Displays the source code of the given action name. * * @param string $actionName Name of the controller's action method. */ public function doDebugViewAction($actionName) { if (RPG::config('debug') === true and strpos($actionName, 'do') === 0) { $method = new ReflectionMethod($this, $actionName); $out = '<h2>' . $method->getDeclaringClass()->getName() . "::{$actionName}()</h2>\n" . '<a href="' . RPG::url('*/debug-list-actions') . '">« Action List</a><br /><br />'; $start = $method->getStartLine() - 1; $end = $method->getEndLine(); $file = file($method->getFileName()); $lines = array_slice($file, $start, $end - $start); $out .= "<pre>\n " . str_replace("\t", ' ', $method->getDocComment()) . "\n"; foreach ($lines as $line) { $out .= htmlentities(str_replace("\t", ' ', $line)); } $out .= '</pre>'; RPG::view()->setLayout('layouts/empty.php')->setContent($out); } }