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; }
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; }
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')) {
/** * 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; }
/** * 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; }
// 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);
<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) {} });
/** * Processes and parsers the xml definition file * and retrieves query info * */ private function parseDefinition() { // Here we use see whether to use the default table names or if // a entity set has been specified. $server_name = $_SERVER['SERVER_NAME']; $myPrefix = Nexista_Config::get('./datasource[@id="' . $server_name . '"]/prefix'); $mydtd = Nexista_Config::get('./datasource[@id="' . $server_name . '"]/dtd'); // this can customize the table prefix based on vhosts in config if (!empty($myPrefix)) { $xmlString = "<!DOCTYPE query [" . file_get_contents(dirname($this->definition) . "/" . $mydtd); $rment = '/(\\<\\!ENTITY prefix "[a-z0-9A-Z]*"\\>)/'; $xmlString = preg_replace($rment, '', $xmlString); $xmlString .= '<!ENTITY prefix "' . $myPrefix . '">]>'; $xmlString .= file_get_contents($this->definition); $rmme = '/(\\<\\!DOCTYPE query SYSTEM "' . $mydtd . '"\\>)/'; $xmlString = preg_replace($rmme, '', $xmlString); $xml = simplexml_load_string($xmlString, null, LIBXML_COMPACT | LIBXML_DTDLOAD); } else { $xml = simplexml_load_file($this->definition, null, LIBXML_COMPACT | LIBXML_DTDLOAD); } $this->queryName = (string) $xml['name']; if (!empty($xml['name'])) { $this->queryType = (string) $xml['type']; } $defaultval = (string) $xml['default']; $loopvar = (string) $xml['loop']; if (!empty($loopvar)) { if (is_numeric($loopvar)) { $this->queryLoop = $loopvar; } else { $array = Nexista_Path::get($loopvar, 'flow'); if (is_array($array)) { $this->queryLoop = sizeof($array); } elseif (empty($array) && $array !== '0' && empty($defaultval)) { // No values at all $this->queryLoop = 0; } elseif (empty($array) && $array !== '0' && $defaultval === 'true') { // Use default value $array = array($defaultval); } else { //single value. loop once and make into array $array = array($array); } } } //get array of query info (query itself, args, etc) if (!($this->query['sql'] = (string) $xml->sql)) { // no sql node, maybe an ldap search? if (!($this->query['searchbase'] = (string) $xml->searchbase)) { Nexista_Error::init('No query specified in ' . $this->definition, NX_ERROR_FATAL); } else { $this->query['filter'] = (string) $xml->filter; $this->query['options'] = (string) $xml->options; } } if (!($this->query['connection'] = (string) $xml->connection)) { Nexista_Error::init('No database connection specified!', NX_ERROR_FATAL); } //make a nice array from in and out values $key = 0; if (isset($xml->params->param)) { foreach ($xml->params->param as $val) { $name = (string) $val['name']; $this->query['params'][$key]['name'] = !empty($name) ? $name : false; $array = (string) $val['array']; $this->query['params'][$key]['array'] = !empty($array) ? $array : false; $array = (string) $val['node-name-array']; $this->query['params'][$key]['node-name-array'] = !empty($array) ? $array : false; $default = (string) $val['default']; $this->query['params'][$key]['default'] = (!empty($default) or $default === '0') ? $default : false; $type = (string) $val['type']; $this->query['params'][$key]['type'] = !empty($type) ? $type : false; $key++; } } return true; }
/* 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";
$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); }
* @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')); */
/** * 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); }
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); } } }