Index: trunk/core/kernel/application.php =================================================================== diff -u -r3137 -r3145 --- trunk/core/kernel/application.php (.../application.php) (revision 3137) +++ trunk/core/kernel/application.php (.../application.php) (revision 3145) @@ -189,10 +189,10 @@ $GLOBALS['debugger']->profileFinish('kernel4_startup'); } - if( defined('CMS') && CMS == 1 && !$this->GetVar('admin') && !$this->IsAdmin() ) - { - define('MOD_REWRITE', 1); - } + $cms_on = defined('CMS') && CMS; + $rewrite_on = $this->ConfigValue('UseModRewrite'); + $admin_on = $this->GetVar('admin') || $this->IsAdmin(); + define('MOD_REWRITE', ($rewrite_on || $cms_on) && !$admin_on ? 1 : 0); $this->InitDone = true; return true; @@ -755,7 +755,8 @@ unset($params['anchor']); } - if (defined('MOD_REWRITE') && MOD_REWRITE) { + if ( $this->RewriteURLs() ) + { $env = $this->BuildEnv('', $params, $pass, $pass_events, false); $env = ltrim($env, ':-'); @@ -765,7 +766,8 @@ $ret = rtrim($this->BaseURL($prefix, $ssl).$t.'.html/'.$env.'/'.$sid.$map_link, '/'); } - else { + else + { $env = $this->BuildEnv($t, $params, $pass, $pass_events); $ret = $this->BaseURL($prefix, $ssl).$index_file.'?'.$env.$map_link; } @@ -776,7 +778,7 @@ function BuildEnv($t, $params, $pass='all', $pass_events=false, $env_var=true) { $session =& $this->recallObject('Session'); - $sid = $session->NeedQueryString() && !(defined('MOD_REWRITE') && MOD_REWRITE) ? $this->GetSID() : ''; + $sid = $session->NeedQueryString() && !$this->RewriteURLs() ? $this->GetSID() : ''; if( getArrayValue($params,'admin') == 1 ) $sid = $this->GetSID(); $ret = ''; @@ -877,6 +879,9 @@ if ($t == '' || $t === true) $t = $this->GetVar('t'); // pass prefixes and special from previous url + $js_redirect = getArrayValue($params, 'js_redirect'); + if( isset($params['js_redirect']) ) unset($params['js_redirect']); + if (!isset($params['pass'])) $params['pass'] = 'all'; $params['__URLENCODE__'] = 1; $location = $this->HREF($t, $prefix, $params, $index_file); @@ -900,13 +905,22 @@ } else { - if(headers_sent() != '') + if($js_redirect) { - echo ''; + $this->InitParser(); + $block_params = Array('name' => 'redirect', 'redirect_to_js' => addslashes($a_location), 'redirect_to' => $a_location ); + echo $this->ParseBlock($block_params); } else { - header("$location"); + if(headers_sent() != '') + { + echo ''; + } + else + { + header("$location"); + } } } @@ -1122,6 +1136,16 @@ } /** + * Apply url rewriting used by mod_rewrite or not + * + * @return bool + */ + function RewriteURLs() + { + return defined('MOD_REWRITE') && MOD_REWRITE; + } + + /** * Reads unit (specified by $prefix) * option specified by $option *