@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | |
77 | 77 | protected function checkPropertyExists($name) { |
78 | 78 | if (!array_key_exists($name, $this->_properties)) { |
79 | - throw new ExceptionPropertyNotExists('Property [' . get_called_class() . '::' . $name . '] not exists', ERR_ERROR); |
|
79 | + throw new ExceptionPropertyNotExists('Property ['.get_called_class().'::'.$name.'] not exists', ERR_ERROR); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | 83 | protected function checkOverwriteAdjusted($name) { |
84 | 84 | if (array_key_exists($name, $this->propertiesAdjusted)) { |
85 | - throw new PropertyAccessException('Property [' . get_called_class() . '::' . $name . '] already was adjusted so no SET is possible until dbSave', ERR_ERROR); |
|
85 | + throw new PropertyAccessException('Property ['.get_called_class().'::'.$name.'] already was adjusted so no SET is possible until dbSave', ERR_ERROR); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return boolean |
132 | 132 | */ |
133 | 133 | public function isContainerEmpty() { |
134 | - throw new Exception('PropertyHider::isContainerEmpty() is not implemented. You should implement it in class ' . get_called_class()); |
|
134 | + throw new Exception('PropertyHider::isContainerEmpty() is not implemented. You should implement it in class '.get_called_class()); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | $result = null; |
176 | 176 | // Now deciding - will we call a protected setter or will we work with protected property |
177 | 177 | // Todo - on init recalc all method_exists |
178 | - if (method_exists($this, $methodName = $action . ucfirst($name))) { |
|
178 | + if (method_exists($this, $methodName = $action.ucfirst($name))) { |
|
179 | 179 | // If method exists - just calling it |
180 | 180 | // TODO - should return TRUE if value changed or FALSE otherwise |
181 | 181 | $result = call_user_func_array(array($this, $methodName), array($value)); |
182 | 182 | } elseif ($this->isPropertyActionAvailable($name, $action)) { |
183 | 183 | // No setter exists - works directly with protected property |
184 | - $result = $this->{$action . 'Property'}($name, $value); |
|
184 | + $result = $this->{$action.'Property'}($name, $value); |
|
185 | 185 | } else { |
186 | - throw new ExceptionPropertyNotExists('Property [' . get_called_class() . '::' . $name . '] does not have ' . $action . 'ter/property to ' . $action, ERR_ERROR); |
|
186 | + throw new ExceptionPropertyNotExists('Property ['.get_called_class().'::'.$name.'] does not have '.$action.'ter/property to '.$action, ERR_ERROR); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return $result; |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @return string |
275 | 275 | */ |
276 | 276 | protected function adjustPropertyString($name, $diff) { |
277 | - return (string)$this->$name . (string)$diff; |
|
277 | + return (string) $this->$name.(string) $diff; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * @return array |
285 | 285 | */ |
286 | 286 | protected function adjustPropertyArray($name, $diff) { |
287 | - $copy = (array)$this->$name; |
|
288 | - HelperArray::merge($copy, (array)$diff, HelperArray::MERGE_PHP); |
|
287 | + $copy = (array) $this->$name; |
|
288 | + HelperArray::merge($copy, (array) $diff, HelperArray::MERGE_PHP); |
|
289 | 289 | |
290 | 290 | return $copy; |
291 | 291 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return int |
298 | 298 | */ |
299 | 299 | protected function deltaInteger($name, $diff) { |
300 | - return (int)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int)$diff; |
|
300 | + return (int) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0) + (int) $diff; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @return float |
308 | 308 | */ |
309 | 309 | protected function deltaDouble($name, $diff) { |
310 | - return (float)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float)$diff; |
|
310 | + return (float) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, 0.0) + (float) $diff; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @return string |
318 | 318 | */ |
319 | 319 | protected function deltaString($name, $diff) { |
320 | - return (string)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '') . (string)$diff; |
|
320 | + return (string) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, '').(string) $diff; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @return array |
328 | 328 | */ |
329 | 329 | protected function deltaArray($name, $diff) { |
330 | - $copy = (array)HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array()); |
|
330 | + $copy = (array) HelperArray::keyExistsOr($this->propertiesAdjusted, $name, array()); |
|
331 | 331 | HelperArray::merge($copy, $diff, HelperArray::MERGE_PHP); |
332 | 332 | |
333 | 333 | return $copy; |
@@ -350,10 +350,10 @@ discard block |
||
350 | 350 | // Capitalizing type name |
351 | 351 | $methodName = explode(' ', $type); |
352 | 352 | array_walk($methodName, 'DbSqlHelper::UCFirstByRef'); |
353 | - $methodName = $prefix . implode('', $methodName); |
|
353 | + $methodName = $prefix.implode('', $methodName); |
|
354 | 354 | |
355 | 355 | if (!method_exists($this, $methodName)) { |
356 | - throw new ExceptionTypeUnsupported('Type "' . $type . '" is unsupported in PropertyHider::propertyMethodResult'); |
|
356 | + throw new ExceptionTypeUnsupported('Type "'.$type.'" is unsupported in PropertyHider::propertyMethodResult'); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | return call_user_func(array($this, $methodName), $name, $diff); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | break; |
31 | 31 | |
32 | 32 | case TYPE_ARRAY: |
33 | - $value = (array)$value; |
|
33 | + $value = (array) $value; |
|
34 | 34 | break; |
35 | 35 | |
36 | 36 | case TYPE_STRING: |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | case TYPE_EMPTY: |
39 | 39 | // No-type defaults to string |
40 | 40 | default: |
41 | - $value = (string)$value; |
|
41 | + $value = (string) $value; |
|
42 | 42 | break; |
43 | 43 | } |
44 | 44 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if (is_callable($callable)) { |
53 | 53 | $this->accessors[$type][$varName] = $callable; |
54 | 54 | } else { |
55 | - throw new Exception('Error assigning callable in ' . get_called_class() . '! Callable typed [' . $type . '] is not a callable or not accessible in the scope'); |
|
55 | + throw new Exception('Error assigning callable in '.get_called_class().'! Callable typed ['.$type.'] is not a callable or not accessible in the scope'); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | public function importRow($row) { |
76 | - if(empty($row)) { |
|
76 | + if (empty($row)) { |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $that = $this; |
79 | 79 | |
80 | 80 | $this->_container->assignAccessor('type', P_CONTAINER_GETTER, |
81 | - function () use ($that) { |
|
81 | + function() use ($that) { |
|
82 | 82 | return $that->type; |
83 | 83 | } |
84 | 84 | ); |
85 | 85 | $this->_container->assignAccessor('type', P_CONTAINER_SETTER, |
86 | - function ($value) use ($that) { |
|
86 | + function($value) use ($that) { |
|
87 | 87 | $that->type = $value; |
88 | 88 | $array = get_unit_param($value); |
89 | 89 | $that->unitInfo = $array; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $propertyName = 'timeStart'; |
100 | 100 | $fieldName = self::$_properties[$propertyName][P_DB_FIELD]; |
101 | 101 | $this->_container->assignAccessor($propertyName, P_CONTAINER_IMPORTER, |
102 | - function (&$row) use ($that, $fieldName) { |
|
102 | + function(&$row) use ($that, $fieldName) { |
|
103 | 103 | if (isset($row[$fieldName])) { |
104 | 104 | $dateTime = new \DateTime($row[$fieldName]); |
105 | 105 | } else { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | ); |
111 | 111 | $this->_container->assignAccessor($propertyName, P_CONTAINER_EXPORTER, |
112 | - function (&$row) use ($that, $fieldName) { |
|
112 | + function(&$row) use ($that, $fieldName) { |
|
113 | 113 | $dateTime = $that->timeStart; |
114 | 114 | if ($dateTime instanceof \DateTime) { |
115 | 115 | $row[$fieldName] = $dateTime->format(FMT_DATE_TIME_SQL); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $propertyName = 'timeFinish'; |
123 | 123 | $fieldName = self::$_properties[$propertyName][P_DB_FIELD]; |
124 | 124 | $this->_container->assignAccessor($propertyName, P_CONTAINER_IMPORTER, |
125 | - function (&$row) use ($that, $fieldName) { |
|
125 | + function(&$row) use ($that, $fieldName) { |
|
126 | 126 | if (isset($row[$fieldName])) { |
127 | 127 | $dateTime = new \DateTime($row[$fieldName]); |
128 | 128 | } else { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | ); |
134 | 134 | $this->_container->assignAccessor($propertyName, P_CONTAINER_EXPORTER, |
135 | - function (&$row) use ($that, $fieldName) { |
|
135 | + function(&$row) use ($that, $fieldName) { |
|
136 | 136 | $dateTime = $that->timeFinish; |
137 | 137 | if ($dateTime instanceof \DateTime) { |
138 | 138 | $row[$fieldName] = $dateTime->format(FMT_DATE_TIME_SQL); |
@@ -27,14 +27,14 @@ |
||
27 | 27 | $cBuddy->new_request_text_unsafe = sys_get_param_str_unsafe('request_text'); |
28 | 28 | $cBuddy->playerArray = $user; |
29 | 29 | |
30 | - $cBuddy->playerId = function (BuddyRoutingParams $cBuddy) { |
|
30 | + $cBuddy->playerId = function(BuddyRoutingParams $cBuddy) { |
|
31 | 31 | return $cBuddy->playerArray['id']; |
32 | 32 | }; |
33 | - $cBuddy->playerName = function (BuddyRoutingParams $cBuddy) { |
|
33 | + $cBuddy->playerName = function(BuddyRoutingParams $cBuddy) { |
|
34 | 34 | return $cBuddy->playerArray['username']; |
35 | 35 | }; |
36 | - $cBuddy->playerNameAndCoordinates = function (BuddyRoutingParams $cBuddy) { |
|
37 | - return "{$cBuddy->playerArray['username']} " . uni_render_coordinates($cBuddy->playerArray); |
|
36 | + $cBuddy->playerNameAndCoordinates = function(BuddyRoutingParams $cBuddy) { |
|
37 | + return "{$cBuddy->playerArray['username']} ".uni_render_coordinates($cBuddy->playerArray); |
|
38 | 38 | }; |
39 | 39 | |
40 | 40 | $result = array(); |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | use Vector\Vector; |
4 | - |
|
5 | 4 | use Common\GlobalContainer; |
6 | 5 | |
7 | 6 | class classSupernova { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
204 | 204 | if (@get_magic_quotes_gpc()) { |
205 | 205 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
206 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
206 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
207 | 207 | $value = stripslashes($value); |
208 | 208 | }); |
209 | 209 | } |
@@ -219,43 +219,43 @@ discard block |
||
219 | 219 | $gc = static::$gc; |
220 | 220 | |
221 | 221 | // Default db |
222 | - $gc->db = function ($c) { |
|
222 | + $gc->db = function($c) { |
|
223 | 223 | $db = new db_mysql($c); |
224 | 224 | $db->sn_db_connect(); |
225 | 225 | |
226 | 226 | return $db; |
227 | 227 | }; |
228 | 228 | |
229 | - $gc->debug = function ($c) { |
|
229 | + $gc->debug = function($c) { |
|
230 | 230 | return new debug(); |
231 | 231 | }; |
232 | 232 | |
233 | - $gc->cache = function ($c) { |
|
233 | + $gc->cache = function($c) { |
|
234 | 234 | return new classCache(classSupernova::$cache_prefix); |
235 | 235 | }; |
236 | 236 | |
237 | - $gc->config = function ($c) { |
|
237 | + $gc->config = function($c) { |
|
238 | 238 | return new classConfig(classSupernova::$cache_prefix); |
239 | 239 | }; |
240 | 240 | |
241 | - $gc->localePlayer = function (GlobalContainer $c) { |
|
241 | + $gc->localePlayer = function(GlobalContainer $c) { |
|
242 | 242 | return new classLocale($c->config->server_locale_log_usage); |
243 | 243 | }; |
244 | 244 | |
245 | - $gc->dbRowOperator = function ($c) { |
|
245 | + $gc->dbRowOperator = function($c) { |
|
246 | 246 | return new DbRowDirectOperator($c); |
247 | 247 | }; |
248 | 248 | |
249 | 249 | $gc->buddyClass = 'Buddy\BuddyModel'; |
250 | - $gc->buddy = $gc->factory(function (GlobalContainer $c) { |
|
250 | + $gc->buddy = $gc->factory(function(GlobalContainer $c) { |
|
251 | 251 | return new $c->buddyClass($c); |
252 | 252 | }); |
253 | 253 | |
254 | - $gc->query = $gc->factory(function (GlobalContainer $c) { |
|
254 | + $gc->query = $gc->factory(function(GlobalContainer $c) { |
|
255 | 255 | return new DbQueryConstructor($c->db); |
256 | 256 | }); |
257 | 257 | |
258 | - $gc->unit = $gc->factory(function (GlobalContainer $c) { |
|
258 | + $gc->unit = $gc->factory(function(GlobalContainer $c) { |
|
259 | 259 | return new \V2Unit\V2UnitModel($c); |
260 | 260 | }); |
261 | 261 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | public static function init_3_load_config_file() { |
269 | 269 | $dbsettings = array(); |
270 | 270 | |
271 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
271 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
272 | 272 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
273 | 273 | self::$db_name = $dbsettings['name']; |
274 | 274 | self::$sn_secret_word = $dbsettings['secretword']; |
@@ -39,7 +39,7 @@ |
||
39 | 39 | * <p>true - транзакция должна быть запущена - для совместимости с $for_update</p> |
40 | 40 | * <p>false - всё равно - для совместимости с $for_update</p> |
41 | 41 | * |
42 | - * @return bool Текущий статус транзакции |
|
42 | + * @return null|boolean Текущий статус транзакции |
|
43 | 43 | */ |
44 | 44 | public function check($status = null) { |
45 | 45 | $error_msg = false; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | if (!empty($error_msg)) { |
60 | 60 | // TODO - Убрать позже |
61 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
61 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
62 | 62 | $backtrace = debug_backtrace(); |
63 | 63 | array_shift($backtrace); |
64 | 64 | pdump($backtrace); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function start($level = '') { |
72 | 72 | $this->check(null); |
73 | 73 | |
74 | - $level ? $this->db->doSql('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
74 | + $level ? $this->db->doSql('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
75 | 75 | |
76 | 76 | $this->transaction_id++; |
77 | 77 | $this->db->doSql('START TRANSACTION'); |
@@ -187,6 +187,9 @@ |
||
187 | 187 | return $error_backtrace; |
188 | 188 | } |
189 | 189 | |
190 | + /** |
|
191 | + * @param string $die_message |
|
192 | + */ |
|
190 | 193 | public function error_fatal($die_message, $details = 'There is a fatal error on page') { |
191 | 194 | // TODO - Записывать детали ошибки в лог-файл |
192 | 195 | die($die_message); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | defined('INSIDE') || die(); |
34 | 34 | |
35 | -if(php_sapi_name() == "cli") { |
|
35 | +if (php_sapi_name() == "cli") { |
|
36 | 36 | // In cli-mode |
37 | 37 | define('__DEBUG_CRLF', "\r\n"); |
38 | - define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
|
38 | + define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF); |
|
39 | 39 | } else { |
40 | 40 | // Not in cli-mode |
41 | 41 | define('__DEBUG_CRLF', '<br />'); |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | public function log_file($message, $ident_change = 0) { |
53 | 53 | static $ident = 0; |
54 | 54 | |
55 | - if(!defined('SN_DEBUG_LOG')) { |
|
55 | + if (!defined('SN_DEBUG_LOG')) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - if($this->log_file_handler === null) { |
|
60 | - $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
|
59 | + if ($this->log_file_handler === null) { |
|
60 | + $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+'); |
|
61 | 61 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
62 | 62 | } |
63 | 63 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
64 | - if($this->log_file_handler) { |
|
65 | - @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
|
64 | + if ($this->log_file_handler) { |
|
65 | + @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n"); |
|
66 | 66 | } |
67 | 67 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
68 | 68 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | public function echo_log() { |
85 | - echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
85 | + echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
86 | 86 | die(); |
87 | 87 | } |
88 | 88 | |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | $result = array(); |
93 | 93 | $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId(); |
94 | 94 | $result[] = "tID {$transaction_id}"; |
95 | - foreach($backtrace as $a_trace) { |
|
96 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
95 | + foreach ($backtrace as $a_trace) { |
|
96 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $function = |
100 | 100 | ($a_trace['type'] |
101 | 101 | ? ($a_trace['type'] == '->' |
102 | - ? "({$a_trace['class']})" . get_class($a_trace['object']) |
|
102 | + ? "({$a_trace['class']})".get_class($a_trace['object']) |
|
103 | 103 | : $a_trace['class'] |
104 | - ) . $a_trace['type'] |
|
104 | + ).$a_trace['type'] |
|
105 | 105 | : '' |
106 | - ) . $a_trace['function'] . '()'; |
|
106 | + ).$a_trace['function'].'()'; |
|
107 | 107 | |
108 | 108 | $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file'])); |
109 | 109 | |
110 | 110 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
111 | 111 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
112 | 112 | |
113 | - if(!$long_comment) { |
|
113 | + if (!$long_comment) { |
|
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | public function dump($dump = false, $force_base = false, $deadlock = false) { |
125 | 125 | global $user, $planetrow; |
126 | 126 | |
127 | - if($dump === false) { |
|
127 | + if ($dump === false) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $error_backtrace = array(); |
132 | 132 | $base_dump = false; |
133 | 133 | |
134 | - if($force_base === true) { |
|
134 | + if ($force_base === true) { |
|
135 | 135 | $base_dump = true; |
136 | 136 | } |
137 | 137 | |
138 | - if($dump === true) { |
|
138 | + if ($dump === true) { |
|
139 | 139 | $base_dump = true; |
140 | 140 | } else { |
141 | - if(!is_array($dump)) { |
|
141 | + if (!is_array($dump)) { |
|
142 | 142 | $dump = array('var' => $dump); |
143 | 143 | } |
144 | 144 | |
145 | - foreach($dump as $dump_var_name => $dump_var) { |
|
146 | - if($dump_var_name == 'base_dump') { |
|
145 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
146 | + if ($dump_var_name == 'base_dump') { |
|
147 | 147 | $base_dump = $dump_var; |
148 | 148 | } else { |
149 | 149 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -151,22 +151,21 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
154 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
155 | 155 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
156 | 156 | $error_backtrace['locks'] = classSupernova::$gc->snCache->getLocks(); |
157 | 157 | $error_backtrace['cSN_data'] = classSupernova::$gc->snCache->getData(); |
158 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
159 | - foreach($location as $location_id => &$location_data) { |
|
160 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
161 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
158 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
159 | + foreach ($location as $location_id => &$location_data) { |
|
160 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
162 | 161 | } |
163 | 162 | } |
164 | 163 | $error_backtrace['cSN_queries'] = classSupernova::$gc->snCache->getQueries(); |
165 | 164 | } |
166 | 165 | |
167 | - if($base_dump) { |
|
168 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
169 | - foreach($this->log_array as $log) { |
|
166 | + if ($base_dump) { |
|
167 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
168 | + foreach ($this->log_array as $log) { |
|
170 | 169 | $error_backtrace['queries'][] = $log; |
171 | 170 | } |
172 | 171 | } |
@@ -195,14 +194,14 @@ discard block |
||
195 | 194 | public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
196 | 195 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
197 | 196 | |
198 | - if(empty(classSupernova::$db->connected)) { |
|
197 | + if (empty(classSupernova::$db->connected)) { |
|
199 | 198 | // TODO - писать ошибку в файл |
200 | 199 | die('SQL server currently unavailable. Please contact Administration...'); |
201 | 200 | } |
202 | 201 | |
203 | 202 | sn_db_transaction_rollback(); |
204 | 203 | |
205 | - if(classSupernova::$config->debug == 1) { |
|
204 | + if (classSupernova::$config->debug == 1) { |
|
206 | 205 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
207 | 206 | echo "<table>{$this->log}</table>"; |
208 | 207 | } |
@@ -214,16 +213,16 @@ discard block |
||
214 | 213 | |
215 | 214 | $userId = empty($user['id']) ? 0 : $user['id']; |
216 | 215 | |
217 | - if(!$sys_log_disabled) { |
|
216 | + if (!$sys_log_disabled) { |
|
218 | 217 | $query = "INSERT INTO `{{logs}}` SET |
219 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
220 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
221 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
218 | + `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."', |
|
219 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
220 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
222 | 221 | // ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
223 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
224 | - classSupernova::$db->doSql($query, true) or die($fatal_error . classSupernova::$db->db_error()); |
|
222 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
223 | + classSupernova::$db->doSql($query, true) or die($fatal_error.classSupernova::$db->db_error()); |
|
225 | 224 | |
226 | - $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>"; |
|
225 | + $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>"; |
|
227 | 226 | |
228 | 227 | $sys_stop_log_hit = true; |
229 | 228 | $sys_log_disabled = true; |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | ob_start(); |
234 | 233 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
235 | 234 | |
236 | - foreach($error_backtrace as $name => $value) { |
|
235 | + foreach ($error_backtrace as $name => $value) { |
|
237 | 236 | print(__DEBUG_LINE); |
238 | 237 | pdump($value, $name); |
239 | 238 | } |
@@ -245,7 +244,7 @@ discard block |
||
245 | 244 | public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
246 | 245 | global $user, $sys_log_disabled; |
247 | 246 | |
248 | - if(empty(classSupernova::$db->connected)) { |
|
247 | + if (empty(classSupernova::$db->connected)) { |
|
249 | 248 | // TODO - писать ошибку в файл |
250 | 249 | die('SQL server currently unavailable. Please contact Administration...'); |
251 | 250 | } |
@@ -254,12 +253,12 @@ discard block |
||
254 | 253 | |
255 | 254 | $userId = empty($user['id']) ? 0 : $user['id']; |
256 | 255 | |
257 | - if(!$sys_log_disabled) { |
|
256 | + if (!$sys_log_disabled) { |
|
258 | 257 | $query = "INSERT INTO `{{logs}}` SET |
259 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
260 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
261 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
262 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
258 | + `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."', |
|
259 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
260 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
261 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
263 | 262 | classSupernova::$db->doSql($query, true); |
264 | 263 | } else { |
265 | 264 | // // TODO Здесь надо писать в файло |
@@ -272,11 +271,11 @@ discard block |
||
272 | 271 | // Dump variables nicer then var_dump() |
273 | 272 | |
274 | 273 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
275 | - if(isset($varname)) { |
|
274 | + if (isset($varname)) { |
|
276 | 275 | $varname .= " = "; |
277 | 276 | } |
278 | 277 | |
279 | - if($level == -1) { |
|
278 | + if ($level == -1) { |
|
280 | 279 | $trans[' '] = '∴'; |
281 | 280 | $trans["\t"] = '⇒'; |
282 | 281 | $trans["\n"] = '¶;'; |
@@ -285,31 +284,31 @@ discard block |
||
285 | 284 | |
286 | 285 | return strtr(htmlspecialchars($value), $trans); |
287 | 286 | } |
288 | - if($level == 0) { |
|
287 | + if ($level == 0) { |
|
289 | 288 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
290 | - $dumper = mt_rand(10, 99) . '|' . $varname; |
|
289 | + $dumper = mt_rand(10, 99).'|'.$varname; |
|
291 | 290 | } |
292 | 291 | |
293 | 292 | $type = gettype($value); |
294 | 293 | $dumper .= $type; |
295 | 294 | |
296 | - if($type == TYPE_STRING) { |
|
297 | - $dumper .= '(' . strlen($value) . ')'; |
|
295 | + if ($type == TYPE_STRING) { |
|
296 | + $dumper .= '('.strlen($value).')'; |
|
298 | 297 | $value = dump($value, '', -1); |
299 | - } elseif($type == TYPE_BOOLEAN) { |
|
298 | + } elseif ($type == TYPE_BOOLEAN) { |
|
300 | 299 | $value = ($value ? 'true' : 'false'); |
301 | - } elseif($type == 'object') { |
|
300 | + } elseif ($type == 'object') { |
|
302 | 301 | $props = get_class_vars(get_class($value)); |
303 | - $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
304 | - foreach($props as $key => $val) { |
|
305 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
302 | + $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
303 | + foreach ($props as $key => $val) { |
|
304 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
306 | 305 | $dumper .= dump($value->$key, '', $level + 1); |
307 | 306 | } |
308 | 307 | $value = ''; |
309 | - } elseif($type == TYPE_ARRAY) { |
|
310 | - $dumper .= '(' . count($value) . ')'; |
|
311 | - foreach($value as $key => $val) { |
|
312 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
|
308 | + } elseif ($type == TYPE_ARRAY) { |
|
309 | + $dumper .= '('.count($value).')'; |
|
310 | + foreach ($value as $key => $val) { |
|
311 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => '; |
|
313 | 312 | $dumper .= dump($val, '', $level + 1); |
314 | 313 | } |
315 | 314 | $value = ''; |
@@ -328,24 +327,24 @@ discard block |
||
328 | 327 | // $backtrace = $backtrace[1]; |
329 | 328 | |
330 | 329 | $caller = ''; |
331 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
332 | - $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
|
333 | - (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
|
334 | - $backtrace[1]['function'] . |
|
330 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
331 | + $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : ''). |
|
332 | + (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : ''). |
|
333 | + $backtrace[1]['function']. |
|
335 | 334 | (!empty($backtrace[0]['file']) |
336 | 335 | ? ( |
337 | - ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) . |
|
338 | - (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') . |
|
336 | + ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN). |
|
337 | + (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : ''). |
|
339 | 338 | ')' |
340 | 339 | ) |
341 | 340 | : '' |
342 | 341 | ); |
343 | - $caller = "\r\n" . $caller; |
|
342 | + $caller = "\r\n".$caller; |
|
344 | 343 | } |
345 | 344 | |
346 | - print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' . |
|
347 | - dump($value, $varname) . |
|
348 | - $caller . |
|
345 | + print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'. |
|
346 | + dump($value, $varname). |
|
347 | + $caller. |
|
349 | 348 | '</pre>' |
350 | 349 | ); |
351 | 350 | } |
@@ -355,24 +354,24 @@ discard block |
||
355 | 354 | } |
356 | 355 | |
357 | 356 | function pr($prePrint = false) { |
358 | - if($prePrint) { |
|
357 | + if ($prePrint) { |
|
359 | 358 | print(__DEBUG_CRLF); |
360 | 359 | } |
361 | - print(mt_rand() . __DEBUG_CRLF); |
|
360 | + print(mt_rand().__DEBUG_CRLF); |
|
362 | 361 | } |
363 | 362 | |
364 | 363 | function pc($prePrint = false) { |
365 | 364 | global $_PRINT_COUNT_VALUE; |
366 | 365 | $_PRINT_COUNT_VALUE++; |
367 | 366 | |
368 | - if($prePrint) { |
|
367 | + if ($prePrint) { |
|
369 | 368 | print(__DEBUG_CRLF); |
370 | 369 | } |
371 | - print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
|
370 | + print($_PRINT_COUNT_VALUE.__DEBUG_CRLF); |
|
372 | 371 | } |
373 | 372 | |
374 | 373 | function prep($message) { |
375 | - print('<pre>' . $message . '</pre>'); |
|
374 | + print('<pre>'.$message.'</pre>'); |
|
376 | 375 | } |
377 | 376 | |
378 | 377 | function backtrace_no_arg() { |
@@ -396,9 +395,9 @@ discard block |
||
396 | 395 | */ |
397 | 396 | function pdie($message = '', $level = 0) { |
398 | 397 | $backtrace = debug_backtrace(); |
399 | - for($i = 0; $i < $level; $i++) { |
|
398 | + for ($i = 0; $i < $level; $i++) { |
|
400 | 399 | array_pop($backtrace); |
401 | 400 | } |
402 | 401 | |
403 | - die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']); |
|
402 | + die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']); |
|
404 | 403 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @return array|bool|mysqli_result|null |
24 | 24 | */ |
25 | 25 | public static function db_missile_list_by_arrival() { |
26 | - $iraks = classSupernova::$db->doSelect("SELECT * FROM `{{iraks}}` WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;"); |
|
26 | + $iraks = classSupernova::$db->doSelect("SELECT * FROM `{{iraks}}` WHERE `fleet_end_time` <= ".SN_TIME_NOW." FOR UPDATE;"); |
|
27 | 27 | |
28 | 28 | return $iraks; |
29 | 29 | } |
@@ -2,6 +2,10 @@ |
||
2 | 2 | |
3 | 3 | class DBStaticFleetMissile { |
4 | 4 | |
5 | + /** |
|
6 | + * @param double $arrival |
|
7 | + * @param integer $target_structure |
|
8 | + */ |
|
5 | 9 | public static function db_missile_insert($target_coord, $user, $planetrow, $arrival, $fleet_ship_count, $target_structure) { |
6 | 10 | classSupernova::$db->doInsert( |
7 | 11 | "INSERT INTO `{{iraks}}` SET |