/** * Get tracking snippet * */ public function getSnippet() { // get config $sefConfig = & Sh404sefFactory::getConfig(); $pageInfo = & Sh404sefFactory::getPageInfo(); // should we insert tracking code snippet ? if (!$this->_shouldInsertSnippet()) { return ''; } // finalize snippet : add user tracking code $snippet = str_replace( '{tracking_code}', trim($sefConfig->analyticsId), $this->_snippet); // prepare empty array to collect custom vars from plugins $customVars = array(); // fire event so that plugin(s) attach custom vars $dispatcher = &JDispatcher::getInstance(); $dispatcher->trigger('onShInsertAnalyticsSnippet', array( &$customVars, $sefConfig)); // put custom vars into snippet for($i=1;$i < 6; $i++) { $marker = '{customVar' . $i . '}'; if (!empty($customVars[$i]) && !empty( $customVars[$i]->name)) { $replace = "_gaq.push(['_setCustomVar', " . $i . ", '" . htmlentities( $customVars[$i]->name, ENT_QUOTES, 'UTF-8') . "', '" . htmlentities( $customVars[$i]->value, ENT_QUOTES, 'UTF-8') . "', 3]);"; } else { $replace = ''; } $snippet = str_replace( $marker, $replace, $snippet); } // in case of 404, we use a custom page url so that 404s can also be tracked in GA $marker = '{customUrl}'; if(!empty($pageInfo->httpStatus) && $pageInfo->httpStatus == 404) { //$customUrl = ", '/__404__?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer"; $customUrl = ", '/__404__'"; } else { $customUrl = ''; } $snippet = str_replace( $marker, $customUrl, $snippet); return $snippet; }
public static function updateShurls() { $pageInfo =& Sh404sefFactory::getPageInfo(); $sefConfig =& Sh404sefFactory::getConfig(); $pageInfo->shURL = empty($pageInfo->shURL) ? '' : $pageInfo->shURL; if ($sefConfig->enablePageId && !$sefConfig->stopCreatingShurls) { try { jimport('joomla.utilities.string'); $nonSefUrl = JString::ltrim($pageInfo->currentNonSefUrl, '/'); $nonSefUrl = shSortURL($nonSefUrl); // make sure we have a language $nonSefUrl = shSetURLVar($nonSefUrl, 'lang', $pageInfo->currentLanguageShortTag); // remove tracking vars (Google Analytics) $nonSefUrl = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef($nonSefUrl); // try to get the current shURL, if any $shURL = ShlDbHelper::selectResult('#__sh404sef_pageids', array('pageid'), array('newurl' => $nonSefUrl)); // if none, we may have to create one if (empty($shURL)) { $shURL = self::_createShurl($nonSefUrl); } // insert in head and header, if not empty if (!empty($shURL)) { $fullShURL = JString::ltrim($pageInfo->getDefaultFrontLiveSite(), '/') . '/' . $shURL; $document = JFactory::getDocument(); if ($sefConfig->insertShortlinkTag) { $document->addHeadLink($fullShURL, 'shortlink'); // also add header, especially for HEAD requests JResponse::setHeader('Link', '<' . $fullShURL . '>; rel=shortlink', true); } if ($sefConfig->insertRevCanTag) { $document->addHeadLink($fullShURL, 'canonical', 'rev', array('type' => 'text/html')); } if ($sefConfig->insertAltShorterTag) { $document->addHeadLink($fullShURL, 'alternate shorter'); } // store for reuse $pageInfo->shURL = $shURL; } } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } } }
function plgSh404sefsimilarurls($context, &$rowContent, &$params, $page = 0) { if (!defined('SH404SEF_IS_RUNNING')) { // only do something if sh404sef is up and running return true; } // a little hack on the side : optionnally display the requested url // first get current sef url $shPageInfo =& Sh404sefFactory::getPageInfo(); // replace marker $rowContent->text = str_replace('{%sh404SEF_404_URL%}', htmlspecialchars(JURI::getInstance()->get('_uri'), ENT_COMPAT, 'UTF-8'), $rowContent->text); // now the similar urls $marker = 'sh404sefSimilarUrls'; // quick check for our marker: if (JString::strpos($rowContent->text, $marker) === false) { return true; } // get plugin params $plugin =& JPluginHelper::getPlugin('sh404sefcore', 'sh404sefsimilarurls'); // init params from plugin $pluginParams = new JRegistry(); $pluginParams->loadString($plugin->params); $matches = array(); // regexp to catch plugin requests $regExp = "#{" . $marker . "}#Us"; // search for our marker} if (preg_match_all($regExp, $rowContent->text, $matches, PREG_SET_ORDER) > 0) { // we have at least one match, we can search for similar urls $html = shGetSimilarUrls(JURI::getInstance()->getPath(), $pluginParams); // remove comment, so that nothing shows if (empty($html)) { $rowContent->text = preg_replace('/{sh404sefSimilarUrlsCommentStart}.*{sh404sefSimilarUrlsCommentEnd}/iUs', '', $rowContent->text); } else { // remove the comment markers themselves $rowContent->text = str_replace('{sh404sefSimilarUrlsCommentStart}', '', $rowContent->text); $rowContent->text = str_replace('{sh404sefSimilarUrlsCommentEnd}', '', $rowContent->text); } // now replace instances of the marker by similar urls list $rowContent->text = str_replace($matches[0], $html, $rowContent->text); } return true; }
/** * Checks whether a request is coming from mobile device * * @return boolean true if current page request is from a known mobile device */ public static function isMobileRequest() { static $isMobile = null; static $defaultRecords = array(array('start' => 0, 'stop' => 0, 'string' => '/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile|o2|opera m(ob|in)i|palm( os)?|p(ixi|re)\\/|plucker|pocket|psp|smartphone|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce; (iemobile|ppc)|xiino/i'), array('start' => 0, 'stop' => 4, 'string' => '/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|e\\-|e\\/|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\\-|2|g)|yas\\-|your|zeto|zte\\-/i')); if (is_null($isMobile)) { jimport('joomla.environment.browser'); $browser =& JBrowser::getInstance(); $isMobile = $browser->get('_mobile'); $userAgent = $browser->get('_lowerAgent'); // detection code adapted from http://detectmobilebrowser.com/ $remoteConfig = Sh404sefHelperUpdates::getRemoteConfig($forced = false); $remotesRecords = empty($remoteConfig->config['mobiledetectionstrings']) ? array() : $remoteConfig->config['mobiledetectionstrings']; $records = empty($remotes) ? $defaultRecords : $remotesRecords; foreach ($records as $record) { $isMobile = $isMobile || (empty($record['stop']) ? preg_match($record['string'], substr($userAgent, $record['start'])) : preg_match($record['string'], substr($userAgent, $record['start'], $record['stop']))); } // tell page information object about this Sh404sefFactory::getPageInfo()->isMobileRequest = $isMobile ? Sh404sefClassPageinfo::LIVE_SITE_MOBILE : Sh404sefClassPageinfo::LIVE_SITE_NOT_MOBILE; } return $isMobile; }
function shSEFConfig() { $sef_config_file = sh404SEF_ADMIN_ABS_PATH . 'config/config.sef.php'; $app = JFactory::getApplication(); if ($app->isAdmin()) { $this->shCheckFilesAccess(); } if (shFileExists($sef_config_file)) { include $sef_config_file; } // shumisha : 2007-04-01 new parameters ! if (isset($shUseURLCache)) { $this->shUseURLCache = $shUseURLCache; } // shumisha : 2007-04-01 new parameters ! if (isset($shMaxURLInCache)) { $this->shMaxURLInCache = $shMaxURLInCache; } // shumisha : 2007-04-01 new parameters ! if (isset($shTranslateURL)) { $this->shTranslateURL = $shTranslateURL; } //V 1.2.4.m if (isset($shInsertLanguageCode)) { $this->shInsertLanguageCode = $shInsertLanguageCode; } if (isset($notTranslateURLList)) { $this->notTranslateURLList = $notTranslateURLList; } if (isset($notInsertIsoCodeList)) { $this->notInsertIsoCodeList = $notInsertIsoCodeList; } // shumisha : 2007-04-03 new parameters ! if (isset($shInsertGlobalItemidIfNone)) { $this->shInsertGlobalItemidIfNone = $shInsertGlobalItemidIfNone; } if (isset($shInsertTitleIfNoItemid)) { $this->shInsertTitleIfNoItemid = $shInsertTitleIfNoItemid; } if (isset($shAlwaysInsertMenuTitle)) { $this->shAlwaysInsertMenuTitle = $shAlwaysInsertMenuTitle; } if (isset($shAlwaysInsertItemid)) { $this->shAlwaysInsertItemid = $shAlwaysInsertItemid; } if (isset($shDefaultMenuItemName)) { $this->shDefaultMenuItemName = $shDefaultMenuItemName; } if (isset($shAppendRemainingGETVars)) { $this->shAppendRemainingGETVars = $shAppendRemainingGETVars; } if (isset($shVmInsertShopName)) { $this->shVmInsertShopName = $shVmInsertShopName; } if (isset($shInsertProductId)) { $this->shInsertProductId = $shInsertProductId; } if (isset($shVmUseProductSKU)) { $this->shVmUseProductSKU = $shVmUseProductSKU; } if (isset($shVmInsertManufacturerName)) { $this->shVmInsertManufacturerName = $shVmInsertManufacturerName; } if (isset($shInsertManufacturerId)) { $this->shInsertManufacturerId = $shInsertManufacturerId; } if (isset($shVMInsertCategories)) { $this->shVMInsertCategories = $shVMInsertCategories; } if (isset($shVmAdditionalText)) { $this->shVmAdditionalText = $shVmAdditionalText; } if (isset($shVmInsertFlypage)) { $this->shVmInsertFlypage = $shVmInsertFlypage; } if (isset($shInsertCategoryId)) { $this->shInsertCategoryId = $shInsertCategoryId; } if (isset($shReplacements)) { $this->shReplacements = $shReplacements; } if (isset($shInsertNumericalId)) { $this->shInsertNumericalId = $shInsertNumericalId; } if (isset($shInsertNumericalIdCatList)) { $this->shInsertNumericalIdCatList = $shInsertNumericalIdCatList; } if (isset($shRedirectNonSefToSef)) { $this->shRedirectNonSefToSef = $shRedirectNonSefToSef; } // disabled, can't be implemented safely //if (isset($shRedirectJoomlaSefToSef)) $this->shRedirectJoomlaSefToSef = $shRedirectJoomlaSefToSef; if (isset($shConfig_live_secure_site)) { $this->shConfig_live_secure_site = JString::rtrim($shConfig_live_secure_site, '/'); } if (isset($shActivateIJoomlaMagInContent)) { $this->shActivateIJoomlaMagInContent = $shActivateIJoomlaMagInContent; } if (isset($shInsertIJoomlaMagIssueId)) { $this->shInsertIJoomlaMagIssueId = $shInsertIJoomlaMagIssueId; } if (isset($shInsertIJoomlaMagName)) { $this->shInsertIJoomlaMagName = $shInsertIJoomlaMagName; } if (isset($shInsertIJoomlaMagMagazineId)) { $this->shInsertIJoomlaMagMagazineId = $shInsertIJoomlaMagMagazineId; } if (isset($shInsertIJoomlaMagArticleId)) { $this->shInsertIJoomlaMagArticleId = $shInsertIJoomlaMagArticleId; } if (isset($shInsertCBName)) { $this->shInsertCBName = $shInsertCBName; } if (isset($shCBInsertUserName)) { $this->shCBInsertUserName = $shCBInsertUserName; } if (isset($shCBInsertUserId)) { $this->shCBInsertUserId = $shCBInsertUserId; } if (isset($shCBUseUserPseudo)) { $this->shCBUseUserPseudo = $shCBUseUserPseudo; } if (isset($shInsertMyBlogName)) { $this->shInsertMyBlogName = $shInsertMyBlogName; } if (isset($shMyBlogInsertPostId)) { $this->shMyBlogInsertPostId = $shMyBlogInsertPostId; } if (isset($shMyBlogInsertTagId)) { $this->shMyBlogInsertTagId = $shMyBlogInsertTagId; } if (isset($shMyBlogInsertBloggerId)) { $this->shMyBlogInsertBloggerId = $shMyBlogInsertBloggerId; } if (isset($shInsertDocmanName)) { $this->shInsertDocmanName = $shInsertDocmanName; } if (isset($shDocmanInsertDocId)) { $this->shDocmanInsertDocId = $shDocmanInsertDocId; } if (isset($shDocmanInsertDocName)) { $this->shDocmanInsertDocName = $shDocmanInsertDocName; } if (isset($shLog404Errors)) { $this->shLog404Errors = $shLog404Errors; } if (isset($shLMDefaultItemid)) { $this->shLMDefaultItemid = $shLMDefaultItemid; } if (isset($shInsertFireboardName)) { $this->shInsertFireboardName = $shInsertFireboardName; } if (isset($shFbInsertCategoryName)) { $this->shFbInsertCategoryName = $shFbInsertCategoryName; } if (isset($shFbInsertCategoryId)) { $this->shFbInsertCategoryId = $shFbInsertCategoryId; } if (isset($shFbInsertMessageSubject)) { $this->shFbInsertMessageSubject = $shFbInsertMessageSubject; } if (isset($shFbInsertMessageId)) { $this->shFbInsertMessageId = $shFbInsertMessageId; } if (isset($shDoNotOverrideOwnSef)) { // V 1.2.4.m $this->shDoNotOverrideOwnSef = $shDoNotOverrideOwnSef; } if (isset($shEncodeUrl)) { // V 1.2.4.m $this->shEncodeUrl = $shEncodeUrl; } if (isset($guessItemidOnHomepage)) { // V 1.2.4.q $this->guessItemidOnHomepage = $guessItemidOnHomepage; } if (isset($shForceNonSefIfHttps)) { // V 1.2.4.q $this->shForceNonSefIfHttps = $shForceNonSefIfHttps; } if (isset($shRewriteMode)) { // V 1.2.4.s $this->shRewriteMode = $shRewriteMode; } if (isset($shRewriteStrings)) { // V 1.2.4.s $this->shRewriteStrings = $shRewriteStrings; } if (isset($shMetaManagementActivated)) { // V 1.2.4.s $this->shMetaManagementActivated = $shMetaManagementActivated; } if (isset($shRemoveGeneratorTag)) { // V 1.2.4.s $this->shRemoveGeneratorTag = $shRemoveGeneratorTag; } if (isset($shPutH1Tags)) { // V 1.2.4.s $this->shPutH1Tags = $shPutH1Tags; } if (isset($shInsertContentTableName)) { // V 1.2.4.s $this->shInsertContentTableName = $shInsertContentTableName; } if (isset($shContentTableName)) { // V 1.2.4.s $this->shContentTableName = $shContentTableName; } if (isset($shAutoRedirectWww)) { // V 1.2.4.s $this->shAutoRedirectWww = $shAutoRedirectWww; } if (isset($shVmInsertProductName)) { // V 1.2.4.s $this->shVmInsertProductName = $shVmInsertProductName; } if (isset($shDMInsertCategories)) { // V 1.2.4.t $this->shDMInsertCategories = $shDMInsertCategories; } if (isset($shDMInsertCategoryId)) { // V 1.2.4.t $this->shDMInsertCategoryId = $shDMInsertCategoryId; } if (isset($shForcedHomePage)) { // V 1.2.4.t $this->shForcedHomePage = $shForcedHomePage; } if (isset($shInsertContentBlogName)) { // V 1.2.4.t $this->shInsertContentBlogName = $shInsertContentBlogName; } if (isset($shContentBlogName)) { // V 1.2.4.t $this->shContentBlogName = $shContentBlogName; } if (isset($shInsertMTreeName)) { // V 1.2.4.t $this->shInsertMTreeName = $shInsertMTreeName; } if (isset($shMTreeInsertListingName)) { // V 1.2.4.t $this->shMTreeInsertListingName = $shMTreeInsertListingName; } if (isset($shMTreeInsertListingId)) { // V 1.2.4.t $this->shMTreeInsertListingId = $shMTreeInsertListingId; } if (isset($shMTreePrependListingId)) { // V 1.2.4.t $this->shMTreePrependListingId = $shMTreePrependListingId; } if (isset($shMTreeInsertCategories)) { // V 1.2.4.t $this->shMTreeInsertCategories = $shMTreeInsertCategories; } if (isset($shMTreeInsertCategoryId)) { // V 1.2.4.t $this->shMTreeInsertCategoryId = $shMTreeInsertCategoryId; } if (isset($shMTreeInsertUserName)) { // V 1.2.4.t $this->shMTreeInsertUserName = $shMTreeInsertUserName; } if (isset($shMTreeInsertUserId)) { // V 1.2.4.t $this->shMTreeInsertUserId = $shMTreeInsertUserId; } if (isset($shInsertNewsPName)) { // V 1.2.4.t $this->shInsertNewsPName = $shInsertNewsPName; } if (isset($shNewsPInsertCatId)) { // V 1.2.4.t $this->shNewsPInsertCatId = $shNewsPInsertCatId; } if (isset($shNewsPInsertSecId)) { // V 1.2.4.t $this->shNewsPInsertSecId = $shNewsPInsertSecId; } if (isset($shInsertRemoName)) { // V 1.2.4.t $this->shInsertRemoName = $shInsertRemoName; } if (isset($shRemoInsertDocId)) { // V 1.2.4.t $this->shRemoInsertDocId = $shRemoInsertDocId; } if (isset($shRemoInsertDocName)) { // V 1.2.4.t $this->shRemoInsertDocName = $shRemoInsertDocName; } if (isset($shRemoInsertCategories)) { // V 1.2.4.t $this->shRemoInsertCategories = $shRemoInsertCategories; } if (isset($shRemoInsertCategoryId)) { // V 1.2.4.t $this->shRemoInsertCategoryId = $shRemoInsertCategoryId; } if (isset($shCBShortUserURL)) { // V 1.2.4.t $this->shCBShortUserURL = $shCBShortUserURL; } if (isset($shKeepStandardURLOnUpgrade)) { // V 1.2.4.t $this->shKeepStandardURLOnUpgrade = $shKeepStandardURLOnUpgrade; } if (isset($shKeepCustomURLOnUpgrade)) { // V 1.2.4.t $this->shKeepCustomURLOnUpgrade = $shKeepCustomURLOnUpgrade; } if (isset($shKeepMetaDataOnUpgrade)) { // V 1.2.4.t $this->shKeepMetaDataOnUpgrade = $shKeepMetaDataOnUpgrade; } if (isset($shKeepModulesSettingsOnUpgrade)) { // V 1.2.4.t $this->shKeepModulesSettingsOnUpgrade = $shKeepModulesSettingsOnUpgrade; } if (isset($shMultipagesTitle)) { // V 1.2.4.t $this->shMultipagesTitle = $shMultipagesTitle; } // shumisha end of new parameters if (isset($Enabled)) { $this->Enabled = $Enabled; } if (isset($replacement)) { $this->replacement = $replacement; } if (isset($pagerep)) { $this->pagerep = $pagerep; } if (isset($stripthese)) { $this->stripthese = $stripthese; } if (isset($friendlytrim)) { $this->friendlytrim = $friendlytrim; } if (isset($suffix)) { $this->suffix = $suffix; } if (isset($addFile)) { $this->addFile = $addFile; } if (isset($LowerCase)) { $this->LowerCase = $LowerCase; } if (isset($HideCat)) { $this->HideCat = $HideCat; } if (isset($replacement)) { $this->UseAlias = $UseAlias; } if (isset($UseAlias)) { $this->page404 = $page404; } if (isset($predefined)) { $this->predefined = $predefined; } if (isset($skip)) { $this->skip = $skip; } if (isset($nocache)) { $this->nocache = $nocache; } // V x if (isset($shKeepConfigOnUpgrade)) { // V 1.2.4.x $this->shKeepConfigOnUpgrade = $shKeepConfigOnUpgrade; } if (isset($shSecEnableSecurity)) { // V 1.2.4.x $this->shSecEnableSecurity = $shSecEnableSecurity; } if (isset($shSecLogAttacks)) { // V 1.2.4.x $this->shSecLogAttacks = $shSecLogAttacks; } if (isset($shSecOnlyNumVars)) { // V 1.2.4.x $this->shSecOnlyNumVars = $shSecOnlyNumVars; } if (isset($shSecAlphaNumVars)) { // V 1.2.4.x $this->shSecAlphaNumVars = $shSecAlphaNumVars; } if (isset($shSecNoProtocolVars)) { // V 1.2.4.x $this->shSecNoProtocolVars = $shSecNoProtocolVars; } $this->ipWhiteList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_IP_white_list.dat'); $this->ipBlackList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_IP_black_list.dat'); $this->uAgentWhiteList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_uAgent_white_list.dat'); $this->uAgentBlackList = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_uAgent_black_list.dat'); if (isset($shSecCheckHoneyPot)) { // V 1.2.4.x $this->shSecCheckHoneyPot = $shSecCheckHoneyPot; } if (isset($shSecDebugHoneyPot)) { // V 1.2.4.x $this->shSecDebugHoneyPot = $shSecDebugHoneyPot; } if (isset($shSecHoneyPotKey)) { // V 1.2.4.x $this->shSecHoneyPotKey = $shSecHoneyPotKey; } if (isset($shSecEntranceText)) { // V 1.2.4.x $this->shSecEntranceText = $shSecEntranceText; } if (isset($shSecSmellyPotText)) { // V 1.2.4.x $this->shSecSmellyPotText = $shSecSmellyPotText; } if (isset($monthsToKeepLogs)) { // V 1.2.4.x $this->monthsToKeepLogs = $monthsToKeepLogs; } if (isset($shSecActivateAntiFlood)) { // V 1.2.4.x $this->shSecActivateAntiFlood = $shSecActivateAntiFlood; } if (isset($shSecAntiFloodOnlyOnPOST)) { // V 1.2.4.x $this->shSecAntiFloodOnlyOnPOST = $shSecAntiFloodOnlyOnPOST; } if (isset($shSecAntiFloodPeriod)) { // V 1.2.4.x $this->shSecAntiFloodPeriod = $shSecAntiFloodPeriod; } if (isset($shSecAntiFloodCount)) { // V 1.2.4.x $this->shSecAntiFloodCount = $shSecAntiFloodCount; } // if (isset($insertSectionInBlogTableLinks)) // V 1.2.4.x // $this->insertSectionInBlogTableLinks = $insertSectionInBlogTableLinks; $this->shLangTranslateList = $this->shInitLanguageList(isset($shLangTranslateList) ? $shLangTranslateList : null, 0, 0); $this->shLangInsertCodeList = $this->shInitLanguageList(isset($shLangInsertCodeList) ? $shLangInsertCodeList : null, 0, 0); if (isset($defaultComponentStringList)) { // V 1.2.4.x $this->defaultComponentStringList = $defaultComponentStringList; } $this->pageTexts = $this->shInitLanguageList(isset($pageTexts) ? $pageTexts : null, isset($pagetext) ? $pagetext : 'Page-%s', isset($pagetext) ? $pagetext : 'Page-%s'); // use value from prev versions if any if (isset($shAdminInterfaceType)) { // V 1.2.4.x $this->shAdminInterfaceType = $shAdminInterfaceType; } // compatibility with version earlier than V x if (isset($shShopName)) { // V 1.2.4.x $this->defaultComponentStringList['virtuemart'] = $shShopName; } if (isset($shIJoomlaMagName)) { // V 1.2.4.x $this->defaultComponentStringList['magazine'] = $shIJoomlaMagName; } if (isset($shCBName)) { // V 1.2.4.x $this->defaultComponentStringList['comprofiler'] = $shCBName; } if (isset($shFireboardName)) { // V 1.2.4.x $this->defaultComponentStringList['fireboard'] = $shFireboardName; } if (isset($shMyBlogName)) { // V 1.2.4.x $this->defaultComponentStringList['myblog'] = $shMyBlogName; } if (isset($shDocmanName)) { // V 1.2.4.x $this->defaultComponentStringList['docman'] = $shDocmanName; } if (isset($shMTreeName)) { // V 1.2.4.x $this->defaultComponentStringList['mtree'] = $shMTreeName; } if (isset($shNewsPName)) { // V 1.2.4.x $this->defaultComponentStringList['news_portal'] = $shNewsPName; } if (isset($shRemoName)) { // V 1.2.4.x $this->defaultComponentStringList['remository'] = $shRemoName; } // end of compatibility code // V 1.3 RC if (isset($shInsertNoFollowPDFPrint)) { $this->shInsertNoFollowPDFPrint = $shInsertNoFollowPDFPrint; } if (isset($shInsertReadMorePageTitle)) { $this->shInsertReadMorePageTitle = $shInsertReadMorePageTitle; } if (isset($shMultipleH1ToH2)) { $this->shMultipleH1ToH2 = $shMultipleH1ToH2; } // V 1.3.1 RC if (isset($shVmUsingItemsPerPage)) { $this->shVmUsingItemsPerPage = $shVmUsingItemsPerPage; } if (isset($shSecCheckPOSTData)) { $this->shSecCheckPOSTData = $shSecCheckPOSTData; } if (isset($shSecCurMonth)) { $this->shSecCurMonth = $shSecCurMonth; } if (isset($shSecLastUpdated)) { $this->shSecLastUpdated = $shSecLastUpdated; } if (isset($shSecTotalAttacks)) { $this->shSecTotalAttacks = $shSecTotalAttacks; } if (isset($shSecTotalConfigVars)) { $this->shSecTotalConfigVars = $shSecTotalConfigVars; } if (isset($shSecTotalBase64)) { $this->shSecTotalBase64 = $shSecTotalBase64; } if (isset($shSecTotalScripts)) { $this->shSecTotalScripts = $shSecTotalScripts; } if (isset($shSecTotalStandardVars)) { $this->shSecTotalStandardVars = $shSecTotalStandardVars; } if (isset($shSecTotalImgTxtCmd)) { $this->shSecTotalImgTxtCmd = $shSecTotalImgTxtCmd; } if (isset($shSecTotalIPDenied)) { $this->shSecTotalIPDenied = $shSecTotalIPDenied; } if (isset($shSecTotalUserAgentDenied)) { $this->shSecTotalUserAgentDenied = $shSecTotalUserAgentDenied; } if (isset($shSecTotalFlooding)) { $this->shSecTotalFlooding = $shSecTotalFlooding; } if (isset($shSecTotalPHP)) { $this->shSecTotalPHP = $shSecTotalPHP; } if (isset($shSecTotalPHPUserClicked)) { $this->shSecTotalPHPUserClicked = $shSecTotalPHPUserClicked; } if (isset($prependToPageTitle)) { $this->prependToPageTitle = $prependToPageTitle; } if (isset($appendToPageTitle)) { $this->appendToPageTitle = $appendToPageTitle; } if (isset($debugToLogFile)) { $this->debugToLogFile = $debugToLogFile; } if (isset($debugStartedAt)) { $this->debugStartedAt = $debugStartedAt; } if (isset($debugDuration)) { $this->debugDuration = $debugDuration; } // V 1.3.1 if (isset($shInsertOutboundLinksImage)) { $this->shInsertOutboundLinksImage = $shInsertOutboundLinksImage; } if (isset($shImageForOutboundLinks)) { $this->shImageForOutboundLinks = $shImageForOutboundLinks; } // V 1.0.12 if (isset($useCatAlias)) { $this->useCatAlias = $useCatAlias; } if (isset($useMenuAlias)) { $this->useMenuAlias = $useMenuAlias; } // V 1.5.3 if (isset($alwaysAppendItemsPerPage)) { $this->alwaysAppendItemsPerPage = $alwaysAppendItemsPerPage; } if (isset($redirectToCorrectCaseUrl)) { $this->redirectToCorrectCaseUrl = $redirectToCorrectCaseUrl; } // V 1.5.5 if (isset($jclInsertEventId)) { $this->jclInsertEventId = $jclInsertEventId; } if (isset($jclInsertCategoryId)) { $this->jclInsertCategoryId = $jclInsertCategoryId; } if (isset($jclInsertCalendarId)) { $this->jclInsertCalendarId = $jclInsertCalendarId; } if (isset($jclInsertCalendarName)) { $this->jclInsertCalendarName = $jclInsertCalendarName; } if (isset($jclInsertDate)) { $this->jclInsertDate = $jclInsertDate; } if (isset($jclInsertDateInEventView)) { $this->jclInsertDateInEventView = $jclInsertDateInEventView; } if (isset($ContentTitleShowCat)) { $this->ContentTitleShowCat = $ContentTitleShowCat; } if (isset($ContentTitleUseAlias)) { $this->ContentTitleUseAlias = $ContentTitleUseAlias; } if (isset($ContentTitleUseCatAlias)) { $this->ContentTitleUseCatAlias = $ContentTitleUseCatAlias; } if (isset($pageTitleSeparator)) { $this->pageTitleSeparator = $pageTitleSeparator; } if (isset($ContentTitleInsertArticleId)) { $this->ContentTitleInsertArticleId = $ContentTitleInsertArticleId; } if (isset($shInsertContentArticleIdCatList)) { $this->shInsertContentArticleIdCatList = $shInsertContentArticleIdCatList; } // 1.5.8 if (isset($shJSInsertJSName)) { $this->shJSInsertJSName = $shJSInsertJSName; } if (isset($shJSShortURLToUserProfile)) { $this->shJSShortURLToUserProfile = $shJSShortURLToUserProfile; } if (isset($shJSInsertUsername)) { $this->shJSInsertUsername = $shJSInsertUsername; } if (isset($shJSInsertUserFullName)) { $this->shJSInsertUserFullName = $shJSInsertUserFullName; } if (isset($shJSInsertUserId)) { $this->shJSInsertUserId = $shJSInsertUserId; } if (isset($shJSInsertUserFullName)) { $this->shJSInsertUserFullName = $shJSInsertUserFullName; } if (isset($shJSInsertGroupCategory)) { $this->shJSInsertGroupCategory = $shJSInsertGroupCategory; } if (isset($shJSInsertGroupCategoryId)) { $this->shJSInsertGroupCategoryId = $shJSInsertGroupCategoryId; } if (isset($shJSInsertGroupId)) { $this->shJSInsertGroupId = $shJSInsertGroupId; } if (isset($shJSInsertGroupBulletinId)) { $this->shJSInsertGroupBulletinId = $shJSInsertGroupBulletinId; } if (isset($shJSInsertDiscussionId)) { $this->shJSInsertDiscussionId = $shJSInsertDiscussionId; } if (isset($shJSInsertMessageId)) { $this->shJSInsertMessageId = $shJSInsertMessageId; } if (isset($shJSInsertPhotoAlbum)) { $this->shJSInsertPhotoAlbum = $shJSInsertPhotoAlbum; } if (isset($shJSInsertPhotoAlbumId)) { $this->shJSInsertPhotoAlbumId = $shJSInsertPhotoAlbumId; } if (isset($shJSInsertPhotoId)) { $this->shJSInsertPhotoId = $shJSInsertPhotoId; } if (isset($shJSInsertVideoCat)) { $this->shJSInsertVideoCat = $shJSInsertVideoCat; } if (isset($shJSInsertVideoCatId)) { $this->shJSInsertVideoCatId = $shJSInsertVideoCatId; } if (isset($shJSInsertVideoId)) { $this->shJSInsertVideoId = $shJSInsertVideoId; } if (isset($shFbInsertUserName)) { $this->shFbInsertUserName = $shFbInsertUserName; } if (isset($shFbInsertUserId)) { $this->shFbInsertUserId = $shFbInsertUserId; } if (isset($shFbShortUrlToProfile)) { $this->shFbShortUrlToProfile = $shFbShortUrlToProfile; } if (isset($shPageNotFoundItemid)) { $this->shPageNotFoundItemid = $shPageNotFoundItemid; } if (isset($autoCheckNewVersion)) { $this->autoCheckNewVersion = $autoCheckNewVersion; } if (isset($error404SubTemplate)) { $this->error404SubTemplate = $error404SubTemplate; } if (isset($enablePageId)) { $this->enablePageId = $enablePageId; } if (isset($compEnablePageId)) { $this->compEnablePageId = $compEnablePageId; } // V 2.1.0 if (isset($analyticsEnabled)) { $this->analyticsEnabled = $analyticsEnabled; } if (isset($analyticsReportsEnabled)) { $this->analyticsReportsEnabled = $analyticsReportsEnabled; } if (isset($analyticsType)) { $this->analyticsType = $analyticsType; } if (isset($analyticsId)) { $this->analyticsId = $analyticsId; } if (isset($analyticsUser)) { $this->analyticsUser = $analyticsUser; } if (isset($analyticsPassword)) { $this->analyticsPassword = $analyticsPassword; } if (isset($analyticsAccount)) { $this->analyticsAccount = $analyticsAccount; } if (isset($analyticsExcludeIP)) { $this->analyticsExcludeIP = $analyticsExcludeIP; } if (isset($analyticsMaxUserLevel)) { $this->analyticsMaxUserLevel = $analyticsMaxUserLevel; } if (isset($analyticsProfile)) { $this->analyticsProfile = $analyticsProfile; } if (isset($autoCheckNewAnalytics)) { $this->autoCheckNewAnalytics = $autoCheckNewAnalytics; } if (isset($analyticsDashboardDateRange)) { $this->analyticsDashboardDateRange = $analyticsDashboardDateRange; } if (isset($analyticsEnableTimeCollection)) { $this->analyticsEnableTimeCollection = $analyticsEnableTimeCollection; } if (isset($analyticsEnableUserCollection)) { $this->analyticsEnableUserCollection = $analyticsEnableUserCollection; } if (isset($analyticsDashboardDataType)) { $this->analyticsDashboardDataType = $analyticsDashboardDataType; } if (isset($slowServer)) { $this->slowServer = $slowServer; } // V 2.1.10 if (isset($useJoomsefRouter)) { $this->useJoomsefRouter = $useJoomsefRouter; } if (isset($useAcesefRouter)) { $this->useAcesefRouter = $useAcesefRouter; } // V 2.1.11 if (isset($insertShortlinkTag)) { $this->insertShortlinkTag = $insertShortlinkTag; } if (isset($insertRevCanTag)) { $this->insertRevCanTag = $insertRevCanTag; } if (isset($insertAltShorterTag)) { $this->insertAltShorterTag = $insertAltShorterTag; } if (isset($canReadRemoteConfig)) { $this->canReadRemoteConfig = $canReadRemoteConfig; } if (isset($stopCreatingShurls)) { $this->stopCreatingShurls = $stopCreatingShurls; } if (isset($shurlBlackList)) { $this->shurlBlackList = $shurlBlackList; } if (isset($shurlNonSefBlackList)) { $this->shurlNonSefBlackList = $shurlNonSefBlackList; } // V 3.0.0 if (isset($includeContentCat)) { $this->includeContentCat = $includeContentCat; } if (isset($includeContentCatCategories)) { $this->includeContentCatCategories = $includeContentCatCategories; } if (isset($contentCategoriesSuffix)) { $this->contentCategoriesSuffix = $contentCategoriesSuffix; } if (isset($contentTitleIncludeCat)) { $this->contentTitleIncludeCat = $contentTitleIncludeCat; } if (isset($useContactCatAlias)) { $this->useContactCatAlias = $useContactCatAlias; } if (isset($contactCategoriesSuffix)) { $this->contactCategoriesSuffix = $contactCategoriesSuffix; } if (isset($includeContactCat)) { $this->includeContactCat = $includeContactCat; } if (isset($includeContactCatCategories)) { $this->includeContactCatCategories = $includeContactCatCategories; } if (isset($useWeblinksCatAlias)) { $this->useWeblinksCatAlias = $useWeblinksCatAlias; } if (isset($weblinksCategoriesSuffix)) { $this->weblinksCategoriesSuffix = $weblinksCategoriesSuffix; } if (isset($includeWeblinksCat)) { $this->includeWeblinksCat = $includeWeblinksCat; } if (isset($includeWeblinksCatCategories)) { $this->includeWeblinksCatCategories = $includeWeblinksCatCategories; } $this->liveSites = $this->shInitLanguageList(isset($liveSites) ? $liveSites : array(), '', ''); if (isset($alternateTemplate)) { $this->alternateTemplate = $alternateTemplate; } if (isset($useJoomlaRouter)) { $this->useJoomlaRouter = $useJoomlaRouter; } if (isset($slugForUncategorizedContent)) { $this->slugForUncategorizedContent = $slugForUncategorizedContent; } if (isset($slugForUncategorizedContact)) { $this->slugForUncategorizedContact = $slugForUncategorizedContact; } if (isset($slugForUncategorizedWeblinks)) { $this->slugForUncategorizedWeblinks = $slugForUncategorizedWeblinks; } // 3.4 if (isset($enableMultiLingualSupport)) { $this->enableMultiLingualSupport = $enableMultiLingualSupport; } if (isset($enableOpenGraphData)) { $this->enableOpenGraphData = $enableOpenGraphData; } if (isset($ogEnableDescription)) { $this->ogEnableDescription = $ogEnableDescription; } if (isset($ogType)) { $this->ogType = $ogType; } if (isset($ogImage)) { $this->ogImage = $ogImage; } if (isset($ogEnableSiteName)) { $this->ogEnableSiteName = $ogEnableSiteName; } if (isset($ogSiteName)) { $this->ogSiteName = $ogSiteName; } if (isset($ogEnableLocation)) { $this->ogEnableLocation = $ogEnableLocation; } if (isset($ogLatitude)) { $this->ogLatitude = $ogLatitude; } if (isset($ogLongitude)) { $this->ogLongitude = $ogLongitude; } if (isset($ogStreetAddress)) { $this->ogStreetAddress = $ogStreetAddress; } if (isset($ogLocality)) { $this->ogLocality = $ogLocality; } if (isset($ogPostalCode)) { $this->ogPostalCode = $ogPostalCode; } if (isset($ogRegion)) { $this->ogRegion = $ogRegion; } if (isset($ogCountryName)) { $this->ogCountryName = $ogCountryName; } if (isset($ogEnableContact)) { $this->ogEnableContact = $ogEnableContact; } if (isset($ogEmail)) { $this->ogEmail = $ogEmail; } if (isset($ogPhoneNumber)) { $this->ogPhoneNumber = $ogPhoneNumber; } if (isset($ogFaxNumber)) { $this->ogFaxNumber = $ogFaxNumber; } if (isset($fbAdminIds)) { $this->fbAdminIds = $fbAdminIds; } if (isset($insertPaginationTags)) { $this->insertPaginationTags = $insertPaginationTags; } // define default values for seldom used params if (!defined('sh404SEF_PROTECT_AGAINST_DOCUMENT_TYPE_ERROR')) { // SECTION : GLOBAL PARAMETERS for sh404sef --------------------------------------------------------------------- $shDefaultParamsHelp['sh404SEF_PROTECT_AGAINST_DOCUMENT_TYPE_ERROR'] = '// if not 0, urls for pdf documents and rss feeds will be only partially turned into sef urls. //The query string &format=pdf or &format=feed will be still be appended. // This will protect against malfunctions when using some plugins which makes a call // to JFactory::getDocument() from a onAfterInitiliaze handler // At this time, SEF urls are not decoded and thus the document type is set to html instead of pdf or feed // resulting in the home page being displayed instead of the correct document'; $shDefaultParams['sh404SEF_PROTECT_AGAINST_DOCUMENT_TYPE_ERROR'] = 0; /* $shDefaultParamsHelp['sh404SEF_PROTECT_AGAINST_BAD_NON_DEFAULT_LANGUAGE_MENU_HOMELINK'] = '// Joomla mod_mainmenu module forces usage of JURI::base() for the homepage link // On multilingual sites, this causes homepage link in other than default language to // be wrong. If the following parameter is non-zero, such a homepage link // will be replaced by the correct link, similar to www.mysite.com/es/ for instance'; $shDefaultParams['sh404SEF_PROTECT_AGAINST_BAD_NON_DEFAULT_LANGUAGE_MENU_HOMELINK'] = 1; */ $shDefaultParamsHelp['sh404SEF_REDIRECT_IF_INDEX_PHP'] = '// if not 0, sh404SEF will do a 301 redirect from http://yoursite.com/index.php // or http://yoursite.com/index.php?lang=xx to http://yoursite.com/ // this may not work on some web servers, which transform yoursite.com into // yoursite.com/index.php, thus creating and endless loop. If your server does // that, set this param to 0'; $shDefaultParams['sh404SEF_REDIRECT_IF_INDEX_PHP'] = 1; $shDefaultParamsHelp['sh404SEF_NON_SEF_IF_SUPERADMIN'] = '// if superadmin logged in, force non-sef, for testing and setting up purpose'; $shDefaultParams['sh404SEF_NON_SEF_IF_SUPERADMIN'] = 0; $shDefaultParamsHelp['sh404SEF_DE_ACTIVATE_LANG_AUTO_REDIRECT'] = '// set to 1 to prevent 303 auto redirect based on user language // use with care, will prevent language switch to work for users without javascript'; $shDefaultParams['sh404SEF_DE_ACTIVATE_LANG_AUTO_REDIRECT'] = 1; $shDefaultParamsHelp['sh404SEF_CHECK_COMP_IS_INSTALLED'] = '// if 1, SEF URLs will only be built for installed components.'; $shDefaultParams['sh404SEF_CHECK_COMP_IS_INSTALLED'] = 1; $shDefaultParamsHelp['sh404SEF_REDIRECT_OUTBOUND_LINKS'] = '// if 1, all outbound links on page will be reached through a redirect // to avoid page rank leakage'; $shDefaultParams['sh404SEF_REDIRECT_OUTBOUND_LINKS'] = 0; $shDefaultParamsHelp['sh404SEF_PDF_DIR'] = '// if not empty, urls to pdf produced by Joomla will be prefixed with this // path. Can be : \'pdf\' or \'pdf/something\' (ie: don\'t put leading or trailing slashes) // Allows you to store some pre-built PDF in a directory called /pdf, with the same name // as a page. Such a pdf will be served directly by the web server instead of being built on // the fly by Joomla. This will save CPU and RAM. (only works this way if using htaccess'; $shDefaultParams['sh404SEF_PDF_DIR'] = 'pdf'; $shDefaultParamsHelp['SH404SEF_URL_CACHE_TTL'] = '// time to live for url cache in hours : default = 168h = 1 week // Set to 0 to keep cache forever'; $shDefaultParams['SH404SEF_URL_CACHE_TTL'] = 168; $shDefaultParamsHelp['SH404SEF_URL_CACHE_WRITES_TO_CHECK_TTL'] = '// number of cache write before checking cache TTL.'; $shDefaultParams['SH404SEF_URL_CACHE_WRITES_TO_CHECK_TTL'] = 1000; $shDefaultParamsHelp['sh404SEF_SEC_MAIL_ATTACKS_TO_ADMIN'] = '// if set to 1, an email will be send to site admin when an attack is logged // if the site is live, you could be drowning in email rapidly !!!'; $shDefaultParams['sh404SEF_SEC_MAIL_ATTACKS_TO_ADMIN'] = 0; $shDefaultParams['sh404SEF_SEC_EMAIL_TO_ADMIN_SUBJECT'] = 'Your site %sh404SEF_404_SITE_NAME% was subject to an attack'; $shDefaultParams['sh404SEF_SEC_EMAIL_TO_ADMIN_BODY'] = 'Hello !' . "\n\n" . 'This is sh404SEF security component, running at your site (%sh404SEF_404_SITE_URL%).' . "\n\n" . 'I have just blocked an attack on your site. Please check details below : ' . "\n" . '------------------------------------------------------------------------' . "\n" . '%sh404SEF_404_ATTACK_DETAILS%' . "\n" . '------------------------------------------------------------------------' . "\n\n" . 'Thanks for using sh404SEF!' . "\n\n"; $shDefaultParamsHelp['SH404SEF_PAGES_TO_CLEAN_LOGS'] = '// number of pages between checks to remove old log files // if 1, we check at every page request'; $shDefaultParams['SH404SEF_PAGES_TO_CLEAN_LOGS'] = 10000; $shDefaultParamsHelp['SH_VM_ALLOW_PRODUCTS_IN_MULTIPLE_CATS'] = '// SECTION : Virtuemart plugin parameters ---------------------------------------------------------------------------- // set to 1 for products to have requested category name included in url // useful if some products are in more than one category. If param set to 0, // only one category will be used for all pages. Not recommended now that sh404SEF // automatically handle rel=canonical on such pages'; $shDefaultParams['SH_VM_ALLOW_PRODUCTS_IN_MULTIPLE_CATS'] = 1; $shDefaultParamsHelp['sh404SEF_SOBI2_PARAMS_ALWAYS_INCLUDE_CATS'] = '// SECTION : SOBI2 plugin parameters ---------------------------------------------------------------------------- // set to 1 to always include categories in SOBI2 entries // details pages url'; $shDefaultParams['sh404SEF_SOBI2_PARAMS_ALWAYS_INCLUDE_CATS'] = 0; $shDefaultParamsHelp['sh404SEF_SOBI2_PARAMS_INCLUDE_ENTRY_ID'] = '// set to 1 so that entry id is prepended to url'; $shDefaultParams['sh404SEF_SOBI2_PARAMS_INCLUDE_ENTRY_ID'] = 0; $shDefaultParamsHelp['sh404SEF_SOBI2_PARAMS_INCLUDE_CAT_ID'] = '// set to 1 so that category id is prepended to category name'; $shDefaultParams['sh404SEF_SOBI2_PARAMS_INCLUDE_CAT_ID'] = 0; // end of parameters $sef_custom_config_file = sh404SEF_ADMIN_ABS_PATH . 'custom.sef.php'; // read user defined values, possibly recovered while upgrading if (JFile::exists($sef_custom_config_file)) { include $sef_custom_config_file; } // generate string for parameter modification if ($app->isAdmin()) { // only need to modify custom params in back-end $this->defaultParamList = '<?php // custom.sef.php : custom.configuration file for sh404SEF // 3.5.1.1299 - anything-digital.com/sh404sef/seo-analytics-and-security-for-joomla.html // DO NOT REMOVE THIS LINE : if (!defined(\'_JEXEC\')) die(\'Direct Access to this location is not allowed.\'); // DO NOT REMOVE THIS LINE' . "\n"; foreach ($shDefaultParams as $key => $value) { $this->defaultParamList .= "\n"; if (!empty($shDefaultParamsHelp[$key])) { $this->defaultParamList .= $shDefaultParamsHelp[$key] . "\n"; } // echo help text, if any $this->defaultParamList .= '$shDefaultParams[\'' . $key . '\'] = ' . (is_string($value) ? "'{$value}'" : $value) . ";\n"; } } // read user set values for these params and create constants if (!empty($shDefaultParams)) { foreach ($shDefaultParams as $key => $value) { define($key, $value); } } unset($shDefaultParams); unset($shDefaultParamsHelp); } // compatiblity variables, for sef_ext files usage from OpenSef/SEf Advance V 1.2.4.p $this->encode_page_suffix = ''; // if using an opensef sef_ext, we don't let them manage suffix $this->encode_space_char = $this->replacement; $this->encode_lowercase = $this->LowerCase; $this->encode_strip_chars = $this->stripthese; $this->content_page_name = empty($this->pageTexts[Sh404sefFactory::getPageInfo()->shMosConfig_locale]) ? 'Page' : str_replace('%s', '', $this->pageTexts[Sh404sefFactory::getPageInfo()->shMosConfig_locale]); // V 1.2.4.r $this->content_page_format = '%s' . $this->replacement . '%d'; // V 1.2.4.r $shTemp = $this->shGetReplacements(); foreach ($shTemp as $dest => $source) { $this->spec_chars_d .= $dest . ','; $this->spec_chars .= $source . ','; } JString::rtrim($this->spec_chars_d, ','); JString::rtrim($this->spec_chars, ','); }
/** * Returns the sh404SEF SEF url for a give non-sef url, * creating it on the fly if not already in the database * * @param string $nonSefUrl non-sef url, starting with index.php?... * @param boolean $fullyQualified if true, return a fully qualified url, including protocol and host * @param boolean $xhtml * @param $ssl */ public static function getSefFromNonSef($nonSefUrl, $fullyQualified = true, $xhtml = false, $ssl = null) { if (!defined('SH404SEF_IS_RUNNING')) { return false; } $pageInfo = Sh404sefFactory::getPageInfo(); if (empty($nonSefUrl)) { return $pageInfo->getDefaultFrontLiveSite(); } $newUri = new JURI($nonSefUrl); $originalUri = clone $newUri; $route = shSefRelToAbs($nonSefUrl, $shLanguageParam = '', $newUri, $originalUri); $route = ltrim(str_replace($pageInfo->getDefaultFrontLiveSite(), '', $route), '/'); $route = $route == '/' ? '' : $route; // find path $nonSefVars = $newUri->getQuery($asArray = true); if (strpos($route, '?') !== false && !empty($nonSefVars)) { $parts = explode('?', $route); // there are some query vars, just use the path $path = $parts[0]; } else { $path = $route; } $newUri->setPath($path); if ($fullyQualified || (int) $ssl === 1) { // remove protocol, host, etc, only keep relative-to-site part $liveSite = $pageInfo->getDefaultFrontLiveSite(); if ((int) $ssl === 1 && substr($liveSite, 0, 7) == 'http://') { $liveSite = str_replace('http://', 'https://', $liveSite); } $sefUrl = $liveSite . '/' . $newUri->toString(); } else { $sefUrl = '/' . $newUri->toString(array('path', 'query', 'fragment')); } if ($xhtml) { $sefUrl = htmlspecialchars($sefUrl); } return $sefUrl; }
private function _sh404sefGetSocialButtons($sefConfig, $url = '', $context = '', $content = null) { // if no URL, use current if (empty($url)) { // no url set on social button tag, we should // use current URL, except if we are on a page // where this would cause the wrong url to be shared // try identify this condition if ($this->_shouldDisplaySocialButtons($sefConfig, $context, $content)) { Sh404sefHelperShurl::updateShurls(); $pageInfo = Sh404sefFactory::getPageInfo(); $url = !$this->_params->get('useShurl', true) || empty($pageInfo->shURL) ? JURI::current() : JURI::base() . $pageInfo->shURL; } else { return ''; } } // buttons html $buttonsHtml = ''; // get language from Joomla $longLang = JFactory::getLanguage()->getTag(); // networks use en_GB, not en-GB $shortLang = substr($longLang, 0, 2); // we wrap buttons in unordered list $wrapperOpen = '<li>'; $wrapperClose = '</li>'; // Tweet if ($this->_params->get('enableTweet', true) && in_array('twitter', $this->_enabledButtons)) { $buttonsHtml .= $wrapperOpen . '<a href="https://twitter.com/share" data-via="' . $this->_params->get('viaAccount', '') . '" data-count="' . $this->_params->get('tweetLayout', 'none') . '" data-url="' . $url . '" data-lang="' . $shortLang . '" class="twitter-share-button">Tweet</a>' . $wrapperClose; } // plus One if ($this->_params->get('enablePlusOne', true) && in_array('googleplusone', $this->_enabledButtons)) { $buttonsHtml .= $wrapperOpen . '<g:plusone callback="_sh404sefSocialTrackGPlusTracking" annotation="' . $this->_params->get('plusOneAnnotation', 'none') . '" size="' . $this->_params->get('plusOneSize', '') . '" href="' . $url . '"></g:plusone>' . $wrapperClose; } // Google plus page badge $page = $this->_params->get('googlePlusPage', ''); $page = JString::trim($page, '/'); if ($this->_params->get('enableGooglePlusPage', true) && in_array('googlepluspage', $this->_enabledButtons) && !empty($page)) { $buttonsHtml .= $wrapperOpen . '<a class="google-page-badge" onclick="_sh404sefSocialTrack.GPageTracking(\'/' . $page . '/\', \'' . $url . '\')" href="https://plus.google.com/' . $page . '/?prsrc=3">'; // badge image switch ($this->_params->get('googlePlusPageSize', 'medium')) { case 'small': $size = '16'; $buttonsHtml .= '<div style="display: inline-block;">'; // custom text if ($this->_params->get('googlePlusCustomText', '')) { $buttonsHtml .= '<span style="float: left; font: bold 13px/16px arial,sans-serif; margin-right: 4px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText', '')) . '</span><span style="float: left; font: 13px/16px arial,sans-serif; margin-right: 11px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</span>'; } $buttonsHtml .= '<div style="float: left;"><img src="https://ssl.gstatic.com/images/icons/gplus-16.png" width="16" height="16" style="border: 0;"/></div><div style="clear: both"></div>'; break; case 'large': $size = '64'; $buttonsHtml .= '<div style="display: inline-block; *display: inline;"><div style="text-align: center;"><img src="https://ssl.gstatic.com/images/icons/gplus-64.png" width="64" height="64" style="border: 0;"></img></div><div style="font: bold 13px/16px arial,sans-serif; text-align: center;">' . $this->_params->get('googlePlusCustomText', '') . '</div><div style="font: 13px/16px arial,sans-serif; text-align: center;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</div>'; break; default: $size = '32'; $buttonsHtml .= '<div style="display: inline-block;">'; // custom text if ($this->_params->get('googlePlusCustomText', '')) { $buttonsHtml .= '<span style="float: left; font: bold 13px/16px arial,sans-serif; margin-right: 4px; margin-top: 7px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText', '')) . '</span><span style="float: left; font: 13px/16px arial,sans-serif; margin-right: 11px; margin-top: 7px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</span>'; } $buttonsHtml .= '<div style="float: left;"><img src="https://ssl.gstatic.com/images/icons/gplus-32.png" width="32" height="32" style="border: 0;"/></div><div style="clear: both"></div>'; break; } $buttonsHtml .= '</div></a>' . $wrapperClose; } // FB Like if ($this->_params->get('enableFbLike', 1) && in_array('facebooklike', $this->_enabledButtons)) { $layout = $this->_params->get('fbLayout', '') == 'none' ? '' : $this->_params->get('fbLayout', ''); if ($this->_params->get('fbUseHtml5', false)) { $buttonsHtml .= $wrapperOpen . '<div class="fb-like" data-href="' . $url . '" data-send="' . ($this->_params->get('enableFbSend', 1) ? 'true' : 'false') . '" data-action="' . $this->_params->get('fbAction', '') . '" data-width="' . $this->_params->get('fbWidth', '') . '" data-layout="' . $layout . '" data-show-faces="' . $this->_params->get('fbShowFaces', 'true') . '" data-colorscheme="' . $this->_params->get('fbColorscheme', 'light') . '"></div>' . $wrapperClose; } else { $buttonsHtml .= $wrapperOpen . '<fb:like href="' . $url . '" send="' . ($this->_params->get('enableFbSend', 1) ? 'true' : 'false') . '" action="' . $this->_params->get('fbAction', '') . '" width="' . $this->_params->get('fbWidth', '') . '" layout="' . $layout . '" show_faces="' . $this->_params->get('fbShowFaces', 'true') . '" colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></fb:like>' . $wrapperClose; } } else { if ($this->_params->get('enableFbSend', 1) && in_array('facebooksend', $this->_enabledButtons)) { if ($this->_params->get('fbUseHtml5', false)) { $buttonsHtml .= $wrapperOpen . '<div class="fb-send" data-href="' . $url . '" data-colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></div>' . $wrapperClose; } else { $buttonsHtml .= $wrapperOpen . '<fb:send href="' . $url . '" colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></fb:send>' . $wrapperClose; } } } // perform replace if (!empty($buttonsHtml)) { $buttonsHtml = '<div class="sh404sef-social-buttons"><ul>' . $buttonsHtml . '</ul></div>'; } return $buttonsHtml; }
/** * * Check a number of conditions, both global and * relative to a provided source page uri * to decide whether a redirect to another page * can take place * Will also check configuration settings * * @param object $uri */ protected function _canRedirectFromNonSef($uri, $method = '') { // if not parsing the initial request, no way we can redirect if (self::$requestParsed) { return false; } // use framework if no method passed if (empty($method)) { $method = JRequest::getMethod(); } // get config $sefConfig = Sh404sefFactory::getConfig(); $pageInfo = Sh404sefFactory::getPageInfo(); // get/set data $vars = $uri->getQuery(true); $url = $uri->get('_uri'); $canRedirect = true; // first condition: component should not be set to "skip" if (!empty($vars['option'])) { $shOption = str_replace('com_', '', $vars['option']); if (!empty($shOption) && in_array($shOption, $sefConfig->skip)) { $canRedirect = false; } } $canRedirect = $canRedirect && $sefConfig->shRedirectNonSefToSef && $this->_canRedirectFrom($uri, $method); return $canRedirect; }
/** * sh404SEF - SEO extension for Joomla! * * @author Yannick Gaultier * @copyright (c) Yannick Gaultier 2012 * @package sh404sef * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @version 4.1.0.1559 * @date 2013-04-25 */ defined('_JEXEC') or die('Direct Access to this location is not allowed.'); global $Itemid; global $sh_LANG; $mainframe = JFactory::getApplication(); $shPageInfo =& Sh404sefFactory::getPageInfo(); // get page details gathered by system plugin $sefConfig =& Sh404sefFactory::getConfig(); $database = ShlDbHelper::getDb(); $view = JREQUEST::getCmd('view', null); $catid = JREQUEST::getInt('catid', null); $id = JREQUEST::getInt('id', null); $limit = JREQUEST::getInt('limit', null); $limitstart = JREQUEST::getInt('limitstart', null); $layout = JREQUEST::getCmd('layout', null); $showall = JREQUEST::getInt('showall', null); $format = JREQUEST::getCmd('format', null); $print = JREQUEST::getInt('print', null); $tmpl = JREQUEST::getCmd('tmpl', null); $lang = JREQUEST::getString('lang', null); $shLangName = empty($lang) ? $shPageInfo->currentLanguageTag : shGetNameFromIsoCode($lang);
/** * * @param string $url * @param array $title * @param string $task * @param int $limit * @param int $limitstart * @return sefurl */ public static function sefGetLocation($nonSefUrl, &$title, $task = null, $limit = null, $limitstart = null, $langParam = null, $showall = null, $suppressPagination = false) { try { $shPageInfo =& Sh404sefFactory::getPageInfo(); $sefConfig =& Sh404sefFactory::getConfig(); $lang = empty($langParam) ? $shPageInfo->currentLanguageTag : $langParam; // shumisha : try to avoid duplicate content on multilingual sites by always adding &lang=xx to url (stored in DB). // warning : must add &lang=xx only if it does not exists already if (!strpos($nonSefUrl, 'lang=')) { $shSepString = substr($nonSefUrl, -9) == 'index.php' ? '?' : '&'; $nonSefUrl .= $shSepString . 'lang=' . shGetIsoCodeFromName($lang); } // make sure url is consistent $nonSefUrl = str_replace('&', '&', $nonSefUrl); // detect multipage homepage $shMultiPageHomePageFlag = shIsHomepage($nonSefUrl); // get all the slugs ready for being urls bits $tempSefUrl = array(); foreach ($title as $titlestring) { $decodedTitletring = urldecode($titlestring); $tempSefUrl[] = titleToLocation($decodedTitletring); } // now build the URL $tempSefUrl = implode("/", $tempSefUrl); // remove duplicate / $tempSefUrl = ShlSystem_Strings::pr('/\\/{2,}/u', '/', $tempSefUrl); // and truncate to max length, according to param $tempSefUrl = JString::substr($tempSefUrl, 0, sh404SEF_MAX_SEF_URL_LENGTH); // trim to max length V 1.2.4.t // if URL is empty, and unless this is a paginated home page, or home page in non-default language, stop there if (empty($tempSefUrl)) { if ((!shIsMultilingual() || shIsMultilingual() && shIsDefaultlang($lang)) && !$sefConfig->addFile && !$shMultiPageHomePageFlag) { // return ''; } // if location is empty, and not multilingual site, or multilingual, but this is default language, then there is nothing to add to url } // we have a valid SEF url, built with the data ($title) sent // by plugin. Now we want to check if it's already in the db // and add it if not // first, we search the memory cache for the non-sef url // as it is faster than looking up the db $finalSefUrl = ''; $sefUrlType = Sh404sefHelperCache::getSefUrlFromCache($nonSefUrl, $finalSefUrl); // if non-sef was not found in cache - or found, but it was a 404 last time we saw it - // we should continue and try adding it if ($sefUrlType == sh404SEF_URLTYPE_NONE || $sefUrlType == sh404SEF_URLTYPE_404) { $finalSefUrl = false; // non-sef was not found in cache, let's look up the database if ($sefUrlType == sh404SEF_URLTYPE_NONE) { $finalSefUrl = ShlDbHelper::selectResult('#__sh404sef_urls', 'oldurl', array('newurl' => $nonSefUrl)); } // we found the sef url in database, we're done if (!empty($finalSefUrl)) { return $finalSefUrl; } // the non-sef url is not in memory cache, nor in database // that's a new one, we need to finalize its sef (add pagination and language information) // After finalizing it, we'll also check that sef is not in the db // as it can already be there, associated with another non-sef (ie: a duplicate) // Either way we'll add it in the db, but mark it as a duplicate if needed // add pagination information, unless we were instructed by extension plugin not to // find if we should separate pagination info from sef with a / or not if (!empty($tempSefUrl)) { $shSeparator = JString::substr($tempSefUrl, -1) == '/' ? '' : '/'; } else { $shSeparator = ''; } $finalSefUrl = $suppressPagination ? $tempSefUrl : shAddPaginationInfo($limit, $limitstart, $showall, 1, $nonSefUrl, $tempSefUrl, $shSeparator); // v 1.2.4.t // if home page, we don't record anything, just return "home page" if ($shMultiPageHomePageFlag && '/' . $finalSefUrl == $tempSefUrl && (!shIsMultilingual() || shIsMultilingual() && shIsDefaultLang($lang))) { // but this is default language // this is start page of multipage homepage, return home or forced home if (!empty($sefConfig->shForcedHomePage)) { return str_replace($shPageInfo->getDefaultFrontLiveSite() . '/', '', $sefConfig->shForcedHomePage); } else { return ''; } } // add language information // first, remove languages in non-sef, to see if we're on homepage // as handling is sligthly different for homepage $v1 = shCleanUpLang($nonSefUrl); $v2 = shCleanUpLang($shPageInfo->homeLink); if ($v1 == $v2 || $v1 == 'index.php') { // check if this is homepage if (shIsMultilingual() && !shIsDefaultLang($lang)) { // if homepage in not-default-language, then add language code regardless of user settings // as we otherwise would not be able to switch language on the frontpage $finalSefUrl = shGetIsoCodeFromName($lang) . '/'; } else { $finalSefUrl = ''; } } else { // not on homepage, insert lang code based on user setting $option = shGetURLVar($nonSefUrl, 'option', ''); if (shInsertIsoCodeInUrl($option, $lang)) { // insert language code based on param // pass URL lang info, as may not be current lang $finalSefUrl = shGetIsoCodeFromName($lang) . '/' . $finalSefUrl; // must be forced lang, not default } } // after adding pagination part of SEF, and adding language code // the new SEF url is now complete and we can try adding to it cache and db if ($finalSefUrl != '') { $dburl = null; $dbUrlId = null; $nonSefUrlType = sh404SEF_URLTYPE_NONE; // search the memory cache for this new sef if ($sefConfig->shUseURLCache) { $nonSefUrlType = Sh404sefHelperCache::getNonSefUrlFromCache($finalSefUrl, $dburl); } $newMaxRank = 0; // if the new SEF was not found in memory cache, or if it was found but // we're set to record duplicates, we search for it in the database if ($sefConfig->shRecordDuplicates || $nonSefUrlType == sh404SEF_URLTYPE_NONE) { $dbUrlList = ShlDbHelper::selectObjectList('#__sh404sef_urls', array('id', 'newurl', 'rank', 'dateadd'), array('oldurl' => $finalSefUrl), $aWhereData = array(), $orderBy = array('rank')); if (count($dbUrlList) > 0) { $dburl = $dbUrlList[0]->newurl; $dbUrlId = $dbUrlList[0]->id; if (empty($dburl)) { // V 1.2.4.t url was found in DB, but was a 404 $nonSefUrlType = sh404SEF_URLTYPE_404; } else { $newMaxRank = $dbUrlList[count($dbUrlList) - 1]->rank + 1; $nonSefUrlType = $dbUrlList[0]->dateadd == '0000-00-00' ? sh404SEF_URLTYPE_AUTO : sh404SEF_URLTYPE_CUSTOM; } } } if ($nonSefUrlType != sh404SEF_URLTYPE_NONE && $nonSefUrlType != sh404SEF_URLTYPE_404) { // we found the SEF, one or more times in the db, in records which do have a non-sef attached $isDuplicate = $dburl != $nonSefUrl; // This is a duplicate so we must indert it with incremented rank; if (is_null($dburl) || $isDuplicate && $sefConfig->shRecordDuplicates) { // shAddSefUrlToDBAndCache( $nonSefUrl, $finalSefUrl, ($isDuplicate ? $newMaxRank : 0), $nonSefUrlType); $dateAdd = $nonSefUrlType == sh404SEF_URLTYPE_AUTO ? '0000-00-00' : date("Y-m-d"); ShlDbHelper::insert('#__sh404sef_urls', array('oldurl' => $finalSefUrl, 'newurl' => $nonSefUrl, 'rank' => $isDuplicate ? $newMaxRank : 0, 'dateadd' => $dateAdd)); // store new sef/non-sef pair in memory cache Sh404sefHelperCache::addSefUrlToCache($nonSefUrl, $finalSefUrl, $nonSefUrlType); // create shURL : get a shURL model, and ask url creation $model = ShlMvcModel_Base::getInstance('pageids', 'Sh404sefModel'); $model->createPageId($finalSefUrl, $nonSefUrl); } } else { // we haven't found the non-sef/sef pair, but maybe there is a record for // a 404 with that SEF. If so, we will "upgrade" the 404 record to a // normal non-sef/sef pair $dbUrlId = empty($dbUrlId) ? 0 : intval($dbUrlId); if ($sefConfig->shLog404Errors) { if ($nonSefUrlType == sh404SEF_URLTYPE_404 && !empty($dbUrlId)) { // we already have seen that it is a 404 $id = $dbUrlId; } elseif ($nonSefUrlType == sh404SEF_URLTYPE_404) { $id = ShlDbHelper::selectResult('#__sh404sef_urls', 'id', array('oldurl' => $finalSefUrl, 'newurl' => '')); } else { $id = null; } } else { $id = null; // if we are not logging 404 errors, then no need to check for } // previous hit of this page. if (!empty($id)) { // we found a 404 record matching the SEF url just created. We'll update that record // instead of creating a new one // need to update dateadd to 0, as otherwise this sef/non-sef pair will be seen as custom // this makes all such 404 errors 'disappear' from the 404 log, but no other solution ShlDbHelper::updateIn('#__sh404sef_urls', array('newurl' => $nonSefUrl, 'dateadd' => '0000-00-00'), 'id', array($id)); Sh404sefHelperCache::addSefUrlToCache($nonSefUrl, $finalSefUrl, sh404SEF_URLTYPE_AUTO); } else { // standard case: creation of a totally new sef/non-sef pair ShlDbHelper::insert('#__sh404sef_urls', array('oldurl' => $finalSefUrl, 'newurl' => $nonSefUrl, 'rank' => 0, 'dateadd' => '0000-00-00')); // store new sef/non-sef pair in memory cache Sh404sefHelperCache::addSefUrlToCache($nonSefUrl, $finalSefUrl, sh404SEF_URLTYPE_AUTO); // create shURL : get a shURL model, and ask url creation $model = ShlMvcModel_Base::getInstance('pageids', 'Sh404sefModel'); $model->createPageId($finalSefUrl, $nonSefUrl); } } } } } catch (Exception $e) { $finalSefUrl = ''; ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } return $finalSefUrl; }
function shSendEmailToAdmin($logData) { if (!sh404SEF_SEC_MAIL_ATTACKS_TO_ADMIN) { return; } $mainframe = JFactory::getApplication(); $subject = str_replace('%sh404SEF_404_SITE_NAME%', $mainframe->getCfg('sitename'), sh404SEF_SEC_EMAIL_TO_ADMIN_SUBJECT); $logText = ''; foreach ($logData as $key => $text) { $logText .= "\n" . $key . "\t\t" . ' :: ' . shSecOutput(JString::trim($text)); } $body = str_replace('%sh404SEF_404_SITE_URL%', Sh404sefFactory::getPageInfo()->getDefaultFrontLiveSite(), sh404SEF_SEC_EMAIL_TO_ADMIN_BODY); $body = str_replace('%sh404SEF_404_ATTACK_DETAILS%', $logText, $body); if (!defined('_ISO')) { define('_ISO', 'charset=iso-8859-1'); } jimport('joomla.mail.mail'); JMail::sendMail($mainframe->getCfg('mailfrom'), $mainframe->getCfg('fromname'), $mainframe->getCfg('mailfrom'), $subject, $body); }
public function onAfterInitialise() { // prevent warning on php5.3+ $this->_fixTimeWarning(); // get joomla application object $app =& JFactory::getApplication(); // register our autoloader $this->_registerAutoloader(); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'sh404sef.class.php'; // get our configuration $sefConfig =& Sh404sefFactory::getConfig(); // hook for a few SEO hacks if ($app->isSite()) { $this->_hacks(JRequest::get(), $sefConfig); } // security layer if (!$app->isAdmin() && $sefConfig->shSecEnableSecurity) { require_once JPATH_ROOT . DS . 'components' . DS . 'com_sh404sef' . DS . 'shSec.php'; // do security checks shDoSecurityChecks(); shCleanUpSecLogFiles(); // see setting in class file for clean up frequency } // optionnally collect page creation time if (!$app->isAdmin() && $sefConfig->analyticsEnableTimeCollection) { jimport('joomla.error.profiler'); // creating the profiler object will start the counter $profiler =& JProfiler::getInstance('sh404sef_profiler'); } // load plugins, as per configuration $this->_loadPlugins($type = 'sh404sefcore'); // load extension plugins, created by others $this->_loadPlugins($type = 'sh404sefext'); // hook to be able to install other SEF extension plugins Sh404sefHelperExtplugins::loadInstallAdapters(); // another hook to allow other SEF extensions language file to be loaded Sh404sefHelperExtplugins::loadLanguageFiles(); if (!$sefConfig->Enabled) { // go away if not enabled return; } // fake language filter if ($sefConfig->enableMultiLingualSupport) { $app->set('menu_associations', 1); if (!$app->isAdmin()) { $app->setLanguageFilter(true); } } if (!defined('SH404SEF_IS_RUNNING')) { DEFINE('SH404SEF_IS_RUNNING', 1); } if (!$app->isAdmin()) { // setup our JPagination replacement, so as to bring // back # of items per page in the url, in order // to properly calculate pagination // will only work if php > 5, so test for that if (version_compare(phpversion(), '5.0') >= 0) { // this register the old file, but do not load it if PHP5 // will prevent further calls to the same jimport() // to actually do anything, because the 'joomla.html.pagination' key // is now registered statically in Jloader::import() jimport('joomla.html.pagination'); // now we can register our own path JLoader::register('JPagination', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'pagination.php'); } // attach parse and build rules to Joomla router $joomlaRouter = $app->getRouter(); $pageInfo =& Sh404sefFactory::getPageInfo(); $pageInfo->router = new Sh404sefClassRouter(); $joomlaRouter->attachParseRule(array($pageInfo->router, 'parseRule')); $joomlaRouter->attachBuildRule(array($pageInfo->router, 'buildRule')); // forece J! router config to SEF if at least one of the installed // components has been set to use raw J! router if (!empty(Sh404sefFactory::getConfig()->useJoomlaRouter)) { $joomlaRouter->setMode(JROUTER_MODE_SEF); } // pretend SEF is on, mostly for Joomla SEF plugin to work // as it checks directly 'sef' value in config, instead of // usgin $router->getMode() JFactory::$config->set('sef', 1); // kill Joomla suffix, so that it doesn't add or remove it in the parsing/building process JFactory::$config->set('sef_suffix', 0); // we use opposite setting from J! $mode = 1 - $sefConfig->shRewriteMode; JFactory::$config->set('sef_rewrite', $mode); // perform startup operations, such as detecting request caracteristics // and checking redirections $pageInfo->router->startup(JURI::getInstance()); } }
function shAddPaginationHeaderLinks(&$buffer) { $sefConfig =& Sh404sefFactory::getConfig(); if (!isset($sefConfig) || empty($sefConfig->shMetaManagementActivated) || empty($sefConfig->insertPaginationTags)) { return; } $pageInfo =& Sh404sefFactory::getPageInfo(); // handle pagination if (!empty($pageInfo->paginationNextLink)) { $link = "\n " . '<link rel="next" href="' . $pageInfo->paginationNextLink . '" />'; $buffer = shInsertCustomTagInBuffer($buffer, '<head>', 'after', $link, 'first'); } if (!empty($pageInfo->paginationPrevLink)) { $link = "\n " . '<link rel="prev" href="' . $pageInfo->paginationPrevLink . '" />'; $buffer = shInsertCustomTagInBuffer($buffer, '<head>', 'after', $link, 'first'); } }
public static function getcategories($catid, $shLang = null, $section = '') { $shPageInfo =& Sh404sefFactory::getPageInfo(); $sefConfig =& Sh404sefFactory::getConfig(); $catid = empty($catid) ? 0 : intval($catid); // get DB $database =& JFactory::getDBO(); $title = ''; // V 1.2.4.q $shLang = empty($shLang) ? $shPageInfo->shMosConfig_locale : $shLang; if (isset($catid) && $catid != 0) { $query = 'SELECT title' . (shTranslateURL('com_content', $shLang) ? ',id' : '') . ' FROM #__categories WHERE id = "' . $catid . '"' . (empty($section) ? '' : ' AND section = \'' . $section . '\''); $database->setQuery($query); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { die($database->stderr()); } elseif (@count($rows) > 0) { if (!empty($rows[0]->title)) { $title = $rows[0]->title; } } } return $title; }
/** * Push current Security configuration items * values into the view for edition */ private function _pushConfigDataSec() { // get configuration object $shPageInfo =& Sh404sefFactory::getPageInfo(); $sefConfig =& Sh404sefFactory::getConfig(); // push it into to the view $this->assignRef('sefConfig', $sefConfig); // special check for Joomfish 2.0 : must be sure href are not cached in language selection module // otherwise new SEF urls will not be created shDisableJFModuleCaching(); $std_opt = 'class="inputbox" size="2"'; // security parameters V x $lists['shSecEnableSecurity'] = JHTML::_('select.booleanlist', 'shSecEnableSecurity', $std_opt, $sefConfig->shSecEnableSecurity); $lists['shSecLogAttacks'] = JHTML::_('select.booleanlist', 'shSecLogAttacks', $std_opt, $sefConfig->shSecLogAttacks); $lists['shSecOnlyNumVars'] = implode("\n", $sefConfig->shSecOnlyNumVars); $lists['shSecAlphaNumVars'] = implode("\n", $sefConfig->shSecAlphaNumVars); $lists['shSecNoProtocolVars'] = implode("\n", $sefConfig->shSecNoProtocolVars); $lists['ipWhiteList'] = implode("\n", $sefConfig->ipWhiteList); $lists['ipBlackList'] = implode("\n", $sefConfig->ipBlackList); $lists['uAgentWhiteList'] = implode("\n", $sefConfig->uAgentWhiteList); $lists['uAgentBlackList'] = implode("\n", $sefConfig->uAgentBlackList); $lists['shSecCheckHoneyPot'] = JHTML::_('select.booleanlist', 'shSecCheckHoneyPot', $std_opt, $sefConfig->shSecCheckHoneyPot); $lists['shSecActivateAntiFlood'] = JHTML::_('select.booleanlist', 'shSecActivateAntiFlood', $std_opt, $sefConfig->shSecActivateAntiFlood); $lists['shSecAntiFloodOnlyOnPOST'] = JHTML::_('select.booleanlist', 'shSecAntiFloodOnlyOnPOST', $std_opt, $sefConfig->shSecAntiFloodOnlyOnPOST); $lists['shSecCheckPOSTData'] = JHTML::_('select.booleanlist', 'shSecCheckPOSTData', $std_opt, $sefConfig->shSecCheckPOSTData); //push params in to view $this->assign('lists', $lists); }
private function _mustCreatePageid($nonSefUrl) { // currently disabled by sef url plugin if (!self::$_mustCreate) { return false; } // if enabled at sef url plugin level, check configuration $sefConfig =& Sh404sefFactory::getConfig(); // check global flags if (!$sefConfig->enablePageId || $sefConfig->stopCreatingShurls) { return false; } // make sure we have a language $pageInfo =& Sh404sefFactory::getPageInfo(); $nonSefUrl = shSetURLVar($nonSefUrl, 'lang', $pageInfo->shMosConfig_shortcode); // not on homepage if (shIsAnyHomepage($nonSefUrl)) { return ''; } // check at component level $option = shGetURLVar($nonSefUrl, 'option'); $option = str_replace('com_', '', $option); $enable = !empty($option) && in_array($option, $sefConfig->compEnablePageId); // check non sef url content black list $sefConfig->shurlNonSefBlackList = JString::trim($sefConfig->shurlNonSefBlackList); if (empty($sefConfig->shurlNonSefBlackList)) { $blackList = array(); } else { if (strpos($sefConfig->shurlNonSefBlackList, '|') !== false) { $blackList = explode('|', $sefConfig->shurlNonSefBlackList); } else { $blackList = array($sefConfig->shurlNonSefBlackList); } } if (!empty($blackList)) { foreach ($blackList as $bit) { if (!empty($bit) && strpos($nonSefUrl, $bit) !== false) { // match, don't create a shurl for this non sef url $enable = false; break; } } } return $enable; }
/** * Create and return the pagination data object. * * @return object Pagination data object. * * @since 11.1 */ protected function _buildDataObject() { // Initialise variables. $data = new stdClass(); $sefConfig =& Sh404sefFactory::getConfig(); // build a "limit" string $limitString = '&limit=' . $this->limit; // Build the additional URL parameters string. $params = ''; if (!empty($this->_additionalUrlParams)) { foreach ($this->_additionalUrlParams as $key => $value) { $params .= '&' . $key . '=' . $value; } } $data->all = new JPaginationObject(JText::_('JLIB_HTML_VIEW_ALL'), $this->prefix); if (!$this->_viewall) { $data->all->base = '0'; $data->all->link = JRoute::_($params . '&' . $this->prefix . 'limitstart='); } // Set the start and previous data objects. $data->start = new JPaginationObject(JText::_('JLIB_HTML_START'), $this->prefix); $data->previous = new JPaginationObject(JText::_('JPREV'), $this->prefix); if ($this->get('pages.current') > 1) { $page = ($this->get('pages.current') - 2) * $this->limit; // Set the empty for removal from route //$page = $page == 0 ? '' : $page; $data->start->base = '0'; $data->start->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=0'); $data->previous->base = $page; $data->previous->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page . $limitString); if ($sefConfig->insertPaginationTags) { $pageInfo =& Sh404sefFactory::getPageInfo(); $pageInfo->paginationPrevLink = $data->previous->link; } } // Set the next and end data objects. $data->next = new JPaginationObject(JText::_('JNEXT'), $this->prefix); $data->end = new JPaginationObject(JText::_('JLIB_HTML_END'), $this->prefix); if ($this->get('pages.current') < $this->get('pages.total')) { $next = $this->get('pages.current') * $this->limit; $end = ($this->get('pages.total') - 1) * $this->limit; $data->next->base = $next; $data->next->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next . $limitString); $data->end->base = $end; $data->end->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end . $limitString); if ($sefConfig->insertPaginationTags) { $pageInfo =& Sh404sefFactory::getPageInfo(); $pageInfo->paginationNextLink = $data->next->link; } } $data->pages = array(); $stop = $this->get('pages.stop'); for ($i = $this->get('pages.start'); $i <= $stop; $i++) { $offset = ($i - 1) * $this->limit; // Set the empty for removal from route //$offset = $offset == 0 ? '' : $offset; $data->pages[$i] = new JPaginationObject($i, $this->prefix); if ($i != $this->get('pages.current') || $this->_viewall) { $data->pages[$i]->base = $offset; $data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset . $limitString); } } return $data; }
function shSendEmailToAdmin($logData) { if (!sh404SEF_SEC_MAIL_ATTACKS_TO_ADMIN) { return; } $mainframe = JFactory::getApplication(); $subject = str_replace('%sh404SEF_404_SITE_NAME%', $mainframe->getCfg('sitename'), sh404SEF_SEC_EMAIL_TO_ADMIN_SUBJECT); $details = array(' Date', "\n" . ' Time', "\n" . ' Cause', "\n" . ' IP', "\n" . ' Name', "\n" . ' User agent', "\n" . "\n" . ' Request method', "\n" . ' Request URI', "\n" . ' Comment'); $items = explode("\t", $logData); $count = 0; $detailText = ''; foreach ($details as $detail) { $detailText .= $detail . ' :: ' . shSecOutput(JString::trim($items[$count++])); } $body = str_replace('%sh404SEF_404_SITE_URL%', Sh404sefFactory::getPageInfo()->getDefaultLiveSite(), sh404SEF_SEC_EMAIL_TO_ADMIN_BODY); $body = str_replace('%sh404SEF_404_ATTACK_DETAILS%', $detailText, $body); if (!defined('_ISO')) { define('_ISO', 'charset=iso-8859-1'); } JUtility::sendMail($mainframe->getCfg('mailfrom'), $mainframe->getCfg('fromname'), $mainframe->getCfg('mailfrom'), $subject, $body); }
function shCheckRedirect ($dest, $incomingUrl) { $sefConfig = & Sh404sefFactory::getConfig(); if (!empty($dest) && $dest != $incomingUrl) { // redirect to alias if ($dest == sh404SEF_HOMEPAGE_CODE) { if (!empty($sefConfig->shForcedHomePage)) { $dest = shFinalizeURL($sefConfig->shForcedHomePage); } else { $dest = shFinalizeURL(Sh404sefFactory::getPageInfo()->getDefaultLiveSite()); } } else { $shUri = new JURI($dest); $shOriginalUri = clone( $shUri); $dest = shSefRelToAbs($dest, '', $shUri, $shOriginalUri) . $shUri->toString( array('query')); } if ($dest != $incomingUrl) { _log('Redirecting to '. $dest .' from alias '.$incomingUrl); shRedirect($dest); } } }
public static function &shPageInfo() { $config =& Sh404sefFactory::getPageInfo(); return $config; }
function shDoHeadersChanges() { global $shCanonicalTag; $sefConfig = & Sh404sefFactory::getConfig(); $shPageInfo = & Sh404sefFactory::getPageInfo(); // get page details gathered by system plugin if (!isset($sefConfig) || empty($sefConfig->shMetaManagementActivated) || empty( $shPageInfo->shCurrentPageNonSef)) { return; } // include plugin to build canonical if needed shIncludeMetaPlugin(); // issue headers for canonical if(!empty( $shCanonicalTag)) { jimport( 'joomla.utilities.string'); $link = JURI::root( false, '') . JString::ltrim( $shCanonicalTag, '/'); JResponse::setHeader( 'Link', '<' . $link . '>; rel="canonical"'); } }
private function _sh404sefGetSocialButtons($sefConfig, $url = '', $context = '', $content = null, $imageSrc = '', $imageDesc = '') { // if no URL, use current if (empty($url)) { // no url set on social button tag, we should // use current URL, except if we are on a page // where this would cause the wrong url to be shared // try identify this condition if ($this->_shouldDisplaySocialButtons($sefConfig, $context, $content)) { Sh404sefHelperShurl::updateShurls(); $pageInfo = Sh404sefFactory::getPageInfo(); $url = !$this->_params->get('useShurl', true) || empty($pageInfo->shURL) ? JURI::current() : JURI::base() . ltrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/') . $pageInfo->shURL; } else { return ''; } } // buttons html $buttonsHtml = ''; // get language from Joomla $longLang = JFactory::getLanguage()->getTag(); // networks use en_GB, not en-GB $shortLang = substr($longLang, 0, 2); // we wrap buttons in unordered list $wrapperOpen = '<li>'; $wrapperClose = '</li>'; // Tweet if ($this->_params->get('enableTweet', true) && in_array('twitter', $this->_enabledButtons)) { $buttonsHtml .= $wrapperOpen . '<a href="https://twitter.com/share" data-via="' . $this->_params->get('viaAccount', '') . '" data-count="' . $this->_params->get('tweetLayout', 'none') . '" data-url="' . $url . '" data-lang="' . $shortLang . '" class="twitter-share-button">Tweet</a>' . $wrapperClose; } // plus One if ($this->_params->get('enablePlusOne', true) && in_array('googleplusone', $this->_enabledButtons)) { $buttonsHtml .= $wrapperOpen . '<g:plusone callback="_sh404sefSocialTrackGPlusTracking" annotation="' . $this->_params->get('plusOneAnnotation', 'none') . '" size="' . $this->_params->get('plusOneSize', '') . '" href="' . $url . '"></g:plusone>' . $wrapperClose; } // Google plus page badge $page = $this->_params->get('googlePlusPage', ''); $page = JString::trim($page, '/'); if ($this->_params->get('enableGooglePlusPage', true) && in_array('googlepluspage', $this->_enabledButtons) && !empty($page)) { $buttonsHtml .= $wrapperOpen . '<a class="google-page-badge" onclick="_sh404sefSocialTrack.GPageTracking(\'/' . $page . '/\', \'' . $url . '\')" href="https://plus.google.com/' . $page . '/?prsrc=3">'; // badge image switch ($this->_params->get('googlePlusPageSize', 'medium')) { case 'small': $size = '16'; $buttonsHtml .= '<div style="display: inline-block;">'; // custom text if ($this->_params->get('googlePlusCustomText', '')) { $buttonsHtml .= '<span style="float: left; font: bold 13px/16px arial,sans-serif; margin-right: 4px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText', '')) . '</span><span style="float: left; font: 13px/16px arial,sans-serif; margin-right: 11px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</span>'; } $buttonsHtml .= '<div style="float: left;"><img src="https://ssl.gstatic.com/images/icons/gplus-16.png" width="16" height="16" style="border: 0;"/></div><div style="clear: both"></div>'; break; case 'large': $size = '64'; $buttonsHtml .= '<div style="display: inline-block; *display: inline;"><div style="text-align: center;"><img src="https://ssl.gstatic.com/images/icons/gplus-64.png" width="64" height="64" style="border: 0;"></img></div><div style="font: bold 13px/16px arial,sans-serif; text-align: center;">' . $this->_params->get('googlePlusCustomText', '') . '</div><div style="font: 13px/16px arial,sans-serif; text-align: center;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</div>'; break; default: $size = '32'; $buttonsHtml .= '<div style="display: inline-block;">'; // custom text if ($this->_params->get('googlePlusCustomText', '')) { $buttonsHtml .= '<span style="float: left; font: bold 13px/16px arial,sans-serif; margin-right: 4px; margin-top: 7px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText', '')) . '</span><span style="float: left; font: 13px/16px arial,sans-serif; margin-right: 11px; margin-top: 7px;">' . htmlspecialchars($this->_params->get('googlePlusCustomText2', '')) . '</span>'; } $buttonsHtml .= '<div style="float: left;"><img src="https://ssl.gstatic.com/images/icons/gplus-32.png" width="32" height="32" style="border: 0;"/></div><div style="clear: both"></div>'; break; } $buttonsHtml .= '</div></a>' . $wrapperClose; } // Pinterest if ($this->_params->get('enablePinterestPinIt', 1) && in_array('pinterestpinit', $this->_enabledButtons)) { // we use either the first image in content, or the provided one (from a user created tag) if (empty($imageSrc)) { // we're using the first image in the content $regExp = '#<img([^>]*)/>#is'; $text = empty($content->fulltext) ? $content->introtext : $content->introtext . $content->fulltext; $img = preg_match($regExp, $text, $match); if (empty($img) || empty($match[1])) { // could not find an image in the article // last chance is maybe webmaster is using Joomla! full text image article feature // note: if we are not on the canonical page (ie the full article display), Joomla! // uses the image_intro instead. However, I decided to still pin the full image // in such case, as the image_intro will most often be a thumbnail // Is this correct? can there be side effects? $imageSrc = ''; if ($context == 'com_content.article' && !empty($content->images)) { $registry = new JRegistry(); $registry->loadString($content->images); $fulltextImage = $registry->get('image_fulltext'); if (!empty($fulltextImage)) { $imageSrc = $fulltextImage; $imageDesc = $registry->get('image_fulltext_alt', ''); } } } else { // extract image details jimport('joomla.utilities.utility'); $attributes = JUtility::parseAttributes($match[1]); $imageSrc = empty($attributes['src']) ? '' : $attributes['src']; $imageDesc = empty($attributes['alt']) ? '' : $attributes['alt']; } } if (!empty($imageSrc)) { if (substr($imageSrc, 0, 4) != 'http' && substr($imageSrc, 0, 1) != '/') { // relative url, prepend root url $imageSrc = JURI::base() . $imageSrc; } $buttonsHtml .= $wrapperOpen; $buttonsHtml .= '<a href="http://pinterest.com/pin/create/button/?url=' . urlencode($url) . '&media=' . urlencode($imageSrc) . (empty($imageDesc) ? '' : '&description=' . urlencode($imageDesc)) . '" ' . 'class="pin-it-button" count-layout="' . $this->_params->get('pinItCountLayout', 'none') . '">' . $this->_params->get('pinItButtonText', 'Pin it') . '</a>'; $buttonsHtml .= $wrapperClose; } } // FB Like if ($this->_params->get('enableFbLike', 1) && in_array('facebooklike', $this->_enabledButtons)) { $layout = $this->_params->get('fbLayout', '') == 'none' ? '' : $this->_params->get('fbLayout', ''); if ($this->_params->get('fbUseHtml5', false)) { $buttonsHtml .= $wrapperOpen . '<div class="fb-like" data-href="' . $url . '" data-send="' . ($this->_params->get('enableFbSend', 1) ? 'true' : 'false') . '" data-action="' . $this->_params->get('fbAction', '') . '" data-width="' . $this->_params->get('fbWidth', '') . '" data-layout="' . $layout . '" data-show-faces="' . $this->_params->get('fbShowFaces', 'true') . '" data-colorscheme="' . $this->_params->get('fbColorscheme', 'light') . '"></div>' . $wrapperClose; } else { $buttonsHtml .= $wrapperOpen . '<fb:like href="' . $url . '" send="' . ($this->_params->get('enableFbSend', 1) ? 'true' : 'false') . '" action="' . $this->_params->get('fbAction', '') . '" width="' . $this->_params->get('fbWidth', '') . '" layout="' . $layout . '" show_faces="' . $this->_params->get('fbShowFaces', 'true') . '" colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></fb:like>' . $wrapperClose; } } else { if ($this->_params->get('enableFbSend', 1) && in_array('facebooksend', $this->_enabledButtons)) { if ($this->_params->get('fbUseHtml5', false)) { $buttonsHtml .= $wrapperOpen . '<div class="fb-send" data-href="' . $url . '" data-colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></div>' . $wrapperClose; } else { $buttonsHtml .= $wrapperOpen . '<fb:send href="' . $url . '" colorscheme="' . $this->_params->get('fbColorscheme', '') . '"></fb:send>' . $wrapperClose; } } } // perform replace if (!empty($buttonsHtml)) { $buttonsHtml = '<div class="sh404sef-social-buttons"><ul>' . $buttonsHtml . '</ul></div>'; } return $buttonsHtml; }
<?php /** * SEF module for Joomla! * * @author $Author: shumisha $ * @copyright Yannick Gaultier - 2007-2011 * @package sh404SEF-16 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @version $Id: sh404sef.php 2050 2011-06-30 13:52:38Z silianacom-svn $ * */ // Security check to ensure this file is being included by a parent file. if (!defined('_JEXEC')) { die('Direct Access to this location is not allowed.'); } // no direct acccess shRedirect(Sh404sefFactory::getPageInfo()->getDefaultLiveSite());