@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Защита от двойного инита |
4 | -if(defined('INIT')) { |
|
4 | +if (defined('INIT')) { |
|
5 | 5 | return; |
6 | 6 | } |
7 | 7 | |
@@ -19,22 +19,22 @@ discard block |
||
19 | 19 | define('SN_DEBUG_PDUMP_CALLER', true); |
20 | 20 | |
21 | 21 | // Бенчмарк |
22 | -register_shutdown_function(function () { |
|
23 | - if(defined('IN_AJAX')) { |
|
22 | +register_shutdown_function(function() { |
|
23 | + if (defined('IN_AJAX')) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | 27 | global $user, $locale_cache_statistic; |
28 | 28 | |
29 | - print('<hr><div class="benchmark">Benchmark ' . (microtime(true) - SN_TIME_MICRO) . 's, memory: ' . number_format(memory_get_usage() - SN_MEM_START) . |
|
30 | - (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') . |
|
31 | - (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') . |
|
29 | + print('<hr><div class="benchmark">Benchmark '.(microtime(true) - SN_TIME_MICRO).'s, memory: '.number_format(memory_get_usage() - SN_MEM_START). |
|
30 | + (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : ''). |
|
31 | + (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: '.classSupernova::$db->time_mysql_total.'ms' : ''). |
|
32 | 32 | '</div>'); |
33 | - if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) { |
|
33 | + if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL.'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL.'badqrys.txt') > 0) { |
|
34 | 34 | echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>'; |
35 | 35 | } |
36 | 36 | |
37 | - if(!empty($locale_cache_statistic['misses'])) { |
|
37 | + if (!empty($locale_cache_statistic['misses'])) { |
|
38 | 38 | print('<!--'); |
39 | 39 | pdump($locale_cache_statistic); |
40 | 40 | print('-->'); |
@@ -54,41 +54,41 @@ discard block |
||
54 | 54 | |
55 | 55 | define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW)); |
56 | 56 | |
57 | -if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
57 | +if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) { |
|
58 | 58 | define('SN_GOOGLE', true); |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Эти три строки должны быть В ЭТОМ ФАЙЛЕ, ПО ЭТОМУ ПУТИ и ПЕРЕД ЭТИМ ИНКЛЮДОМ!!! |
62 | -define('SN_ROOT_PHYSICAL', str_replace(array('\\', '//'), '/', dirname(__DIR__) . '/')); |
|
62 | +define('SN_ROOT_PHYSICAL', str_replace(array('\\', '//'), '/', dirname(__DIR__).'/')); |
|
63 | 63 | define('SN_ROOT_PHYSICAL_STR_LEN', strlen(SN_ROOT_PHYSICAL)); |
64 | 64 | $phpbb_root_path = SN_ROOT_PHYSICAL; // Это нужно для работы PTL |
65 | 65 | |
66 | -$sn_root_relative = str_replace(array('\\', '//'), '/', getcwd() . '/'); |
|
66 | +$sn_root_relative = str_replace(array('\\', '//'), '/', getcwd().'/'); |
|
67 | 67 | //$sn_root_relative .= $sn_root_relative[strlen($sn_root_relative) - 1] == '/' ? '' : '/'; |
68 | 68 | $sn_root_relative = str_replace(SN_ROOT_PHYSICAL, '', $sn_root_relative); |
69 | 69 | $sn_root_relative .= basename($_SERVER['SCRIPT_NAME']); |
70 | 70 | $sn_root_relative = str_replace($sn_root_relative, '', $_SERVER['SCRIPT_NAME']); |
71 | 71 | define('SN_ROOT_RELATIVE', $sn_root_relative); |
72 | 72 | |
73 | -define('SN_ROOT_VIRTUAL', 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . SN_ROOT_RELATIVE); |
|
73 | +define('SN_ROOT_VIRTUAL', 'http'.(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '').'://'.$_SERVER['HTTP_HOST'].SN_ROOT_RELATIVE); |
|
74 | 74 | define('SN_ROOT_VIRTUAL_PARENT', str_replace('//google.', '//', SN_ROOT_VIRTUAL)); |
75 | 75 | |
76 | 76 | $phpEx = strpos($phpEx = substr(strrchr(__FILE__, '.'), 1), '/') === false ? $phpEx : ''; |
77 | 77 | define('PHP_EX', $phpEx); // PHP extension on this server |
78 | -define('DOT_PHP_EX', '.' . PHP_EX); // PHP extension on this server |
|
78 | +define('DOT_PHP_EX', '.'.PHP_EX); // PHP extension on this server |
|
79 | 79 | |
80 | 80 | |
81 | 81 | header('Content-type: text/html; charset=utf-8'); |
82 | 82 | ob_start(); |
83 | 83 | ini_set('error_reporting', E_ALL ^ E_NOTICE); |
84 | 84 | |
85 | -empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL . 'includes/classes/' : false; |
|
86 | -spl_autoload_register(function ($class) use ($classRoot) { |
|
85 | +empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL.'includes/classes/' : false; |
|
86 | +spl_autoload_register(function($class) use ($classRoot) { |
|
87 | 87 | $class = str_replace('\\', '/', $class); |
88 | - if (file_exists($classRoot . $class . '.php')) { |
|
89 | - require_once $classRoot . $class . '.php'; |
|
90 | - } elseif (file_exists($classRoot . 'UBE/' . $class . '.php')) { |
|
91 | - require_once $classRoot . 'UBE/' . $class . '.php'; |
|
88 | + if (file_exists($classRoot.$class.'.php')) { |
|
89 | + require_once $classRoot.$class.'.php'; |
|
90 | + } elseif (file_exists($classRoot.'UBE/'.$class.'.php')) { |
|
91 | + require_once $classRoot.'UBE/'.$class.'.php'; |
|
92 | 92 | } |
93 | 93 | }); |
94 | 94 | |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | // Initializing global 'debug' object |
103 | 103 | classSupernova::$debug = new debug(); |
104 | 104 | |
105 | -require_once SN_ROOT_PHYSICAL . "includes/db" . DOT_PHP_EX; |
|
105 | +require_once SN_ROOT_PHYSICAL."includes/db".DOT_PHP_EX; |
|
106 | 106 | classSupernova::init_main_db(new db_mysql()); |
107 | 107 | |
108 | -require_once(SN_ROOT_PHYSICAL . "includes/init/init_functions" . DOT_PHP_EX); |
|
108 | +require_once(SN_ROOT_PHYSICAL."includes/init/init_functions".DOT_PHP_EX); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @var classConfig $config |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | // define('BE_DEBUG', true); // Отладка боевого движка |
119 | 119 | classSupernova::init_debug_state(); |
120 | 120 | |
121 | -require_once(SN_ROOT_PHYSICAL . "includes/vars/vars" . DOT_PHP_EX); |
|
122 | -require_once(SN_ROOT_PHYSICAL . "includes/general" . DOT_PHP_EX); |
|
121 | +require_once(SN_ROOT_PHYSICAL."includes/vars/vars".DOT_PHP_EX); |
|
122 | +require_once(SN_ROOT_PHYSICAL."includes/general".DOT_PHP_EX); |
|
123 | 123 | |
124 | 124 | init_update(); |
125 | 125 | |
@@ -128,28 +128,28 @@ discard block |
||
128 | 128 | ? trim(strip_tags($_GET['page'])) |
129 | 129 | : str_replace(DOT_PHP_EX, '', str_replace(SN_ROOT_RELATIVE, '', str_replace('\\', '/', $_SERVER['SCRIPT_NAME']))); |
130 | 130 | define('INITIAL_PAGE', $sn_page_name_original); |
131 | -define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova') . (defined('SN_GOOGLE') ? '_G' : '')); |
|
132 | -define('SN_COOKIE_I', SN_COOKIE . AUTH_COOKIE_IMPERSONATE_SUFFIX); |
|
133 | -define('SN_COOKIE_D', SN_COOKIE . '_D'); |
|
134 | -define('SN_COOKIE_T', SN_COOKIE . '_T'); // Time measure cookie |
|
135 | -define('SN_COOKIE_F', SN_COOKIE . '_F'); // Font size cookie |
|
136 | -define('SN_COOKIE_U', SN_COOKIE . '_U'); // Current user cookie aka user ID |
|
137 | -define('SN_COOKIE_U_I', SN_COOKIE_U . AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID |
|
131 | +define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova').(defined('SN_GOOGLE') ? '_G' : '')); |
|
132 | +define('SN_COOKIE_I', SN_COOKIE.AUTH_COOKIE_IMPERSONATE_SUFFIX); |
|
133 | +define('SN_COOKIE_D', SN_COOKIE.'_D'); |
|
134 | +define('SN_COOKIE_T', SN_COOKIE.'_T'); // Time measure cookie |
|
135 | +define('SN_COOKIE_F', SN_COOKIE.'_F'); // Font size cookie |
|
136 | +define('SN_COOKIE_U', SN_COOKIE.'_U'); // Current user cookie aka user ID |
|
137 | +define('SN_COOKIE_U_I', SN_COOKIE_U.AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID |
|
138 | 138 | define('TEMPLATE_NAME', classSupernova::$config->game_default_template ? classSupernova::$config->game_default_template : 'OpenGame'); |
139 | -define('TEMPLATE_PATH', 'design/templates/' . TEMPLATE_NAME); |
|
140 | -define('TEMPLATE_DIR', SN_ROOT_PHYSICAL . TEMPLATE_PATH); |
|
139 | +define('TEMPLATE_PATH', 'design/templates/'.TEMPLATE_NAME); |
|
140 | +define('TEMPLATE_DIR', SN_ROOT_PHYSICAL.TEMPLATE_PATH); |
|
141 | 141 | define('DEFAULT_SKINPATH', classSupernova::$config->game_default_skin ? classSupernova::$config->game_default_skin : 'skins/EpicBlue/'); |
142 | 142 | define('DEFAULT_LANG', classSupernova::$config->game_default_language ? classSupernova::$config->game_default_language : 'ru'); |
143 | 143 | define('FMT_DATE', classSupernova::$config->int_format_date ? classSupernova::$config->int_format_date : 'd.m.Y'); |
144 | 144 | define('FMT_TIME', classSupernova::$config->int_format_time ? classSupernova::$config->int_format_time : 'H:i:s'); |
145 | -define('FMT_DATE_TIME', FMT_DATE . ' ' . FMT_TIME); |
|
145 | +define('FMT_DATE_TIME', FMT_DATE.' '.FMT_TIME); |
|
146 | 146 | |
147 | 147 | $HTTP_ACCEPT_LANGUAGE = DEFAULT_LANG; |
148 | 148 | |
149 | -require_once(SN_ROOT_PHYSICAL . "includes/template" . DOT_PHP_EX); |
|
149 | +require_once(SN_ROOT_PHYSICAL."includes/template".DOT_PHP_EX); |
|
150 | 150 | $template_result = array('.' => array('result' => array())); |
151 | 151 | |
152 | -sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", PHP_EX); |
|
152 | +sn_sys_load_php_files(SN_ROOT_PHYSICAL."includes/functions/", PHP_EX); |
|
153 | 153 | |
154 | 154 | |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | // Конфиг - часть манифеста? |
162 | 162 | classSupernova::$auth = new core_auth(); |
163 | 163 | |
164 | -sn_sys_load_php_files(SN_ROOT_PHYSICAL . "modules/", PHP_EX, true); |
|
164 | +sn_sys_load_php_files(SN_ROOT_PHYSICAL."modules/", PHP_EX, true); |
|
165 | 165 | // Здесь - потому что core_auth модуль лежит в другом каталоге и его нужно инициализировать отдельно |
166 | 166 | |
167 | 167 | // Подключаем дефолтную страницу |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | // Сейчас мы делаем это здесь только для того, что бы содержание дефолтной страницы оказалось вверху. Что не факт, что нужно всегда |
170 | 170 | // Но нужно, пока у нас есть не MVC-страницы |
171 | 171 | $sn_page_data = $sn_data['pages'][$sn_page_name]; |
172 | -$sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX; |
|
173 | -if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
172 | +$sn_page_name_file = 'includes/pages/'.$sn_page_data['filename'].DOT_PHP_EX; |
|
173 | +if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) { |
|
174 | 174 | require_once($sn_page_name_file); |
175 | - if(is_array($sn_page_data['options'])) { |
|
175 | + if (is_array($sn_page_data['options'])) { |
|
176 | 176 | classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']); |
177 | 177 | } |
178 | 178 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | |
184 | 184 | // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу |
185 | -if(!isset($sn_data['pages'][$sn_page_name])) { |
|
185 | +if (!isset($sn_data['pages'][$sn_page_name])) { |
|
186 | 186 | $sn_page_name = ''; |
187 | 187 | } |
188 | 188 | |
@@ -190,6 +190,6 @@ discard block |
||
190 | 190 | classLocale::$lang = $lang = new classLocale(classSupernova::$config->server_locale_log_usage); |
191 | 191 | classLocale::$lang->lng_switch(sys_get_param_str('lang')); |
192 | 192 | |
193 | -if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
193 | +if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) { |
|
194 | 194 | require_once "init_secondary.php"; |
195 | 195 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | define('SN_IN_FLEET', true); |
6 | 6 | define('SN_RENDER_NAVBAR_PLANET', true); |
7 | 7 | |
8 | -include('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
8 | +include('../common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
9 | 9 | |
10 | 10 | // TODO - Переместить это куда-нибудь |
11 | 11 | $fleet_page = sys_get_param_int('fleet_page', sys_get_param_int('mode')); |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | // break; |
193 | 193 | } |
194 | 194 | |
195 | - if($exceptionCode !== null) { |
|
196 | - print('<span style="color: red; font-size: 200%;">FAILED! Expected Exception [' . $exceptionCode . ']: "' . classLocale::$lang['fl_attack_error'][$exceptionCode] . '" - FAILED!</span><br />'); |
|
195 | + if ($exceptionCode !== null) { |
|
196 | + print('<span style="color: red; font-size: 200%;">FAILED! Expected Exception ['.$exceptionCode.']: "'.classLocale::$lang['fl_attack_error'][$exceptionCode].'" - FAILED!</span><br />'); |
|
197 | 197 | print('<div style="color: red; font-size: 200%;">NO EXCEPTION RAISED</div>'); |
198 | 198 | pdie(); |
199 | 199 | } else { |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | if ($exceptionCode !== null && $e->getCode() === $exceptionCode) { |
204 | 204 | // print('<span style="color: darkgreen;">Exception [' . $exceptionCode . ']: "' . classLocale::$lang['fl_attack_error'][$exceptionCode] . '" - passed</span><br />'); |
205 | 205 | } else { |
206 | - print('<div style="color: red; font-size: 200%;">Expected Exception [' . $exceptionCode . ']: "' . classLocale::$lang['fl_attack_error'][$exceptionCode] . '" - FAILED!</div>'); |
|
207 | - print('<div style="color: red; font-size: 200%;">Got Exception [' . $e->getCode() . ']: "' . $e->getMessage() . '"/"' . classLocale::$lang['fl_attack_error'][$e->getCode()] . '" . "</div>'); |
|
206 | + print('<div style="color: red; font-size: 200%;">Expected Exception ['.$exceptionCode.']: "'.classLocale::$lang['fl_attack_error'][$exceptionCode].'" - FAILED!</div>'); |
|
207 | + print('<div style="color: red; font-size: 200%;">Got Exception ['.$e->getCode().']: "'.$e->getMessage().'"/"'.classLocale::$lang['fl_attack_error'][$e->getCode()].'" . "</div>'); |
|
208 | 208 | throw $e; |
209 | 209 | } |
210 | 210 | } |