function onAfterDispatch() { if (JFactory::getApplication()->isAdmin()) { return; } if (JFactory::getApplication()->getCfg('sef') == 0) { return; } if (JFactory::getURI()->getVar('tmpl') == 'component') { return; } $config = SEFConfig::getConfig(); if (!$config->enabled) { return; } if ($config->google_enable == 0) { return; } if (JRequest::getInt('google_analytics_exclude', 0, 'cookie') == 1) { return; } $ips_exclude = explode("\r\n", $config->google_exclude_ip); if (in_array(IPAddressHelper::getip(), $ips_exclude)) { return; } $user = JFactory::getUser(); if (in_array($user->gid, $config->google_exclude_level)) { return; } JFactory::getDocument()->addScriptDeclaration(" var _gaq = _gaq || [];\n _gaq.push(['_setAccount', '" . $config->google_id . "']);\n _gaq.push(['_trackPageview']);\n\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n"); }
function display($tpl = null) { JToolBarHelper::title(JText::_('COM_SEF_JOOMSEF'), 'artio.png'); $user = JFactory::getUser(); if ($user->authorise('core.admin', 'com_sef')) { JToolBarHelper::preferences('com_sef'); } // Get number of URLs for purge warning $model = SEFModel::getInstance('URLs', 'SEFModel'); $this->assign('purgeCount', $model->getCount(0)); // Get newest version available $sefConfig = SEFConfig::getConfig(); if ($sefConfig->versionChecker) { $model2 = SEFModel::getInstance('Upgrade', 'SEFModel'); $newVer = $model2->getNewSEFVersion(); $sefinfo = SEFTools::getSEFInfo(); if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) { $newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span> <input type="button" class="btn btn-small" onclick="showUpgrade();" value="' . JText::_('COM_SEF_GO_TO_UPGRADE_PAGE') . '" />'; } $newVer .= ' <input type="button" class="btn btn-danger btn-small" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_DISABLE_VERSION_CHECKER') . '" />'; $this->assign('newestVersion', $newVer); } else { $newestVersion = JText::_('COM_SEF_VERSION_CHECKER_DISABLED') . ' <input type="button" class="btn btn-success btn-small" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_ENABLE') . '" />'; $this->assign('newestVersion', $newestVersion); } // Get statistics $stats = $model->getStatistics(); $this->assignRef('stats', $stats); // Get feed $feed = $this->get('Feed'); $this->assignRef('feed', $feed); // Check language filter plugin $this->getModel('sef')->checkLanguagePlugins(); parent::display($tpl); }
function getContactName($id) { $sefConfig =& SEFConfig::getConfig(); $title = array(); $field = 'name'; if (SEFTools::UseAlias($this->params, 'contact_alias')) { $field = 'alias'; } $id = intval($id); $query = "SELECT `id`, `{$field}` AS `name`, `catid`, `metakey`, `metadesc`, `metadata`, `language`,`misc` FROM `#__contact_details` WHERE `id` = '{$id}'"; $this->_db->setQuery($query); $row = $this->_db->loadObject('stdClass', $this->config->translateItems); if (is_null($row)) { JoomSefLogger::Log("Contact with ID {$id} could not be found.", $this, 'com_contact'); return array(); } $name = ($this->params->get('contactid', '0') != '0' ? $id . '-' : '') . $row->name; // use contact description as page meta tags if available if ($row->misc = JString::trim($row->misc)) { $this->metadesc = $row->misc; } if ($this->params->get('show_category', '2') != '0') { $catInfo = $this->getCategoryInfo($row->catid); if ($catInfo === false) { JoomSefLogger::Log("Category with ID {$row->catid} could not be found.", $this, 'com_contact'); } if (is_array($catInfo->path)) { $title = array_merge($title, $catInfo->path); } } $title[] = $row->name; $this->getMetaData($row); return $title; }
function getFeed() { $sefConfig =& SEFConfig::getConfig(); if (!$sefConfig->artioFeedDisplay) { return ''; } $rssDoc = JFactory::getFeedParser($sefConfig->artioFeedUrl); if ($rssDoc === false) { return JText::_('COM_SEF_ERROR_CONNECTING_TO_RSS_FEED'); } $items = $rssDoc->get_items(); if (count($items) == 0) { return JText::_('COM_SEF_NO_ITEMS_TO_DISPLAY'); } $txt = ''; for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $title = $item->get_title(); $link = $item->get_link(); $desc = $item->get_description(); $date = $item->get_date('j. F Y'); $author = $item->get_author(); $txt .= '<div class="feed-item">'; $txt .= '<div class="feed-title"><a href="' . $link . '" target="_blank">' . $title . '</a></div>'; $txt .= '<div class="feed-text">' . $desc . '</div>'; $txt .= '</div>'; } return $txt; }
function display($tpl = null) { JToolBarHelper::title(JText::_('JoomSEF'), 'artio.png'); // Get number of URLs for purge warning $model =& JModel::getInstance('URLs', 'SEFModel'); $this->assign('purgeCount', $model->getCount(0)); // Get newest version available $sefConfig =& SEFConfig::getConfig(); if ($sefConfig->versionChecker) { $model2 =& JModel::getInstance('Upgrade', 'SEFModel'); $newVer = $model2->getNewSEFVersion(); $sefinfo = SEFTools::getSEFInfo(); if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) { $newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span> <input type="button" onclick="showUpgrade();" value="' . JText::_('Go to Upgrade page') . '" />'; } $newVer .= ' <input type="button" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('Disable version checker') . '" />'; $this->assign('newestVersion', $newVer); } else { $newestVersion = JText::_('Version checker disabled') . ' <input type="button" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('Enable') . '" />'; $this->assign('newestVersion', $newestVersion); } // Get statistics $stats = $model->getStatistics(); $this->assignRef('stats', $stats); // Get feed $feed = $this->get('Feed'); $this->assignRef('feed', $feed); JHTML::_('behavior.tooltip'); parent::display($tpl); }
function getFeed() { $sefConfig =& SEFConfig::getConfig(); if (!$sefConfig->artioFeedDisplay) { return ''; } $options = array(); $options['rssUrl'] = $sefConfig->artioFeedUrl; $options['cache_time'] = null; $rssDoc =& JFactory::getXMLparser('RSS', $options); if ($rssDoc == false) { return JText::_('Error connecting to RSS feed.'); } $items = $rssDoc->get_items(); if (count($items) == 0) { return JText::_('No items to display.'); } $txt = ''; for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $title = $item->get_title(); $link = $item->get_link(); $desc = $item->get_description(); $date = $item->get_date('j. F Y'); $author = $item->get_author(); $txt .= '<div class="feed-item">'; $txt .= '<div class="feed-title"><a href="' . $link . '" target="_blank">' . $title . '</a></div>'; $txt .= '<div class="feed-text">' . $desc . '</div>'; $txt .= '</div>'; } return $txt; }
function getContactName($id) { $database =& JFactory::getDBO(); $sefConfig =& SEFConfig::getConfig(); $field = 'name'; if (SEFTools::UseAlias($this->params, 'contact_alias')) { $field = 'alias'; } $jfTranslate = $sefConfig->translateNames ? ', `id`' : ''; $id = intval($id); $database->setQuery("SELECT `{$field}` AS `name`, `catid` {$jfTranslate} FROM `#__contact_details` WHERE `id` = '{$id}'"); $contact = $database->loadObject(); if (is_null($contact)) { JoomSefLogger::Log("Contact with ID {$id} could not be found.", $this, 'com_contact'); return array(); } if ($contact) { $name = ($this->params->get('contactid', '0') != '0' ? $id . '-' : '') . $contact->name; if ($this->params->get('category', '1') != '1') { return array($name); } else { return array($this->getCategoryTitle($contact->catid), $name); } } }
function getStatistics() { $sefConfig =& SEFConfig::getConfig(); $stats = array(); $stat = new stdClass(); $stat->text = 'Automatic SEF URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_AUTOMATIC); $stat->link = 'index.php?option=com_sef&controller=sefurls&viewmode=0'; $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Custom SEF URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_CUSTOM); $stat->link = 'index.php?option=com_sef&controller=sefurls&viewmode=2'; $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Trashed SEF URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_TRASHED); $stat->link = 'index.php?option=com_sef&controller=sefurls&viewmode=6'; $stats[] = $stat; $stat = new stdClass(); $stat->text = '404 URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_404); $stat->link = 'index.php?option=com_sef&controller=sefurls&viewmode=1'; $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Moved URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_MOVED); $stat->link = 'index.php?option=com_sef&controller=movedurls'; $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Total URLs'; $stat->value = $stats[0]->value + $stats[1]->value + $stats[2]->value + $stats[3]->value + $stats[4]->value; $stats[] = $stat; $stat = new stdClass(); $stat->text = ''; $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Disabled URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_DISABLED); $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Not SEFed URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_NOT_SEFED); $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Locked URLs'; $stat->value = $this->getCount(_COM_SEF_COUNT_LOCKED); $stats[] = $stat; $stat = new stdClass(); $stat->text = 'Cache entries'; if ($sefConfig->useCache) { $cache =& sefCache::getInstance(); $stat->value = $cache->getCount(); } else { $stat->value = JText::_('Cache disabled'); } $stats[] = $stat; return $stats; }
function &getData() { // Load the data if (empty($this->_data)) { if ($this->_id != 0) { $query = "SELECT * FROM `#__sefurls` WHERE `id` = '{$this->_id}'"; $this->_db->setQuery($query); $this->_data = $this->_db->loadObject(); if (isset($this->_data->metacustom)) { $this->_data->metacustom = @unserialize($this->_data->metacustom); } } } if (!$this->_data) { $sefConfig =& SEFConfig::getConfig(); $this->_data = new stdClass(); $this->_data->id = 0; $this->_data->cpt = null; $this->_data->sefurl = null; $this->_data->origurl = null; $this->_data->Itemid = null; $this->_data->metadesc = null; $this->_data->metakey = null; $this->_data->metatitle = null; $this->_data->metalang = null; $this->_data->metarobots = null; $this->_data->metagoogle = null; $this->_data->metacustom = null; $this->_data->canonicallink = null; $this->_data->dateadd = null; $this->_data->enabled = 1; $this->_data->locked = 0; $this->_data->sef = 1; $this->_data->sm_indexed = $sefConfig->sitemap_indexed ? 1 : 0; $this->_data->sm_date = date('Y-m-d'); $this->_data->sm_frequency = $sefConfig->sitemap_frequency; $this->_data->sm_priority = $sefConfig->sitemap_priority; $this->_data->trace = null; $this->_data->aliases = null; } else { // Get the aliases $query = "SELECT * FROM `#__sefaliases` WHERE `url` = '{$this->_id}'"; $this->_db->setQuery($query); $objs = $this->_db->loadObjectList(); $aliases = array(); if ($objs) { foreach ($objs as $obj) { $aliases[] = $this->_aliasToString($obj); } } $this->_data->aliases = implode("\n", $aliases); } return $this->_data; }
function create(&$uri) { $sefConfig =& SEFConfig::getConfig(); $database =& JFactory::getDBO(); $this->params =& SEFTools::getExtParams('com_weblinks'); // JF translate extension. $jfTranslate = $sefConfig->translateNames ? ', `id`' : ''; $vars = $uri->getQuery(true); extract($vars); $title = array(); $title[] = JoomSEF::_getMenuTitle($option, @$this_task); if (@$view == 'category') { $title[] = $this->getCategoryTitle($id, SEFTools::UseAlias($this->params, 'category_alias')); } elseif (empty($this_task) && @$view == 'weblink') { if (isset($catid)) { if ($this->params->get('show_category', '1')) { $title[] = $this->getCategoryTitle($catid, SEFTools::UseAlias($this->params, 'category_alias')); } } if (!empty($id)) { $field = 'title'; if (SEFTools::UseAlias($this->params, 'weblink_alias')) { $field = 'alias'; } $id = intval($id); $database->setQuery("SELECT `{$field}` AS `title` {$jfTranslate} FROM `#__weblinks` WHERE `id` = '{$id}'"); $row = $database->loadObject(); if (is_null($row)) { JoomSefLogger::Log("Weblink with ID {$id} could not be found.", $this, 'com_weblinks'); } elseif (!empty($row->title)) { $name = $row->title; if ($this->params->get('weblink_id', '0')) { $name = $id . '-' . $name; } $title[] = $name; } } else { $title[] = JText::_('Submit'); } } if (isset($task) && $task == 'new') { $title[] = 'new' . $sefConfig->suffix; } $newUri = $uri; if (count($title) > 0) { // Generate meta tags $metatags = $this->getMetaTags(); $priority = $this->getPriority($uri); $sitemap = $this->getSitemapParams($uri); $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], null, null, $metatags, $priority, false, null, $sitemap); } return $newUri; }
function setinfotext() { // Get new state $state = JRequest::getVar('state'); if (is_null($state)) { jexit(); } $sefConfig =& SEFConfig::getConfig(); $sefConfig->showInfoTexts = $state ? true : false; $sefConfig->saveConfig(0); jexit(); }
function display($tpl = null) { JToolBarHelper::title(JText::_('COM_SEF_JOOMSEF_CONFIGURATION'), 'config.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::spacer(); JToolBarHelper::cancel(); // Get data from the model $lists =& $this->get('Lists'); $this->assignRef('lists', $lists); $this->langs = $this->get('langs'); $this->subdomains = $this->get('subdomains'); // Which tabs to show? $sefConfig =& SEFConfig::getConfig(); $tabs = array('basic'); if ($sefConfig->professionalMode) { $tabs[] = 'advanced'; } $tabs[] = 'cache'; $tabs[] = 'metatags'; $tabs[] = 'seo'; $tabs[] = 'sitemap'; $tabs[] = 'language'; $tabs[] = 'analytics'; $tabs[] = 'subdomains'; $tabs[] = '404'; $tabs[] = 'registration'; $tab = JRequest::getVar('tab', 'basic'); $tabIdx = array_search($tab, $tabs); if ($tabIdx === false) { $tabIdx = 0; } $this->assignRef('tabs', $tabs); $this->assign('tab', $tabIdx); // Root domain for subdomains configuration $rootDomain = JFactory::getURI()->getHost(); if (substr($rootDomain, 0, 4) == 'www.') { $rootDomain = substr($rootDomain, 4); } $this->assign('rootDomain', $rootDomain); JHTML::_('behavior.tooltip'); JHTML::_('behavior.framework'); $doc =& JFactory::getDocument(); $doc->addStyleDeclaration('form#adminForm div.current { width: auto; }'); $sefConfig =& SEFConfig::getConfig(); if (!$sefConfig->professionalMode) { $mainframe =& JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('COM_SEF_BEGINNER_MODE_INFO')); } parent::display($tpl); }
function onAfterDispatch() { if (JFactory::getApplication()->isAdmin()) { return; } if (JFactory::getApplication()->getCfg('sef') == 0) { return; } if (JFactory::getURI()->getVar('tmpl') == 'component') { return; } $config = SEFConfig::getConfig(); if (!$config->enabled) { return; } if ($config->google_enable == 0) { return; } if (JRequest::getInt('google_analytics_exclude', 0, 'cookie') == 1) { return; } $ips_exclude = explode("\r\n", $config->google_exclude_ip); if (in_array(IPAddressHelper::getip(), $ips_exclude)) { return; } $groups = null; $user = JFactory::getUser(); if ($user) { $groups = $user->get('groups'); } if (is_array($groups)) { foreach ($groups as $group) { if (in_array($group, $config->google_exclude_level)) { return; } } } $script = " (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\r\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\r\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\r\n })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\r\n\r\n ga('create', '" . htmlspecialchars($config->google_id) . "', 'auto');\n"; if ($config->google_demographic_reports) { $script .= " ga('require', 'displayfeatures');\n"; } if ($config->google_link_attribution) { $script .= " ga('require', 'linkid', 'linkid.js');\n"; } $script .= " ga('send', 'pageview');\n"; JFactory::getDocument()->addScriptDeclaration($script); }
function _getVars() { $app =& JFactory::getApplication(); $this->filterMessage = $app->getUserStateFromRequest("sef.logger.filterMessage", 'filterMessage', ''); $this->filterComponent = $app->getUserStateFromRequest("sef.logger.filterComponent", 'comFilter', ''); $this->filterPage = $app->getUserStateFromRequest("sef.logger.filterPage", 'filterPage', ''); $this->filterUrl = $app->getUserStateFromRequest("sef.logger.filterUrl", 'filterUrl', ''); $this->filterOrder = $app->getUserStateFromRequest('sef.logger.filter_order', 'filter_order', 'time'); $this->filterOrderDir = $app->getUserStateFromRequest('sef.logger.filter_order_Dir', 'filter_order_Dir', 'desc'); $this->limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $this->limitstart = $app->getUserStateFromRequest('sef.logger.limitstart', 'limitstart', 0, 'int'); // in case limit has been changed, adjust limitstart accordingly $this->limitstart = $this->limit != 0 ? floor($this->limitstart / $this->limit) * $this->limit : 0; // enabled? $config =& SEFConfig::getConfig(); $this->enabled = $config->logErrors; }
function create(&$uri) { $sefConfig =& SEFConfig::getConfig(); $database =& JFactory::getDBO(); $vars = $uri->getQuery(true); extract($vars); $title = array(); $title[] = JoomSEF::_getMenuTitleLang($option, $this->lang); switch (@$view) { case 'categories': break; case 'category': $catInfo = $this->getCategoryInfo($id); if ($catInfo === false) { JoomSefLogger::Log("Category with ID {$id} could not be found.", $this, 'com_newsfeeds'); } if (is_array($catInfo->path)) { $title = array_merge($title, $catInfo->path); } break; case 'newsfeed': $title = array_merge($title, $this->getFeedTitle($id)); break; } if (isset($format)) { if ($format == 'feed' && isset($type)) { $title[] = $type; } else { $title[] = $format; } } $newUri = $uri; if (count($title) > 0) { // Generate meta tags $this->metatags = $this->getMetaTags(); $priority = $this->getPriority($uri); $sitemap = $this->getSitemapParams($uri); if (isset($this->lang)) { $lang = $this->lang; } $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, null, $this->metatags, $priority, false, null, $sitemap); } return $newUri; }
function display($tpl = null) { JToolBarHelper::title(JText::_('JoomSEF Configuration'), 'config.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::spacer(); JToolBarHelper::cancel(); // Get data from the model $lists =& $this->get('Lists'); $this->assignRef('lists', $lists); $this->subdomains = $this->get('subdomains'); // Which tab to show? $sefConfig =& SEFConfig::getConfig(); $tabs = array('basic'); if ($sefConfig->professionalMode) { $tabs[] = 'advanced'; } $tabs[] = 'cache'; $tabs[] = 'metatags'; $tabs[] = 'seo'; $tabs[] = 'sitemap'; if (SEFTools::JoomFishInstalled()) { $tabs[] = 'joomfish'; } $tabs[] = 'analytics'; if (!SEFTools::JoomFishInstalled()) { $tabs[] = 'subdomains'; } $tabs[] = 'tab404'; $tabs[] = 'registration'; $tab = JRequest::getVar('tab', 'basic'); $tabIdx = array_search($tab, $tabs); if ($tabIdx === false) { $tabIdx = 0; } $this->assign('tab', $tabIdx); JHTML::_('behavior.tooltip'); $sefConfig =& SEFConfig::getConfig(); if (!$sefConfig->professionalMode) { $mainframe =& JFactory::getApplication(); $mainframe->enqueueMessage(JText::_('COM_SEF_BEGINNER_MODE_INFO')); } parent::display($tpl); }
function create(&$uri) { $sefConfig =& SEFConfig::getConfig(); $params = SEFTools::GetExtParams('com_content'); $vars = $uri->getQuery(true); extract($vars); // Set title. $title = array(); $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid); if (!empty($tmpl)) { $title[] = $tmpl; } $newUri = $uri; if (count($title) > 0) { $this->_createNonSefVars($uri); $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, $this->ignoreVars); } return $newUri; }
function showInfoText($str) { $sefConfig =& SEFConfig::getConfig(); $this->assign('infoString', JText::_($str)); $this->assign('infoShown', $sefConfig->showInfoTexts); // Prepare JS variables $document =& JFactory::getDocument(); $js = "var jsInfoTextShown = " . ($sefConfig->showInfoTexts ? 'true' : 'false') . ";\n"; $js .= "var jsInfoTextHide = '" . JText::_('COM_SEF_INFOTEXT_HIDE', true) . "';\n"; $js .= "var jsInfoTextShow = '" . JText::_('COM_SEF_INFOTEXT_SHOW', true) . "';\n"; $js .= "var jsInfoTextUrl = '" . JURI::root() . "administrator/index.php?option=com_sef&controller=config&task=setinfotext';\n"; $document->addScriptDeclaration($js); // Load JS JHTML::script('infotexts.js', 'administrator/components/com_sef/assets/js/', false); JHTML::_('behavior.mootools'); $prevLayout = $this->setLayout('default'); echo $this->loadTemplate('infotext'); $this->setLayout($prevLayout); }
function __construct() { $this->_config = SEFConfig::getConfig(); $auth_url = "https://www.google.com/accounts/ClientLogin"; $auth_params = array(); $auth_params["accountType"] = "GOOGLE"; $auth_params["Email"] = $this->_config->google_email; $auth_params["Passwd"] = $this->_config->google_password; $auth_params["service"] = "analytics"; $auth_params["source"] = JFactory::getApplication()->getCfg('sitename') . "-joomsef-4.1.2"; $this->_certFile = realpath(dirname(__FILE__) . '/../cacert.pem'); if (function_exists('curl_init')) { // Use CURL $c = curl_init($auth_url); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_POSTFIELDS, $auth_params); curl_setopt($c, CURLOPT_CAINFO, $this->_certFile); $data = curl_exec($c); curl_close($c); } else { // Try to use OpenSSL $response = SEFTools::PostRequest($auth_url, null, $auth_params); if ($response === false) { return; } $data = $response->content; } if (!$data) { return; } $data = explode("\n", $data); array_pop($data); $this->_info = array(); for ($i = 0; $i < count($data); $i++) { $row = explode("=", $data[$i]); $this->_info[$row[0]] = $row[1]; } }
function create(&$uri) { $sefConfig =& SEFConfig::getConfig(); $this->params =& SEFTools::getExtParams('com_banners'); $vars = $uri->getQuery(true); extract($vars); $title[] = JoomSEF::_getMenuTitleLang(@$option, @$task, @$Itemid); switch (@$task) { case 'click': $title[] = $this->GetBannerName($id); unset($task); break; } $newUri = $uri; if (isset($this->lang)) { $lang = $this->lang; } if (count($title) > 0) { $newUri = JoomSEF::_sefGetLocation($uri, $title, @$task, null, null, @$lang); } return $newUri; }
function _removeURL($option, $item) { $db = JFactory::getDBO(); $sefConfig =& SEFConfig::getConfig(); $cache = SEFCache::getInstance(); if ($sefConfig->update_urls == false) { return true; } $file = JPATH_ROOT . '/components/com_sef/sef_ext/' . $option . '.php'; if (!file_exists($file)) { return true; } require_once $file; $class = 'SefExt_' . $option; if (!class_exists($class)) { return true; } $sef_ext = new $class(); if (!method_exists($sef_ext, 'getURLPatterns')) { return true; } $urls = $sef_ext->getURLPatterns($item); foreach ($urls as $url) { $query = "SELECT id, sefurl,locked \n"; $query .= "FROM #__sefurls \n"; $query .= "WHERE origurl REGEXP " . $db->quote($url); $db->setQuery($query); $sefurl = $db->loadObject(); if (is_object($sefurl)) { if ($sefurl->locked) { JError::raiseError('JoomSEF Error', JText::_('COM_SEF_ERROR_LOCKED_URL')); return false; } // Clean urls which relate to removed item $query = "DELETE FROM #__sefurls \n"; $query .= "WHERE id=" . $sefurl->id; $db->setQuery($query); if (!$db->query()) { JError::raiseError('JoomSEF Error', $db->stderr(true)); return false; } // Clean unnecessary redirects $query = "DELETE FROM #__sefmoved \n"; $query .= "WHERE new=" . $db->quote($sefurl->sefurl); $db->setQuery($query); if (!$db->query()) { JError::raiseError('JoomSEF Error', $db->stderr(true)); return false; } } // Clean urls which relate to removed item from cache too $cache->removeCacheURL($url); } return true; }
/** * Tries to find a SEF URL corresponding with given nonSEF URL * * @param string $nonsef * @param string $Itemid * @return string */ function getSefUrl($nonsef, $Itemid = null) { $sefConfig =& SEFConfig::getConfig(); // Load the cache if needed if (!$this->cacheLoaded) { $this->LoadCache(); } // Check if the cache was loaded successfully if (!$this->cacheLoaded) { return false; } // Check if non-sef url doesn't contain Itemid $vars = array(); parse_str(str_replace('index.php?', '', $nonsef), $vars); if (is_null($Itemid) && strpos($nonsef, 'Itemid=')) { if (isset($vars['Itemid'])) { $Itemid = $vars['Itemid']; } $nonsef = SEFTools::removeVariable($nonsef, 'Itemid'); } // Get the ignoreSource parameter if (isset($vars['option'])) { $params = SEFTools::getExtParams($vars['option']); $extIgnore = $params->get('ignoreSource', 2); } else { $extIgnore = 2; } $ignoreSource = $extIgnore == 2 ? $sefConfig->ignoreSource : $extIgnore; // If Itemid is set as ignored for the component, set ignoreSource to 1 if (!is_null($Itemid) && isset($vars['option'])) { if (SEFTools::isItemidIgnored($vars['option'], $Itemid)) { $ignoreSource = 1; } } // Get all sef urls matching non-sef url if (isset($this->cache[$nonsef]) && is_array($this->cache[$nonsef]) && count($this->cache[$nonsef]) > 0) { // Search with Itemid if set to and Itemid set if (!$ignoreSource && !is_null($Itemid)) { $nullId = null; for ($i = 0, $n = count($this->cache[$nonsef]); $i < $n; $i++) { $row = $this->cache[$nonsef][$i]; if (isset($row->Itemid) && $row->Itemid == $Itemid) { return $row; } if (empty($row->Itemid)) { $nullId = $i; } } // Not found with correct itemid, try to find without itemid if (!is_null($nullId)) { // Update Itemid in cache $this->cache[$nonsef][$i]->Itemid = $Itemid; $row = $this->cache[$nonsef][$i]; // Save the cache $this->saveCache(); // Return found row return $row; } } else { return $this->cache[$nonsef][0]; } } // URL does not exist in the cache return false; }
function getLists() { // make the select list for the component filter $comList[] = JHTML::_('select.option', '', JText::_('COM_SEF_ALL')); $rows = SEFTools::getInstalledComponents(); foreach (array_keys($rows) as $i) { $row =& $rows[$i]; $comList[] = JHTML::_('select.option', $row->option, $row->name); } $lists['comList'] = JHTML::_('select.genericlist', $comList, 'comFilter', "class=\"inputbox\" onchange=\"document.adminForm.submit();\" size=\"1\"", 'value', 'text', $this->filterComponent); // make the filter text boxes $lists['filterSEF'] = "<input class=\"hasTip\" type=\"text\" name=\"filterSEF\" value=\"{$this->filterSEF}\" size=\"40\" maxlength=\"255\" onkeydown=\"return handleKeyDown(event);\" title=\"" . JText::_('COM_SEF_TT_FILTER_SEF') . "\" />"; $lists['filterReal'] = "<input class=\"hasTip\" type=\"text\" name=\"filterReal\" value=\"{$this->filterReal}\" size=\"40\" maxlength=\"255\" onkeydown=\"return handleKeyDown(event);\" title=\"" . JText::_('COM_SEF_TT_FILTER_REAL') . "\" />"; $lists['filterSEFRE'] = JText::_('COM_SEF_USE_RE') . ' <input type="checkbox" style="float:none" ' . (substr($this->filterSEF, 0, 4) == 'reg:' ? 'checked="checked"' : '') . ' onclick="useRE(this, document.adminForm.filterSEF);" />'; $lists['filterRealRE'] = JText::_('COM_SEF_USE_RE') . ' <input type="checkbox" style="float:none" ' . (substr($this->filterReal, 0, 4) == 'reg:' ? 'checked="checked"' : '') . ' onclick="useRE(this, document.adminForm.filterReal);" />'; // Filter meta tags $metas[] = JHTML::_('select.option', 0, JText::_('COM_SEF_ALL')); $metas[] = JHTML::_('select.option', 1, JText::_('COM_SEF_EMPTY')); $metas[] = JHTML::_('select.option', 2, JText::_('COM_SEF_FILLED')); $lists['filterTitle'] = JHTML::_('select.genericlist', $metas, 'filterTitle', 'class="inputbox" onchange="document.adminForm.submit();" style="width: 120px;" size="1"', 'value', 'text', $this->filterTitle); $lists['filterDesc'] = JHTML::_('select.genericlist', $metas, 'filterDesc', 'class="inputbox" onchange="document.adminForm.submit();" style="width: 120px;" size="1"', 'value', 'text', $this->filterDesc); $lists['filterKeys'] = JHTML::_('select.genericlist', $metas, 'filterKeys', 'class="inputbox" onchange="document.adminForm.submit();" style="width: 120px;" size="1"', 'value', 'text', $this->filterKeys); // Language filter $sefConfig = SEFConfig::getConfig(); if ($sefConfig->langEnable) { $langs = JLanguageHelper::getLanguages(); $langList = array(); $langList[] = JHTML::_('select.option', '', JText::_('COM_SEF_ALL')); foreach ($langs as $lng) { $langList[] = JHTML::_('select.option', $lng->sef, $lng->title); } $lists['filterLang'] = JHTML::_('select.genericlist', $langList, 'filterLang', 'class="inputbox" onchange="document.adminForm.submit();" size="1"', 'value', 'text', $this->filterLang); } $lists['filterReset'] = '<input type="button" class="btn" value="' . JText::_('COM_SEF_RESET') . '" onclick="resetFilters();" />'; // Ordering $lists['filter_order'] = $this->filterOrder; $lists['filter_order_Dir'] = $this->filterOrderDir; return $lists; }
<?php /** * SEF component for Joomla! * * @package JoomSEF * @version 4.6.2 * @author ARTIO s.r.o., http://www.artio.net * @copyright Copyright (C) 2015 ARTIO s.r.o. * @license GNU/GPLv3 http://www.artio.net/license/gnu-general-public-license */ defined('_JEXEC') or die('Restricted access'); echo JHtml::_('tabs.panel', JText::_('COM_SEF_CACHE'), 'cache'); $sefConfig =& SEFConfig::getConfig(); $x = 0; ?> <fieldset class="adminform"> <legend><?php echo JText::_('COM_SEF_CACHE_CONFIGURATION'); ?> </legend> <table class="adminform table table-stripped"> <tr> <td><?php echo $this->lists['cache_info']; ?> </td> </tr> </table> <table class="adminform table table-striped">
function store() { $row =& $this->getTable(); $data = JRequest::get('post'); // Make sure origurl follows the rules $this->fixOrigurlPost($data); // Handle the enabled, sef and locked checkboxes if (!isset($data['enabled'])) { $data['enabled'] = '0'; } if (!isset($data['sef'])) { $data['sef'] = '0'; } if (!isset($data['locked'])) { $data['locked'] = '0'; } // Create the array of custom meta tags if (isset($data['metanames']) && is_array($data['metanames'])) { for ($i = 0, $n = count($data['metanames']); $i < $n; $i++) { if (empty($data['metanames'][$i])) { unset($data['metanames'][$i]); if (isset($data['metacontents'][$i])) { unset($data['metacontents'][$i]); } } } // Create the associative array of custom meta tags $data['metacustom'] = array_combine($data['metanames'], $data['metacontents']); } else { // No meta tags $data['metacustom'] = array(); } $data['metacustom'] = serialize($data['metacustom']); // Bind the form fields to the table if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); return false; } // Make sure the record is valid if (!$row->check()) { $this->setError($row->_error); return false; } // Set the priority according to Itemid if ($row->Itemid != '') { $row->priority = _COM_SEF_PRIORITY_DEFAULT_ITEMID; } else { $row->priority = _COM_SEF_PRIORITY_DEFAULT; } // Store the table to the database if (!$row->store()) { $this->setError($row->getError()); return false; } // Handle the aliases references // remove the current bindings $this->_db->setQuery("DELETE FROM `#__sefaliases` WHERE `url` = '{$row->id}'"); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } // add all the aliases for current URL $data['aliases'] = trim($data['aliases']); if (!empty($data['aliases'])) { $aliases = str_replace("\r", '', $data['aliases']); $aliases = explode("\n", $aliases); $vals = array(); foreach ($aliases as $arow) { if (strpos($arow, '?') !== false) { list($alias, $vars) = explode('?', $arow); $vars = str_replace('&', "\n", $vars); } else { $alias = $arow; $vars = ''; } $alias = ltrim($alias, '/'); $vals[] = '(' . $this->_db->Quote($alias) . ', ' . $this->_db->Quote($vars) . ", '{$row->id}')"; } $query = "INSERT INTO `#__sefaliases` (`alias`, `vars`, `url`) VALUES " . implode(', ', $vals); $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); return false; } } // check if there's old url to save to Moved Permanently table $unchanged = JRequest::getVar('unchanged'); if ($data["addtosefmoved"]) { $row =& $this->getTable('MovedUrl'); $row->old = $unchanged; $row->new = JRequest::getVar('sefurl'); // pre-save checks if (!$row->check()) { $this->setError($row->getError()); return false; } // save the changes if (!$row->store()) { $this->setError($row->getError()); return false; } } $config = SEFConfig::getConfig(); if ($config->useCache) { $data = (object) $data; $cache = SEFCache::getInstance(); $nonsefcache = $cache->getNonSEFURL($data->unchanged); if ($nonsefcache) { $cache->changeUrl($row->id, $data->origurl, $data->sefurl, 0, $data->Itemid, $data->metatitle, $data->metadesc, $data->metakey, $data->metalang, $data->metarobots, $data->metagoogle, $data->canonicallink, $data->metacustom, $data->enabled, $data->sef, true, $row->host, $row->showsitename); } } return true; }
?> </td> <td> <?php echo $this->lists['locked']; ?> <?php echo $this->tooltip(JText::_('COM_SEF_TT_URL_LOCKED'), JText::_('COM_SEF_LOCKED')); ?> </td> </tr> <?php } ?> <?php $config =& SEFConfig::getConfig(); ?> <?php if ($config->trace) { ?> <tr><th colspan="2"><?php echo JText::_('COM_SEF_URL_SOURCE_TRACING'); ?> </th></tr> <tr> <td valign="top" class="key"><?php echo JText::_('COM_SEF_TRACE_INFORMATION'); ?> :</td> <td align="left"><?php
/** * Returns the Joomla category for given id * * @param int $catid * @return string */ function _getCategories($catid, $useAlias = false) { $sefConfig =& SEFConfig::getConfig(); $database =& JFactory::getDBO(); $jfTranslate = $sefConfig->translateNames ? ', `id`' : ''; $cat_table = "#__categories"; $field = 'title'; if ($useAlias) { $field = 'alias'; } // Let's find the Joomla category name for given category ID $title = ''; if (isset($catid) && $catid != 0) { $catid = intval($catid); $query = "SELECT `{$field}` AS `title` {$jfTranslate} FROM `{$cat_table}` WHERE `id` = '{$catid}'"; $database->setQuery($query); $rows = $database->loadObjectList(); if ($database->getErrorNum()) { $msg = JText::_('Database error'); if (JDEBUG) { $msg .= ': ' . $database->stderr(); } JError::raiseError('JoomSEF Error', $msg); } elseif (@count($rows) > 0 && !empty($rows[0]->title)) { $title = $rows[0]->title; } } return $title; }
function _checkBaseHref() { $sefConfig = SEFConfig::getConfig(); $checkBaseHref = $sefConfig->check_base_href; // now we can set base href $document = JFactory::getDocument(); if ($checkBaseHref == _COM_SEF_BASE_HOMEPAGE) { $uri = JURI::getInstance(); $curUri = clone $uri; $domain = JoomSEF::get('real_domain'); if ($domain) { $curUri->setHost($domain); } // dajo 10.9.2012: Make sure base ends with a slash $base = $curUri->toString(array('scheme', 'host', 'port')) . JURI::base(true); $base = rtrim($base, '/') . '/'; $document->setBase($base); } elseif ($checkBaseHref == _COM_SEF_BASE_CURRENT) { $uri = JURI::getInstance(); $curUri = clone $uri; $domain = JoomSEF::get('real_domain'); if ($domain) { $curUri->setHost($domain); } $document->setBase(htmlspecialchars($curUri->toString(array('scheme', 'host', 'port', 'path')))); } elseif ($checkBaseHref == _COM_SEF_BASE_NONE) { $document->setBase(''); } else { return; } }
function _getPackageFromServer($extension) { // Make sure that zlib is loaded so that the package can be unpacked if (!extension_loaded('zlib')) { JError::raiseWarning(100, JText::_('WARNINSTALLZLIB')); return false; } // build the appropriate paths $sefConfig =& SEFConfig::getConfig(); $config =& JFactory::getConfig(); if (empty($extension)) { $tmp_dest = $config->getValue('config.tmp_path') . DS . 'joomsef.zip'; } else { $tmp_dest = $config->getValue('config.tmp_path') . DS . $extension . '.zip'; } // Validate the upgrade on server $data = array(); $data['username'] = $sefConfig->artioUserName; $data['password'] = $sefConfig->artioPassword; if (empty($extension)) { $data['download_id'] = $sefConfig->artioDownloadId; $data['file'] = 'com_joomsef'; } else { $params =& SEFTools::getExtParams($extension); $data['download_id'] = $params->get('downloadId', ''); $data['file'] = 'ext_joomsef3_' . substr($extension, 4); } $uri = parse_url(JURI::root()); $url = $uri['host'] . $uri['path']; $url = trim($url, '/'); $data['site'] = $url; $data['ip'] = $_SERVER['SERVER_ADDR']; $lang =& JFactory::getLanguage(); $data['lang'] = $lang->getTag(); $data['cat'] = 'joomsef3'; // Get the server response $response = SEFTools::PostRequest($sefConfig->serverAutoUpgrade, JURI::root(), $data); // Check the response if ($response === false || $response->code != 200) { JError::raiseWarning(100, JText::_('Connection to server could not be established.')); return false; } // Response OK, check what we got if (strpos($response->header, 'Content-Type: application/zip') === false) { JError::raiseWarning(100, $response->content); return false; } // Seems we got the ZIP installation package, let's save it to disk if (!JFile::write($tmp_dest, $response->content)) { JError::raiseWarning(100, JText::_('Unable to save installation file in temp directory.')); return false; } // Unpack the downloaded package file $package = JInstallerHelper::unpack($tmp_dest); // Delete the package file JFile::delete($tmp_dest); return $package; }
function create(&$uri) { $sefConfig =& SEFConfig::getConfig(); $vars = $uri->getQuery(true); extract($vars); $title[] = JoomSEF::_getMenuTitleLang($option, $this->lang, @$Itemid); switch (@$view) { case 'categories': break; case 'category': $catInfo = $this->getCategoryInfo($id); if ($catInfo === false) { JoomSefLogger::Log("Category with ID {$id} could not be found.", $this, 'com_weblinks'); } if (is_array($catInfo->path)) { $title = array_merge($title, $catInfo->path); } break; case 'form': if (isset($w_id)) { $title = array_merge($title, $this->getWeblinkTitle(@$w_id)); } break; case 'weblink': if (!empty($id)) { $title = array_merge($title, $this->getWeblinkTitle($id)); } else { if ($this->params->get('always_en', '0') == '1') { $title[] = 'Submit'; } else { $title[] = JText::_('COM_SEF_SUBMIT'); } } break; } switch (@$task) { case 'weblink.go': if (!empty($id)) { $title = array_merge($title, $this->getWeblinkTitle($id)); } else { if ($this->params->get('always_en', '0') == '1') { $title[] = 'Submit'; } else { $title[] = JText::_('COM_SEF_SUBMIT'); } } break; case 'new': $title[] = 'new' . $sefConfig->suffix; break; case 'weblink.edit': $title = array_merge($title, $this->getWeblinkTitle(@$w_id)); if ($this->params->get('always_en', '0') == '1') { $title[] = 'Edit'; } else { $title[] = JText::_('COM_SEF_EDIT'); } if (@$return) { $nonSefVars['return'] = $return; } break; } if (@$format) { if ($format == 'feed' && @$type) { $title[] = ucfirst($type); } else { $title[] = ucfirst($format); } } $newUri = $uri; if (count($title)) { // Generate meta tags $this->metatags = $this->getMetaTags(); $priority = $this->getPriority($uri); $sitemap = $this->getSitemapParams($uri); if (isset($this->lang)) { $lang = $this->lang; } $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, @$nonSefVars, null, $this->metatags, $priority, false, null, $sitemap); } return $newUri; }