Beispiel #1
0
function shFinalizeURL($url)
{
    $sefConfig = shRouter::shGetConfig();
    if ($sefConfig->shEncodeUrl && !empty($url) && strpos($url, '/index.php?/') === false) {
        // V w 27/08/2007 13:38:34 sh_NetURL does not work if
        $URI = new sh_Net_URL($url);
        // using this rewrite mode as the added ? fools it if there is indeed
        if (!empty($URI->path)) {
            // a query string. Better not do anything
            $url = $URI->protocol . '://' . $URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($URI->port) ? '' : ':' . $URI->port);
            $url .= $sefConfig->shEncodeUrl ? shUrlEncode($URI->path) : $URI->path;
            if (count($URI->querystring) > 0) {
                $shTemp = '';
                foreach ($URI->querystring as $key => $value) {
                    if (is_array($value)) {
                        // array fix, thanks doorknob
                        foreach ($value as $k => $v) {
                            $shTemp .= '&' . $key . '[' . $k . ']=' . ($sefConfig->shEncodeUrl ? shUrlEncode($v) : $v);
                        }
                    } else {
                        $shTemp .= '&' . $key . '=' . ($sefConfig->shEncodeUrl ? shUrlEncode($value) : $value);
                    }
                }
                $shTemp = JString::ltrim($shTemp, '&');
                // V x 02/09/2007 21:17:19
                $url .= '?' . $shTemp;
                // V x 02/09/2007 21:17:24
            }
            if ($URI->anchor) {
                $url .= '#' . ($sefConfig->shEncodeUrl ? shUrlEncode($URI->anchor) : $URI->anchor);
            }
        }
    }
    // V 1.2.4.s hack to workaround Virtuemart/SearchEngines issue with cookie check
    // V 1.2.4.t fixed bug, was checking for vmcchk instead of vmchk
    if (shIsSearchEngine() && strpos($url, 'vmchk') !== false) {
        $url = str_replace('vmchk/', '', $url);
        // remove check,
        //cookie will be forced if user agent is searchengine
    }
    $url = str_replace('&', '&', $url);
    // when Joomla wil turn that into & we are sur we won't have &
    return $url;
}
Beispiel #2
0
         // if it ends with a /, remove it
         rtrim($shPageInfo->shSaveRequestURI, '/');
     }
     $shQueryString = $sef_ext->revert($shTempPathArray, $pos);
     // warning : revert may do a 301 to same url with correct case !
     $shPageInfo->shSaveRequestURI = $shSaveRequestURIBackup;
     if (is_valid($shQueryString)) {
         //let's redirect to this new URL
         $dest = str_replace($GLOBALS['shConfigLiveSite'] . $sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '', $shPageInfo->URI->url);
         $dest = JString::trim(str_replace($GLOBALS['shConfigLiveSite'], '', $dest), '/');
         _log('Redirecting to same with trailing slash added');
         shRedirect($GLOBALS['shConfigLiveSite'] . $sefConfig->shRewriteStrings[$sefConfig->shRewriteMode] . $dest . (empty($shLastBit) ? '' : '/'));
     }
 }
 // V 1.3.1 : check for aliases
 $path = $sefConfig->shEncodeUrl ? shUrlEncode($path) : $path;
 shCheckCustomRedirects($path, $shPageInfo);
 // check Joomla 1.5 sef redirect to sh404sef redirect
 if (empty($shPageInfo->autoRedirectsDisabled) && $sefConfig->shRedirectJoomlaSefToSef) {
     // get current URI and router
     $jUri = clone $uri;
     $shRouter =& $mainframe->getRouter();
     // ask Joomla stored router to parse the uri
     $nonSefVars = $shRouter->jRouter->parse($jUri);
     // make sure we don't have a conflict with 1.0.x style sef urls, when they start with componen/option,...
     if (!empty($nonSefVars['option']) && preg_match('/^com_[_A-Za-z0-9]*$/', $nonSefVars['option'])) {
         // reset pre-existing query and path
         $jUri->setQuery('');
         $jUri->setPath('');
         // set vars obtained from parsing the current request
         if (!empty($nonSefVars)) {