shKeepModulesSettingsOnUpgrade) { // we've been told not to preserve modules settings so erase file
@unlink($moduleFile);
} else { // we want to read settings for this module
if (file_exists($moduleFile))
include($moduleFile);
}
}
function shInsertModule( $modName, $shConfig, $shPub, $sefConfig ) {
global $database;
shGetModuleSavedParams( $modName, $shConfig, $shPub, $sefConfig );
$sql = "INSERT INTO `#__modules` (`title`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `published`, `module`, `numnews`, `access`, `showtitle`, `params`, `iscore`, `client_id`) VALUES ('".$shConfig['title']."', '', ".$shConfig['ordering'].", '".$shConfig['position']."', 0, '0000-00-00 00:00:00', ".$shConfig['published'].", '".$modName."', 0, ".$shConfig['access'].", ".$shConfig['showtitle'].", '".$shConfig['params']."', 0, 0);";
$database->setQuery( $sql);
$database->query();
$moduleID = $database->insertid();
// set pages where module is published
foreach ($shPub as $pub) {
$database->setQuery( "INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES ($moduleID, $pub);");
$database->query();
}
}
function com_install()
{
global $database, $mosConfig_absolute_path, $mosConfig_live_site;
// V 1.2.4.t improved upgrade data preservation
// V 1.2.4.q Copy existing config file from /media to current component. Used to recover configuration when upgrading
// V 1.2.4.s check if old file exists before deleting stub config file
$adminDir = dirname(__FILE__);
$oldConfigFile = $mosConfig_absolute_path.'/media/sh404_upgrade_conf_'
.str_replace('/','_',str_replace('http://', '', $mosConfig_live_site)).'.php';
if (is_readable($oldConfigFile)) {
@unlink($adminDir. '/config/config.sef.php');
@copy( $oldConfigFile, $adminDir. '/config/config.sef.php' );
}
// restore log files
if ($handle = @opendir($mosConfig_absolute_path.'/media/sh404_upgrade_conf_logs')) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..')
@copy($mosConfig_absolute_path.'/media/sh404_upgrade_conf_logs/'.$file,
$adminDir.'/logs/'.$file);
}
closedir($handle);
}
// restore black/white lists
if ($handle = @opendir($mosConfig_absolute_path.'/media/sh404_upgrade_conf_security')) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
@unlink($adminDir.'/security/'.$file);
@copy($mosConfig_absolute_path.'/media/sh404_upgrade_conf_security/'.$file,
$adminDir.'/security/'.$file);
}
}
closedir($handle);
}
// restore customized default params
$oldDefaultConfigFile = $mosConfig_absolute_path.'/media/sh404_upgrade_conf_'
.str_replace('/','_',str_replace('http://', '', $mosConfig_live_site)).'.default.php';
if (is_readable($oldDefaultConfigFile) && filesize($oldDefaultConfigFile) > 1000) {
@unlink($adminDir. '/default.sef.php');
@copy( $oldDefaultConfigFile, $adminDir. '/default.sef.php' );
}
$sef_config_class = $GLOBALS['mosConfig_absolute_path']."/administrator/components/com_sef/sh404sef.class.php";
// Make sure class was loaded.
if (!class_exists('SEFConfig')) { // V 1.2.4.T was wrong variable name $SEFConfig_class instead of $sef_config_class
if (is_readable($sef_config_class)) require_once($sef_config_class);
else die(_COM_SEF_NOREAD."( $sef_config_class )
"._COM_SEF_CHK_PERMS);
}
$sefConfig = new SEFConfig();
ob_start();
//this code is adapted from the install file of Joomfish 1.7
// meta module install
$shConfig = array('title'=>'sh404SEF Custom tags module', 'ordering'=>2,'position'=>'user3','published'=> 0,'access'=>0,'showtitle'=>0,'params'=>''); // V 1.2.4.T preserve config
$shPub = array('0');
shInsertModule( 'mod_shCustomTags', $shConfig, $shPub, $sefConfig);
@rename( $adminDir. '/modules/mod_shCustomTags.php',
$mosConfig_absolute_path.'/modules/mod_shCustomTags.php');
@rename( $adminDir. '/modules/mod_shCustomTags.tmp',
$mosConfig_absolute_path.'/modules/mod_shCustomTags.xml');
// end of code adapted from Joomfish 1.7 install file
// success !
echo '