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; }
public static function getcategories($catid, $shLang = null, $section = '') { ShlSystem_Log::debug('sh404sef', 'Calling deprecated sef_404::getCategories() method. Use Sh404sefModelSlugs model instead.'); return ''; }
$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']); }
/** * 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; }
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; }
/** * 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; }
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); } } }
/** * 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(); }
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)); }
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'); } } }