Example #1
0
 /**
  * Initializes the user, setting them up as a member or guest, and
  * checking for automatic logins.
  * 
  * @param RPG_Model $model Instance of a user model.
  * @param RPG_Session $session Instance of session class.
  * @param RPG_Input $input Instance of input class.
  */
 public function __construct($model = null, $session = null, $input = null)
 {
     if ($model === null) {
         $model = RPG::model('user');
     }
     if ($session === null) {
         $session = RPG::session();
     }
     if ($input === null) {
         $input = RPG::input();
     }
     $this->_model = $model;
     $this->_session = $session;
     $this->_input = $input;
     // try to see if we're logged in according to the session
     if ($this->isLoggedIn()) {
         // setup registered user
         $this->setupMember();
     } else {
         if (!$this->_attemptAutoLogin()) {
             // if auto-login failed, we're a guest
             $this->setupGuest();
         }
     }
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
	<?php 
if (RPG::session()->hasFlash('frontend_error')) {
    ?>
		<div id="frontend_error"><?php 
    echo RPG::session()->getFlash('frontend_error');
    ?>
</div>
	<?php 
}
?>
	
	<?php 
if (RPG::session()->hasFlash('frontend_message')) {
    ?>
		<div id="frontend_message"><?php 
    echo RPG::session()->getFlash('frontend_message');
    ?>
</div>
	<?php 
}
?>
	
	<?php 
if (isset($title)) {
    ?>
	<h2 id="pagetitle">&raquo; <?php 
    $this->escape($title);
    ?>
</h2>
	<?php 
}
Example #4
0
// Set up the error handler
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">