Beispiel #1
0
 /**
  * Gets the existing User or creates a new one
  */
 public static function getUser()
 {
     if (!SkinnySettings::$CONFIG['session persistency']) {
         throw new SkinnyException("Session persistency not enabled");
     }
     $sess = null;
     session_start();
     if (file_exists("tmp/" . session_id() . ".session")) {
         $sess = unserialize(@file_get_contents("tmp/" . session_id() . ".session"));
         $session_inactive = time() - $sess->last_accessed;
         if ($session_inactive > $sess->timeout) {
             $sess->last_accessed = time();
             $sess->setAuthenticated(false);
             $sess->save();
         } else {
             $sess->last_accessed = time();
             $sess->save();
         }
     } else {
         $sess = new SkinnyUser();
         $sess->timeout = SkinnySettings::$CONFIG['session timeout'];
         $sess->last_accessed = time();
         $sess->save();
     }
     return $sess;
 }
Beispiel #2
0
 /**
  * The main controller script, running with every request.
  */
 public function main()
 {
     //
     // Get the Module and Action from the CGI parameters.
     //
     if (isset($_GET['__action']) && !empty($_GET['__action'])) {
         $action = $_GET['__action'];
     } else {
         $action = 'index';
     }
     if (isset($_GET['__module']) && !empty($_GET['__module'])) {
         $module = $_GET['__module'];
     } else {
         $module = 'default';
         $action = 'index';
     }
     //
     // Set up $param.
     //
     $paramGET = $_GET;
     unset($paramGET['__module']);
     unset($paramGET['__action']);
     $param = array('GET' => $paramGET, 'POST' => $_POST, 'FILES' => $_FILES);
     //
     // Set up variable that are used by the run() method.
     //
     $this->module = $module;
     $this->action = $action;
     $this->param = $param;
     //
     // Handle the missing slashes if there are any.
     //
     // Slash after the module missing?
     $hasMissingSlash = '' == @$_GET['__action'] && '/' == substr($_SERVER['REQUEST_URI'], 0, 1) && 1 < strlen($_SERVER['REQUEST_URI']) && FALSE == strpos($_SERVER['REQUEST_URI'], '/', 1);
     if ($hasMissingSlash) {
         if ($this->allowModulesAsFiles) {
             // Nothing here.
         } else {
             if ($this->fixMisspellings) {
                 if ('' != $this->module && '' == @$_GET['__action']) {
                     $href = '/' . $this->module . '/';
                     header('Location: ' . $href);
                     exit;
                 }
             } else {
                 //Error: Action does not exist
                 header("HTTP/1.1 404 Not Found");
                 echo file_get_contents(WP_XMLIMP_PLUGIN_BASE . "templates/404.php");
                 exit;
             }
         }
     }
     // Slash after the action missing?
     $hasMissingSlash = '' != @$_GET['__action'] && '/' == substr($_SERVER['REQUEST_URI'], 0, 1) && 1 < strlen($_SERVER['REQUEST_URI']) && FALSE !== strpos($_SERVER['REQUEST_URI'], '/', 1) && FALSE == strpos($_SERVER['REQUEST_URI'], '/', strpos($_SERVER['REQUEST_URI'], '/', 1));
     if ($hasMissingSlash) {
         if ($this->allowActionsAsFiles) {
             // Nothing here.
         } else {
             if ($this->fixMisspellings) {
                 if ('' != $this->module && '' != @$_GET['__action']) {
                     $href = '/' . $this->module . '/' . $this->action . '/';
                     header('Location: ' . $href);
                     exit;
                 }
             } else {
                 //Error: Action does not exist
                 header("HTTP/1.1 404 Not Found");
                 echo file_get_contents(WP_XMLIMP_PLUGIN_BASE . "templates/404.php");
                 exit;
             }
         }
     }
     //Get the core classes
     $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/core/base/*.php");
     $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/core/*.php");
     // Get the db controller classes
     $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/dbcontroller/base/*.php");
     $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/dbcontroller/*.php");
     // Get the controller classes
     $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/controller/base/*.php");
     $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/controller/*.php");
     //Get all Model classes
     if (SkinnySettings::$CONFIG['preload model']) {
         $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/model/*.php");
         $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "lib/skinnymvc/model/base/*.php");
     }
     //Initialize session
     if (SkinnySettings::$CONFIG['session persistency']) {
         $this->skinnyUser = SkinnyUser::getUser();
     }
     //Get all plugins
     $this->require_once_many(WP_XMLIMP_PLUGIN_BASE . "plugins/skinnyPlugin*.php");
     //
     // Call the run() method.
     //
     $this->run();
 }