/** * @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>'); } } } }
function upd_create_table($table_name, $declaration) { global $config, $update_tables; if (!$update_tables[$table_name]) { upd_do_query('set foreign_key_checks = 0;', true); $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$config->db_prefix}{$table_name}` {$declaration}"); $error = db_error(); if ($error) { die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); } upd_do_query('set foreign_key_checks = 1;', true); upd_load_table_info($table_name, false); sys_refresh_tablelist(); } return $result; }
upd_alter_table('planets', "DROP KEY `I_planet_protector`", $update_indexes['planets']['I_planet_protector']); upd_alter_table('planets', "DROP KEY `I_interceptor_misil`", $update_indexes['planets']['I_interceptor_misil']); upd_alter_table('planets', "DROP KEY `I_interplanetary_misil`", $update_indexes['planets']['I_interplanetary_misil']); } // #ctv upd_do_query('COMMIT;', true); $new_version = 40; case 40: upd_log_version_update(); upd_do_query('COMMIT;', true); // $new_version = 41; } upd_log_message('Upgrade complete.'); upd_do_query('SET FOREIGN_KEY_CHECKS=1;', true); classSupernova::$cache->unset_by_prefix('lng_'); if ($new_version) { $config->db_saveItem('db_version', $new_version); upd_log_message("<font color=green>DB version is now {$new_version}</font>"); } else { upd_log_message("DB version didn't changed from {$config->db_version}"); } $config->db_loadAll(); /* if($user['authlevel'] >= 3) { print(str_replace("\r\n", '<br>', $upd_log)); } */ unset($sn_cache->tables); sys_refresh_tablelist(); upd_log_message('Restoring server status'); $config->db_saveItem('game_disable', $old_server_status);
* @version 1.0 * @copyright 2009 by Gorlum for http://oGame.Triolan.COM.UA */ define('INSIDE', true); define('INSTALL', false); define('IN_ADMIN', true); require '../common.' . substr(strrchr(__FILE__, '.'), 1); // if($user['authlevel'] < 1) if ($user['authlevel'] < 3) { AdminMessage($lang['adm_err_denied']); } $mode = sys_get_param_int('mode'); switch ($mode) { case ADM_TOOL_CONFIG_RELOAD: $config->db_loadAll(); sys_refresh_tablelist($config->db_prefix); $config->db_loadItem('game_watchlist'); if ($config->game_watchlist) { $config->game_watchlist_array = explode(';', $config->game_watchlist); } else { unset($config->game_watchlist_array); } break; case ADM_TOOL_MD5: $template = gettemplate("admin/md5enc", true); $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED); $password_length = sys_get_param_int('length', 16); $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed); $template->assign_vars(array('SEED' => $password_seed, 'LENGTH' => $password_length, 'STRING' => htmlentities($string), 'MD5' => md5($string))); display($template, $lang['adm_tools_md5_header'], false, '', true); break;
public static function init_global_objects() { /** * @var classSupernova $supernova */ global $supernova, $sn_cache, $config; self::$user_options = new userOptions(0); /** * @var classSupernova $supernova */ $supernova = new classSupernova(); // Initializing global 'cacher' object static::$cache = new classCache(classSupernova::$cache_prefix); $sn_cache = static::$cache; empty($sn_cache->tables) && sys_refresh_tablelist(); empty($sn_cache->tables) && die('DB error - cannot find any table. Halting...'); // Initializing global "config" object static::$config = new classConfig(classSupernova::$cache_prefix); $config = static::$config; //$config->db_prefix = classSupernova::$db_prefix; //$config->secret_word = classSupernova::$sn_secret_word; //$config->db_saveItem('secret_word', classSupernova::$sn_secret_word); //$config->db_saveItem('db_prefix', classSupernova::$db_prefix); //$config->db_saveItem('cache_prefix', classSupernova::$cache_prefix); }
require_once SN_ROOT_PHYSICAL . "includes/constants" . DOT_PHP_EX; // required for db.php // Initializing global 'debug' object require_once SN_ROOT_PHYSICAL . "includes/debug.class" . DOT_PHP_EX; global $debug; $debug = new debug(); require_once SN_ROOT_PHYSICAL . "includes/classes/_classes" . DOT_PHP_EX; 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);
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); define('DEFAULT_SKINPATH', $config->game_default_skin ? $config->game_default_skin : 'skins/EpicBlue/'); define('DEFAULT_LANG', $config->game_default_language ? $config->game_default_language : 'ru');