Index: trunk/core/kernel/utility/http_query.php =================================================================== diff -u -r3425 -r3440 --- trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 3425) +++ trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 3440) @@ -68,7 +68,7 @@ * @access public */ var $Conn; - + /** * Loads info from $_POST, $_GET and * related arrays into common place @@ -81,7 +81,7 @@ { parent::Params(); $this->Conn =& $this->Application->GetADODBConnection(); - + $this->Order = $order; $this->Admin = $this->Application->IsAdmin(); // better cache this value, not to calculate it each time in foreach } @@ -97,7 +97,7 @@ } ini_set('magic_quotes_gpc', 0); } - + function removeSpecials($array) { $ret = Array(); @@ -133,31 +133,31 @@ $this->Get = $this->AddVars($_GET); $this->processQueryString(); break; - + case 'P': $this->Post = $this->AddVars($_POST); $this->convertPostEvents(); break; - + case 'C': $this->Cookie = $this->AddVars($_COOKIE); break; - + case 'E'; $this->Env = $this->AddVars($_ENV); break; - + case 'S'; $this->Server = $this->AddVars($_SERVER); break; - + case 'F'; $this->convertFiles(); $this->Files = $this->MergeVars($_FILES, false); //do not strip slashes! break; } } - + if( $this->Application->RewriteURLs() ) { if( $this->Application->isDebugMode() ) @@ -170,7 +170,7 @@ { $this->processRewriteURL(); } - + } } @@ -288,22 +288,22 @@ } $passed = implode(',', $passed); $this->Set('passed', $passed); - + $env = $this->Application->BuildEnv( $this->Get('t'), $module_params, $passed, false, false ); $this->Set(ENV_VAR_NAME, $env); $_REQUEST['env'] = $_GET['env'] = $env; // for capability with old in-portal code } - + function processRewriteURL() { // directory_1_2_3/sc1/inlink/detail/3/l1_ka_asd.html - + $url = $this->Get('_mod_rw_url_'); - if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 ); - + if( substr($url, -5) == '.html' ) $url = substr($url, 0, strlen($url) - 5 ); + $url_parts = $url ? explode('/', $url) : Array(); - - if($this->Get('rewrite') == 'on') + + if($this->Get('rewrite') == 'on' || !$url_parts) { // set default values $defaults = Array('m_cat_id' => 0, 'm_cat_page' => 1, 'm_opener' => 's'); @@ -312,7 +312,7 @@ $this->Set($default_key, $default_value); } } - + if(!$url_parts) { $this->Application->Phrases = new PhrasesCache(); @@ -328,9 +328,9 @@ { $this->Set('t', ''); } - + $url_part = array_shift($url_parts); - + // match language $sql = 'SELECT LanguageId FROM '.TABLE_PREFIX.'Language WHERE LOWER(PackName) = '.$this->Conn->qstr($url_part).' AND Enabled = 1'; $language_id = $this->Conn->GetOne($sql); @@ -340,12 +340,12 @@ $this->Set('m_lang', $language_id); $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing } - + $this->Application->VerifyLanguageId(); - + $this->Application->Phrases->Init('phrases'); // $this->Get('m_lang') ); - + // match theme if($url_part) { @@ -356,10 +356,9 @@ $this->Set('m_theme', $theme_id); $url_part = $url_parts ? array_shift($url_parts) : ''; // prepare next url part for parsing } - - $this->Application->VerifyThemeId(); } - + $this->Application->VerifyThemeId(); // verify anyway - will set default if not found!!! + // match category if($url_part) { @@ -370,24 +369,24 @@ do { $category_path = trim($category_path.'/'.$url_part, '/'); - + if( preg_match('/(.*)_([\d]+)$/', $category_path, $rets) ) { $category_path = $rets[1]; $this->Set('m_cat_page', $rets[2]); } - + $sql = 'SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE NamedParentPath = '.$this->Conn->qstr($category_path); array_push($category_stack, $this->Conn->GetOne($sql) ); $category_found = end($category_stack); if($category_found) $url_part = array_shift($url_parts); - + }while ($category_found && $url_part); - + if( count($category_stack) >= 2 ) { $category_id = array_pop($category_stack); // remove last not found category - if($category_id === false) + if($category_id === false) { $category_id = array_pop($category_stack); } @@ -401,7 +400,7 @@ $url_part = array_shift($url_parts); } } - + // match module $next_template = $this->Get('next_template'); if($url_part || $next_template) @@ -415,7 +414,7 @@ { $module_folder = $url_part; } - + foreach ($this->Application->ModuleInfo as $module_name => $module_data) { if( trim($module_data['TemplatePath'], '/') == $module_folder ) @@ -425,7 +424,7 @@ } } } - + // match template $template_path = ''; $template_found = false; @@ -437,17 +436,17 @@ do { $template_path = implode('/', $template_parts); - + $sql = 'SELECT FileId FROM '.TABLE_PREFIX.'ThemeFiles WHERE CONCAT(FilePath, "/", FileName) = '.$this->Conn->qstr('/'.$template_path.'.tpl'); $template_found = $this->Conn->GetOne($sql); if(!$template_found) { array_unshift( $url_parts, array_pop($template_parts) ); } - + }while (!$template_found && $template_parts); } - + // guess template if no existing template found if(!$template_found && isset($module_folder) && $module_folder) { @@ -466,22 +465,22 @@ if(!$template_path) $template_path = 'error_notfound'; } } - - + + $this->Set('t', $this->getDefaultTemplate($template_found ? $template_path : '') ); // pass params left to module - + $passed = Array('m'); $module_params = Array(); - + if( isset($module_prefix) ) { $passed[] = $module_prefix; $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => $url_parts) ); $this->Application->HandleEvent($module_event); $item_id = $this->Get($module_prefix.'_id'); $module_params = Array($module_prefix.'_id' => $item_id ? $item_id : '0' ); - + if($module_event->status == erFAIL) { $not_found = $this->Application->ConfigValue('ErrorTemplate'); @@ -491,14 +490,14 @@ $this->finalizeParsing($passed, $module_params); } - + function getDefaultTemplate($t) { $t = $this->getTemplateName( trim($t, '/') ); if (!$t) $t = 'index'; return trim($t, '/'); } - + function extractSIDAndTemplate(&$parts) { if ( defined('INPORTAL_ENV') && INPORTAL_ENV ) // SID-TEMPLATE @@ -527,7 +526,7 @@ $this->Set('t', $this->getDefaultTemplate($t) ); } } - + /** * Process QueryString only, create * events, ids, based on config @@ -677,7 +676,7 @@ } return $array; } - + /** * Returns all $_GET array excluding system parameters, that are not allowed to be passed through generated urls *