<a name="top" id="top"> <div id="toparea"> <div class="toplinks"> <?php if (RPG::user()->isLoggedIn()) { ?> <a href="<?php echo $this->url('user'); ?> ">Logged in as <strong><?php $this->escape(RPG::user()->name); ?> </strong></a> <a href="<?php echo $this->url('auth/logout', array('hash' => RPG::user()->logouthash, 'returnto' => RPG::input()->getPath(true))); ?> ">Logout</a> <?php } else { ?> <form action="<?php echo $this->url('auth/login'); ?> " method="post"> <input type="hidden" name="returnto" value="<?php $this->escape(RPG::input()->getPath(true)); ?> " /> <input type="hidden" name="csrf_token" value="<?php $this->escape(RPG::session()->getFormToken('core_login'));
/** * 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); }
set_error_handler(array('RPG', 'handlePhpError')); // Default configuration items $defaultConfig = array('modelPath' => RPG_ROOT . '/models', 'viewPath' => RPG_ROOT . '/views', 'controllerPath' => RPG_ROOT . '/controllers', 'cachePath' => RPG_ROOT . '/cache', 'tmpPath' => RPG_ROOT . '/tmp', 'sessionPath' => RPG_ROOT . '/tmp/sessions', 'objectsPath' => RPG_ROOT . '/cache/objects'); // Override defaults if needed $config = array_merge($defaultConfig, $config); // // Start the main execution! // Top-level try/catch block for a last-ditch effort error page. // 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; }