コード例 #1
0
ファイル: com_myblog.php プロジェクト: alesconti/FF_2015
 function shFetchPostId($show, $option, $shLangName)
 {
     if (empty($show)) {
         return null;
     }
     try {
         $postId = ShlDbHelper::selectResult('#__myblog_permalinks', 'contentid', array('permalink' => $show));
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
     }
     return isset($postId) ? $postId : '';
 }
コード例 #2
0
ファイル: k2category.php プロジェクト: GitIPFire/Homeworks
    /**
     * Overriden method, to add indentation to the list of categories
     *
     */
    public function onJosettaLoadItems($context, $state)
    {

        if ((!empty($context) && ($context != $this->_context)))
        {
            return null;
        }

        // read data. Can't use parent, as this would slice the results
        // using limitstart and limit. K2 needs to slice later on,
        // after indenting has been done
        $items = array();
        $db = JFactory::getDbo();
        $this->_buildItemsListQuery($state);
        $db->setQuery($this->_query);
        $rawItems = $db->loadObjectList();

        // Check for a database error.
        if ($db->getErrorNum())
        {
            ShlSystem_Log::logError(__METHOD__.': '.$db->getErrorMsg());
            $rawItems = array();
        }

        // now indent
        if (!empty($rawItems))
        {

            // Joomla! framework menu utility used to indent
            // requires fields as parent_id instead of parent
            foreach ($rawItems as &$item)
            {
                $item->title = $item->name;
                $item->parent_id = $item->parent;
            }

            // indent cat list, for easier reading
            $items = self::indentCategories($rawItems);
            foreach ($items as &$item)
            {
                $item->name = JString::str_ireplace('<sup>|_</sup>', '', $item->treename);
            }

            // finally slice up to get the set we need
            $items = array_slice($items, $state->get('list.start'), $state->get('list.limit'));
        }

        return $items;
    }
コード例 #3
0
ファイル: ogp.php プロジェクト: alesconti/FF_2015
 public static function getDefinitions()
 {
     if (is_null(self::$_definitions)) {
         jimport('joomla.utilities.xmlelement');
         // Disable libxml errors and allow to fetch error information as needed
         $errorSetting = libxml_use_internal_errors(true);
         self::$_definitions = JFactory::getXML(sh404SEF_ADMIN_ABS_PATH . 'helpers/ogp.xml');
         libxml_use_internal_errors($errorSetting);
         if (!self::$_definitions) {
             foreach (libxml_get_errors() as $error) {
                 ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $error);
             }
         }
     }
     return self::$_definitions;
 }
コード例 #4
0
ファイル: shurl.php プロジェクト: alesconti/FF_2015
 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());
         }
     }
 }
コード例 #5
0
ファイル: pageids.php プロジェクト: alesconti/FF_2015
 private function _getNextDBId($table)
 {
     if (empty($table)) {
         return false;
     }
     try {
         // need to force replace prefix
         $query = 'show table status like ' . $this->_db->Quote($table);
         $this->_db->setQuery($query);
         $status = $this->_db->shlLoadAssoc();
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
     }
     if (empty($status) || empty($status['Auto_increment'])) {
         return false;
     } else {
         return (int) $status['Auto_increment'];
     }
 }
コード例 #6
0
ファイル: com_mtree.php プロジェクト: alesconti/FF_2015
 function shMTGetCustomFieldById($cfId)
 {
     static $fields = null;
     if (is_null($fields)) {
         try {
             $fields = ShlDbHelper::selectObjectList('#__mt_customfields', array('cf_id', 'caption'), $mWhere = '', $aWhereData = array(), $orderBy = array(), $offset = 0, $lines = 0, $key = 'cf_id');
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
     }
     // check if we have this field
     $cfCaption = empty($fields[$cfId]) ? '' : $fields[$cfId]->caption;
     if (!empty($cfCaption)) {
         shRemoveFromGETVarsList('cf_id');
     }
     return $cfCaption;
 }
コード例 #7
0
ファイル: shPageRewrite.php プロジェクト: alesconti/FF_2015
 function shDoTitleTags(&$buffer)
 {
     // Replace TITLE and DESCRIPTION and KEYWORDS
     if (empty($buffer)) {
         return;
     }
     global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag, $shCustomRobotsTag, $shCustomLangTag, $shCanonicalTag;
     $database = ShlDbHelper::getDb();
     $shPageInfo =& Sh404sefFactory::getPageInfo();
     $sefConfig =& Sh404sefFactory::getConfig();
     $document = JFactory::getDocument();
     $headData = $document->getHeadData();
     // V 1.2.4.t protect against error if using shCustomtags without sh404SEF activated
     // this should not happen, so we simply do nothing
     if (!isset($sefConfig) || empty($shPageInfo->currentNonSefUrl)) {
         return;
     }
     // check if there is a manually created set of tags from tags file
     // need to get them from DB
     if ($sefConfig->shMetaManagementActivated) {
         shIncludeMetaPlugin();
         // is this homepage ? set flag for future use
         // V 1.2.4.t make sure we have lang info and properly sorted params
         if (!preg_match('/(&|\\?)lang=[a-zA-Z]{2,3}/iuU', $shPageInfo->currentNonSefUrl)) {
             // no lang string, let's add default
             $shTemp = explode('-', $shPageInfo->currentLanguageTag);
             $shLangTemp = $shTemp[0] ? $shTemp[0] : 'en';
             $shPageInfo->currentNonSefUrl .= '&lang=' . $shLangTemp;
         }
         $nonSef = shGetCurrentNonSef();
         $isHome = $nonSef == shSortUrl(shCleanUpAnchor(Sh404sefFactory::getPageInfo()->homeLink));
         $shCustomTags = shGetCustomMetaData($isHome ? sh404SEF_HOMEPAGE_CODE : $nonSef);
         // J! 2.5 finder canonical handling/hack
         $highlight = shGetURLVar($nonSef, 'highlight', null);
         if (!empty($highlight) && empty($shCanonicalTag)) {
             $searchCanoNonSef = str_replace('?highlight=' . $highlight, '', $nonSef);
             $searchCanoNonSef = str_replace('&highlight=' . $highlight, '', $searchCanoNonSef);
             $shCanonicalTag = JRoute::_($searchCanoNonSef);
         }
         $tagsToInsert = '';
         // group new tags insertion, better perf
         if (!empty($shCustomTags)) {
             $shCustomTitleTag = !empty($shCustomTags->metatitle) ? $shCustomTags->metatitle : $shCustomTitleTag;
             $shCustomDescriptionTag = !empty($shCustomTags->metadesc) ? $shCustomTags->metadesc : $shCustomDescriptionTag;
             $shCustomKeywordsTag = !empty($shCustomTags->metakey) ? $shCustomTags->metakey : $shCustomKeywordsTag;
             $shCustomRobotsTag = !empty($shCustomTags->metarobots) ? $shCustomTags->metarobots : $shCustomRobotsTag;
             $shCustomLangTag = !empty($shCustomTags->metalang) ? $shCustomTags->metalang : $shCustomLangTag;
             $shCanonicalTag = !empty($shCustomTags->canonical) ? $shCustomTags->canonical : $shCanonicalTag;
         }
         // then insert them in page
         if (empty($shCustomTitleTag)) {
             $shCustomTitleTag = $document->getTitle();
         }
         if (!empty($shCustomTitleTag)) {
             $prepend = $isHome ? '' : $sefConfig->prependToPageTitle;
             $append = $isHome ? '' : $sefConfig->appendToPageTitle;
             $shPageInfo->pageTitle = htmlspecialchars(shCleanUpTitle($prepend . $shCustomTitleTag . $append), ENT_COMPAT, 'UTF-8');
             $buffer = ShlSystem_Strings::pr('/\\<\\s*title\\s*\\>.*\\<\\s*\\/title\\s*\\>/isuU', '<title>' . $shPageInfo->pageTitle . '</title>', $buffer);
             $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"title.*\\/\\>/isuU', '', $buffer);
             // remove any title meta
         }
         if (!is_null($shCustomDescriptionTag)) {
             $t = htmlspecialchars(shCleanUpDesc($shCustomDescriptionTag), ENT_COMPAT, 'UTF-8');
             $shPageInfo->pageDescription = ShlSystem_Strings::pr('#\\$([0-9]*)#u', '\\\\$${1}', $t);
             if (strpos($buffer, '<meta name="description" content=') !== false) {
                 $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"description.*\\/\\>/isUu', '<meta name="description" content="' . $shPageInfo->pageDescription . '" />', $buffer);
             } else {
                 $tagsToInsert .= "\n" . '<meta name="description" content="' . $shPageInfo->pageDescription . '" />';
             }
         } else {
             // read Joomla! description if none set by us
             if (empty($shPageInfo->pageDescription)) {
                 $shPageInfo->pageDescription = empty($headData['description']) ? '' : htmlspecialchars(shCleanUpDesc($headData['description']), ENT_COMPAT, 'UTF-8');
             }
         }
         if (!is_null($shCustomKeywordsTag)) {
             $t = htmlspecialchars(shCleanUpDesc($shCustomKeywordsTag), ENT_COMPAT, 'UTF-8');
             $shPageInfo->pageKeywords = ShlSystem_Strings::pr('#\\$([0-9]*)#u', '\\\\$${1}', $t);
             if (strpos($buffer, '<meta name="keywords" content=') !== false) {
                 $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"keywords.*\\/\\>/isUu', '<meta name="keywords" content="' . $shPageInfo->pageKeywords . '" />', $buffer);
             } else {
                 $tagsToInsert .= "\n" . '<meta name="keywords" content="' . $shPageInfo->pageKeywords . '" />';
             }
         } else {
             // read Joomla! description if none set by us
             if (empty($shPageInfo->pageKeywords)) {
                 $shPageInfo->pageKeywords = empty($headData['metaTags']['standard']['keywords']) ? '' : htmlspecialchars(shCleanUpDesc($headData['metaTags']['standard']['keywords']), ENT_COMPAT, 'UTF-8');
             }
         }
         if (!is_null($shCustomRobotsTag)) {
             $shPageInfo->pageRobotsTag = $shCustomRobotsTag;
             if (strpos($buffer, '<meta name="robots" content="') !== false) {
                 $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+name\\s*=\\s*"robots.*\\/\\>/isUu', '<meta name="robots" content="' . $shCustomRobotsTag . '" />', $buffer);
             } else {
                 if (!empty($shCustomRobotsTag)) {
                     $tagsToInsert .= "\n" . '<meta name="robots" content="' . $shCustomRobotsTag . '" />';
                 }
             }
         } else {
             // read Joomla! description if none set by us
             if (empty($shPageInfo->pageRobotsTag)) {
                 $shPageInfo->pageRobotsTag = empty($headData['metaTags']['standard']['robots']) ? '' : htmlspecialchars(shCleanUpDesc($headData['metaTags']['standard']['robots']), ENT_COMPAT, 'UTF-8');
             }
         }
         if (!is_null($shCustomLangTag)) {
             $shLang = $shCustomLangTag;
             $shPageInfo->pageLangTag = $shCustomLangTag;
             if (strpos($buffer, '<meta http-equiv="Content-Language"') !== false) {
                 $buffer = ShlSystem_Strings::pr('/\\<\\s*meta\\s+http-equiv\\s*=\\s*"Content-Language".*\\/\\>/isUu', '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />', $buffer);
             } else {
                 $tagsToInsert .= "\n" . '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />';
             }
         }
         // custom handling of canonical
         $canonicalPattern = '/\\<\\s*link[^>]+rel\\s*=\\s*"canonical[^>]+\\/\\>/isUu';
         $matches = array();
         $canonicalCount = preg_match_all($canonicalPattern, $buffer, $matches);
         // more than one canonical already: kill them all
         if ($canonicalCount > 1 && Sh404sefFactory::getConfig()->removeOtherCanonicals) {
             $buffer = ShlSystem_Strings::pr($canonicalPattern, '', $buffer);
             $canonicalCount = 0;
         }
         // more than one and J3: must be the one inserted by J3 SEF plugin
         if ($canonicalCount > 0 && Sh404sefFactory::getConfig()->removeOtherCanonicals && version_compare(JVERSION, '3.0', 'ge')) {
             // kill it, if asked to
             $buffer = ShlSystem_Strings::pr($canonicalPattern, '', $buffer);
             $canonicalCount = 0;
         }
         // if there' a custom canonical for that page, insert it, or replace any existing ones
         if (!empty($shCanonicalTag) && $canonicalCount == 0) {
             // insert a new canonical
             $tagsToInsert .= "\n" . '<link href="' . htmlspecialchars($shCanonicalTag, ENT_COMPAT, 'UTF-8') . '" rel="canonical" />' . "\n";
         } else {
             if (!empty($shCanonicalTag)) {
                 // replace existing canonical
                 $buffer = ShlSystem_Strings::pr($canonicalPattern, '<link href="' . htmlspecialchars($shCanonicalTag, ENT_COMPAT, 'UTF-8') . '" rel="canonical" />', $buffer);
             }
         }
         // insert all tags in one go
         if (!empty($tagsToInsert)) {
             $buffer = shInsertCustomTagInBuffer($buffer, '<head>', 'after', $tagsToInsert, 'first');
         }
         // remove Generator tag
         if ($sefConfig->shRemoveGeneratorTag) {
             $buffer = ShlSystem_Strings::pr('/<meta\\s*name="generator"\\s*content=".*\\/>/isUu', '', $buffer);
         }
         // put <h1> tags around content elements titles
         if ($sefConfig->shPutH1Tags) {
             if (strpos($buffer, 'class="componentheading') !== false) {
                 $buffer = ShlSystem_Strings::pr('/<div class="componentheading([^>]*)>\\s*(.*)\\s*<\\/div>/isUu', '<div class="componentheading$1><h1>$2</h1></div>', $buffer);
                 $buffer = ShlSystem_Strings::pr('/<td class="contentheading([^>]*)>\\s*(.*)\\s*<\\/td>/isUu', '<td class="contentheading$1><h2>$2</h2></td>', $buffer);
             } else {
                 // replace contentheading by h1
                 $buffer = ShlSystem_Strings::pr('/<td class="contentheading([^>]*)>\\s*(.*)\\s*<\\/td>/isUu', '<td class="contentheading$1><h1>$2</h1></td>', $buffer);
             }
         }
         // version x : if multiple h1 headings, replace them by h2
         if ($sefConfig->shMultipleH1ToH2 && substr_count(JString::strtolower($buffer), '<h1>') > 1) {
             $buffer = str_replace('<h1>', '<h2>', $buffer);
             $buffer = str_replace('<H1>', '<h2>', $buffer);
             $buffer = str_replace('</h1>', '</h2>', $buffer);
             $buffer = str_replace('</H1>', '</h2>', $buffer);
         }
         // V 1.3.1 : replace outbounds links by internal redirects
         if (sh404SEF_REDIRECT_OUTBOUND_LINKS) {
             $tmp = preg_replace_callback('/<\\s*a\\s*href\\s*=\\s*"(.*)"/isUu', 'shDoRedirectOutboundLinksCallback', $buffer);
             if (empty($tmp)) {
                 ShlSystem_Log::error('shlib', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, 'RegExp failed: invalid character on page ' . Sh404sefFactory::getPageInfo()->currentSefUrl);
             } else {
                 $buffer = $tmp;
             }
         }
         // V 1.3.1 : add symbol to outbounds links
         if ($sefConfig->shInsertOutboundLinksImage) {
             $tmp = preg_replace_callback("/<\\s*a\\s*href\\s*=\\s*(\"|').*(\"|')\\s*>.*<\\/a>/isUu", 'shDoInsertOutboundLinksImageCallback', $buffer);
             if (empty($tmp)) {
                 ShlSystem_Log::error('shlib', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, 'RegExp failed: invalid character on page ' . Sh404sefFactory::getPageInfo()->currentSefUrl);
             } else {
                 $buffer = $tmp;
             }
         }
         // fix homepage link when using Joomfish in non default languages, error in joomla mainmenu helper
         /*
         if (sh404SEF_PROTECT_AGAINST_BAD_NON_DEFAULT_LANGUAGE_MENU_HOMELINK && !shIsDefaultLang( $shPageInfo->currentLanguageTag)) {
         			$badHomeLink = preg_quote(JURI::base());
         			$targetLang = explode( '-', $shPageInfo->currentLanguageTag);
         			$goodHomeLink = rtrim(JURI::base(), '/') . $sefConfig->shRewriteStrings[$sefConfig->shRewriteMode] . $targetLang[0] . '/';
         			$buffer = preg_replace( '#<div class="module_menu(.*)href="' . $badHomeLink . '"#isU',
            '<div class="module_menu$1href="' . $goodHomeLink . '"', $buffer);
         			$buffer = preg_replace( '#<div class="moduletable_menu(.*)href="' . $badHomeLink . '"#isU',
            '<div class="moduletable_menu$1href="' . $goodHomeLink . '"', $buffer);
         			}
         */
         // all done
         return $buffer;
     }
 }
コード例 #8
0
ファイル: shCache.php プロジェクト: alesconti/FF_2015
function shAddSefURLToCache($nonSefURL, $sefURL, $URLType)
{
    global $shURLMemCache, $shURLTotalCount;
    $sefConfig =& Sh404sefFactory::getConfig();
    if (!$sefConfig->shUseURLCache) {
        return null;
    }
    if ($shURLTotalCount >= $sefConfig->shMaxURLInCache) {
        return null;
    }
    // v 1.2.4.c added total cache size control
    // Filter out non sef url which include &mosmsg, as I don't want to have a cache entry for every single msg
    // that can be thrown at me, including every 404 error
    if (strpos(strtolower($nonSefURL), '&mosmsg')) {
        return null;
    }
    $count = count($shURLMemCache);
    // new cache format : non-sef#sef#type
    $shURLMemCache[$count] = htmlentities($nonSefURL, ENT_QUOTES) . '#' . $sefURL . '#' . $URLType;
    ShlSystem_Log::debug('sh404sef', 'Adding to URL cache : ' . $sefURL . ' <= ' . $nonSefURL);
    $shURLTotalCount++;
    // v 1.2.4.c added total cache size control
    return true;
}
コード例 #9
0
ファイル: sef_ext.php プロジェクト: alesconti/FF_2015
 public static function getcategories($catid, $shLang = null, $section = '')
 {
     ShlSystem_Log::debug('sh404sef', 'Calling deprecated sef_404::getCategories() method. Use Sh404sefModelSlugs model instead.');
     return '';
 }
コード例 #10
0
ファイル: sh404sef.class.php プロジェクト: alesconti/FF_2015
/**
 * 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;
}
コード例 #11
0
ファイル: configuration.php プロジェクト: alesconti/FF_2015
 /**
  * Push current error documents content
  * values into the view for edition
  * this is a altered version of the same
  * method in the old config view.
  */
 private function _getErrorPageContent()
 {
     // find about sh404sef custom content category id
     $sh404sefContentCatId = Sh404sefHelperCategories::getSh404sefContentCat()->id;
     try {
         // read current content of 404 page in default language
         $article = ShlDbHelper::selectAssoc('#__content', array('id', 'introtext'), array('title' => '__404__', 'catid' => $sh404sefContentCatId, 'language' => '*'));
         $txt404 = empty($article['introtext']) ? JText::_('COM_SH404SEF_DEF_404_MSG') : $article['introtext'];
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         $txt404 = JText::_('COM_SH404SEF_DEF_404_MSG');
     }
     // push params in to view
     return $txt404;
 }
コード例 #12
0
ファイル: com_kunena.php プロジェクト: alesconti/FF_2015
 function shKUTopicName($topicid, $option, $shLangIso, $shLangName)
 {
     static $topics = array();
     $sefConfig =& Sh404sefFactory::getConfig();
     if (empty($topicid) || !$sefConfig->shFbInsertMessageSubject) {
         return '';
     }
     if (class_exists('KunenaForum')) {
         // Kunena 2.0 support
         $topic = KunenaForumTopic::getInstance($topicid);
         $topicsubject = $topic->subject;
     } elseif (class_exists('KunenaRouter')) {
         // Kunena 1.6 support
         if (empty(KunenaRouter::$msgidcache[$topicid])) {
             try {
                 KunenaRouter::$msgidcache[$topicid] = ShlDbHelper::selectResult('#__kunena_messages', array('subject', 'id'), array('id' => $topicid));
             } catch (Exception $e) {
                 ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
             }
         }
         $topicsubject = KunenaRouter::$msgidcache[$topicid];
     } else {
         // Kunena 1.0 / 1.5 support
         if (empty($topics[$topicid])) {
             try {
                 $topicDetails = ShlDbHelper::selectObject('#__fb_messages', array('id', 'subject'), array('id' => $topicid));
             } catch (Exception $e) {
                 ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
             }
             $topics[$topicid] = empty($topicDetails) ? '' : $topicDetails->subject;
         }
         $topicsubject = $topics[$topicid];
     }
     // we have a user name
     $topicstring = empty($topicsubject) ? 't' . $sefConfig->replacement . $topicid : ($sefConfig->shFbInsertMessageId ? $topicid . $sefConfig->replacement : '');
     // if name, put ID only if requested
     $topicstring = $topicstring . (empty($topicsubject) ? '' : $topicsubject);
     return $topicstring;
 }
コード例 #13
0
ファイル: html.php プロジェクト: alesconti/FF_2015
 /**
  * Builds a select list with all possible user levels
  *
  * Adapted from JCal pro
  *
  * @param $current
  * @param $name
  * @param $autoSubmit
  * @param $addSelectAll
  * @param $selectAllTitle
  */
 public static function buildUserLevelsList($current, $name, $autoSubmit = false, $addSelectAll = false, $selectAllTitle = '', $customSubmit = '')
 {
     ShlSystem_Log::debug('sh404sef', 'Sh404sefHelperHtml::buildUserLevelsList has been removed, not needed as there is no user levels anymore but groups instead');
     return array();
 }
コード例 #14
0
ファイル: urls.php プロジェクト: alesconti/FF_2015
 public function getUrlsCount($which = 'auto')
 {
     switch (strtolower($which)) {
         // we want to read all automatic urls (include duplicates)
         case 'auto':
             $numberOfUrls = ShlDbHelper::count($this->_getTableName(), '*', array('dateadd' => '0000-00-00'));
             break;
             // we want to read urls as per current selection input fields
             // ie : component, language, custom, ...
         // we want to read urls as per current selection input fields
         // ie : component, language, custom, ...
         case 'selected':
             $numberOfUrls = $this->getTotal();
             break;
         case 'view404':
         case '404':
             $query = 'select count(*) from ' . $this->_db->quoteName($this->_getTableName()) . ' where ' . $this->_db->quoteName('dateadd') . '!=' . $this->_db->Quote('0000-00-00') . ' and ' . $this->_db->quoteName('newurl') . '=' . $this->_db->Quote('');
             try {
                 $this->_db->setQuery($query);
                 $numberOfUrls = $this->_db->shlLoadResult();
             } catch (Exception $e) {
                 ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
                 $numberOfUrls = 0;
             }
             break;
         default:
             $numberOfUrls = 0;
             break;
     }
     return intval($numberOfUrls);
 }
コード例 #15
0
ファイル: pageinfo.php プロジェクト: alesconti/FF_2015
 public function loadHomepages()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return;
     }
     // store default links in each language
     jimport('joomla.language.helper');
     $languages = JLanguageHelper::getLanguages();
     $this->isMultilingual = shIsMultilingual();
     $defaultLanguage = shGetDefaultLang();
     if ($this->isMultilingual === false || $this->isMultilingual == 'joomla') {
         $menu = JFactory::getApplication()->getMenu();
         foreach ($languages as $language) {
             $menuItem = $menu->getDefault($language->lang_code);
             if (!empty($menuItem)) {
                 $this->homeLinks[$language->lang_code] = $this->_prepareLink($menuItem);
                 if ($language->lang_code == $defaultLanguage) {
                     $this->homeLink = $this->homeLinks[$language->lang_code];
                     $this->homeItemid = $menuItem->id;
                 }
             }
         }
         // find about the "All" languages home link
         $menuItem = $menu->getDefault('*');
         if (!empty($menuItem)) {
             $this->allLangHomeLink = $this->_prepareLink($menuItem);
         }
     } else {
         // trouble starts
         $db = ShlDbHelper::getDb();
         $query = $db->getQuery(true);
         $query->select('id,language,link');
         $query->from('#__menu');
         $query->where('home <> 0');
         try {
             $db->setQuery($query);
             $items = $db->shlloadObjectList('language');
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
         if (!empty($items)) {
             if (count($items) == 1) {
                 $tmp = array_values($items);
                 $defaultItem = $tmp[0];
             }
             if (empty($defaultItem)) {
                 $defaultItem = empty($items[$defaultLanguage]) ? null : $items[$defaultLanguage];
             }
             if (empty($defaultItem)) {
                 $defaultItem = empty($items['*']) ? null : $items['*'];
             }
             foreach ($languages as $language) {
                 if (!empty($items[$language->lang_code])) {
                     $this->homeLinks[$language->lang_code] = $this->_prepareLink($items[$language->lang_code]);
                 } else {
                     // no menu item for home link
                     // let's try to  build one
                     $this->homeLinks[$language->lang_code] = $this->_prepareLink($defaultItem, shGetIsoCodeFromName($language->lang_code));
                 }
                 if ($language->lang_code == $defaultLanguage) {
                     $this->homeLink = $this->homeLinks[$language->lang_code];
                     $this->homeItemid = $defaultItem->id;
                     $this->allLangHomeLink = shCleanUpLang($this->homeLinks[$language->lang_code]);
                 }
             }
         }
     }
     ShlSystem_Log::debug('sh404sef', 'HomeLinks = %s', print_r($this->homeLinks, true));
 }
コード例 #16
0
ファイル: basemodel.php プロジェクト: alesconti/FF_2015
 /**
  * Create or update a record to
  * DB from POST data or input array of data
  *
  * @param array $dataArray an array holding data to save. If empty, $_POST is used
  * @return integer id of created or updated record
  */
 public function save($dataArray = null)
 {
     // get required tools
     jimport('joomla.database.table');
     $this->_data = JTable::getInstance($this->_defaultTable, 'Sh404sefTable');
     $post = is_null($dataArray) ? JRequest::get('post') : $dataArray;
     // use table save method
     try {
         $status = $this->_data->save($post);
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         $this->_data->setError($e->getMessage());
         $status = false;
     }
     // report error
     if (!$status) {
         JFactory::getApplication()->enqueuemessage($this->_data->getError());
         return 0;
     }
     // if success, fetch last insert id and return that
     $tableDb = $this->_data->getDBO();
     $keyName = $this->_data->getKeyName();
     $id = empty($post[$keyName]) ? 0 : intval($post[$keyName]);
     $savedId = empty($id) ? $tableDb->insertid() : $id;
     return $savedId;
 }
コード例 #17
0
ファイル: aliases.php プロジェクト: alesconti/FF_2015
 /**
  * Finds the sef url record to which an
  * alias record, identified by its id,
  * elongs to
  *
  * @param integer $aliasId
  */
 public function getUrlByAliasId($aliasId)
 {
     $aliasId = empty($aliasId) ? 0 : intval($aliasId);
     $query = 'select r.* from ' . $this->_db->quoteName('#__sh404sef_urls') . ' as r' . ' left join ' . $this->_db->quoteName('#__sh404sef_aliases') . ' as a' . ' on a.' . $this->_db->quoteName('newurl') . ' = r.' . $this->_db->quoteName('newurl') . ' where a.' . $this->_db->quoteName('id') . ' = ' . $this->_db->Quote($aliasId) . ' order by ' . $this->_db->quoteName('rank');
     try {
         $this->_db->setQuery($query);
         $url = $this->_db->shlLoadObject();
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         $this->setError('Internal database error # ' . $e->getMessage());
     }
     return $url;
 }
コード例 #18
0
ファイル: metas.php プロジェクト: alesconti/FF_2015
 /**
  * Purge meta data records from the database
  * either all of them or the currently selected set
  * as per user filter settings in meta manager
  *
  * @param string $type either 'all' or 'selected'
  */
 public function purgeMetas($type)
 {
     // make sure we use latest user state
     $this->_updateContextData();
     // call the appropriate sub-method to get the db query
     $methodName = '_getPurgeQuery' . ucfirst($type);
     if (is_callable(array($this, $methodName))) {
         $deleteQuery = $this->{$methodName}();
     } else {
         $this->setError('Invalid method call _purge ' . $type);
         return;
     }
     // then run the query
     if (!empty($deleteQuery)) {
         try {
             $this->_db->setQuery($deleteQuery);
             $this->_db->shlQuery();
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
             $this->setError('Internal database error ' . $e->getMessage());
         }
         // reset limit and limitstart variables, to avoid
         // issue when displaying again results
         $this->_setState('limitstart', 0);
         $this->_setState('limit', 0);
     } else {
         $this->setError(JText::_('COM_SH404SEF_NORECORDS'));
     }
 }
コード例 #19
0
ファイル: com_community.php プロジェクト: alesconti/FF_2015
 function shGetJSVideoTitle($id, $option, $shLangName)
 {
     $sefConfig =& Sh404sefFactory::getConfig();
     try {
         $result = ShlDbHelper::selectObject('#__community_videos', array('id', 'title', 'category_id'), array('id' => $id));
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
     }
     $videoName = ($sefConfig->shJSInsertVideoId ? $id . $sefConfig->replacement : '') . $result->title;
     // optionnally insert video category
     if ($sefConfig->shJSInsertVideoCat) {
         $title = array(shGetJSVideoCategoryTitle($result->category_id, $option, $shLangName), $videoName);
     } else {
         $title = array($videoName);
     }
     return $title;
 }
コード例 #20
0
ファイル: shSec.php プロジェクト: alesconti/FF_2015
function shCleanUpSecLogFiles()
{
    // delete security log files older than param
    $sefConfig = Sh404sefFactory::getConfig();
    if (mt_rand(1, SH404SEF_PAGES_TO_CLEAN_LOGS) != 1) {
        return;
    }
    // probability = 1/SH404SEF_PAGES_TO_CLEAN_LOGS
    $curMonth = 12 * (intval(date('Y')) - 2000) + intval(date('m'));
    if ($sefConfig->shSecLogAttacks) {
        if ($handle = @opendir(JPATH_ROOT . '/logs/sh404sef/sec')) {
            while (false !== ($file = readdir($handle))) {
                $matches = array();
                if ($file != '.' && $file != '..' && preg_match('/\\.[0-9]*\\./', $file, $matches)) {
                    $fileNum = JString::trim($matches[0], '.');
                    if ($curMonth - $fileNum > $sefConfig->monthsToKeepLogs) {
                        @unlink(JPATH_ROOT . '/logs/sh404sef/sec/' . $file);
                        ShlSystem_Log::debug('sh404sef', 'Erasing security log file : ' . $file);
                    }
                }
            }
            closedir($handle);
        }
    }
}
コード例 #21
0
 public function purge($allCaches = true)
 {
     try {
         $purged = ShlCache_Manager::clear();
     } catch (ShlException $e) {
         $purged = false;
         ShlSystem_Log::debug('sh404sef', 'could not purge shared memory cache: %s', $e->getMessage());
     }
     ShlSystem_Log::debug('sh404sef', __METHOD__ . ': purged shared memory cache: ' . ($purged ? 'ok' : 'failed'));
     return $purged;
 }
コード例 #22
0
ファイル: editurl.php プロジェクト: alesconti/FF_2015
 /**
  * Save an url to the database, updating various elements
  * at the same time like ranking of duplicates
  *
  * @param integer $type force url type, used when saving a custom url
  */
 private function _saveUrl($type = sh404SEF_URLTYPE_AUTO)
 {
     // check for homepage handling
     if (!empty($this->_data['newurl']) && ($this->_data['newurl'] == '/' || $this->_data['newurl'] == sh404SEF_HOMEPAGE_CODE)) {
         $this->_saveHomeUrl();
         return sh404SEF_HOMEPAGE_CODE;
     }
     // check for importing urls : if importing, rank will already be set in
     // incoming data. If saving a url from the UI, rank is never set
     // as it is caculated upon saving the url
     $importing = isset($this->_data['rank']);
     // get required tools
     jimport('joomla.database.table');
     $row = JTable::getInstance($this->_defaultTable, 'Sh404sefTable');
     try {
         // now bind incoming data to table row
         if (!$row->bind($this->_data)) {
             $this->setError($row->getError());
             return 0;
         }
         // pre-save checks
         if (!$row->check()) {
             $this->setError($row->getError());
             return 0;
         }
         // must load cache from disk, so that it can be written back later, with new url
         require_once JPATH_ROOT . '/components/com_sh404sef/shCache.php';
         shLoadURLCache();
         // find if we are adding a custom or automatic url
         $urlType = $row->dateadd == '0000-00-00' ? sh404SEF_URLTYPE_AUTO : sh404SEF_URLTYPE_CUSTOM;
         // override with user supplied
         if (!empty($type)) {
             $urlType = $type;
         }
         // adjust date added field if needed
         if ($urlType == sh404SEF_URLTYPE_CUSTOM) {
             $row->dateadd = date("Y-m-d");
         }
         // if custom url, and no language string, let's add default one
         if ($urlType == sh404SEF_URLTYPE_CUSTOM && !preg_match('/(&|\\?)lang=[a-zA-Z]{2,3}/iUu', $row->newurl)) {
             $shTemp = explode('-', shGetDefaultLang());
             $shLangTemp = $shTemp[0] ? $shTemp[0] : 'en';
             $row->newurl .= '&lang=' . $shLangTemp;
         }
         // normalize the non-sef url representation, sorting query parts alphabetically
         $row->newurl = shSortUrl($row->newurl);
         // retrieve previous values of sef and non sef urls
         $previousSefUrl = JRequest::getVar('previousSefUrl', null, 'POST');
         $previousNonSefUrl = JRequest::getVar('previousNonSefUrl', null, 'POST');
         // if both were set, and nothing has changed, then nothing to do
         if (!empty($previousSefUrl) && !empty($previousNonSefUrl) && $previousNonSefUrl == $row->newurl && $previousSefUrl == $row->oldurl) {
             // nothing changed ! must be changing meta or aliases
             $this->_url = $row;
             return $row->id;
         }
         // search DB for urls pairs with same SEF url
         $query = 'SELECT * FROM #__sh404sef_urls WHERE binary oldurl = ' . $this->_db->Quote($row->oldurl) . ' ORDER BY rank ASC';
         $this->_db->setQuery($query);
         $dbUrlList = $this->_db->shlLoadObjectList();
         // do we have urls in the db with same SEF ?
         if (count($dbUrlList) > 0) {
             // yes we do
             // get config object
             $sefConfig = Sh404sefFactory::getConfig();
             if (!$sefConfig->shRecordDuplicates) {
                 // we don't allow duplicates : reject this URL
                 $this->setError(JText::_('COM_SH404SEF_DUPLICATE_NOT_ALLOWED'));
             } else {
                 // same SEF, but we allow duplicates
                 $existingRecord = null;
                 // importing meta data for instance
                 foreach ($dbUrlList as $urlInDB) {
                     // same SEF, but is the incoming non-sef in this list of URl with same SEF ?
                     if ($urlInDB->newurl == $row->newurl) {
                         $existingRecord = $urlInDB;
                         $this->setError(JText::_('COM_SH404SEF_URLEXIST'));
                     }
                 }
                 if (empty($existingRecord)) {
                     // this new non-sef does not already exists
                     $shTemp = array('nonSefURL' => $row->newurl);
                     // which means we must update the record for the old non-sef url
                     Sh404sefHelperCache::removeURLFromCache($shTemp);
                     // remove the old url from cache
                     // then find new rank (as we are adding a duplicate, we add it at the end of the duplicate list)
                     // but only if not importing. When importing, rank is already set
                     if (!$importing) {
                         $row->rank = $dbUrlList[count($dbUrlList) - 1]->rank + 1;
                     }
                     // store will create a new record if id=0, or update existing if id non 0
                     $row->store();
                     // put custom URL in DB and cache
                     Sh404sefHelperCache::addSefUrlToCache($row->newurl, $row->oldurl, $urlType);
                     // we must add the previous SEF url to the alias list, only if
                     //   - not already there
                     //   - this sef url does not already exists in the DB; which will happen if the url
                     //     being saved was customized and also had duplicates
                     // TODO this code is duplicated just a few line below, need refactoring
                     if (!empty($previousSefUrl) && strpos($this->_data['shAliasList'], $previousSefUrl) === false) {
                         // check if not already a valid SEF url in the DB
                         $query = 'SELECT count(id) FROM #__sh404sef_urls WHERE binary oldurl = ' . $this->_db->Quote($previousSefUrl);
                         $this->_db->setQuery($query);
                         $isThere = $this->_db->shlLoadResult();
                         if (empty($isThere)) {
                             $this->_data['shAliasList'] .= $previousSefUrl . "\n";
                         }
                     }
                 } else {
                     // there is already a record with both this sef and non sef.
                     // just do nothing but return success (ie: record id).
                     // Later, controller may store new aliases or metas
                     // This should never happen when saving regular data as we added
                     // a check for this case earlier
                     // May happen when importing though
                     $this->_url = $row;
                     return $row->id;
                 }
                 // additional step : if we are here, it may be because we have modified
                 // an existing url, and specifically changed it sef value to something else
                 // Now it may be that this record was the one with rank = 0 in a series
                 // of duplicate urls. If so, the urls which was ranked above must now become
                 // the main url, having rank = 0
                 // note : when importing, we don't enter this test as previousSefUrl is empty
                 // TODO this code is duplicated just a few line below, need refactoring
                 if (!empty($previousSefUrl) && $previousSefUrl != $row->newurl) {
                     // search for the old #2 record in duplicate list
                     $query = 'SELECT id FROM #__sh404sef_urls WHERE binary oldurl = ' . $this->_db->Quote($previousSefUrl) . ' ORDER BY rank ASC';
                     $this->_db->setQuery($query);
                     $previousRanked2 = $this->_db->shlLoadObject();
                     // there was more than one duplicate in the same series, promote #2 to top spot
                     if (!empty($previousRanked2)) {
                         $query = 'UPDATE #__sh404sef_urls SET rank="0" WHERE id = ' . $this->_db->Quote($previousRanked2->id);
                         $this->_db->setQuery($query);
                         $this->_db->shlQuery();
                     }
                 }
             }
         } else {
             // there is no URL with same SEF URL, we are customizing an existing SEF url
             $shTemp = array('nonSefURL' => $row->newurl);
             Sh404sefHelperCache::removeURLFromCache($shTemp);
             // remove it from cache
             // simply store URL. If there is already one with same non-sef, this will raise an error in store()
             // as we don't allow creating a custom url for an already existing non-sef. User should
             // directly edit the existing non-sef/sef pair
             if (!$row->check()) {
                 $this->setError($row->getError());
                 return 0;
             }
             if (!$row->store()) {
                 $this->setError($row->getError());
                 return 0;
             }
             // add also to cache if saved to db
             Sh404sefHelperCache::addSefUrlToCache($row->newurl, $row->oldurl, $urlType);
             // we must add the previous SEF url to the alias list, only if
             //   - not already there
             //   - this sef url does not already exists in the DB; which will happen if the url
             //     begin saved was customized and also had duplicates
             // note : when importing, we don't enter this test as previousSefUrl is empty
             // TODO this code is duplicated just a few line above, need refactoring
             if (!empty($previousSefUrl) && strpos($this->_data['shAliasList'], $previousSefUrl) === false) {
                 // check if not already a valid SEF url in the DB
                 $query = 'SELECT count(id) FROM #__sh404sef_urls WHERE binary oldurl = ' . $this->_db->Quote($previousSefUrl);
                 $this->_db->setQuery($query);
                 $isThere = $this->_db->shlLoadResult();
                 if (empty($isThere)) {
                     $this->_data['shAliasList'] .= $previousSefUrl . "\n";
                 }
             }
             // finally, also check db for urls with same sef as previous SEF if any. We need
             // to search for the first duplicate of this old sef, and set it to be
             // the new main url
             // note : when importing, we don't enter this test as previousSefUrl is empty
             // TODO this code is duplicated just a few line above, need refactoring
             if (!empty($previousSefUrl) && $previousSefUrl != $row->newurl) {
                 // search for the old #2 record in duplicate list
                 $query = 'SELECT id FROM #__sh404sef_urls WHERE binary oldurl = ' . $this->_db->Quote($previousSefUrl) . ' ORDER BY rank ASC';
                 $this->_db->setQuery($query);
                 $previousRanked2 = $this->_db->shlLoadObject();
                 // there was more than one duplicate in the same series, promote #2 to top spot
                 if (!empty($previousRanked2)) {
                     ShlDbHelper::update('#__sh404sef_urls', array('rank' => 0), array('id' => $previousRanked2->id));
                 }
             }
         }
         // store saved url object
         $this->_url = $row;
         // return what should be a non-zero id
         return $this->_url->id;
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         $this->setError($e->getMessage());
         return 0;
     }
 }
コード例 #23
0
ファイル: com_virtuemart.php プロジェクト: alesconti/FF_2015
        $query = $item->query;
        // // when limitstart is not set, VM2 fetches start from the session, instead
        // of just assuming 0
        if (!empty($query['view']) && $query['view'] == 'category') {
            if (!isset($query['limitstart'])) {
                $limitstart = 0;
                shAddToGETVarsList('limitstart', $limitstart);
                shRemoveFromGETVarsList('limitstart');
            }
        }
        ShlSystem_Log::debug('sh404sef', 'Inside com_virtuemart.php, building url from menu item route');
        $title = array($item->route);
    }
}
if (empty($title)) {
    ShlSystem_Log::debug('sh404sef', 'Loading component own router.php file from inside com_virtuemart.php');
    $functionName = ucfirst(str_replace('com_', '', $option)) . 'BuildRoute';
    if (!function_exists($functionName)) {
        include JPATH_ROOT . '/components/' . $option . '/router.php';
    }
    $helper = vmrouterHelper::getInstance($originalVars);
    $menuItem = $helper->menuVmitems;
    $shopName = empty($menuItem) ? 'vm' : $menuItem[0]->alias;
    // check for shop root url, else normal routing
    if (!empty($originalVars['view']) && $originalVars['view'] == 'virtuemart') {
        // if VM is homepage, then that's fine
        if (!shIsAnyHomepage($string)) {
            // else use menu item alias as slug
            $title[] = $shopName;
            unset($originalVars['view']);
        }
コード例 #24
0
ファイル: baseanalytics.php プロジェクト: alesconti/FF_2015
 /**
  * Connects to analytics supplier
  *
  * Meant to be overloaded by adapter
  *
  * @param $config , sef config object, holding connecton parameters
  */
 protected function _connect()
 {
     // get the http client
     $hClient = Sh404sefHelperAnalytics::getHttpClient();
     // establish connection with available methods
     $adapters = array('Zendshl_Http_Client_Adapter_Curl', 'Zendshl_Http_Client_Adapter_Socket');
     $rawResponse = null;
     // perform connect request
     foreach ($adapters as $adapter) {
         try {
             $hClient->setAdapter($adapter);
             $rawResponse = $hClient->request();
             break;
         } catch (Exception $e) {
             // we failed, let's try another method
         }
     }
     // return if error
     if (empty($rawResponse)) {
         $msg = 'unknown code';
         ShlSystem_Log::debug('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, JText::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
         throw new Sh404sefExceptionDefault(JText::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     if (!is_object($rawResponse) || $rawResponse->isError()) {
         $msg = method_exists($rawResponse, 'getStatus') ? $rawResponse->getStatus() : 'unknown code';
         ShlSystem_Log::debug('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, JText::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
         throw new Sh404sefExceptionDefault(JText::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     // success, return response
     return $rawResponse;
 }
コード例 #25
0
ファイル: general.php プロジェクト: alesconti/FF_2015
 /**
  * Creates a link to the shLib plugin page
  * @return string
  */
 public static function getShLibPluginLink($xhtml = true)
 {
     try {
         $pluginId = ShlDbHelper::selectResult('#__extensions', array('extension_id'), array('type' => 'plugin', 'element' => 'shlib', 'folder' => 'system'));
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', __CLASS__ . '/' . __METHOD__ . '/' . __LINE__ . ': ' . $e->getMessage());
     }
     $link = '';
     $pluginId = (int) $pluginId;
     if (!empty($pluginId)) {
         $link = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $pluginId;
     }
     if ($xhtml) {
         $link = htmlspecialchars($link);
     }
     return $link;
 }
コード例 #26
0
ファイル: view.html.php プロジェクト: alesconti/FF_2015
 private function _prepareControlPanelData()
 {
     $sefConfig = Sh404sefFactory::getConfig();
     $this->assign('sefConfig', $sefConfig);
     // update information
     $versionsInfo = Sh404sefHelperUpdates::getUpdatesInfos();
     $this->assign('updates', $versionsInfo);
     // url databases stats
     $database = ShlDbHelper::getDb();
     try {
         $sql = 'SELECT count(*) FROM #__sh404sef_urls WHERE ';
         $database->setQuery($sql . "`dateadd` > '0000-00-00' and `newurl` = '' ");
         // 404
         $count404 = $database->shlLoadResult();
         $database->setQuery($sql . "`dateadd` > '0000-00-00' and `newurl` != '' ");
         // custom
         $customCount = $database->shlLoadResult();
         $database->setQuery($sql . "`dateadd` = '0000-00-00'");
         // regular
         $sefCount = $database->shlLoadResult();
         // calculate security stats
         $default = empty($sefConfig->shSecLastUpdated) ? '- -' : '0';
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         $sefCount = 0;
         $count404 = 0;
         $customCount = 0;
     }
     $this->assign('sefCount', $sefCount);
     $this->assign('Count404', $count404);
     $this->assign('customCount', $customCount);
 }
コード例 #27
0
 case 'task2':
     $dosef = false;
     // these tasks do not require SEF URL
     break;
 default:
     $title[] = $sh_LANG[$shLangIso]['COM_SH404SEF_VIEW_SAMPLE'];
     // insert a 'View sample' string,
     // according to language
     // only if you have defined the
     if (!empty($sampleId)) {
         // fetch some data about the content
         try {
             // using shLib database helper is J2.x/J3.x safe
             $sampleTitle = ShlDbHelper::selectObject('#__sample_names', array('id', 'title'), array('id' => $sampleId));
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
         if ($sampleTitle) {
             // if we found a title for this element
             $title[] = $sampleTitle->title;
             // insert it in URL array
             shRemoveFromGETVarsList('sampleId');
             // remove sampleId var from GET vars list
             // as we have found a text equivalent
             shMustCreatePageId('set', true);
             // NEW: ask sh404sef to create a short URL for this SEF URL (pageId)
         }
     }
     shRemoveFromGETVarsList('task');
     // also remove task, as it is not needed
     // because we can revert the SEF URL without
コード例 #28
0
ファイル: filecache.php プロジェクト: alesconti/FF_2015
 protected function _loadURLCache()
 {
     static $shDiskCacheLoaded = false;
     if (!$shDiskCacheLoaded) {
         ShlSystem_Log::debug('sh404sef', 'Cache not loaded - trying to load ' . $this->_cacheFilefullpath);
         if (file_exists($this->_cacheFilefullpath)) {
             $startMem = function_exists('memory_get_usage') ? memory_get_usage() : 'unavailable';
             ShlSystem_Log::debug('sh404sef', 'Including cache file (mem = ' . $startMem . ')');
             $this->_urlCache = array();
             // we try lock the cache file until the end of the request
             // so as to avoid other concurrent requests writing to it
             // while we have some pending data
             $this->_acquireLock();
             // read cache file content
             include $this->_cacheFilefullpath;
             $this->_urlCacheCreationDate = $shURLCacheCreationDate;
             $endMem = function_exists('memory_get_usage') ? memory_get_usage() : 'unavailable';
             $this->_urlCacheRam = $startMem == 'unavailable' ? $startMem : $endMem - $startMem;
             $shDiskCacheLoaded = !empty($this->_urlCache);
             $this->_urlCacheCount = !empty($this->_urlCache) ? count($this->_urlCache) : 0;
             ShlSystem_Log::debug('sh404sef', 'Cache file included : ' . ($startMem == 'unavailable' ? $startMem : $endMem - $startMem) . ' bytes used, ' . $this->_urlCacheCount . ' URLs');
         } else {
             // cache file not there, create it
             $now = time();
             $cache = sprintf($this->_fileHeader, $this->_config->version, $now);
             // lock cache file before using it
             if ($this->_acquireLock()) {
                 $cacheFile = fopen($this->_cacheFilefullpath, 'ab');
                 if ($cacheFile) {
                     fwrite($cacheFile, $cache);
                     fclose($cacheFile);
                 }
             }
             $this->_urlCache = array();
             $this->_urlCacheCount = 0;
             $shDiskCacheLoaded = true;
             // we don't want to try again if it failed first time
             $this->_urlCacheCreationDate = $now;
             ShlSystem_Log::debug('sh404sef', 'Cache file does not exists');
         }
     }
 }