shDeleteAllSEFUrl('Custom');
    shDeleteTable('sh404sef_aliases');
    shDeleteTable('sh404sef_pageids');
}
if (!$sefConfig->shKeepMetaDataOnUpgrade) {
    shDeleteTable('sh404SEF_meta');
}
// remove admin quick icon module
shSaveDeleteModuleParams('mod_sh404sef_cpicon', $client = 1);
// remove system plugin
shSaveDeletePluginParams('shsef', 'system', $folders = null);
shSaveDeletePluginParams('shjlang16', 'system', $folders = array('shjlang16'));
shSaveDeletePluginParams('shmobile', 'system', $folders = array('shmobile'));
// remove core plugins
shSaveDeletePluginGroup('sh404sefcore');
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 = JPATH_ROOT . DS . 'media' . DS . 'sh404_upgrade_conf_' . str_replace('/', '_', str_replace('http://', '', $front_live_site)) . '.php';
    if (JFile::exists($fileName)) {
        JFile::delete($fileName);
    }
    // user custom config file
    $fileName = JPATH_ROOT . DS . 'media' . DS . 'sh404_upgrade_conf_' . str_replace('/', '_', str_replace('http://', '', $front_live_site)) . '.custom.php';
    if (JFile::exists($fileName)) {
        JFile::delete($fileName);
    }
    if ($handle = opendir(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'security' . DS)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..' && $file != 'index.html') {
                @rename(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_sh404sef' . DS . 'security' . DS . $file, JPATH_ROOT . DS . 'media' . DS . 'sh404_upgrade_conf_security' . DS . $file);
            }
        }
        closedir($handle);
    }
}
// remove system plugin
shSaveDeletePluginParams('shsef', 'system', $folders = null);
shSaveDeletePluginParams('shjlang16', 'system', $folders = array('shjlang16'));
shSaveDeletePluginParams('shmobile', 'system', $folders = array('shmobile'));
// remove core plugins
shSaveDeletePluginGroup('sh404sefcore');
// remove extensions plugins
//shSaveDeletePluginGroup( 'sh404sefext');
// 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 #__redirection)<br />';
} else {
    echo '- automatically generated SEF url have been deleted<br />';
}
echo '<br />';
if ($sefConfig->shKeepCustomURLOnUpgrade) {
    echo '- custom SEF url and aliases have not been deleted (table #__redirection and sh404sef_aliases)<br />';
} else {
    echo '- custom SEF url and aliases have been deleted<br />';