function getSefURL($id) { $url = ""; if (is_numeric($id)) { $url = MijoDatabase::loadResult("SELECT url_sef FROM #__mijosef_sitemap WHERE id = {$id}"); } return $url; }
function _getItemCatId($id) { static $cache = array(); if (!isset($cache[$id])) { if ($this->MijosefConfig->cache_instant == 1) { $rows = MijoDatabase::loadRowList("SELECT id, cid FROM #__banner"); foreach ($rows as $row) { $cache[$row[0]] = $row[1]; } } else { $cache[$id] = MijoDatabase::loadResult("SELECT cid FROM #__banner WHERE id = {$id}"); } } if (!isset($cache[$id])) { $cache[$id] = ""; } return $cache[$id]; }
function onAfterDispatch() { if (!self::_systemCheckup(true)) { return; } $url_1 = "index.php?option=com_content"; // Get item id $item_id = JRequest::getInt('id'); $url_2 = "id={$item_id}&view=article"; $url_3 = "format=pdf"; // Get row $url = MijoDatabase::loadResult("SELECT url_sef FROM #__mijosef_urls WHERE url_real LIKE '{$url_1}%' AND url_real LIKE '%{$url_2}%' AND url_real NOT LIKE '%{$url_3}%'"); if ($url && !Mijosef::get('utility')->JoomFishInstalled()) { $row = MijoDatabase::loadObject("SELECT id, url_sef, title, description, keywords, lang, robots, googlebot FROM #__mijosef_metadata WHERE url_sef = '{$url}'"); if (!$row) { $row = new stdClass(); $row->id = 0; $row->url_sef = $url; $row->title = ''; $row->description = ''; $row->keywords = ''; $row->lang = ''; $row->robots = ''; $row->googlebot = ''; } $mainframe = JFactory::getApplication(); $mainframe->setUserState('com_mijosef.metadata', $row); $language = JFactory::getLanguage(); $language->load('com_mijosef'); // Render output $output = Mijosef::get('utility')->render(JPATH_ROOT . '/plugins/system/mijosefmetacontent/mijosefmetacontent_tmpl.php'); $document = JFactory::getDocument(); $document->setBuffer($document->getBuffer('component') . $output, 'component'); } return true; }
JError::raiseWarning('100', JText::sprintf('COM_MIJOSEF_CPANEL_STATUS_NOTE_MOD', '<a href="index.php?option=com_config">', '</a>')); } if ($status['sef'] && !$status['htaccess']) { JError::raiseWarning('100', JText::sprintf('COM_MIJOSEF_CPANEL_STATUS_HTA_NO')); } if (!$status['htaccess'] || !$status['mod_rewrite'] || !$status['sef']) { JError::raiseNotice('100', JText::sprintf('COM_MIJOSEF_CPANEL_STATUS_NOTE_REQUIREMENTS', '<a href="http://www.mijosoft.com/support/docs/mijosef/installation-upgrading/requirements" target="_blank">', '</a>')); } if (Mijosef::get('utility')->JoomFishInstalled()) { $jf_id = MijoDatabase::loadResult("SELECT extension_id FROM #__extensions WHERE element = 'jfrouter' AND folder = 'system' AND enabled = '1'"); if (!is_null($jf_id)) { JError::raiseNotice('100', JText::sprintf('COM_MIJOSEF_CPANEL_STATUS_NOTE_JFROUTER', '<a href="index.php?option=com_plugins&view=plugin&client=site&task=edit&cid[]=' . $jf_id . '">', '</a>')); } } if ($this->MijosefConfig->multilang == 1) { $lf_id = MijoDatabase::loadResult("SELECT extension_id FROM #__extensions WHERE element = 'languagefilter' AND folder = 'system' AND enabled = '1'"); if (!is_null($lf_id)) { JError::raiseNotice('100', JText::sprintf('COM_MIJOSEF_CPANEL_STATUS_NOTE_LANGUAGEFILTER', '<a href="index.php?option=com_plugins&task=plugin.edit&extension_id=' . $lf_id . '">', '</a>')); } } if (empty($this->MijosefConfig->pid) && (MIJOSEF_PACK == 'plus' || MIJOSEF_PACK == 'pro')) { JError::raiseWarning('100', JText::sprintf('COM_MIJOSEF_CPANEL_STATUS_NOTE_PERSONAL_ID', '<a href="index.php?option=com_mijosef&controller=config&task=edit">', '</a>')); } ?> </th> </tr> <tr> <td valign="top" width="58%"> <table> <tr>
function unpublishTag($tag) { if (empty($tag)) { return false; } $urls = self::_getURLs(); if (!is_array($urls) || empty($urls)) { return false; } foreach ($urls as $url) { $found = MijoDatabase::loadResult("SELECT url_sef FROM #__mijosef_tags_map WHERE tag = '{$tag}' AND url_sef = '{$url}'"); if ($found) { continue; } MijoDatabase::query("INSERT INTO #__mijosef_tags_map (tag, url_sef) VALUES ('{$tag}', '{$url}')"); } return true; }
function getCountMeta() { $count = array(); $count['all'] = MijoDatabase::loadResult("SELECT COUNT(id) FROM #__mijosef_metadata WHERE title != '' AND description != '' AND keywords != ''"); $count['title'] = MijoDatabase::loadResult("SELECT COUNT(id) FROM #__mijosef_metadata WHERE title != ''"); $count['desc'] = MijoDatabase::loadResult("SELECT COUNT(id) FROM #__mijosef_metadata WHERE description != ''"); $count['key'] = MijoDatabase::loadResult("SELECT COUNT(id) FROM #__mijosef_metadata WHERE keywords != ''"); $count['total'] = array_sum($count); return $count; }
function getExtensionFromRequest() { static $extension; if (!isset($extension)) { $cid = JRequest::getVar('cid', array(0), 'method', 'array'); $extension = MijoDatabase::loadResult("SELECT extension FROM #__mijosef_extensions WHERE id = " . $cid[0]); } return $extension; }
function _setExtension($option) { static $components = array(); if (!isset($components[$option])) { $filter = Mijosef::get('utility')->getSkippedComponents(); $component = MijoDatabase::loadResult("SELECT `element` FROM `#__extensions` WHERE `type` = 'component' AND `element` NOT IN ({$filter}) AND `element` = '{$option}'"); if (!is_null($component)) { $routed = false; $name = ""; if (!$routed) { if (file_exists(JPATH_MIJOSEF_ADMIN . '/extensions/' . $component . '.php')) { $name = Mijosef::get('utility')->getXmlText(JPATH_MIJOSEF_ADMIN . '/extensions/' . $component . '.xml', 'name'); $router = 3; $routed = true; } } if (!$routed) { if (file_exists(JPATH_SITE . '/components/' . $component . '/router.php')) { $router = 2; $routed = true; } } if (!$routed) { $router = 1; } $prms = array(); $prms['router'] = "{$router}"; $prms['prefix'] = ""; $prms['skip_menu'] = "0"; $reg = new JRegistry($prms); $params = $reg->toString(); MijoDatabase::query("INSERT IGNORE INTO #__mijosef_extensions (name, extension, params) VALUES ('{$name}', '{$component}', '{$params}')"); $components[$option] = $params; } else { $components[$option] = false; } } return $components[$option]; }
function checkComponents() { $filter = Mijosef::get('utility')->getSkippedComponents(); $components = MijoDatabase::loadResultArray("SELECT `element` FROM `#__extensions` WHERE `type` = 'component' AND `element` NOT IN ({$filter}) ORDER BY `element`"); foreach ($components as $component) { // Check if there is already a record available $total = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_extensions WHERE extension = '{$component}'"); if ($total < 1) { $name = ""; $routed = false; if (!$routed) { $ext = JPATH_MIJOSEF_ADMIN . '/extensions/' . $component . '.php'; if (file_exists($ext)) { $name = Mijosef::get('utility')->getXmlText(JPATH_MIJOSEF_ADMIN . '/extensions/' . $component . '.xml', 'name'); $router = 3; $routed = true; } } if (!$routed) { $router = JPATH_SITE . '/components/' . $component . '/router.php'; if (file_exists($router)) { $router = 2; $routed = true; } } if (!$routed) { $router = 1; $routed = true; } if ($routed) { $prms = array(); $prms['router'] = "{$router}"; $prms['prefix'] = ""; $prms['skip_menu'] = "0"; $reg = new JRegistry($prms); $params = $reg->toString(); MijoDatabase::query("INSERT INTO #__mijosef_extensions (name, extension, params) VALUES ('{$name}', '{$component}', '{$params}')"); } } } }
function getInfo() { static $info; if (!isset($info)) { $info = array(); if ($this->MijosefConfig->version_checker == 1) { $info['version_installed'] = Mijosef::get('utility')->getXmlText(JPATH_MIJOSEF_ADMIN . '/a_mijosef.xml', 'version'); $version_info = Mijosef::get('utility')->getRemoteInfo(); $info['version_latest'] = $version_info['mijosef']; // Set the version status $info['version_status'] = version_compare($info['version_installed'], $info['version_latest']); $info['version_enabled'] = 1; } else { $info['version_status'] = 0; $info['version_enabled'] = 0; } $info['pid'] = $this->MijosefConfig->pid; $info['urls_sef'] = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_urls"); $info['urls_moved'] = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_urls_moved"); $info['metadata'] = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_metadata"); $info['sitemap'] = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_sitemap"); $info['tags'] = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_tags"); $info['ilinks'] = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_ilinks"); $info['bookmarks'] = MijoDatabase::loadResult("SELECT COUNT(*) FROM #__mijosef_bookmarks"); } return $info; }
public function getPermissions() { return MijoDatabase::loadResult('SELECT rules FROM #__assets WHERE name = "com_mijosef" AND title = "com_mijosef"'); }
function parseURI($uri, $old_uri) { $mainframe = JFactory::getApplication(); $route = $uri->getPath(); $lang = $uri->getVar('lang'); // Get the variables from the uri $vars = $uri->getQuery(true); // Handle an empty URL (special case) if (empty($route)) { self::determineLanguage(JRequest::getVar('lang')); $menu = Mijosef::get('utility')->getMenu(); // if route is empty AND option is set in the query, assume it's non-sef url, and parse apropriately if (isset($vars['option']) || isset($vars['Itemid'])) { return self::_parseRawRoute($uri); } $item = self::getDefaultMenuItem(); //Set the information in the request $vars = $item->query; //Get the itemid $vars['Itemid'] = $item->id; // Set the active menu item $menu->setActive($vars['Itemid']); // Set mainframe vars $row = Mijosef::get('cache')->checkURL('', true); if (is_object($row) && Mijosef::get('utility')->getParam($row->params, 'published') == '1') { $mainframe->set('mijosef.url.id', $row->id); $mainframe->set('mijosef.url.sef', $row->url_sef); $mainframe->set('mijosef.url.real', $row->url_real); $mainframe->set('mijosef.url.params', $row->params); $meta = Mijosef::get('cache')->checkMetadata($row->url_sef); if (is_object($meta)) { if (!empty($meta->title)) { $mainframe->set('mijosef.meta.title', $meta->title); } if (!empty($meta->description)) { $mainframe->set('mijosef.meta.desc', $meta->description); } if (!empty($meta->keywords)) { $mainframe->set('mijosef.meta.key', $meta->keywords); } if (!empty($meta->lang)) { $mainframe->set('mijosef.meta.lang', $meta->lang); } if (!empty($meta->robots)) { $mainframe->set('mijosef.meta.robots', $meta->robots); } if (!empty($meta->google)) { $mainframe->set('mijosef.meta.google', $meta->google); } if (!empty($meta->canonical)) { $mainframe->set('mijosef.link.canonical', $meta->canonical); } } } return $vars; } $q = $uri->getQuery(); $new_vars = self::_newVars($old_uri, $route, $q, $lang); // Joomfish $lang = isset($new_vars['lang']) ? $new_vars['lang'] : (isset($vars['lang']) ? $vars['lang'] : null); self::determineLanguage($lang); if (!empty($new_vars) && !empty($vars)) { // If this was SEF url, consider the vars in query as nonsef $non_sef_vars = array_diff_key($vars, $new_vars); if (!empty($non_sef_vars)) { $mainframe->set('mijosef.global.nonsefvars', $non_sef_vars); } } if (!empty($vars)) { // append the original query string because some components // (like SMF Bridge and SOBI2) use it $vars = array_merge($vars, $new_vars); } else { $vars = $new_vars; } if (!empty($new_vars)) { self::sendHeader('HTTP/1.0 200 OK'); } else { $menu = Mijosef::get('utility')->getMenu(); // set nonsef vars $mainframe->set('mijosef.global.nonsefvars', $vars); // Check if 404 records should be saved in DB if ($this->MijosefConfig->db_404_errors == 1) { $routee = MijoDatabase::quote($route); $found = MijoDatabase::loadObject("SELECT url_sef FROM #__mijosef_urls WHERE url_sef = {$routee} AND params LIKE '%\"notfound\":1%' LIMIT 1"); if ($found) { // Found, update hits MijoDatabase::query("UPDATE #__mijosef_urls SET hits = (hits+1) WHERE url_sef = {$routee}"); } else { // Save 404 URL $prms = array(); $prms['custom'] = 0; $prms['published'] = 0; $prms['locked'] = 0; $prms['blocked'] = 0; $prms['trashed'] = 0; $prms['notfound'] = 1; $prms['tags'] = 0; $prms['ilinks'] = 0; $prms['bookmarks'] = 0; $prms['visited'] = 0; $prms['notes'] = ''; $reg = new JRegistry($prms); $params = $reg->toString(); MijoDatabase::query("INSERT IGNORE INTO #__mijosef_urls (url_sef, url_real, cdate, params) VALUES ({$routee}, {$routee}, '" . date('Y-m-d H:i:s') . "', '{$params}')"); } } // Check if should be written to a logfile if ($this->MijosefConfig->log_404_errors == '1') { Mijosef::get('utility')->import('library.error'); MijosefError::logNotFoundURL($route); } if ($this->MijosefConfig->page404 == 'custom') { if ($url = Mijosef::get('cache')->checkURL('404' . $this->MijosefConfig->url_suffix, true)) { $url_real = str_replace('&', '&', $url->url_real); $QUERY_STRING = str_replace('index.php?', '', $url_real); parse_str($QUERY_STRING, $vars); if (!empty($vars['Itemid'])) { $menu->setActive($vars['Itemid']); } } elseif ($id = MijoDatabase::loadResult("SELECT id FROM #__content WHERE title = '404' AND state = '1'")) { $vars['option'] = 'com_content'; $vars['view'] = 'article'; $vars['id'] = $id; $vars['Itemid'] = 99999; } else { die(JText::_('ERROR_DEFAULT_404') . ' PAGE NOT FOUND: ' . $route . "<br />URI:" . $_SERVER['REQUEST_URI']); } } elseif ($this->MijosefConfig->page404 == 'home') { $item = self::getDefaultMenuItem(); //Get the vars $vars = $item->query; $vars['Itemid'] = $item->id; $menu->setActive($vars['Itemid']); } elseif ($this->MijosefConfig->page404 == 'joomla') { JError::raiseError(404, JText::_("THE REQUESTED RESOURCE WAS NOT FOUND")); } self::sendHeader('HTTP/1.0 404 NOT FOUND'); } // Set QUERY_STRING if set to if ($this->MijosefConfig->set_query_string == 1) { $qs = array(); foreach ($vars as $name => $val) { if (is_array($val)) { foreach ($val as $k => $v) { $qs[] = $name . '[' . $k . ']=' . urlencode($v); } } else { $qs[] = $name . '=' . urlencode($val); } } $qs = implode('&', $qs); if (!empty($qs)) { $_SERVER['QUERY_STRING'] = $qs; } } return $vars; }
function getSefUrl() { static $sef; $id = JRequest::getVar('id'); if (!isset($sef) && is_numeric($id)) { $sef = MijoDatabase::loadResult("SELECT url_sef FROM #__mijosef_urls WHERE id = {$id}"); } return $sef; }
function _googleNews($title, $id) { $num = ''; $add = $this->params->get('google_news', '1'); // ID $digits = trim($this->params->get('google_news_digits', '3')); if (!is_numeric($digits)) { $digits = '3'; } $articleid = sprintf('%0' . $digits . 'd', $id); // Date if ($add == '3' || $add == '4') { $time = MijoDatabase::loadResult("SELECT publish_up FROM #__content WHERE id = {$id}"); $time = strtotime($time); $date = $this->params->get('google_news_dateformat', 'ddmm'); $search = array('dd', 'd', 'mm', 'm', 'yyyy', 'yy'); $replace = array(date('d', $time), date('j', $time), date('m', $time), date('n', $time), date('Y', $time), date('y', $time)); $articledate = str_replace($search, $replace, $date); } if ($add == '2') { $num = $articleid; } elseif ($add == '3') { $num = $articledate; } elseif ($add == '4') { $num = $articledate . $articleid; } if (!empty($num)) { $sep = $this->MijosefConfig->replacement_character; $where = $this->params->get('google_news_pos', '2'); if ($where == '2') { $title = $title . $sep . $num; } else { $title = $num . $sep . $title; } } return $title; }