コード例 #1
0
ファイル: view.html.php プロジェクト: lautarodragan/ideary
 public function display($tpl = null)
 {
     // get model and update context with current
     $model =& $this->getModel();
     $context = $model->setContext($this->_context . '.' . $this->getLayout());
     // display type: simple for very large sites/slow slq servers
     $sefConfig =& Sh404sefFactory::getConfig();
     // if set for a slowServer, display simplified version of the url manager
     $this->assign('slowServer', $sefConfig->slowServer);
     // read data from model
     $list =& $model->getList((object) array('layout' => $this->getLayout(), 'simpleUrlList' => $this->slowServer, 'slowServer' => $sefConfig->slowServer));
     // and push it into the view for display
     $this->assign('items', $list);
     $this->assign('itemCount', count($this->items));
     $this->assign('pagination', $model->getPagination((object) array('layout' => $this->getLayout(), 'simpleUrlList' => $this->slowServer, 'slowServer' => $sefConfig->slowServer)));
     $options = $model->getDisplayOptions();
     $this->assign('options', $options);
     $this->assign('optionsSelect', $this->_makeOptionsSelect($options));
     // add behaviors and styles as needed
     $modalSelector = 'a.modalediturl';
     $js = '\\function(){window.parent.shAlreadySqueezed = false;if(window.parent.shReloadModal) {parent.window.location=\'' . $this->defaultRedirectUrl . '\';window.parent.shReloadModal=true}}';
     $params = array('overlayOpacity' => 0, 'classWindow' => 'sh404sef-popup', 'classOverlay' => 'sh404sef-popup', 'onClose' => $js);
     Sh404sefHelperHtml::modal($modalSelector, $params);
     // build the toolbar
     $toolbarMethod = '_makeToolbar' . ucfirst($this->getLayout());
     if (is_callable(array($this, $toolbarMethod))) {
         $this->{$toolbarMethod}($params);
     }
     // add our own css
     JHtml::styleSheet('urls.css', Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/');
     // link to  custom javascript
     JHtml::script('list.js', Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/');
     // now display normally
     parent::display($tpl);
 }
コード例 #2
0
 function shGetNEWSPCategories($catId, $option, $shLangName, &$cat, &$sec)
 {
     if (empty($catId)) {
         return false;
     }
     static $catData = null;
     $sefConfig =& Sh404sefFactory::getConfig();
     if (!is_null($catData[$shLangName][$catId])) {
         // get DB
         $database =& JFactory::getDBO();
         $query = "SELECT c.id, c.section, c.title, s.id as sectionid, s.title as stitle" . "\n FROM #__categories as c, #__sections as s" . "\n WHERE " . "\n s.id = c.section" . "\n AND c.id = '" . $catId . "'";
         $database->setQuery($query);
         if (shTranslateUrl($option, $shLangName)) {
             $categories = $database->loadObjectList();
         } else {
             $categories = $database->loadObjectList(false);
         }
         if (!empty($categories)) {
             $sec = ($sefConfig->shNewsPInsertSecId ? $sectionId . $sefConfig->replacement : '') . $categories[0]->stitle;
             // section
             $cat = ($sefConfig->shNewsPInsertCatId ? $sectionId . $sefConfig->replacement : '') . $categories[0]->title;
             // category
             $catData[$shLangName][$catId]['cat'] = $cat;
             $catData[$shLangName][$catId]['sec'] = $sec;
         }
     } else {
         $cat = $catData[$shLangName][$catId]['cat'];
         $sec = $catData[$shLangName][$catId]['sec'];
     }
     return !empty($cat);
 }
コード例 #3
0
ファイル: view.raw.php プロジェクト: alesconti/FF_2015
 private function _doQuickControl($tpl)
 {
     // get configuration object
     $sefConfig = Sh404sefFactory::getConfig($reset = true);
     // push it into to the view
     $this->sefConfig = $sefConfig;
     $messages = JFactory::getApplication()->getMessageQueue();
     $noMsg = JRequest::getInt('noMsg', 0);
     $this->error = array();
     // push any message
     if (is_array($messages) && !empty($messages)) {
         foreach ($messages as $msg) {
             if (!empty($msg['message'])) {
                 $msg['type'] = isset($msg['type']) ? $msg['type'] : 'info';
                 if ($msg['type'] != 'error') {
                     if (empty($noMsg)) {
                         $this->message = $msg['message'];
                     }
                 } else {
                     $this->errors[] = $msg['message'];
                 }
             }
         }
     }
     parent::display($tpl);
 }
コード例 #4
0
ファイル: sh404seffactory.php プロジェクト: alesconti/FF_2015
 /**
  * Get a Extplugin object for the requested extension
  * If no specific plugin is found, the default, generic
  * public is used instead
  *
  * @param string $option the Joomla! component name. Should begin with "com_"
  * @return object Sh404sefExtpluginBaseextplugin descendant
  */
 public static function &getExtensionPlugin($option)
 {
     static $_plugins = array();
     if (empty($option)) {
         $option = 'default';
     }
     // plugin is cached, check if we already created
     // the plugin for $option
     if (empty($_plugins[$option])) {
         // build the class name for this plugin
         // autolaoder will find the appropriate file and load it
         // if not loaded
         if ($option !== 'default' && strpos($option, 'com_') !== 0) {
             $option = 'com_' . $option;
         }
         $className = 'Sh404sefExtplugin' . ucfirst(strtolower($option));
         // does this class exists?
         $sefConfig =& Sh404sefFactory::getConfig();
         if (class_exists($className, $autoload = true)) {
             // instantiate plugin
             $_plugins[$option] = new $className($option, $sefConfig);
         } else {
             // else use generic plugin
             $_plugins[$option] = new Sh404sefExtpluginDefault($option, $sefConfig);
         }
     }
     // return cached plugin
     return $_plugins[$option];
 }
コード例 #5
0
ファイル: view.html.php プロジェクト: alesconti/FF_2015
 public function display($tpl = null)
 {
     // version prefix
     $this->joomlaVersionPrefix = Sh404sefHelperGeneral::getJoomlaVersionPrefix();
     // get model and update context with current
     $model = ShlMvcModel_Base::getInstance('urls', 'Sh404sefModel');
     $context = $model->setContext($this->_context . '.' . $this->getLayout());
     // display type: simple for very large sites/slow slq servers
     $sefConfig = Sh404sefFactory::getConfig();
     // store it
     $model = $this->setModel($model, true);
     // read data from model
     $list = $model->getList((object) array('layout' => $this->getLayout(), 'getMetaData' => true, 'simpleUrlList' => true, 'slowServer' => $sefConfig->slowServer));
     // and push it into the view for display
     $this->assign('items', $list);
     $this->assign('itemCount', count($this->items));
     $this->assign('contentcs', Sh404sefHelperGeneral::getDataMD5($this->items, array('metatitle', 'metadesc')));
     $this->assign('pagination', $model->getPagination((object) array('layout' => $this->getLayout(), 'simpleUrlList' => true, 'slowServer' => $sefConfig->slowServer)));
     $options = $model->getDisplayOptions();
     $this->assign('options', $options);
     $this->assign('helpMessage', JText::_('COM_SH404SEF_META_HELP'));
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $document = JFactory::getDocument();
         // add our own css and js
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/' . $this->joomlaVersionPrefix . '_list.css');
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/shajax.js');
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/j3.js');
         // add modal css and js
         ShlHtmlBs_helper::addBootstrapCss(JFactory::getDocument());
         ShlHtmlBs_helper::addBootstrapJs(JFactory::getDocument());
         // variable for modal, not used in 3..x+
         $params = array();
         $this->_addFilters();
         // render submenu sidebar
         $this->sidebar = Sh404sefHelperHtml::renderSubmenu();
     } else {
         // add our own css
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/' . $this->joomlaVersionPrefix . '_urls.css');
         // link to  custom javascript
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/list.js');
         JHtml::script(Sh404sefHelperGeneral::getComponentUrl() . '/assets/js/metas.js');
         // add behaviors and styles as needed
         $modalSelector = 'a.modalediturl';
         $js = '\\function(){window.parent.shAlreadySqueezed = false;if(window.parent.shReloadModal) {parent.window.location=\'' . $this->defaultRedirectUrl . '\';window.parent.shReloadModal=true}}';
         $params = array('overlayOpacity' => 0, 'classWindow' => 'sh404sef-popup', 'classOverlay' => 'sh404sef-popup', 'onClose' => $js);
         Sh404sefHelperHtml::modal($modalSelector, $params);
         $this->assign('optionsSelect', $this->_makeOptionsSelect($options));
         // add our own css
         JHtml::styleSheet(Sh404sefHelperGeneral::getComponentUrl() . '/assets/css/list.css');
     }
     // build the toolbar
     $toolbarMethod = '_makeToolbar' . ucfirst($this->getLayout() . ucfirst($this->joomlaVersionPrefix));
     if (is_callable(array($this, $toolbarMethod))) {
         $this->{$toolbarMethod}($params);
     }
     // now display normally
     parent::display($this->joomlaVersionPrefix);
 }
コード例 #6
0
ファイル: analyticsga.php プロジェクト: lautarodragan/ideary
 protected function _fetchAccountsList()
 {
     $hClient =& Sh404sefHelperAnalytics::getHttpClient();
     $hClient->resetParameters($clearAll = true);
     // build the request
     $sefConfig = Sh404sefFactory::getConfig();
     $accountIdBits = explode('-', trim($sefConfig->analyticsId));
     if (empty($accountIdBits) || count($accountIdBits) < 3) {
         throw new Sh404sefExceptionDefault(JText::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', 'Invalid account Id'));
     }
     $accoundId = $accountIdBits[1];
     // set target API url
     $hClient->setUri($this->_endPoint . 'management/accounts/' . $accoundId . '/webproperties/' . trim($sefConfig->analyticsId) . '/profiles?key=' . $this->_getAppKey());
     // make sure we use GET
     $hClient->setMethod(Sh_Zend_Http_Client::GET);
     // set headers required by Google Analytics
     $headers = array('GData-Version' => 2, 'Authorization' => 'GoogleLogin auth=' . $this->_Auth);
     $hClient->setHeaders($headers);
     //perform request
     // establish connection with available methods
     $adapters = array('Sh_Zend_Http_Client_Adapter_Curl', 'Sh_Zend_Http_Client_Adapter_Socket');
     $rawResponse = null;
     // perform connect request
     foreach ($adapters as $adapter) {
         try {
             $hClient->setAdapter($adapter);
             $response = $hClient->request();
             break;
         } catch (Exception $e) {
             // need that to be Exception, so as to catch Sh_Zend_Exceptions.. as well
             // we failed, let's try another method
         }
     }
     // return if error
     if (empty($response)) {
         $msg = 'unknown code';
         throw new Sh404sefExceptionDefault(JText::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     if (empty($response) || !is_object($response) || $response->isError()) {
         $msg = method_exists($response, 'getStatus') ? $response->getStatus() : 'unknown code';
         throw new Sh404sefExceptionDefault(JText::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     // analyze response
     // check if authentified
     Sh404sefHelperAnalytics::verifyAuthResponse($response);
     $xml = simplexml_load_string($response->getBody());
     if (!empty($xml->entry)) {
         foreach ($xml->entry as $entry) {
             $account = new StdClass();
             $bits = explode('/', (string) $entry->id);
             $account->id = array_pop($bits);
             $account->title = str_replace('Google Analytics Profile ', '', (string) $entry->title);
             $this->_accounts[] = clone $account;
         }
     }
 }
コード例 #7
0
ファイル: view.raw.php プロジェクト: alesconti/FF_2015
 /**
  * Prepare and display the control panel
  * dashboard, which is a simplified view
  * of main analytics results
  *
  * @param string $tpl layout name
  */
 private function _makeViewDashboard($tpl)
 {
     // get configuration object
     $sefConfig =& Sh404sefFactory::getConfig();
     // push it into to the view
     $this->assignRef('sefConfig', $sefConfig);
     // get analytics data using helper, possibly from cache
     $analyticsData = Sh404sefHelperAnalytics::getData($this->options);
     // push analytics stats into view
     $this->assign('analytics', $analyticsData);
 }
コード例 #8
0
ファイル: cache.php プロジェクト: lautarodragan/ideary
 protected static function &_getInstance($type = 'file')
 {
     static $_instance = null;
     if (empty($_instance)) {
         // get global config
         $config =& Sh404sefFactory::getConfig();
         // instantiate object
         $className = 'Sh404sefClass' . $type . 'cache';
         $_instance = new $className($config);
     }
     return $_instance;
 }
コード例 #9
0
ファイル: cache.php プロジェクト: alesconti/FF_2015
 protected static function &_getInstance($handler = '')
 {
     static $_instance = null;
     if (empty($_instance)) {
         // get global config
         $config =& Sh404sefFactory::getConfig();
         // instantiate object
         $handler = empty($handler) ? $config->UrlCacheHandler : $handler;
         $className = 'Sh404sefClass' . ucfirst($handler) . 'cache';
         $_instance = new $className($config);
     }
     return $_instance;
 }
コード例 #10
0
ファイル: security.php プロジェクト: alesconti/FF_2015
 private static function _shDecodeSecLogLine($line)
 {
     $sefConfig =& Sh404sefFactory::getConfig();
     // skip comments
     if (substr($line, 0, 1) == '#') {
         return;
     }
     if (preg_match('/[0-9]{2}\\-[0-9]{2}\\-[0-9]{2}/', $line)) {
         // this is not header or comment line
         self::$_counters['shSecTotalAttacks']++;
         $bits = explode("\t", $line);
         switch (substr($bits[2], 0, 15)) {
             case 'Flooding':
                 self::$_counters['shSecTotalFlooding']++;
                 break;
             case 'Caught by Honey':
                 self::$_counters['shSecTotalPHP']++;
                 break;
             case 'Honey Pot but u':
                 self::$_counters['shSecTotalPHPUserClicked']++;
                 break;
             case 'Var not numeric':
             case 'Var not alpha-n':
             case 'Var contains ou':
                 self::$_counters['shSecTotalStandardVars']++;
                 break;
             case 'Image file name':
                 self::$_counters['shSecTotalImgTxtCmd']++;
                 break;
             case '<script> tag in':
                 self::$_counters['shSecTotalScripts']++;
                 break;
             case 'Base 64 encoded':
                 self::$_counters['shSecTotalBase64']++;
                 break;
             case 'mosConfig_var i':
                 self::$_counters['shSecTotalConfigVars']++;
                 break;
             case 'Blacklisted IP':
                 self::$_counters['shSecTotalIPDenied']++;
                 break;
             case 'Blacklisted use':
                 self::$_counters['shSecTotalUserAgentDenied']++;
                 break;
             default:
                 // if not one of those, then it's a 404, don't count it as an attack
                 self::$_counters['shSecTotalAttacks']--;
                 break;
         }
     }
 }
コード例 #11
0
ファイル: view.raw.php プロジェクト: lautarodragan/ideary
 private function _doQuickControl($tpl)
 {
     // get configuration object
     $sefConfig =& Sh404sefFactory::getConfig();
     // push it into to the view
     $this->assignRef('sefConfig', $sefConfig);
     // push any message
     $error = $this->getError();
     if (empty($error)) {
         $noMsg = JRequest::getInt('noMsg', 0);
         if (empty($noMsg)) {
             $this->assign('message', JText::_('COM_SH404SEF_ELEMENT_SAVED'));
         }
     }
     parent::display($tpl);
 }
コード例 #12
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());
         }
     }
 }
コード例 #13
0
 function shSimpleLogger($siteName, $basePath, $fileName, $isActive)
 {
     $sefConfig = Sh404sefFactory::getConfig();
     if (empty($isActive)) {
         $this->isActive = 0;
         return;
     } else {
         $this->isActive = 1;
     }
     $traceFileName = $basePath . $sefConfig->debugStartedAt . '.' . $fileName . '_' . str_replace('/', '_', str_replace('http://', '', $siteName)) . '.log';
     // Create file
     $fileIsThere = file_exists($traceFileName);
     $sep = "\t";
     if (!$fileIsThere) {
         // create file
         $fileHeader = 'sh404SEF trace file - created : ' . $this->logTime() . ' for ' . $siteName . "\n\n" . str_repeat('-', 25) . ' PHP Configuration ' . str_repeat('-', 25) . "\n\n";
         $config = $this->parsePHPConfig();
         $line = str_repeat('-', 69) . "\n\n";
         // look for ob handlers, as we cannot use print_r from one (thanks Moovur !)
         $handlers = ob_list_handlers();
         $line .= "\nHandlers found : " . count($handlers);
         if (!empty($handlers)) {
             foreach ($handlers as $key => $handler) {
                 $line .= "\nHandler " . ($key + 1) . ' : ' . $handler;
             }
         }
         $line .= "\n" . str_repeat('-', 69) . "\n\n";
     } else {
         $fileHeader = '';
     }
     $file = fopen($traceFileName, 'ab');
     if ($file) {
         if (!empty($fileHeader)) {
             fWrite($file, $fileHeader);
             fWrite($file, print_r($config, true));
             fwrite($file, $line);
         }
         $this->logFile = $file;
     } else {
         $this->isActive = 0;
         return;
     }
 }
コード例 #14
0
ファイル: com_mtree.php プロジェクト: lautarodragan/ideary
 function shAppendListing($link_name, $link_id, $add_details = false, $shLangIso, $option, $shLangName)
 {
     global $sh_LANG;
     $sefConfig =& Sh404sefFactory::getConfig();
     $sef = array();
     if ($sefConfig->shMTreeInsertListingId) {
         if (!$sefConfig->shMTreePrependListingId) {
             $sef[] = ($sefConfig->shMTreeInsertListingName ? $link_name . $sefConfig->replacement : '') . $link_id;
         } else {
             $sef[] = $link_id . ($sefConfig->shMTreeInsertListingName ? $sefConfig->replacement . $link_name : '');
         }
     } else {
         if ($sefConfig->shMTreeInsertListingName) {
             $sef[] = $link_name;
         }
     }
     if ($add_details) {
         $sef[] = $sh_LANG[$shLangIso]['_MT_SEF_DETAILS'];
     }
     if ($sefConfig->shMTreeInsertListingName || $sefConfig->shMTreeInsertListingId) {
         shRemoveFromGETVarsList('link_id');
     }
     return $sef;
 }
コード例 #15
0
ファイル: sefurls.php プロジェクト: alesconti/FF_2015
 public function getSefURLFromCacheOrDB($nonSefUrl, &$sefUrl)
 {
     $sefConfig = Sh404sefFactory::getConfig();
     if (empty($nonSefUrl)) {
         return sh404SEF_URLTYPE_NONE;
     }
     $sefUrl = '';
     $urlType = sh404SEF_URLTYPE_NONE;
     if ($sefConfig->shUseURLCache) {
         $urlType = Sh404sefHelperCache::getSefUrlFromCache($nonSefUrl, $sefUrl);
     }
     // Check if the url is already saved in the database.
     if ($urlType == sh404SEF_URLTYPE_NONE) {
         $urlType = $this->getSefUrlFromDatabase($nonSefUrl, $sefUrl);
         if ($urlType == sh404SEF_URLTYPE_NONE || $urlType == sh404SEF_URLTYPE_404) {
             return $urlType;
         } else {
             if ($sefConfig->shUseURLCache) {
                 Sh404sefHelperCache::addSefUrlToCache($nonSefUrl, $sefUrl, $urlType);
             }
         }
     }
     return $urlType;
 }
コード例 #16
0
ファイル: shPageRewrite.php プロジェクト: alesconti/FF_2015
 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');
     }
 }
コード例 #17
0
ファイル: view.html.php プロジェクト: poorgeek/JEvents
 public function renderVersionsForClipboard()
 {
     if (!JEVHelper::isAdminUser()) {
         return;
     }
     jimport("joomla.filesystem.folder");
     $apps = array();
     // Joomla
     $app = new stdClass();
     $app->name = "Joomla";
     $version = new JVersion();
     $app->version = $version->getShortVersion();
     $apps[$app->name] = $app;
     // TODO :  Can we do this from the database???
     // components (including JEvents)
     $xmlfiles3 = array_merge(JFolder::files(JPATH_ADMINISTRATOR . "/components", "manifest\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "sh404sef\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "virtuemart\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "jce\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "jmailalerts\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "hikashop\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "jev_latestevents\\.xml", true, true));
     foreach ($xmlfiles3 as $manifest) {
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         // is sh404sef disabled ?
         if (basename(dirname($manifest)) == "com_sh404sef") {
             if (is_callable("Sh404sefFactory::getConfig")) {
                 $sefConfig = Sh404sefFactory::getConfig();
                 if (!$sefConfig->Enabled) {
                     $app->version = $manifestdata["version"] . " (Disabled in SH404 settings)";
                 }
             } else {
                 $app->version = $manifestdata["version"] . " (sh404sef system plugins not enabled)";
             }
         }
         $name = "component_" . basename(dirname($manifest));
         $apps[$name] = $app;
     }
     // modules
     if (JFolder::exists(JPATH_SITE . "/modules")) {
         $xmlfiles4 = JFolder::files(JPATH_SITE . "/modules", "\\.xml", true, true);
     } else {
         $xmlfiles4 = array();
     }
     foreach ($xmlfiles4 as $manifest) {
         if (strpos($manifest, "mod_") === false) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $app->criticalversion = "";
         $name = "module_" . str_replace(".xml", "", basename($manifest));
         $apps[$name] = $app;
     }
     // club layouts
     $xmlfiles1 = JFolder::files(JEV_PATH . "views", "manifest\\.xml", true, true);
     foreach ($xmlfiles1 as $manifest) {
         if (realpath($manifest) != $manifest) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $apps["layout_" . basename(dirname($manifest))] = $app;
     }
     $xmlfiles1 = JFolder::files(JPATH_ADMINISTRATOR . "/manifests/files", "\\.xml", true, true);
     foreach ($xmlfiles1 as $manifest) {
         if (realpath($manifest) != $manifest) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $apps[str_replace(".xml", "", "layout_" . basename($manifest))] = $app;
     }
     // plugins
     if (JFolder::exists(JPATH_SITE . "/plugins")) {
         $xmlfiles2 = JFolder::files(JPATH_SITE . "/plugins", "\\.xml", true, true);
     } else {
         $xmlfiles2 = array();
     }
     foreach ($xmlfiles2 as $manifest) {
         if (strpos($manifest, "Zend") > 0) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $name = str_replace(".xml", "", basename($manifest));
         $group = basename(dirname(dirname($manifest)));
         $plugin = JPluginHelper::getPlugin($group, $name);
         if (!$plugin) {
             $app->version .= " (not enabled)";
         }
         $name = "plugin_" . $group . "_" . $name;
         $apps[$name] = $app;
     }
     $output = "<textarea rows='40' cols='80' class='versionsinfo'>[code]\n";
     $output .= "PHP Version : " . phpversion() . "\n";
     $output .= "MySQL Version : " . JFactory::getDbo()->getVersion() . "\n";
     $output .= "Server Information : " . php_uname() . "\n";
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     if ($params->get("fixjquery", -1) == -1) {
         $output .= "*** CONFIG NOT SAVED*** \n";
     }
     $output .= "Fix jQuery? : " . ($params->get("fixjquery", 1) ? "Yes" : "No") . "\n";
     $output .= "Load JEvents Bootstrap CSS? : " . ($params->get("bootstrapcss", 1) ? "Yes" : "No") . "\n";
     $output .= "Load JEvents Bootstrap JS? : " . ($params->get("bootstrapjs", 1) ? "Yes" : "No") . "\n";
     if (ini_get("max_input_vars") > 0 && ini_get("max_input_vars") <= 10000) {
         $output .= "Max Input Vars ? : " . ini_get("max_input_vars") . "\n";
     }
     $output .= "Club code set? : " . ($params->get("clubcode", false) ? "Yes" : "No") . "  \n";
     $server = new JInput($_SERVER);
     $useragent = $server->get('HTTP_USER_AGENT', false, "string");
     $output .= $useragent ? "User Agent : " . $useragent . "  \n" : "";
     foreach ($apps as $appname => $app) {
         $output .= "{$appname} : {$app->version}\n";
     }
     $output .= "[/code]</textarea>";
     return $output;
 }
コード例 #18
0
ファイル: shSec.php プロジェクト: lautarodragan/ideary
function shDoAntiFloodCheck($ip)
{
    $sefConfig = Sh404sefFactory::getConfig();
    if (!$sefConfig->shSecActivateAntiFlood || empty($sefConfig->shSecAntiFloodPeriod) || $sefConfig->shSecAntiFloodOnlyOnPOST && empty($_POST) || empty($sefConfig->shSecAntiFloodCount) || empty($ip)) {
        return;
    }
    // disable for requests coming from same site, including ajax calls
    // coming from jomsocial
    // activate if using JomSocial on your site, removing the /* and */ marks surrounding the next few lines
    /*
    $referrer =  empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
      if (!empty($referrer) && strpos( $referrer, Sh404sefFactory::getPageInfo()->getDefaultLiveSite()) === 0) {
      if (!empty($_POST['option']) && $_POST['option'] == 'community'
      && !empty( $_POST['task']) && $_POST['task'] == 'azrul_ajax') {
      return;
      }
      }
    */
    // end of Jomsocial specific code
    $nextId = 1;
    $cTime = time();
    $count = 0;
    $floodData = shReadFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_AntiFlood_Data.dat');
    if (!empty($floodData)) {
        // find next id
        $lastRec = $floodData[count($floodData) - 1];
        $lastRecId = explode(',', $lastRec);
        if (!empty($lastRecId)) {
            $nextId = intval($lastRecId[0]) + 1;
        }
        // trim flood data : remove lines older than set time limit
        foreach ($floodData as $data) {
            $rec = explode(', ', $data);
            if (empty($rec[2]) || $cTime - intVal($rec[2]) > $sefConfig->shSecAntiFloodPeriod) {
                unset($floodData[$count]);
            }
            $count++;
        }
        $floodData = array_filter($floodData);
    }
    // we have only requests made in the last $sefConfig->shSecAntiFloodPeriod seconds left in $floodArray
    $count = 0;
    if (!empty($floodData)) {
        foreach ($floodData as $data) {
            $rec = explode(',', $data);
            if (!empty($rec[1]) && JString::trim($rec[1]) == $ip) {
                $count++;
            }
        }
    }
    // log current request
    $floodData[] = $nextId . ', ' . $ip . ', ' . $cTime;
    // write to file;
    $saveData = implode("\n", $floodData);
    shSaveFile(sh404SEF_ADMIN_ABS_PATH . 'security/sh404SEF_AntiFlood_Data.dat', $saveData);
    if ($count >= $sefConfig->shSecAntiFloodCount) {
        shDoRestrictedAccess('Flooding', $count . ' requests in less than ' . $sefConfig->shSecAntiFloodPeriod . ' seconds (max = ' . $sefConfig->shSecAntiFloodCount . ')');
    }
}
コード例 #19
0
ファイル: analytics.php プロジェクト: alesconti/FF_2015
 public static function getDataTypeTitle()
 {
     // need config, to know which data user wants to display : visits, unique visitors, pageviews
     $sefConfig = Sh404sefFactory::getConfig();
     $dataType = $sefConfig->analyticsDashboardDataType;
     $dataTypeString = str_replace('ga:', '', $dataType);
     $label = JText::_('COM_SH404SEF_ANALYTICS_DATA_' . strtoupper($dataTypeString));
     return $label;
 }
コード例 #20
0
 /**
  * NUmerical sort function
  *
  * @param $first
  * @param $second
  * @return unknown_type
  */
 protected function _sortSourcesDataCompareFunction($first, $second)
 {
     // need config, to know which data user wants to display : visits, unique visitors, pageviews
     $sefConfig = Sh404sefFactory::getConfig();
     // Google does not allow combining dimension=ga:medium with metric = unique visitors
     $metric = $sefConfig->analyticsDashboardDataType == 'ga:visitors' ? 'ga:visits' : $sefConfig->analyticsDashboardDataType;
     $dataTypeString = str_replace('ga:', '', $metric);
     if ($first->{$dataTypeString} == $second->{$dataTypeString}) {
         return 0;
     }
     return $first->{$dataTypeString} > $second->{$dataTypeString} ? +1 : -1;
 }
コード例 #21
0
 public function renderVersionsForClipboard()
 {
     if (!JEVHelper::isAdminUser()) {
         return;
     }
     jimport("joomla.filesystem.folder");
     $apps = array();
     // Joomla
     $app = new stdClass();
     $app->name = "Joomla";
     $version = new JVersion();
     $app->version = $version->getShortVersion();
     $apps[$app->name] = $app;
     // components (including JEvents)
     $xmlfiles3 = array_merge(JFolder::files(JPATH_ADMINISTRATOR . "/components", "manifest\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "sh404sef\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "virtuemart\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "jce\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "jmailalerts\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "hikashop\\.xml", true, true), JFolder::files(JPATH_ADMINISTRATOR . "/components", "jev_latestevents\\.xml", true, true));
     foreach ($xmlfiles3 as $manifest) {
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         // is sh404sef disabled ?
         if (basename(dirname($manifest)) == "com_sh404sef") {
             if (is_callable("Sh404sefFactory::getConfig")) {
                 $sefConfig = Sh404sefFactory::getConfig();
                 if (!$sefConfig->Enabled) {
                     $app->version = $manifestdata["version"] . " (Disabled in SH404 settings)";
                 }
             } else {
                 $app->version = $manifestdata["version"] . " (sh404sef system plugins not enabled)";
             }
         }
         $name = "component_" . basename(dirname($manifest));
         $apps[$name] = $app;
     }
     // modules
     if (JFolder::exists(JPATH_SITE . "/modules")) {
         $xmlfiles4 = JFolder::files(JPATH_SITE . "/modules", "\\.xml", true, true);
     } else {
         $xmlfiles4 = array();
     }
     foreach ($xmlfiles4 as $manifest) {
         if (strpos($manifest, "mod_") === false) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $app->criticalversion = "";
         $name = "module_" . str_replace(".xml", "", basename($manifest));
         $apps[$name] = $app;
     }
     // club layouts
     $xmlfiles1 = JFolder::files(JEV_PATH . "views", "manifest\\.xml", true, true);
     foreach ($xmlfiles1 as $manifest) {
         if (realpath($manifest) != $manifest) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $apps["layout_" . basename(dirname($manifest))] = $app;
     }
     $xmlfiles1 = JFolder::files(JPATH_ADMINISTRATOR . "/manifests/files", "\\.xml", true, true);
     foreach ($xmlfiles1 as $manifest) {
         if (realpath($manifest) != $manifest) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $apps[str_replace(".xml", "", "layout_" . basename($manifest))] = $app;
     }
     // plugins
     if (JFolder::exists(JPATH_SITE . "/plugins")) {
         $xmlfiles2 = JFolder::files(JPATH_SITE . "/plugins", "\\.xml", true, true);
     } else {
         $xmlfiles2 = array();
     }
     foreach ($xmlfiles2 as $manifest) {
         if (strpos($manifest, "Zend") > 0) {
             continue;
         }
         if (!($manifestdata = $this->getValidManifestFile($manifest))) {
             continue;
         }
         $app = new stdClass();
         $app->name = $manifestdata["name"];
         $app->version = $manifestdata["version"];
         $name = str_replace(".xml", "", basename($manifest));
         $group = basename(dirname(dirname($manifest)));
         $plugin = JPluginHelper::getPlugin($group, $name);
         if (!$plugin) {
             $app->version .= " (not enabled)";
         }
         $name = "plugin_" . $group . "_" . $name;
         $apps[$name] = $app;
     }
     $output = "<textarea rows='40' cols='80' class='versionsinfo'>[code]\n";
     $output .= "PHP Version : " . phpversion() . "\n";
     $output .= "MySQL Version : " . JFactory::getDbo()->getVersion() . "\n";
     foreach ($apps as $appname => $app) {
         $output .= "{$appname} : {$app->version}\n";
     }
     $output .= "[/code]</textarea>";
     return $output;
 }
コード例 #22
0
ファイル: sef_ext.php プロジェクト: alesconti/FF_2015
 /**
  *
  * @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('&amp;', '&', $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;
 }
コード例 #23
0
ファイル: shCache.php プロジェクト: lautarodragan/ideary
function shRemoveURLFromCache($nonSefURLList)
{
    global $shURLMemCache, $shURLDiskCache, $shURLTotalCount;
    $sefConfig =& Sh404sefFactory::getConfig();
    if (!$sefConfig->shUseURLCache || empty($nonSefURLList)) {
        return null;
    }
    $foundInDiskCache = false;
    $foundInMemCache = false;
    foreach ($nonSefURLList as $nonSefURL) {
        if (!empty($shURLMemCache)) {
            foreach ($shURLMemCache as $key => $cacheItem) {
                // look up in memory cache
                $tmp = explode('#', $cacheItem);
                $cacheNonSef = html_entity_decode($tmp[0], ENT_QUOTES);
                if ($cacheNonSef == $nonSefURL) {
                    unset($shURLMemCache[$key]);
                    $shURLTotalCount--;
                    $foundInMemCache = true;
                }
            }
        }
        if (!empty($shURLDiskCache)) {
            foreach ($shURLDiskCache as $key => $cacheItem) {
                // look up disk cache
                $tmp = explode('#', $cacheItem);
                $cacheNonSef = html_entity_decode($tmp[0], ENT_QUOTES);
                if ($cacheNonSef == $nonSefURL) {
                    unset($shURLDiskCache[$key]);
                    $shURLTotalCount--;
                    $foundInDiskCache = true;
                }
            }
        }
    }
    if ($foundInMemCache) {
        $shURLMemCache = array_values($shURLMemCache);
        // simply reindex mem cache
        return;
    }
    if ($foundInDiskCache) {
        // we need to remove these url from the disk cache file
        // to make it simpler, I simply rewrite the complete file
        $shURLMemCache = empty($shURLMemCache) ? array_values($shURLDiskCache) : array_merge($shURLDiskCache, $shURLMemCache);
        $shURLDiskCache = array();
        // don't need disk cache anymore, as all URL are in mem cache
        // so we remove both on disk cache and in memory copy of on disk cache
        $cacheFile = sh404SEF_FRONT_ABS_PATH . 'cache/shCacheContent.php';
        if (file_exists($cacheFile)) {
            unlink($cacheFile);
        }
        // no need to write new URL list in disk file, as this will be done automatically at shutdown
    }
}
コード例 #24
0
  /**
   * Check if user set parameters and request
   * data allow inserting tracking snippet
   */
  protected function _shouldInsertSnippet() {

    // get config
    $sefConfig = & Sh404sefFactory::getConfig();

    // check if we have a tracking code, no need to insert snippet if no tracking code
    if (empty( $sefConfig->analyticsId)) {
      return false;
    }

    // check if we are set to include tracking code for current user
    $user = JFactory::getUser();
    if ( !empty( $sefConfig->analyticsMaxUserLevel) && $sefConfig->analyticsMaxUserLevel != 'Public Frontend' && Sh404sefHelperGeneral::compareGroups( $user->usertype, $sefConfig->analyticsMaxUserLevel) == 1) {
      return false;
    }

    // check if current IP is on exclusion list
    if( !empty( $sefConfig->analyticsExcludeIP)) {
      $ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'];
      $exclude = Sh404sefHelperGeneral::checkIPList( $ip, $sefConfig->analyticsExcludeIP);
      if ($exclude) {
        return false;
      }
    }

    return true;
  }
コード例 #25
0
 /**
  *
  * 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;
 }
コード例 #26
0
ファイル: slugs.php プロジェクト: lautarodragan/ideary
 public function getCategorySlugArray($extension, $id, $whichCat, $useAlias, $insertId, $uncategorizedPath = '', $requestedLanguage = '*', $separator = '')
 {
     // special case for the "uncategorised" category
     $unCat = Sh404sefHelperCategories::getUncategorizedCat($extension);
     if (!empty($unCat) && $id == $unCat->id) {
         $slugArray = empty($uncategorizedPath) ? array() : array($uncategorizedPath);
         return $slugArray;
     }
     // regular category, build the path to the cat
     $separator = empty($separator) ? Sh404sefFactory::getConfig()->replacement : $separator;
     $pathArray = $this->getCategoryPathArray($extension, $id, $whichCat, $useAlias, $insertId, $requestedLanguage, $separator);
     $slugArray = array();
     foreach ($pathArray as $catObject) {
         $slugArray[] = $catObject->slug;
     }
     return $slugArray;
 }
コード例 #27
0
ファイル: helper.php プロジェクト: kosmosby/medicine-prof
    public static function sefToolEnabled() {

        //check mijosef
        $mijoseffilename = JPATH_ADMINISTRATOR . '/components/com_mijosef/library/mijosef.php';
        if (JFile::exists($mijoseffilename)) {
            require_once($mijoseffilename);
            $mijoconfig = Mijosef::getConfig();

            if ($mijoconfig->mode == 1){
                return true;
            }
        }
        //check sh404
        $sh404filename = JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.class.php';
        if (JFile::exists($sh404filename)) {
            require_once($sh404filename);
            // get our configuration
            $sefConfig = &Sh404sefFactory::getConfig();

            if ($sefConfig->Enabled)
            {
                return true;
            }
        }

        //check acesef
        //no more necessary with acesef > 4.1.1
//        $aceseffilename = JPATH_ADMINISTRATOR . '/components/com_acesef/library/utility.php';
//        if (JFile::exists($aceseffilename)) {
//            require_once($aceseffilename);
//            $AcesefConfig =  AcesefFactory::getConfig();
//            if ($AcesefConfig->mode == 1){
//                //woraround to set language filter mijosef don't set it in 4.1.1
//                $app = JFactory::getApplication();
//                if ($app->isSite()){
//                    $app->setLanguageFilter(true);
//                }
//                return true;
//            }
//        }

        return false;
    }
コード例 #28
0
ファイル: updates.php プロジェクト: lautarodragan/ideary
 /**
  * Use response object from request to update info server
  * to find if an update is required
  *
  * @param object $response
  */
 private function _updateRequired($response)
 {
     // get configuration
     $sefConfig =& Sh404sefFactory::getConfig();
     // compare versions
     $thisVersion = $sefConfig->version == '@ant_version_number@' ? '3.0.0.987654' : $sefConfig->version;
     $response->shouldUpdate = version_compare($thisVersion, $response->current) == -1;
     $response->shouldUpdate = $response->shouldUpdate && version_compare($thisVersion, $response->minVersionToUpgrade) == 1;
     $response->shouldUpdate = $response->shouldUpdate && (empty($response->maxVersionToUpgrade) || version_compare($thisVersion, $response->maxVersionToUpgrade) == -1);
     if ($response->shouldUpdate) {
         // check specific versions exclusion list
         $response->shouldUpdate = $response->shouldUpdate && !in_array($thisVersion, $response->excludes);
     }
     // build status message based on result of should update calculation
     $response->statusMessage = $response->shouldUpdate ? JText::sprintf('COM_SH404SEF_NEW_VERSION_AVAILABLE') : JText::sprintf('COM_SH404SEF_YOU_ARE_UP_TO_DATE');
     // return whatever we found
     return $response;
 }
コード例 #29
0
<?php

/**
 * 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.');
// ------------------  standard plugin initialize function - don't change ---------------------------
global $sh_LANG;
$sefConfig =& Sh404sefFactory::getConfig();
$shLangName = '';
$shLangIso = '';
$title = array();
$shItemidString = '';
$dosef = shInitializePlugin($lang, $shLangName, $shLangIso, $option);
if ($dosef == false) {
    return;
}
// ------------------  standard plugin initialize function - don't change ---------------------------
// ------------------  load language file - adjust as needed ----------------------------------------
//$shLangIso = shLoadPluginLanguage( 'com_XXXXX', $shLangIso, '_SEF_SAMPLE_TEXT_STRING');
// ------------------  load language file - adjust as needed ----------------------------------------
// remove common URL from GET vars list, so that they don't show up as query string in the URL
shRemoveFromGETVarsList('option');
shRemoveFromGETVarsList('lang');
コード例 #30
0
 public function onContentAfterDisplay($context, &$row, &$params, $page = 0)
 {
     if ($this->_params->get('buttonsContentLocation', 'onlyTags') == 'after') {
         $buttons = $this->_sh404sefGetSocialButtons(Sh404sefFactory::getConfig(), $url = '', $context, $row);
     } else {
         $buttons = '';
     }
     return $buttons;
 }