/** * @param classConfig $config */ function init_update(&$config) { $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX; if (file_exists($update_file)) { if (filemtime($update_file) > $config->db_loadItem('var_db_update') || $config->db_loadItem('db_version') < DB_VERSION) { if (defined('IN_ADMIN')) { sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована if (SN_TIME_NOW >= $config->db_loadItem('var_db_update_end')) { $config->db_saveItem('var_db_update_end', SN_TIME_NOW + ($config->upd_lock_time ? $config->upd_lock_time : 300)); sn_db_transaction_commit(); require_once $update_file; sys_refresh_tablelist(); $current_time = time(); $config->db_saveItem('var_db_update', $current_time); $config->db_saveItem('var_db_update_end', $current_time); } elseif (filemtime($update_file) > $config->var_db_update) { $timeout = $config->var_db_update_end - SN_TIME_NOW; die("Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br />\n Obnovljaetsja baza dannyh. Rasschetnoe vremya okonchanija - {$timeout} secund. Pozhalujsta, podozhdute...<br />\n Database update in progress. Estimated update time {$timeout} seconds (can increase depending on update process). Please wait..."); } sn_db_transaction_rollback(); } else { die('Происходит обновление сервера - пожалуйста, подождите...<br /> Proishodit obnovlenie servera - pozhalujsta, podozhdute...<br /> Server upgrading now - please wait...<br /> <a href="admin/overview.php">Admin link</a>'); } } } }
require_once SN_ROOT_PHYSICAL . "includes/db" . DOT_PHP_EX; require_once SN_ROOT_PHYSICAL . "includes/init/init_functions" . DOT_PHP_EX; global $supernova; $supernova = new classSupernova(); doquery("SET NAMES 'utf8';"); // Initializing global 'cacher' object global $sn_cache; $sn_cache = new classCache($cache_prefix); empty($sn_cache->tables) && sys_refresh_tablelist($db_prefix); empty($sn_cache->tables) && die('DB error - cannot find any table. Halting...'); // Initializing global "config" object $config = new classConfig($cache_prefix); //$config->db_saveItem('db_prefix', $db_prefix); //$config->db_saveItem('secret_word', $sn_secret_word); $config->db_prefix = $db_prefix; $config->db_saveItem('db_prefix', $db_prefix); $config->db_saveItem('cache_prefix', $cache_prefix); $config->secret_word = $sn_secret_word; if (defined('BE_DEBUG') || $config->debug) { @define('BE_DEBUG', true); @ini_set('display_errors', 1); @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); } else { @define('BE_DEBUG', false); @ini_set('display_errors', 0); } require_once SN_ROOT_PHYSICAL . "includes/vars" . DOT_PHP_EX; require_once SN_ROOT_PHYSICAL . "includes/general" . DOT_PHP_EX; init_update($config); unset($db_name); // Initializing constants
$config->db_prefix = $db_prefix; $config->secret_word = $sn_secret_word; if (!defined('BE_DEBUG')) { if ($config->debug) { define('BE_DEBUG', true); ini_set('display_errors', 1); } else { define('BE_DEBUG', false); ini_set('display_errors', 0); } } $update_file = "{$sn_root_physical}includes/update.{$phpEx}"; if (file_exists($update_file)) { if (filemtime($update_file) > $config->var_db_update || $config->db_version < DB_VERSION) { if ($time_now >= $config->var_db_update_end) { $config->db_saveItem('var_db_update_end', $time_now + $config->upd_lock_time); require_once $update_file; sys_refresh_tablelist($db_prefix); $time_now = time(); $config->db_saveItem('var_db_update', $time_now); $config->db_saveItem('var_db_update_end', $time_now); } elseif (filemtime($update_file) > $config->var_db_update) { $timeout = $config->var_db_update_end - $time_now; die("Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br>Obnovljaetsja baza dannyh. Rasschetnoe vremya okonchanija - {$timeout} secund. Pozhalujsta, podozhdute...<br>Database update in progress. Estimated update time {$timeout} seconds (can increase depending on update process). Please wait..."); } } } unset($db_name); // Initializing constants define('TEMPLATE_NAME', $config->game_default_template ? $config->game_default_template : 'OpenGame'); define('TEMPLATE_DIR', SN_ROOT_PHYSICAL . 'design/templates/' . TEMPLATE_NAME);