コード例 #1
0
ファイル: sh404sef.class.php プロジェクト: sangkasi/joomla
function shAddPaginationInfo($limit, $limitstart, $showall, $iteration, $url, $location, $shSeparator = null)
{
    global $mainframe;
    $sefConfig =& shRouter::shGetConfig();
    $database =& JFactory::getDBO();
    // get a default limit value, for urls where it's missing
    $listLimit = shGetDefaultDisplayNumFromURL($url, $includeBlogLinks = true);
    $defaultListLimit = shGetDefaultDisplayNumFromConfig($url, $includeBlogLinks = false);
    //echo 'Incoming pagination : $listLimit : ' . $listLimit . ' | $defaultListLimit : ' . $defaultListLimit . "\n";
    // clean suffix and index file before starting to add things to the url
    // clean suffix
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'format=pdf') !== false) {
        $shSuffix = '.pdf';
    } else {
        $shSuffix = $sefConfig->suffix;
    }
    $suffixLength = JString::strLen($shSuffix);
    if (!empty($shSuffix) && $shSuffix != '/' && JString::substr($location, -$suffixLength) == $shSuffix) {
        $location = JString::substr($location, 0, JString::strlen($location) - $suffixLength);
    }
    // clean index file
    if ($sefConfig->addFile && (empty($shSuffix) || JString::subStr($location, -$suffixLength) != $shSuffix)) {
        $indexFileLength = JString::strlen($sefConfig->addFile);
        if ($sefConfig->addFile != '/' && JString::substr($location, -$indexFileLength) == $sefConfig->addFile) {
            $location = JString::substr($location, 0, JString::strlen($location) - $indexFileLength);
        }
    }
    // do we have a trailing slash ?
    if (empty($shSeparator)) {
        $shSeparator = JString::substr($location, -1) == '/' ? '' : '/';
    }
    if (!empty($limit) && is_numeric($limit)) {
        $pagenum = intval($limitstart / $limit);
        $pagenum++;
    } else {
        if (!isset($limit) && !empty($limitstart)) {
            // only limitstart
            if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false) {
                $pagenum = intval($limitstart + 1);
                // multipage article
            } else {
                $pagenum = intval($limitstart / $listLimit) + 1;
                // blogs, tables, ...
            }
        } else {
            $pagenum = $iteration;
        }
    }
    // Make sure we do not end in infite loop here.
    if ($pagenum < $iteration) {
        $pagenum = $iteration;
    }
    // shumisha added to handle table-category and table-section which may have variable number of items per page
    // There still will be a problem with filter, which may reduce the total number of items. Thus the item we are looking for
    if ($sefConfig->alwaysAppendItemsPerPage || strpos($url, 'option=com_virtuemart') && $sefConfig->shVmUsingItemsPerPage) {
        $shMultPageLength = $sefConfig->pagerep . (empty($limit) ? $listLimit : $limit);
    } else {
        $shMultPageLength = '';
    }
    // shumisha : modified to add # of items per page to URL, for table-category or section-category
    if (!empty($sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]) && false !== strpos($sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']], '%s')) {
        $page = str_replace('%s', $pagenum, $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]) . $shMultPageLength;
    } else {
        $page = $sefConfig->pagerep . $pagenum . $shMultPageLength;
    }
    // V 1.2.4.t special processing to replace page number by headings
    $shPageNumberWasReplaced = false;
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && !empty($limitstart)) {
        // this is multipage article - limitstart instead of limit in J1.5
        if ($sefConfig->shMultipagesTitle) {
            parse_str($url, $shParams);
            if (!empty($shParams['id'])) {
                $shPageTitle = '';
                $sql = 'SELECT c.id, c.fulltext, c.introtext  FROM #__content AS c WHERE id=\'' . $shParams['id'] . '\'';
                $database->setQuery($sql);
                $contentElement = $database->loadObject();
                if ($database->getErrorNum()) {
                    JError::RaiseError(500, $database->stderr());
                }
                $contentText = $contentElement->introtext . $contentElement->fulltext;
                if (!empty($contentElement) && strpos($contentText, 'class="system-pagebreak') !== false) {
                    // search for mospagebreak tags
                    // copied over from pagebreak plugin
                    // expression to search for
                    $regex = '#<hr([^>]*)class=(\\"|\')system-pagebreak(\\"|\')([^>]*)\\/>#iU';
                    // find all instances of mambot and put in $matches
                    $shMatches = array();
                    preg_match_all($regex, $contentText, $shMatches, PREG_SET_ORDER);
                    // adds heading or title to <site> Title
                    if (empty($limitstart)) {
                        // if first page use heading of first mospagebreak
                        /* if ( $shMatches[0][2] ) {
                           parse_str( html_entity_decode( $shMatches[0][2] ), $args );
                           if ( @$args['heading'] ) {
                           $shPageTitle = stripslashes( $args['heading'] );
                           }
                           }*/
                    } else {
                        // for other pages use title of mospagebreak
                        if ($limitstart > 0 && $shMatches[$limitstart - 1][1]) {
                            $args = JUtility::parseAttributes($shMatches[$limitstart - 1][0]);
                            if (@$args['title']) {
                                $shPageTitle = $args['title'];
                            } else {
                                if (@$args['alt']) {
                                    $shPageTitle = $args['alt'];
                                } else {
                                    // there is a page break, but no title. Use a page number
                                    $shPageTitle = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]);
                                }
                            }
                        }
                    }
                }
                if (!empty($shPageTitle)) {
                    // found a heading, we should use that as a Title
                    $location .= $shSeparator . titleToLocation($shPageTitle);
                }
                $shPageNumberWasReplaced = true;
                // always set the flag, otherwise we'll a Page-1 added
            }
        } else {
            // mutiple pages article, but we don't want to use smart title.
            // directly use limitstart
            $page = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]);
        }
    }
    // maybe this is a multipage with "showall=1"
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && strpos($url, 'showall=1') !== false) {
        // this is multipage article with showall
        $tempTitle = JText::_('All Pages');
        $location .= $shSeparator . titleToLocation($tempTitle);
        $shPageNumberWasReplaced = true;
        // always set the flag, otherwise we'll a Page-1 added
    }
    // make sure we remove bad characters
    $takethese = str_replace('|', '', $sefConfig->friendlytrim);
    $location = JString::trim($location, $takethese);
    // add page number
    if (!$shPageNumberWasReplaced && (!isset($limitstart) && (isset($limit) && $limit != $listLimit && $limit != $defaultListLimit) || isset($limitstart) && ($limitstart != 0 || $limitstart == 0 && (strpos($url, 'option=com_virtuemart') && $sefConfig->shVmUsingItemsPerPage && (isset($limit) && $limit != $listLimit))))) {
        $location .= $shSeparator . $page;
    }
    // add suffix
    if (!empty($shSuffix) && $location != '/' && JString::substr($location, -1) != '/') {
        $location = $shSuffix == '/' ? $location . $shSuffix : str_replace($shSuffix, '', $location) . $shSuffix;
    }
    // add default index file
    if ($sefConfig->addFile) {
        // V 1.2.4.t
        if (empty($shSuffix) || !empty($shSuffix) && JString::subStr($location, -$suffixLength) != $shSuffix) {
            $location .= (JString::substr($location, -1) == '/' ? '' : '/') . $sefConfig->addFile;
        }
    }
    return JString::ltrim($location, '/');
}
コード例 #2
0
ファイル: admin.sh404sef.php プロジェクト: sangkasi/joomla
    die('Direct Access to this location is not allowed.');
}
// Ensure that user has access to this function.
$user =& JFactory::getUser();
if (!($user->usertype == 'Super Administrator' || $user->usertype == 'Administrator')) {
    $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH'));
}
// Setup paths.
$sef_config_class = JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.class.php';
$sef_config_file = JPATH_ADMINISTRATOR . '/components/com_sh404sef/config/config.sef.php';
// Make sure class was loaded.
if (!class_exists('shSEFConfig')) {
    if (is_readable($sef_config_class)) {
        require_once $sef_config_class;
    } else {
        JError::RaiseError(500, COM_SH404SEF_NOREAD . "( {$sef_config_class} )<br />" . COM_SH404SEF_CHK_PERMS);
    }
}
// testing JLanguage16
jimport('joomla.language.language');
$j16Language =& shjlang16Helper::getLanguage();
$loaded = $j16Language->load('com_sh404sef', JPATH_BASE);
// include sh404sef default language file
shIncludeLanguageFile();
// find about specific controller requested
$cName = JRequest::getCmd('c');
// get controller from factory
$controller = Sh404sefFactory::getController($cName);
// read and execute task
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();
コード例 #3
0
ファイル: sh404sef.php プロジェクト: alesconti/FF_2015
// sometimes users disable our plugin
if (!defined('SH404SEF_AUTOLOADER_LOADED')) {
    echo 'sh404SEF system plugin has been disabled or has failed initializing. Please enable it again to use sh404SEF, with Joomla! <a href="index.php?option=com_plugins">plugin manager</a>';
    return;
}
// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_sh404sef')) {
    return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
// load base class file (functions, not autolaoded
if (!defined('SH404SEF_BASE_CLASS_LOADED')) {
    $baseClassFile = JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.class.php';
    if (is_readable($baseClassFile)) {
        require_once $baseClassFile;
    } else {
        JError::RaiseError(500, JText::_('COM_SH404SEF_NOREAD') . "( {$baseClassFile} )<br />" . JText::_('COM_SH404SEF_CHK_PERMS'));
    }
}
// Ensure the behavior is loaded
JHtml::_('behavior.framework');
if (version_compare(JVERSION, '3.0', 'ge')) {
    JHtml::_('bootstrap.framework');
}
// find about specific controller requested
$cName = JFactory::getApplication()->input->getCmd('c');
// get controller from factory
$controller = Sh404sefFactory::getController($cName);
Sh404sefHelperHtml::addSubmenu(JFactory::getApplication()->input);
// read and execute task
$controller->execute(JFactory::getApplication()->input->getCmd('task'));
$controller->redirect();
コード例 #4
0
 protected function _do404(&$uri)
 {
     if (self::$requestParsed) {
         return array();
     }
     // get config objects
     $pageInfo =& Sh404sefFactory::getPageInfo();
     $sefConfig = Sh404sefFactory::getConfig();
     // store the status
     $pageInfo->httpStatus = 404;
     // request path
     $reqPath = $uri->getPath();
     // optionnally log the 404 details
     if ($sefConfig->shLog404Errors && !empty($reqPath)) {
         try {
             $record = Sh404sefHelperDb::selectObject('#__sh404sef_urls', '*', array('oldurl' => $reqPath));
             if (!empty($record)) {
                 // we have, so update counter
                 Sh404sefHelperDb::queryQuote('update ?? set cpt=(cpt+1) where ?? = ?', array('#__sh404sef_urls', 'oldurl'), array($reqPath));
             } else {
                 // record the 404
                 Sh404sefHelperDb::insert('#__sh404sef_urls', array('cpt' => 1, 'rank' => 0, 'oldurl' => $reqPath, 'newurl' => '', 'dateadd' => Sh404sefHelperDate::getUTCNow('Y-m-d')));
             }
             // add more details about 404 into security log file
             if ($sefConfig->shSecEnableSecurity && $sefConfig->shSecLogAttacks) {
                 $sep = "\t";
                 $logData = date('Y-m-d') . $sep . date('H:i:s') . $sep . 'Page not found (404)' . $sep . $_SERVER['REMOTE_ADDR'] . $sep;
                 $logData .= getHostByAddr($_SERVER['REMOTE_ADDR']) . $sep;
                 $userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? 'No user agent' : $_SERVER['HTTP_USER_AGENT'];
                 $logData .= $userAgent . $sep . $_SERVER['REQUEST_METHOD'] . $sep . $_SERVER['REQUEST_URI'];
                 $logData .= empty($_SERVER['HTTP_REFERER']) ? "\n" : $sep . $_SERVER['HTTP_REFERER'] . "\n";
                 shLogToSecFile($logData);
             }
         } catch (Sh404sefExceptionDefault $e) {
             _log(__METHOD__ . '/' . __LINE__ . '/' . __CLASS__ . ': Database error: ' . $e->getMessage());
         }
     }
     // display the error page
     $vars['option'] = 'com_content';
     $vars['view'] = 'article';
     // use provided Itemid
     if (empty($sefConfig->shPageNotFoundItemid)) {
         $shHomePage = JFactory::getApplication()->getMenu()->getDefault();
         $vars['Itemid'] = empty($shHomePage) ? null : $shHomePage->id;
     } else {
         $vars['Itemid'] = $sefConfig->shPageNotFoundItemid;
     }
     // user picked our default 404 error page, read its id from DB
     if ($sefConfig->page404 == '0') {
         try {
             $requestedlanguageTag = JFactory::getLanguage()->getTag();
             $languageTag = JRequest::getString(JUtility::getHash('language'), null, 'cookie');
             if (!empty($languageTag)) {
                 $vars['lang'] = $languageTag;
             }
             $ids = Sh404sefHelperDb::queryQuoteOnly('select ?? from ?? where ?? = ? and ?? in ( ?, ?) order by ?? desc', array('id', '#__content', 'title', 'language', 'language'), array('__404__', $languageTag, '*'))->eLoadResultArray();
             $id = empty($ids[0]) ? null : $ids[0];
         } catch (Sh404sefExceptionDefault $e) {
             _log(__METHOD__ . '/' . __LINE__ . '/' . __CLASS__ . ': Database error: ' . $e->getMessage());
         }
         if (empty($id)) {
             JError::raiseError(404, JText::_('Component Not Found') . ' (' . $pageInfo->getDefaultLiveSite() . '/' . $uri->getPath() . ')');
         }
     } else {
         $id = $sefConfig->page404;
     }
     $vars['id'] = $id;
     $uri = new JURI($pageInfo->getDefaultLiveSite() . '/index.php?' . 'option=com_content&view=article&id=' . $id . (empty($vars['Itemid']) ? '' : '&Itemid=' . $vars['Itemid']) . (empty($vars['lang']) ? '' : '&lang=' . shGetIsoCodeFromName($vars['lang'])));
     $tmpl = str_replace('.php', '', $sefConfig->error404SubTemplate);
     if (!empty($tmpl)) {
         $vars['tmpl'] = $tmpl;
     }
     // and prepare the item for display
     $menus =& JFactory::getApplication()->getMenu();
     $menuItem = $menus->getItem($vars['Itemid']);
     if (!empty($menuItem)) {
         $menus->setActive($vars['Itemid']);
     } else {
         $menuItem = $menus->getDefault();
     }
     if (!empty($menuItem->params)) {
         $disableParams = array('show_title', 'show_category', 'show_author', 'show_create_date', 'show_modify_date', 'show_publish_date', 'show_vote', 'show_readmore', 'show_icons', 'show_hits', 'show_feed_link', 'show_page_heading');
         foreach ($disableParams as $p) {
             $menuItem->params->set($p, 0);
         }
         //set a custom page title
         $menuItem->params->set('page_title', htmlspecialchars($uri->get('_uri')));
     }
     // set the menu query array, J! will use that for breadcrumb
     $menuItem->query = $vars;
     // throw 404 http return code, and prepare for page display
     if (!headers_sent()) {
         JResponse::setHeader('status', '404 NOT FOUND');
         // custom error page, faster than loading Joomla 404 page. Not recommended though, why not show
         // your site ?
         if (is_readable(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html')) {
             $errorPage = file_get_contents(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html');
             if ($errorPage !== false) {
                 $errorPage = str_replace('%sh404SEF_404_URL%', ' (' . $pageInfo->getDefaultLiveSite() . '/' . $uri->getPath() . ')', $errorPage);
                 $errorPage = str_replace('%sh404SEF_404_SITE_URL%', $pageInfo->getDefaultLiveSite(), $errorPage);
                 $errorPage = str_replace('%sh404SEF_404_SITE_NAME%', JFactory::getApplication()->getCfg('sitename'), $errorPage);
                 echo $errorPage;
                 die;
             }
         }
     } else {
         _log('Headers already sent before getting control on 404 page - message displayed');
         $shUri = new JUri();
         $shOriginalUri = new JURI();
         $url = shSefRelToAbs($pageInfo->getDefaultLiveSite() . "/index.php?" . $_SERVER['QUERY_STRING'], '', $shUri, $shOriginalUri);
         JError::RaiseError(500, "<br />SH404SEF : headers were already sent when I got control!<br />This is not necessarily a sh404sef error. It may have been caused by any of your extensions or even Joomla itself. If there is no error message above this one, providing more details, then you may look inside the error log file of your web server for an indication of what may be breaking things up.<br />URL=" . $url . '<br />');
     }
     return $vars;
 }
コード例 #5
0
}
// sometimes users disable our plugin
if (!defined('sh404SEF_AUTOLOADER_LOADED')) {
    echo 'sh404SEF system plugin has been disabled. Please enable it again to use sh404SEF, with Joomla! <a href="index.php?option=com_plugins">plugin manager</a>';
    return;
}
// Access check.
if (!JFactory::getUser()->authorise('core.manage', 'com_sh404sef')) {
    return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Setup paths.
$sef_config_class = JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.class.php';
// Make sure class was loaded.
if (!class_exists('shSEFConfig')) {
    if (is_readable($sef_config_class)) {
        require_once $sef_config_class;
    } else {
        JError::RaiseError(500, JText::_('COM_SH404SEF_NOREAD') . "( {$sef_config_class} )<br />" . JText::_('COM_SH404SEF_CHK_PERMS'));
    }
}
JHtml::_('behavior.framework');
// include sh404sef default language file
shIncludeLanguageFile();
// find about specific controller requested
$cName = JRequest::getCmd('c');
// get controller from factory
$controller = Sh404sefFactory::getController($cName);
Sh404sefHelperHtml::addSubmenu(JRequest::get());
// read and execute task
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();
コード例 #6
0
ファイル: shInit.php プロジェクト: sangkasi/joomla
            if (!empty($shPageInfo->URI->host) && strpos($GLOBALS['shConfigLiveSite'], $shPageInfo->URI->host) === false && strpos($sefConfig->shConfig_live_secure_site, $shPageInfo->URI->host) === false) {
                _log('Redirecting to home : host don\'t match our config : ' . $GLOBALS['shConfigLiveSite'] . ' | ' . $shPageInfo->URI->host . ' | ' . $sefConfig->shConfig_live_secure_site);
                shRedirect($GLOBALS['shConfigLiveSite']);
            } else {
                $shPageInfo->shCurrentPagePath = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $shPageInfo->URI->path;
                $shPageInfo->shCurrentPagePath = shUrlDecode($shPageInfo->shCurrentPagePath);
                $shPageInfo->shCurrentPagePath = str_replace($GLOBALS['shConfigLiveSite'], '', $shPageInfo->shCurrentPagePath);
                _log('Current page path : ' . $shPageInfo->shCurrentPagePath);
                $qString = $shPageInfo->URI->getQueryString();
                $shPageInfo->shCurrentPageURL = empty($qString) ? $shPageInfo->shCurrentPagePath : $shPageInfo->shCurrentPagePath . '?' . JString::ltrim($qString, '&');
                $rewriteBit = empty($sefConfig->shRewriteMode) ? '' : JString::rtrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/');
                $shPageInfo->baseUrl = $GLOBALS['shConfigLiveSite'] . $rewriteBit . $shPageInfo->shCurrentPagePath;
                _log('Current base url : ' . $shPageInfo->baseUrl);
                // V 1.2.4.s PR2 : workaround for Virtuemart cookie check issue
                // see second part in shSef404.php
                if (shIsSearchEngine()) {
                    // simulate doing successfull cookie check
                    _log('Setting VMCHECK cookie for search engine');
                    $_COOKIE['VMCHECK'] = 'OK';
                    $_REQUEST['vmcchk'] = 1;
                    // from VM 1.1.2 onward, result is stored in session, not cookie
                    $_SESSION['VMCHECK'] = 'OK';
                }
            }
        } else {
            JError::RaiseError(COM_SH404SEF_NOREAD . "( {$sef404} )<br />" . COM_SH404SEF_CHK_PERMS);
        }
    }
    // save page info
    shRouter::shPageInfo($shPageInfo);
}
コード例 #7
0
ファイル: sh404sef.inc.php プロジェクト: justinlyon/scc
                $tmpl = str_replace('.php', '', $sefConfig->error404SubTemplate);
                if (!empty($tmpl)) {
                    $vars['tmpl'] = $tmpl;
                }
                if (!headers_sent()) {
                    header('HTTP/1.0 404 NOT FOUND');
                    // V x : include error page, faster than loading Joomla 404 page. Not recommended though, why not show
                    // your site ?
                    if (is_readable(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html')) {
                        $errorPage = file_get_contents(sh404SEF_FRONT_ABS_PATH . '404-Not-Found.tpl.html');
                        if ($errorPage !== false) {
                            $errorPage = str_replace('%sh404SEF_404_URL%', $vars['mosmsg'], $errorPage);
                            $errorPage = str_replace('%sh404SEF_404_SITE_URL%', $GLOBALS['shConfigLiveSite'], $errorPage);
                            $errorPage = str_replace('%sh404SEF_404_SITE_NAME%', $mainframe->getCfg('sitename'), $errorPage);
                            echo $errorPage;
                            die;
                        }
                    }
                } else {
                    _log('Headers already sent before getting control on 404 page - message displayed');
                    $shUri = null;
                    $shOriginalUri = null;
                    $url = shSefRelToAbs($GLOBALS['shConfigLiveSite'] . "/index.php?" . $_SERVER['QUERY_STRING'], '', $shUri, $shOriginalUri);
                    print_r($path_array);
                    JError::RaiseError(500, "<br />SH404SEF : headers were already sent when I got control!<br />This is not necessarily a sh404sef error. It may have been caused by any of your extensions or even Joomla itself. If there is no error message above this one, providing more details, then you may look inside the error log file of your web server for an indication of what may be breaking things up.<br />URL=" . @$url . '<br />');
                }
            }
        }
        //end bad url
        //
}
コード例 #8
0
 /**
  * Performs pre-uninstall backup of configuration
  *
  * @param object $parent
  */
 private function _doUninstall($parent)
 {
     $this->_definePaths();
     $this->_includeLibs();
     // V 1.2.4.t before uninstalling modules, save their settings, if told to do so
     $sef_config_class = JPATH_ADMINISTRATOR . '/components/com_sh404sef/sh404sef.class.php';
     // Make sure class was loaded.
     if (!class_exists('shSEFConfig')) {
         if (is_readable($sef_config_class)) {
             require_once $sef_config_class;
         } else {
             JError::RaiseError(500, JText::_('COM_SH404SEF_NOREAD') . "( {$sef_config_class} )<br />" . JText::_('COM_SH404SEF_CHK_PERMS'));
         }
     }
     $sefConfig = new shSEFConfig();
     if (!$sefConfig->shKeepStandardURLOnUpgrade && !$sefConfig->shKeepCustomURLOnUpgrade) {
         $this->_shDeleteTable('sh404sef_urls');
         $this->_shDeleteTable('sh404sef_aliases');
         $this->_shDeleteTable('sh404sef_pageids');
     } elseif (!$sefConfig->shKeepStandardURLOnUpgrade) {
         $this->_shDeleteAllSEFUrl('Standard');
     } elseif (!$sefConfig->shKeepCustomURLOnUpgrade) {
         $this->_shDeleteAllSEFUrl('Custom');
         $this->_shDeleteTable('sh404sef_aliases');
         $this->_shDeleteTable('sh404sef_pageids');
     }
     if (!$sefConfig->shKeepMetaDataOnUpgrade) {
         $this->_shDeleteTable('sh404sef_metas');
     }
     // remove admin quick icon module
     $this->_shSaveDeleteModuleParams('mod_sh404sef_cpicon', $client = 1);
     // remove language switcher module
     // custom language switcher module disabled for now, not needed
     //$this->_shSaveDeleteModuleParams( 'mod_sh_languages', $client = 0);
     // remove system plugins
     $this->_shSaveDeletePluginParams('sh404sef', 'system');
     $this->_shSaveDeletePluginParams('shmobile', 'system');
     // unregister from shLib, then possibly uninstall it
     if (JFile::exists(JPATH_ROOT . '/plugins/system/shlib/shl_packages/system/resourcemanager.php')) {
         require_once JPATH_ROOT . '/plugins/system/shlib/shl_packages/system/resourcemanager.php';
         ShlSystem_Resourcemanager::unregister('shlib', 'com_sh404sef');
         if (ShlSystem_Resourcemanager::canUninstall('shlib')) {
             $this->_shSaveDeletePluginParams('shlib', 'system');
         }
     }
     // remove core plugins
     $this->_shSaveDeletePluginGroup('sh404sefcore');
     $this->_shSaveDeletePluginGroup('sh404sefextplugins');
     // delete analytics cached data, to force update
     // in case this part of sh404sef has changed
     $cache = JFactory::getCache('sh404sef_analytics');
     $cache->clean();
     // preserve configuration or not ?
     if (!$sefConfig->shKeepConfigOnUpgrade) {
         // main config file
         $fileName = $this->_preserveConfigFolder . 'sh404_upgrade_conf_' . $this->_siteId . '.php';
         if (JFile::exists($fileName)) {
             JFile::delete($fileName);
         }
         // user custom config file
         $fileName = $this->_preserveConfigFolder . 'sh404_upgrade_conf_' . $this->_siteId . '.custom.php';
         if (JFile::exists($fileName)) {
             JFile::delete($fileName);
         }
         // related extensions (plugins) config files folder
         if (JFolder::exists($this->_preserveConfigFolder . 'sh404_upgrade_conf')) {
             JFolder::delete($this->_preserveConfigFolder . 'sh404_upgrade_conf');
         }
         // log files folder
         if (JFolder::exists($this->_preserveConfigFolder . 'sh404_upgrade_conf_logs')) {
             JFolder::delete($this->_preserveConfigFolder . 'sh404_upgrade_conf_logs');
         }
         // security log files folder
         if (JFolder::exists($this->_preserveConfigFolder . 'sh404_upgrade_conf_security')) {
             JFolder::delete($this->_preserveConfigFolder . 'sh404_upgrade_conf_security');
         }
     } else {
         // if we keep config
         if (JFolder::exists(JPATH_ROOT . '/logs/sh404sef')) {
             JFolder::copy(JPATH_ROOT . '/logs/sh404sef', $this->_preserveConfigFolder . 'sh404_upgrade_conf_logs', $path = '', $force = true);
         }
         if (JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_sh404sef/security')) {
             JFolder::copy(JPATH_ADMINISTRATOR . '/components/com_sh404sef/security', $this->_preserveConfigFolder . 'sh404_upgrade_conf_security', $path = '', $force = true);
         }
     }
     // delete folder in /media
     // display results
     echo '<h3>sh404SEF has been succesfully uninstalled. </h3>';
     echo '<br />';
     if ($sefConfig->shKeepStandardURLOnUpgrade) {
         echo '- automatically generated SEF url have not been deleted (table #__sh404sef_urls)<br />';
     } else {
         echo '- automatically generated SEF url have been deleted<br />';
     }
     echo '<br />';
     if ($sefConfig->shKeepCustomURLOnUpgrade) {
         echo '- custom SEF url, aliases and pageIds have not been deleted (tables #__sh404sef_urls, #__sh404sef_aliases and #__sh404sef_pageids)<br />';
     } else {
         echo '- custom SEF url, aliases and pageIds have been deleted<br />';
     }
     echo '<br />';
     if ($sefConfig->shKeepMetaDataOnUpgrade) {
         echo '- Custom Title and META data have not been deleted (table #__sh404sef_metas)<br />';
     } else {
         echo '- Custom Title and META data have been deleted<br />';
     }
     echo '<br />';
 }
コード例 #9
0
function sef_ext_exists($this_name)
{
    $sefConfig =& shRouter::shGetConfig();
    $database =& JFactory::getDBO();
    // check for sef_ext
    $this_name = str_replace($sefConfig->replacement, " ", $this_name);
    $this_name = str_replace('\'', '', $this_name);
    // V 1.2.4.t 21/08/2007 20:45:58 bug #165
    $sql = "SELECT `id`,`link` FROM #__menu  WHERE ((`name` LIKE '%" . $this_name . "%') AND (`published` > 0))";
    $database->setQuery($sql);
    $rows = @$database->loadObjectList();
    if ($database->getErrorNum()) {
        JError::RaiseError(500, $database->stderr());
    }
    if (@count($rows) > 0) {
        $option = str_replace("index.php?option=", "", $rows[0]->link);
        if (shFileExists(sh404SEF_ABS_PATH . "components/{$option}/sef_ext.php")) {
            return @$rows[0];
        } else {
            unset($rows);
        }
    }
    return null;
}