コード例 #1
0
ファイル: init.php プロジェクト: savonix/nexista
 /**
  * Reads sitemap for current gate data
  *
  * This function retrieves the correct gate based on request.
  *
  * @return null
  */
 public function process()
 {
     include NX_PATH_COMPILE . 'sitemap.php';
     $this->info['uri'] = false;
     $mymethod = strtolower($_SERVER['REQUEST_METHOD']) . ':';
     if (isset($gatesExact[$mymethod . $_ID_])) {
         $this->info['uri'] = $gatesExact[$mymethod . $_ID_]['uri'];
         if (!isset($gatesExact[$mymethod . $_ID_]['nosession'])) {
             $this->initSession();
         }
         if (isset($gatesExact[$mymethod . $_ID_]['cache_control'])) {
             $cache_control = $gatesExact[$mymethod . $_ID_]['cache_control'];
             header("Cache-Control: " . $cache_control);
         }
         if (isset($gatesExact[$mymethod . $_ID_]['content_type'])) {
             header("Content-Type: " . $gatesExact[$mymethod . $_ID_]['content_type']);
             $this->info['content_type'] = $gatesExact[$mymethod . $_ID_]['content_type'];
         }
         if (isset($gatesExact[$mymethod . $_ID_]['cache'])) {
             $this->info['cacheExpiryTime'] = $gatesExact[$mymethod . $_ID_]['cache'];
         }
         if (isset($gatesExact[$mymethod . $_ID_]['role'])) {
             $this->info['requireRole'] = $gatesExact[$mymethod . $_ID_]['role'];
             $auth = Nexista_Auth::singleton('Nexista_Auth');
             $auth->requireRole($this->info['requireRole']);
         }
         $gateFound = true;
         /* THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS */
     } elseif (isset($gatesDeprecated[$_ID_])) {
         $this->info['uri'] = $gatesDeprecated[$_ID_]['uri'];
         if (!isset($gatesDeprecated[$_ID_]['nosession'])) {
             $this->initSession();
         }
         if (isset($gatesDeprecated[$_ID_]['cache_control'])) {
             $cache_control = $gatesDeprecated[$_ID_]['cache_control'];
             header("Cache-Control: " . $cache_control);
         }
         if (isset($gatesDeprecated[$_ID_]['content_type'])) {
             header("Content-Type: " . $gatesDeprecated[$_ID_]['content_type']);
             $this->info['content_type'] = $gatesExact[$_ID_]['content_type'];
         }
         if (isset($gatesDeprecated[$_ID_]['cache'])) {
             $this->info['cacheExpiryTime'] = $gatesDeprecated[$_ID_]['cache'];
         }
         if (isset($gatesDeprecated[$_ID_]['role'])) {
             $this->info['requireRole'] = $gatesDeprecated[$_ID_]['role'];
             $auth = Nexista_Auth::singleton('Nexista_Auth');
             $auth->requireRole($this->info['requireRole']);
         }
         $gateFound = true;
         /* END DEPRECATION NOTE */
     } elseif (isset($gatesRegex)) {
         foreach ($gatesRegex as $regex => $_info) {
             if (preg_match("/" . $regex . "/", $_ID_, $match)) {
                 $GLOBALS['regex'] = $match;
                 $this->info['uri'] = $_info['uri'];
                 if (!isset($_info['nosession'])) {
                     $this->initSession();
                 }
                 if (isset($_info['cache_control'])) {
                     $cache_control = $_info['cache_control'];
                     header("Cache-Control: " . $cache_control);
                 }
                 if (isset($_info['content_type'])) {
                     header("Content-Type: " . $_info['content_type']);
                 }
                 if (isset($_info['cache'])) {
                     $this->info['cacheExpiryTime'] = $_info['cache'];
                 }
                 if (isset($_info['role'])) {
                     $this->info['requiredRole'] = $_info['role'];
                     $auth = Nexista_Auth::singleton('Nexista_Auth');
                     $auth->requireRole($_info['role']);
                 }
                 $gateFound = true;
                 break;
             }
         }
     }
     if (isset($gateMissing) && !isset($gateFound)) {
         $this->info['uri'] = $gateMissing['uri'];
         if (!isset($gateMissing['nosession'])) {
             $this->initSession();
         }
         if (isset($gateMissing['cache_control'])) {
             $cache_control = $gateMissing['cache_control'];
             header("Cache-Control: " . $cache_control);
         }
         if (isset($gateMissing['content_type'])) {
             header("Content-Type: " . $gateMissing['content_type']);
         }
         if (isset($gateMissing['cache'])) {
             $this->info['cacheExpiryTime'] = $gateMissing['cache'];
         }
         if (isset($gateMissing['role'])) {
             $this->info['requireRole'] = $gateMissing['role'];
             $auth = Nexista_Auth::singleton('Nexista_Auth');
             $auth->requireRole($this->info['requireRole']);
         }
     }
 }
コード例 #2
0
ファイル: auth.php プロジェクト: savonix/nexista
 /**
  * Registers a function to be called on auth session timeout
  * This function will be called when the user's session times out from
  * inactivity. It might be used to reshow a login screen.
  *
  * @param mixed $handler function or an array of class=>method
  *
  * @return null
  */
 public static function registerTimeoutHandler($handler)
 {
     if (is_callable($handler)) {
         self::$_timeoutHandler = $handler;
     } else {
         Nexista_Error::init('Auth Timeout Handler Error', NX_ERROR_FATAL);
     }
 }
コード例 #3
0
ファイル: nexista_auth.php プロジェクト: savonix/nexista
<?php

/*
Extension Name: Nexista Authn Handler Plugin
Extension URI:
Description: Uses Nexista Authn
Version: 0.1
Copyright: Savonix Corporation
Author: Albert Lash
License: LGPL
*/
function nexista_authLogin($auth)
{
    if (empty($_SESSION['authReferer'])) {
        $_SESSION['authReferer'] = $_SERVER['REQUEST_URI'];
    }
    $link_prefix = dirname(NX_LINK_PREFIX);
    $login_page = Nexista_Config::get('//nexista_auth/login');
    header('Location: ' . $link_prefix . '/' . $login_page);
    exit;
}
Nexista_Auth::registerTimeoutHandler('nexista_authLogin');
Nexista_Auth::registerLoginHandler('nexista_authLogin');
Nexista_Auth::registerDeniedHandler('nexista_authLogin');
Nexista_Auth::registerExpiredHandler('nexista_authLogin');