Пример #1
0
 /**
  * Start session
  */
 function start()
 {
     $params = Nexista_Config::getSection('session');
     $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
     $excluded_agents = 'googlebot';
     if (!is_array($excluded_agents)) {
         $excluded_agents = (array) $excluded_agents;
     }
     $nosess = false;
     foreach ($excluded_agents as $xagent) {
         if (strpos($useragent, $xagent)) {
             $nosess = true;
         }
     }
     if ($params['active'] == 0 || $nosess) {
         return false;
     } else {
         if (!is_null(self::$_sessionStartHandler)) {
             call_user_func(self::$_sessionStartHandler);
         } else {
             if (!empty($params['cacheLimiter'])) {
                 session_cache_limiter($params['cacheLimiter']);
             }
             if (!empty($params['cacheExpires'])) {
                 session_cache_expire($params['cacheExpires']);
             }
             if (!empty($params['cookieLifetime'])) {
                 $cookie_life = $params['cookieLifetime'];
             } else {
                 $cookie_life = 0;
             }
             if (!empty($params['cookiePath'])) {
                 $cookie_path = $params['cookiePath'];
             } else {
                 $cookie_path = '/';
             }
             session_set_cookie_params($cookie_life, $cookie_path);
             if (session_id() == '') {
                 session_start();
             }
             define('NX_SESSION_ID', session_name() . '=' . session_id());
         }
         return true;
     }
 }
Пример #2
0
 /**
  * Initialize a new auth session with config parameters
  *
  * @return null
  */
 private function _initSession()
 {
     $params = Nexista_Config::getSection('auth');
     //Time in min till expiry from start of session (0=never expire)
     $this->sessionData['expireTime'] = !empty($params['expire']) ? $params['expire'] : '0';
     //Time in min till expiry from inactivity (0=never expire)
     $this->sessionData['idleTime'] = !empty($params['idle']) ? $params['idle'] : '0';
     //user is logged in
     $this->sessionData['status'] = self::NX_AUTH_STATUS_ACTIVE;
     //set login time
     $this->sessionData['lastTime'] = time();
 }
Пример #3
0
 /**
  * Retrieves database info from global.xml file based
  * on query type
  *
  * @param   string      datasource name - must match one on global.xml
  * @param   array       database parameters (username, host, password, etc)
  */
 private function getDatasource($name, &$datasource)
 {
     $datasource = Nexista_Config::getSection('datasource', $name);
     //Caution: this will output the password as well.
     //Nexista_Debug::dump($datasource);
     //Developer note: This is where you set what Datasource handler you would
     //like to use based on type (<type> in global.xml)
     switch ($datasource['type']) {
         case 'mysql':
         case 'mysqli':
         case 'sqlite':
         case 'pgsql':
             $this->datasourceHandler = 'mdb2sql';
             //metabase
             break;
         case 'ldap':
             $this->datasourceHandler = 'ldap';
             //ldap
             break;
         default:
             Nexista_Error::init($type . ' datasource type is not supported', NX_ERROR_WARNING);
             return false;
             break;
     }
     return true;
 }
Пример #4
0
along with this program; if not, see http://www.gnu.org/licenses
or write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA 02110-1301 USA -->
*/
/* <!--
For use with Apache's mod_rewrite

RewriteCond %{REQUEST_URI} ^/a/dev/phunkybb/
RewriteCond %{REQUEST_URI} !/a/dev/phunkybb/index.php|.css
RewriteRule ^/a/dev/phunkybb/(\w+)/$ /a/dev/phunkybb/index.php?nxrw_path=/a/dev/phunkybb/index.php&nid=forum&forum_basename=$1 [L]

RewriteCond %{REQUEST_URI} ^/a/dev/phunkybb/
RewriteCond %{REQUEST_URI} !/a/dev/phunkybb/index.php|.css
RewriteRule ^/a/dev/phunkybb/(\w+)/(\w+)/ /a/dev/phunkybb/index.php?nxrw_path=/a/dev/phunkybb/index.php&nid=topic&forum_basename=$1&basename=$2 [L]
 --> */
$defaults = Nexista_Config::getSection('./defaults');
Nexista_Flow::add('defaults', $defaults);
//print_r($defaults);
$path = $_SERVER['SCRIPT_NAME'];
if ($_GET['nxrw_path']) {
    $path = $_GET['nxrw_path'];
}
$path_prefix = dirname($path) . '/';
$link_prefix = $path . '?nid=';
/* Expired session */
if ($_SESSION['NX_AUTH']['username'] == 1016) {
    $_SESSION['NX_AUTH']['username'] = 0;
}
// Prefix is needed for Mozilla as its the 0 position.
$ua = '_' . $_SERVER['HTTP_USER_AGENT'];
if (stripos($ua, 'Google') || stripos($ua, 'Yahoo') || stripos($ua, 'bot')) {
Пример #5
0
 /**
  * Loads the sitemap
  *
  * @return null
  */
 private function _loadSitemap()
 {
     if (isset($_ENV['NEXISTA_MODE'])) {
         Nexista_Config::setMode($_ENV['NEXISTA_MODE']);
     }
     //read sitemap as xml
     $this->sitemapDocument = new DOMDocument("1.0", "UTF-8");
     $my_sitemap = Nexista_Config::get('./build/sitemap');
     $this->sitemapDocument->load($my_sitemap);
     $gate_items = $this->sitemapDocument->getElementsByTagName('*');
     foreach ($gate_items as $gate_i) {
         if ($gate_i->hasAttribute("src")) {
             $my_src = $gate_i->getAttribute("src");
             // Do not alter absolute or starting with inline flow paths
             if ($my_src[0] != "/" && $my_src[0] != "{") {
                 $gate_i->removeAttribute("src");
                 $gate_i->setAttribute("src", dirname($my_sitemap) . "/" . $my_src);
             }
         }
     }
     //process extensions sitemaps
     $extensions = Nexista_Config::getSection('extensions');
     if (is_array($extensions)) {
         foreach ($extensions as $extension => $value) {
             $thisExtension = Nexista_Config::getSection($extension, false, '/extensions/');
             if ($ext_sitemap = $thisExtension['sitemap']) {
                 if (is_file($ext_sitemap)) {
                     $zdoc = new DOMDocument();
                     $zdoc->load($ext_sitemap);
                     $gate_items = $zdoc->getElementsByTagName('*');
                     foreach ($gate_items as $gate_item) {
                         if ($gate_item->hasAttribute("src")) {
                             $my_src = $gate_item->getAttribute("src");
                             $gate_item->removeAttribute("src");
                             $gate_item->setAttribute("src", dirname($ext_sitemap) . "/" . $my_src);
                         }
                     }
                     // Only import gates
                     $z = new DOMXPath($zdoc);
                     $zimported_gates = $z->query('//map:gate');
                     foreach ($zimported_gates as $zimport) {
                         $a = $this->sitemapDocument->importNode($zimport, 1);
                         $this->sitemapDocument->documentElement->appendChild($a);
                     }
                 }
             }
         }
     }
 }
Пример #6
0
 /**
  * Initialize flow with basic data (request,session)
  *
  * @return null
  */
 public function init()
 {
     //get config data
     $params = Nexista_Config::getSection('flow');
     //create a new DOM document and init with root
     $this->flowDocument = new DOMDocument('1.0', 'UTF-8');
     $this->flowDocument->preserveWhiteSpace = false;
     $this->flowDocument->strictErrorChecking = false;
     $this->flowDocument->formatOutput = false;
     $my_doc_root = $params['my_doc_root'];
     if (empty($my_doc_root)) {
         $my_doc_root = '__ROOT__';
     }
     $this->root = $this->flowDocument->createElement($my_doc_root);
     $this->root = $this->flowDocument->appendChild($this->root);
     for ($i = 0; $i < strlen($params['request']); $i++) {
         switch ($params['request'][$i]) {
             //add $_GET vars
             case 'G':
                 if (!is_null(self::$_importHandler)) {
                     $ref = $this->add('_get', call_user_func(self::$_importHandler, $_GET));
                 } else {
                     $ref = $this->add('_get', $_GET);
                 }
                 break;
                 //add $_POST vars
             //add $_POST vars
             case 'P':
                 if (!is_null(self::$_importHandler)) {
                     $ref = $this->add('_post', call_user_func(self::$_importHandler, $_POST));
                 } else {
                     $ref = $this->add('_post', $_POST);
                 }
                 break;
                 //add $_FILES vars
             //add $_FILES vars
             case 'F':
                 if (!is_null(self::$_importHandler)) {
                     $ref = $this->add('_files', call_user_func(self::$_importHandler, $_FILES));
                 } else {
                     $ref = $this->add('_files', $_FILES);
                 }
                 break;
                 //add $_SESSION vars
             //add $_SESSION vars
             case 'S':
                 if (!is_null(self::$_importHandler)) {
                     $ref = $this->add('_session', call_user_func(self::$_importHandler, $_SESSION));
                 } else {
                     $ref = $this->add('_session', $_SESSION);
                 }
                 break;
                 //add server
             //add server
             case 'V':
                 if (!is_null(self::$_importHandler)) {
                     $ref = $this->add('_server', call_user_func(self::$_importHandler, $_SERVER));
                 } else {
                     $ref = $this->add('_server', $_SERVER);
                 }
                 break;
                 //add env
             //add env
             case 'E':
                 if (!is_null(self::$_importHandler)) {
                     $ref = $this->add('_env', call_user_func(self::$_importHandler, $_ENV));
                 } else {
                     $ref = $this->add('_env', $_ENV);
                 }
                 break;
                 //add globals
             //add globals
             case 'W':
                 if (!is_null(self::$_importHandler)) {
                     $ref = $this->add('_globals', call_user_func(self::$_importHandler, $GLOBALS));
                 } else {
                     $ref = $this->add('_globals', $GLOBALS);
                 }
                 break;
         }
     }
 }