query( $SQL, __FILE__,__LINE__ ); if($db->get_record()) { $user_authenticated = true; } } // If user not authenticated show dialog if( !$user_authenticated ) { header('WWW-Authenticate: Basic realm="'.$ORGANIZATION_NAME.'"'); header('HTTP/1.0 401 Unauthorized'); die('You do not have permission to access this resource'); } } if ($P3P_POLICY) { header("P3P: policyref=\"" . $P3P_REF_PATH . "\", CP=\"" . $P3P_CP . "\""); } if ($_GET["source"] != "") setcookie("user_srccode", $_GET["source"], -1, "/"); // Force this page to expire (disable local caching) //header("Pragma: no-cache"); //header("Cache-Control: no-cache"); $SELF = $CONTROL_FILE; $PATH = $REQUEST_URI; $posq = strpos($PATH, "?"); if ($posq !== false) $PATH = substr($PATH, 0, $posq); $BASE_URL = $PATH; $PATH = explode("/", $PATH); // Break down URL into an array ($PATH) $begin_params = 0; while($begin_params < count($PATH) && ($PATH[$begin_params] != $SELF) && $begin_params < count($PATH)) $begin_params++; // Break down URL path parameters (separated by slashes) into location variables $NUM_PARAMS = 0; if ($PATH[$begin_params] == $SELF) { unset($PARAM); for ($i = $begin_params+1; $i < count($PATH); $i++) $PARAM[] = $PATH[$i]; $NUM_PARAMS = count($PARAM); } $CURRENT_PARAM = 0; // Set default location variable values $TEMPLATE = $DEFAULT_TEMPLATE; $ELEMENT = $DEFAULT_ELEMENT; $LEVEL = 0; $ID = false; $EXTENSION = ""; $MODULE = ""; $CSS_FILE = "/site.css"; $CSS_TOGGLE = "?enlarged"; $CSS_ALTSIZE = "Larger font"; if ($QUERY_STRING == "normal") { setcookie("css_enlarged", "0", 0, "/"); } else if ($QUERY_STRING == "enlarged" || $HTTP_COOKIE_VARS["css_enlarged"] == 1) { $CSS_FILE = "/large.css"; setcookie("css_enlarged", "1", 0, "/"); $CSS_TOGGLE = "?normal"; $CSS_ALTSIZE = "Normal font"; } unset($DOCTYPE_COUNT); unset($GL_DOCTYPE_COUNT); $SHOW_MEMBERS = false; $NUM_PHOTOS = 0; $SHOW_LOGIN = false; $ACCESS_DENIED = false; $CHECK_PERMISSIONS = true; $URL_DOCID = ""; // Test URL Params for provided information if ($NUM_PARAMS > $CURRENT_PARAM && isset($PARAM[$CURRENT_PARAM])) { // Check for extension reference first, then assume an element reference // Note: Only extensions in the /extensions/DOC/ directory can be directly // referenced in the URL and hence accessed as a page-level extension. $TEMPNAME = strtolower(str_replace(" ", "_", $PARAM[$CURRENT_PARAM])); if (file_exists("$EXTENSION_PATH/DOC/$TEMPNAME.mod")) { // --> host/[/extensionName[/param1[/param2[/..]]]] $EXTENSION = $TEMPNAME; $CURRENT_PARAM++; $LEVEL = $PARAM[1]; // Redirect SSL Extensions if( $SERVER_PORT != 443 && is_array($SSL_EXTENSIONS) && in_array( $EXTENSION, $SSL_EXTENSIONS ) && !$DISABLE_SSL ) { if( $SSL_SERVER_NAME == "" ) $SSL_SERVER_NAME = $SERVER_NAME; Redirect("https://" . $SSL_SERVER_NAME . $REQUEST_URI); } } else { // --> host/[/elementType[/levelNumber[.docID]]] $ELEMENT = str_replace(" ", "_", $PARAM[$CURRENT_PARAM]); $CURRENT_PARAM++; if ($NUM_PARAMS > $CURRENT_PARAM && isset($PARAM[$CURRENT_PARAM])) { // Fix for malformed image references if ($ELEMENT == "images") { $fn = $PARAM[$CURRENT_PARAM]; header("Location: /images/$fn"); exit(); } if (eregi("([0-9]+)|([0-9]+[\.-][0-9]+)", $PARAM[$CURRENT_PARAM])) { $LEVEL_DOCID = $PARAM[$CURRENT_PARAM]; if (strpos($LEVEL_DOCID, ".") !== false) list($LEVEL, $ID) = explode(".", $LEVEL_DOCID); else $LEVEL = $LEVEL_DOCID; $URL_DOCID = $ID; $CURRENT_PARAM++; } } } } // Must count globals outside of level incase of no level as in site map $SQL = " SELECT doctype, COUNT(doctype) as total FROM documents WHERE status='A' GROUP BY doctype "; $db->query($SQL,__FILE__,__LINE__); while ($db->get_record()) $GL_DOCTYPE_COUNT[$db->f["doctype"]] = $db->f["total"]; $GL_DOCTYPE_COUNT["EV"] = CountEventDocs("ALL"); // If a valid level ID was supplied, find the layout ID for it if (isPosInt($LEVEL) && strlen($LEVEL) > 0 && $EXTENSION == "") { $SQL = " SELECT * FROM levels WHERE levid=$LEVEL "; $db->query($SQL,__FILE__,__LINE__); $db->get_record_parse_variables("Level_"); // Check to see if level is a URL-Redirect... if ($Level_layout == 10 && $Level_info != "") Redirect($Level_info); // Check to see if level needs to be SSL Secured, if so redirect if( ( $Level_useSSL == "Y" || $Level_template == "secure_ssl" ) && $SERVER_PORT != 443 && !$DISABLE_SSL ) { if( $SSL_SERVER_NAME == "" ) $SSL_SERVER_NAME = $SERVER_NAME; Redirect("https://" . $SSL_SERVER_NAME . $REQUEST_URI); } if ($Level_template != "") $TEMPLATE = strtolower(preg_replace("/[^0-9A-Za-z]/", "_", $Level_template)); else $TEMPLATE = strtolower(preg_replace("/[^0-9A-Za-z]/", "_", GetTopLevelName($LEVEL))); // Build HTML Title if( $ELEMENT == 'docs' ) { $document_id = false; if( ! isPosInt($ID) && $Level_layout == 0 ) { $SQL = "SELECT docid, layout FROM documents WHERE level=$LEVEL AND doctype='AR' AND status = 'A' ORDER BY position LIMIT 1 "; $db->query($SQL, __FILE__, __LINE__); if( $db->get_record() ) { $document_id = $db->f['docid']; } } else { $document_id = $ID; } if( $document_id ) { $db->query("SELECT title FROM documents WHERE docid = $document_id",__FILE__,__LINE__); if( $db->get_record() && $db->f['title'] != '' ) { $HTML_TITLE = ": ".$db->f['title']; } } } // If title not built, use level description if( $HTML_TITLE == '' ) { $HTML_TITLE = ": " . $Level_label; if( $Level_descr != "") $HTML_TITLE .= " - " . substr($Level_descr, 0, 80); } $HTML_DESCR_TAG = ""; if ($Level_descr != "") $HTML_DESCR_TAG = '' . "\n"; $SQL = " SELECT doctype, COUNT(doctype) as total FROM documents WHERE level=$LEVEL AND status='A' GROUP BY doctype "; $db->query($SQL,__FILE__,__LINE__); while ($db->get_record()) { $DOCTYPE_COUNT[$db->f["doctype"]] = $db->f["total"]; } $DOCTYPE_COUNT["EV"] = CountEventDocs($LEVEL); if ($Level_secure == "Y") include("$ELEMENT_PATH/_default/security.mod"); } else { if ($Login_attempt == "Y") include("$ELEMENT_PATH/_default/security.mod"); } include ("$ELEMENT_PATH/_default/popup.mod"); // see if a plugin wants to handle this request $REQUEST_HANDLER = false; if( is_array($PLUGINS) ) { foreach( $PLUGINS as $plugin_info ) { $plugin = $plugin_info['instance']; if( method_exists($plugin,'request_handlers') && in_array( $PARAM[0], $plugin->request_handlers() ) ) { $REQUEST_HANDLER = $plugin; break; } } } // Handle with a plugin if( $REQUEST_HANDLER ) { // Plugins are handled by plugin_handler module $MODULE = $_SERVER['DOCUMENT_ROOT'].'/include/plugin_handler.php'; // get the model from the plugin $MODEL = $REQUEST_HANDLER->request_handle($PARAM); if( is_string($MODEL) ) { $VIEW = $MODEL; } else if( isset( $MODEL['view'] ) ) { $VIEW = $MODEL['view']; } else { // default view to 1st param (search in /www/search) $VIEW = $PARAMS[0]; } if( isset( $MODEL['template'] ) ) { $TEMPLATE = $MODEL['template']; } else { $TEMPLATE = $PARAMS[0]; } // do interceptors foreach( $PLUGINS as $plugin_info ) { $plugin = $plugin_info['instance']; if( method_exists($plugin,'request_intercept') ) { $vars = $plugin->request_intercept($PARAM,$MODEL); $MODEL = array_merge($MODEL,$vars); } } // scope the model extract($MODEL); // include template if (file_exists("$TEMPLATE_PATH/$TEMPLATE.tpl")) { include("$TEMPLATE_PATH/$TEMPLATE.tpl"); } else if (file_exists("$TEMPLATE_PATH/$PARAM[0].tpl")) { include("$TEMPLATE_PATH/$PARAM[0].tpl"); } else if (file_exists("$TEMPLATE_PATH/$DEFAULT_TEMPLATE.tpl")) { include("$TEMPLATE_PATH/$DEFAULT_TEMPLATE.tpl"); } else { include("$DOCUMENT_ROOT/error404.php"); } } else if ($EXTENSION != "") { // Load extension page template $SECTION_NAME = ucfirst(str_replace("_", " ", $EXTENSION)); if ($EXTENSION_TPL_MAP[strtolower($EXTENSION)] != "") $TEMPLATE = $EXTENSION_TPL_MAP[strtolower($EXTENSION)]; if (file_exists("$SPECIAL_INC_PATH/$EXTENSION.mod")) include("$SPECIAL_INC_PATH/$EXTENSION.mod"); if (file_exists("$TEMPLATE_PATH/$TEMPLATE.tpl")) include("$TEMPLATE_PATH/$TEMPLATE.tpl"); else if (file_exists("$TEMPLATE_PATH/$DEFAULT_TEMPLATE.tpl")) include("$TEMPLATE_PATH/$DEFAULT_TEMPLATE.tpl"); else include("$DOCUMENT_ROOT/error404.php"); } else // Load section page template { $SECTION_NAME = ucfirst(str_replace("_", " ", $TEMPLATE)); if (file_exists("$ELEMENT_PATH/$ELEMENT/default.mod")) $MODULE = "$ELEMENT_PATH/$ELEMENT/default.mod"; else if (file_exists("$ELEMENT_PATH/$ELEMENT.mod")) $MODULE = "$ELEMENT_PATH/$ELEMENT.mod"; else if (file_exists("$CUSTOM_MODULE_PATH/$ELEMENT.mod")) { $MODULE = "$CUSTOM_MODULE_PATH/$ELEMENT.mod"; if( isset( $EXTENSION_TPL_MAP[strtolower($ELEMENT)] ) ) { $TEMPLATE = $EXTENSION_TPL_MAP[strtolower($ELEMENT)]; } } else $MODULE = "$ELEMENT_PATH/_default/default.mod"; if (file_exists("$SPECIAL_INC_PATH/$ELEMENT.mod")) include("$SPECIAL_INC_PATH/$ELEMENT.mod"); // Determine template if (file_exists("$TEMPLATE_PATH/$TEMPLATE.tpl") && $TEMPLATE != "") include("$TEMPLATE_PATH/$TEMPLATE.tpl"); else if (file_exists("$TEMPLATE_PATH/$DEFAULT_TEMPLATE.tpl")) include("$TEMPLATE_PATH/$DEFAULT_TEMPLATE.tpl"); else { echo("\n\n

SiteNow Configuration Error

\n"); echo("

There is no default template (common.tpl) file available

\n"); echo("\n"); die ("
\n
http://$SERVER_NAME
\n\n\n"); } } ob_end_flush(); ?>