Пример #1
0
function nexista_rewrite($superglobals)
{
    // RuleID
    // RuleOrder
    // RewriteMap - its really needed for this to be really useful.
    // RewriteCond TestString CondPattern
    // TestString can be a string or an xpath query, CondPattern can be eregi
    // Example: "RewriteCond {//_server/REQUEST_URI} blahblah
    // (the xpath query value would be fetched in the compiled gate
    // if unsuccessful, return false and break
    // RewriteRule Pattern Substition [flags]
    // Pattern is a regular preg_match
    // Only a subset of flags supported
    // Supported flags:
    // * CO - Cookie
    // * L - Last
    // * R - Redirect
    // * E - Env
    // * F - Forbidden
    // Configuration:
    /*
    <net_rewrite>
    <rewrite_base></rewrite_base>
    <rewrite_map></rewrite_map>
    <rewrite>
        <description>This rule will match if the domain name being accessed
        is 4.2.2.1, and if so, it will return a 403 (FORBIDDEN RESPONSE).
        </description>
        <cond test="REQUEST_URI" pattern="index"/>
        <cond test="REQUEST_METHOD" pattern="POST"/>
        <rule pattern="{//path_prefix}(.*)" substitution="{//path_prefix}" flags="L"/>
    </rewrite>
    <rewrite>
        <description>This rule will match if the domain name being accessed
        is 4.2.2.1, and if so, it will return a 403 (FORBIDDEN RESPONSE).
        </description>
        <cond test="HTTP_HOST" pattern="4.2.2.1"/>
        <rule pattern="." substitution="-" flags="F"/>
    </rewrite>
    </net_rewrite>
    */
    // For each rewrite:
    // Process Conditions
    // Process Rules
    // If matched, continue.
    if ($superglobals == $_GET) {
        // gate_key is usually "nid", but since its configurable, not hard coded
        $gate_key = Nexista_Config::get('./build/query');
        if ($superglobals[$gate_key] == 'index' || $superglobals[$gate_key] == '') {
            // need to replace
            $superglobals[$gate_key] = 'configurations';
            $superglobals['barf'] = 'true';
        }
    }
    return $superglobals;
}
Пример #2
0
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;
}
Пример #3
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;
     }
 }
Пример #4
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();
 }
Пример #5
0
 /**
  * Returns array of required files to insert in require_once fields
  *
  * @return    array Required files
  * @see
  */
 public function getRequired()
 {
     $req[] = Nexista_Config::get('./path/handlers') . 'query.handler.php';
     return $req;
 }
Пример #6
0
        // Sounds good:
        /*
         * Disable / Tune the automatic cleaning process
         *
         * The automatic cleaning process destroy too old (for the given life time)
         * cache files when a new cache file is written.
         * 0               => no automatic cache cleaning
         * 1               => systematic cache cleaning
         * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
         *
         */
    }
}
/* Handle Exclusions */
$included = true;
$excludes = Nexista_Config::get('./extensions/nexista_cache/excludes');
if (strpos($excludes, ',')) {
    $x_array = explode(',', $excludes);
} else {
    if (!empty($excludes)) {
        $x_array[] = $excludes;
    }
}
if (!empty($x_array)) {
    if (in_array($_GET['nid'], $x_array)) {
        unset($included);
    } else {
        // this could be slow, might want to have a setting to turn on / off
        foreach ($x_array as $value) {
            if (eregi($value, $_GET['nid'])) {
                unset($included);
Пример #7
0
 /**
  * Loads site configuration info
  *
  * @return null
  */
 public function loadConfig()
 {
     $this->config = Nexista_Config::singleton('Nexista_Config');
     $this->config->setMaster(NX_PATH_COMPILE . 'config.xml');
     $this->config->loadMasterConfig();
 }
Пример #8
0
  <placement>predisplay</placement>
  <code>raw code</code>
  <!-- xpath trumps code -->
  <xpath>//o_google_analytics_code</xpath>
  <priority>100</priority>
  <cookie_path>100</cookie_path>
  <source>&includepath;extensions/google_analytics.php</source>
</google_analytics_code>
*/
$analytics_code = Nexista_Config::get('./extensions/google_analytics_code/code');
$analytics_xpath = Nexista_Config::get('./extensions/google_analytics_code/xpath');
$analytics_cpath = Nexista_Config::get('./extensions/google_analytics_code/cookie_path');
if ($analytics_xpath) {
    $analytics_code = Nexista_Flow::getByPath($analytics_xpath);
}
if (!($priority = Nexista_Config::get('./extensions/google_analytics_code/priority'))) {
    $priority = 10;
}
if ($analytics_code) {
    $google_analytics_code = <<<EOS
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
if (typeof jQuery != 'undefined') {
    \$(document).ready(function()
    {
        try {
        var pageTracker = _gat._getTracker("{$analytics_code}");
        pageTracker._setCookiePath("{$analytics_cpath}");
        pageTracker._trackPageview();
        } catch(err) {}
    });
Пример #9
0
Copyright: Savonix Corporation
Author: Albert Lash
License: LGPL

TODO:
    1. Add a hook to nexista_cache for debugging purposes.
    2. Add custom error handling for more detailed error reports when developing.

--> */
/* START EXCLUSIONS CHECK */
/*
This section is always processed. It checks for exlusions to the
development output buffer.
*/
$tidy_it = true;
$excludes = Nexista_Config::get('./extensions/tidy/excludes');
if (strpos($excludes, ',')) {
    $x_array = explode(',', $excludes);
} else {
    if (!empty($excludes)) {
        $x_array[] = $excludes;
    }
}
if (!empty($x_array)) {
    // this could be slow, might want to have a setting to turn on / off
    foreach ($x_array as $value) {
        if (eregi($value, $_GET['nid'])) {
            unset($tidy_it);
        }
    }
}
Пример #10
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')) {
Пример #11
0
/*
Extension Name: google_adsense_plugin.php
Extension URI: http://www.nexista.org/
Description: Ads Google Adsense Code
Version:
Copyright: Savonix Corporation
Author: Albert Lash
License: LGPL
*/
/* TODO - Get this from the database. */
$adsense_account = Nexista_Config::get('./extensions/google_adsense_account/code');
$adsense_xpath = Nexista_Config::get('./extensions/google_adsense_account/xpath');
if ($adsense_xpath) {
    $adsense_account = Nexista_Flow::get($adsense_xpath);
}
if (!($priority = Nexista_Config::get('./extensions/google_adsense_account/priority'))) {
    $priority = 10;
}
$google_adsense_code = <<<EOS
<div style="position: absolute; top: 18px; right: 25px;">
<script type="text/javascript"><!--
google_ad_client = "{$adsense_account}";
google_alternate_color = "FFFFFF"
google_ad_width = 234;
google_ad_height = 60;
google_ad_format = "234x60_as";
google_ad_type = "text";
//2007-10-29: Technology
google_ad_channel = "6222844825";
google_ad_channel = "6222844825";
google_color_border = "0066CC";
Пример #12
0
    $i = 0;
    foreach ($tmparr as $v) {
        $newarr[$i] = $v;
        $i++;
    }
} else {
    $newarr = $roles;
}
$newarr = array('phunky_user', 'phunky_admin');
$auth =& new Nexista_Auth();
if (!$auth->registerUser($newarr)) {
    trigger_error(Nexista_Error::getError() . ' in login.php', WARNING);
}
$auth->setSessionData('user_id', $user_id);
$auth->setSessionData('group_id', $group_id);
$auth->setSessionData('username', $username);
$auth->setSessionData('last_visit', $last_visit);
$auth->setSessionData('last_visit_timestamp', $user_last_visit);
//go back where we were called from
$redirect = Nexista_Path::get('//_post/redirect', 'flow');
if (isset($_SESSION['NX_AUTH']['requestedUrl']) && !$_SESSION['NX_AUTH']['requestedUrl'] == "") {
    $redirect = $_SESSION['NX_AUTH']['requestedUrl'];
} else {
    $redirect = Nexista_Config::get('//build/default');
}
if ($_GET['nid'] == 'x-login') {
    echo '<result>Success</result>';
    exit;
} else {
    header('Location: ' . $redirect);
}
Пример #13
0
 * @author   Albert Lash <*****@*****.**>
 * @license  http://www.gnu.org LGPL
 * @version  SVN: 123
 * @link     http://www.nexista.org/
 *
 */
/*
Configuration:

<nexista_session>
    <placement>prepend</placement>
    <source>&includepath;extensions/nexista_session.php</source>
    <handler>files</handler>
</nexista_session>
*/
$handler = Nexista_Config::get('./extensions/nexista_session/handler');
if (1 == 2) {
    ini_set('session.save_handler', 'user');
    include 'HTTP/Session2.php';
    Nexista_Session::registerSessionStartHandler(array('HTTP_Session2', 'start'));
} elseif (class_exists('Memcacxhe') && $handler == 'memcached') {
    ini_set('session.save_handler', 'memcache');
    ini_set('session.save_path', 'tcp://192.168.3.3:11211?persistent=1&weight=2,tcp://memcached1.private.savonix.com:11211?persistent=1&weight=2&timeout=2&retry_interval=4,tcp://memcached2.private.savonix.com:11211?persistent=1&weight=2&timeout=2&retry_interval=4');
} else {
    ini_set('session.save_handler', 'files');
}
/* Get this from config
HTTP_Session2::setContainer('MDB2',
    array('dsn' => 'mysql://*****:*****@localhost/database',
    'table' => 'sessiondata'));
*/
Пример #14
0
 /**
  * Compiles individual gate files
  *
  * @param string &$gatedata the cdata content for this gate
  * @param string &$gatenum  the number (in order) of this gate
  *
  * @return null
  */
 private function _writeGate(&$gatedata, &$gatenum)
 {
     //write gate file
     $compile_path = Nexista_Config::get('./path/compile');
     if (!is_dir($compile_path)) {
         // TODO - Error handling
         mkdir($compile_path, 0775, true);
     }
     $gatefile = fopen($compile_path . 'gate-' . $gatenum . ".php", "w+");
     if (flock($gatefile, LOCK_EX)) {
         fwrite($gatefile, $gatedata);
         flock($gatefile, LOCK_UN);
     }
     fclose($gatefile);
 }
Пример #15
0
 /**
  * Writes a combined config file for runtime
  *
  * The master config and optional local config are output as a combined xml
  * file that is used by the runtime system
  *
  * @param string &$config         config
  * @param string $config_filename path to xml config file
  *
  * @return null
  */
 public static function writeConfig(&$config, $config_filename)
 {
     $canonical_filename = Nexista_Config::get('./path/compile') . $config_filename;
     $config_compile_error = "Can't open {$canonical_filename}.\n        Check permissions of parent directories,\n        or simply refresh to try and rebuild it.\n        chmod 0777 {$canonical_filename} ?";
     $tdir = dirname($canonical_filename);
     if (!is_dir($tdir)) {
         mkdir($tdir, 0777, true);
     }
     if ($tmp = fopen($canonical_filename, "w+")) {
         if (flock($tmp, LOCK_EX)) {
             fwrite($tmp, self::$xml->asXML());
             flock($tmp, LOCK_UN);
         } else {
             Nexista_Error::Init($config_compile_error, NX_ERROR_FATAL);
             return false;
         }
         fclose($tmp);
     }
     return true;
 }
Пример #16
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;
 }
Пример #17
0
Copyright: Savonix Corporation
Author: Albert Lash
License: LGPL

TODO:
    1. Add a hook to nexista_cache for debugging purposes.
    2. Add custom error handling for more detailed error reports when developing.

--> */
/* START EXCLUSIONS CHECK */
/*
This section is always processed. It checks for exlusions to the
development output buffer.
*/
$development_console = true;
$excludes = Nexista_Config::get('./extensions/dev_buffer/excludes');
if (strpos($excludes, ',')) {
    $x_array = explode(',', $excludes);
} else {
    if (!empty($excludes)) {
        $x_array[] = $excludes;
    }
}
$ua = '_' . $_SERVER['HTTP_USER_AGENT'];
if (stripos($ua, 'Google') || stripos($ua, 'Yahoo') || stripos($ua, 'bot')) {
    $user_agent = 'bot';
} elseif (stripos($ua, 'MSIE')) {
    $user_agent = 'gui_browser_msie';
} elseif (stripos($ua, 'Mozilla') || stripos($ua, 'Opera') || stripos($ua, 'webkit')) {
    $user_agent = 'gui_browser_moz';
} elseif (stripos($ua, 'Elinks') || stripos($ua, 'w3m') || stripos($ua, 'Lynx')) {
Пример #18
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;
         }
     }
 }