* * @package IWP */ // Our primary class include(dirname(__FILE__) . '/api/iwp.php'); // Initialize everything! IWP::Init(); if(!IWP::isInstalled()){ header('Location: ./admin/index.php'); die(); } if(iwp_config::Get('downForMaintenance')) { echo iwp_language::GetHtml('maintenance'); die(); } /* If we're on IIS, we will be using ISAPI rewrite, and with some versions it will be using an alternative variable */ if (isset($_SERVER["HTTP_X_REWRITE_URL"])) { $_SERVER['REQUEST_URI'] = $_SERVER["HTTP_X_REWRITE_URL"]; } /* Check the URL for get variables that might be needed */ if(in_string('?', $_SERVER['REQUEST_URI'])){ $Qmark = strpos($_SERVER['REQUEST_URI'], '?'); $QueryString = substr($_SERVER['REQUEST_URI'], $Qmark+1); $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $Qmark); $ArgumentList = explode("&", $QueryString); foreach ($ArgumentList as $name => $value) { $tmpArray = array(); $tmpArray = explode("=", $value); if(isset($tmpArray[0]) && isset($tmpArray[1])){ $_REQUEST[$tmpArray[0]] = $_GET[$tmpArray[0]] = urldecode($tmpArray[1]); }elseif(isset($tmpArray[0])){ $_REQUEST[$tmpArray[0]] = $_GET[$tmpArray[0]] = urldecode($tmpArray[0]); } } } if (class_exists('iwp_config') && iwp_config::Get('AllowTestingCommands')) { // these are used by internal test mechanisms and are safely ignored if testing is not allowed by the config file if (isset($_GET['IWP_TEMPLATE'])) { $layout = iwp_admin_layout::getInstance(); $oldTemplate = iwp_config::Get('template'); if ($layout->SelectTemplate($_GET['IWP_TEMPLATE'], $_GET['IWP_TEMPLATE_COLOR'])) { $newTemplate = iwp_config::Get('template'); if ($newTemplate != $oldTemplate) { iwp_config::SetPublic('CurrentTemplateUrl', iwp_config::Get('siteURL') . "/templates/" . $newTemplate); iwp_config::SetPublic('CurrentTemplatePath', IWP_BASE_PATH . "/templates/" . $newTemplate); iwp_config::SetPublic('TemplateColor', iwp_config::Get('SiteColor')); iwp_activity::AddEntry('core', 'layout', 'selecttemplate', 0, $newTemplate, null, 'Testing Commands'); } } else { die('Invalid template specified by testing commands.'); } } /* We want the URL that we're working with, but we don't want any of the application paths */ if (isset($_GET['IWP_REQUEST_URI'])) { // debugging purposes, allow a querystring to override the URL $_SERVER['REQUEST_URI'] = $_GET['IWP_REQUEST_URI']; } } $CurrentURL = $_SERVER['REQUEST_URI']; if(substr($CurrentURL,0, strlen(GetConfig('appPath'))) == GetConfig('appPath')){ $CurrentURL = substr($CurrentURL, strlen(GetConfig('appPath'))); } // If we can easily detect that they're accessing the home page, then show it without processing any URL information if(in_array($CurrentURL, array('/','//','','/index.php', 'index.php'))){ iwp_controller::ShowPage('home'); die(); } // checking the URL $urls = iwp_urls::getInstance(); $urls->SetCurrentURL($CurrentURL); if($urls->IsStaticURL()){ // they're accessing a IWP specific URL iwp_controller::getInstance()->ShowPage(); die(); } // It wasn't a static URL, lets see if its in our database for content $query = 'select * from ' . IWP_TABLE_URLS .' where urlpath="/'.$urls->db->Quote($CurrentURL).'"'; $data = $urls->db->FetchQuery($query); if(!$data || is_null($data) || !is_array($data) || empty($data)) { // The URL wasn't in our database, so we'll check the modules if($urls->IsModuleURL('/'.$CurrentURL)){ // It is a module URL $module = iwp_modules::getInstance()->GetModule($urls->GetCurrentModule()); // Set the module language variables like {$moduleName.lang.myLangVar} $setVar = array(); $setVar['lang'] = $module->lang->GetLangVars(); $setVar['urlToModule'] = IWP_MODULES_URI . '/' . $urls->GetCurrentModule(); $module->template->assign($urls->GetCurrentModule(), $setVar); // Calls the main module function to display a page $module->ShowPageByIniUri($CurrentURL); }else{ // Unknown URL, show 404 not found iwp_controller::getInstance()->ShowPage('NotFound'); } die(); } // There was a a URL in the database if($data['assoctype'] == 'redirect'){ // its just a redirect though, find the new URL and redirect to it $data = $urls->db->FetchQuery('select * from ' . IWP_TABLE_URLS .' where assoctype="'.$urls->db->Quote($data['redirecttype']).'" and associd='.(int)$data['associd']); if(!isset($data['urlpath'])){ iwp_controller::getInstance()->ShowPage('NotFound'); } header("HTTP/1.1 301 Moved Permanently"); header("Location: ".iwp_config::Get('siteURL').$data['urlpath']); die(); }elseif($data['assoctype'] == 'content'){ // they're using a content url $content = new iwp_page_viewcontent(); $content->ShowPage($data['associd']); }elseif($data['assoctype'] == 'module'){ // lastly, is it a module URL stored in the database $module = iwp_modules::getInstance()->GetModule($data['modulename'])->ShowPageByDbUri($data); }