/**
 * @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>');
            }
        }
    }
}
Exemple #2
0
 public static function getInstance($gamePrefix = 'sn_')
 {
     if (!isset(self::$cacheObject)) {
         $className = get_class();
         self::$cacheObject = new $className($gamePrefix, 'config');
     }
     return self::$cacheObject;
 }
Exemple #3
0
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);
    @ini_set('display_errors', 0);
}
require_once SN_ROOT_PHYSICAL . "includes/vars" . DOT_PHP_EX;
Exemple #4
0
    }
    if ($extension == $phpEx) {
        require_once "{$dir_name}/{$file}";
    }
}
// Initializing global 'cacher' object
$sn_cache = new classCache($db_prefix);
if (!$sn_cache->tables) {
    sys_refresh_tablelist($db_prefix);
}
if (empty($sn_cache->tables)) {
    print 'DB error - cannot find any table. Halting...';
    die;
}
// Initializing global "config" object
$config = new classConfig($db_prefix);
$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) {