/*! Check cache folder is writable! */ @chmod(CC_CACHE_DIR, chmod_writable()); if (!is_writable(CC_CACHE_DIR)) { $cache_dir = str_replace(CC_ROOT_DIR, '', CC_CACHE_DIR); die('<p>Please make sure the following folders are writable in order to continue.</p><pre>' . $cache_dir . '</pre>'); }
$gitignore = CC_ROOT_DIR.'/images/source/.gitignore'; if (file_exists($gitignore)) { @unlink($gitignore); if (file_exists($gitignore)) { die('Please delete the images/source/.gitignore file before proceeding.'); } }
if (isset($_GET['autoupdate']) && $_GET['autoupdate']) { $_SESSION['setup'] = array(); // remove any past upgrade/install data $_SESSION['setup']['method'] = 'upgrade'; $_SESSION['setup']['autoupgrade'] = true; httpredir('index.php'); } // Empty the cache before we start $GLOBALS['cache'] = Cache::getInstance(); if (!isset($_SESSION['setup']) || (isset($_SESSION['setup']) && empty($_SESSION['setup']))) { $GLOBALS['cache']->clear();
## Remap store country from id to numcode if (isset($main_config['siteCountry']) && $main_config['siteCountry'] > 0) { $country = $db->select('CubeCart_geo_country', array( 'numcode' ), array( 'id' => $main_config['siteCountry'] )); $main_config['siteCountry'] = $country[0]['numcode']; }
if ($update_config) { $_SESSION['setup']['admin_rename'] = true; foreach ($glob as $key => $value) { if ($key=='adminFile') { $value = $adminFile; } elseif ($key=='adminFolder') { $value = $adminFolder; } $value = is_array($value) ? var_export($value, true) : "'".addslashes($value)."'"; $config[] = sprintf("\$glob['%s'] = %s;", $key, $value); } $config = sprintf("<?php\n%s\n?>", implode("\n", $config)); ## Backup existing config file, if it exists if (file_exists($global_file)) { rename($global_file, $global_file.'-'.date('Ymdgis').'.php'); } if (file_put_contents($global_file, $config)); } $adminURL = str_replace('/setup', '', CC_STORE_URL).'/'.$adminFile; if ($admins = $db->select('CubeCart_admin_users', false, array('status'=> 1))) { $headers = 'From: nobody@'.parse_url(CC_STORE_URL, PHP_URL_HOST); foreach ($admins as $admin) { mail($admin['email'], "Store Admin URL", "Hi ".html_entity_decode($admin['name'], ENT_QUOTES).",\r\n\r\nYour store has been setup to CubeCart version ".CC_VERSION.".\r\n\r\nFor security reasons the administrator URL has been obscured to divert any possible unwanted attention. Please set your bookmark to ".$adminURL."\r\n\r\n\r\nThis email was sent automatically by the CubeCart setup tool.", $headers); } }*/ $adminFile = '[[soft_adminFile]]'; $GLOBALS['smarty']->assign('ADMIN_URL', $adminURL); $GLOBALS['smarty']->assign('STORE_URL', str_replace('/setup', '', CC_STORE_URL).'/'); $GLOBALS['smarty']->assign('SHOW_LINKS', true); //}
// secure global files $gfs = glob(CC_INCLUDES_DIR.'global.*.php'); if (is_array($gfs)) { foreach ($gfs as $gf) { chmod($gf, 0444); } }
/* Truncate CubeCart_system_error_log table. There are a number of failed SQL queries on upgrade depending * on to/from version. We need a clean slate to detect operational errors. */ $db->truncate('CubeCart_system_error_log'); include $global_file; if ($_SESSION['setup']['autoupgrade'] && !$update_config) { httpredir('../'.$glob['adminFile'].'?_g=maintenance&node=index', 'upgrade'); } } }