@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | ), |
23 | 23 | ); |
24 | 24 | |
25 | - foreach($queries as &$query) { |
|
26 | - if(!empty($query['query'])) { |
|
25 | + foreach ($queries as &$query) { |
|
26 | + if (!empty($query['query'])) { |
|
27 | 27 | $query['result'] = doquery($query['query']); |
28 | - } elseif(!empty($query['callable']) && is_callable($query['callable'])) { |
|
28 | + } elseif (!empty($query['callable']) && is_callable($query['callable'])) { |
|
29 | 29 | call_user_func($query['callable']); |
30 | 30 | } |
31 | 31 | $query['error'] = classSupernova::$db->db_error(); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']); |
70 | 70 | // pdump($prev_run_array); |
71 | 71 | $scheduleList = explode(',', $scheduleList); |
72 | - array_walk($scheduleList, function (&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
|
72 | + array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
|
73 | 73 | // pdump($schedule); |
74 | 74 | $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule)))); |
75 | 75 | |
@@ -81,21 +81,21 @@ discard block |
||
81 | 81 | */ |
82 | 82 | // pdump($schedule); |
83 | 83 | |
84 | - foreach($prev_run_array as $index => $date_part) { |
|
84 | + foreach ($prev_run_array as $index => $date_part) { |
|
85 | 85 | $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part; |
86 | 86 | $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index]; |
87 | 87 | } |
88 | - if($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
88 | + if ($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
89 | 89 | unset($schedule['array']['now']); |
90 | 90 | } |
91 | 91 | |
92 | - foreach($schedule['array'] as $name => $array) { |
|
92 | + foreach ($schedule['array'] as $name => $array) { |
|
93 | 93 | $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}"; |
94 | - $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval; |
|
95 | - $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval; |
|
94 | + $schedule['string'][$name.'_next'] = $schedule['string'][$name].' +1 '.$interval; |
|
95 | + $schedule['string'][$name.'_prev'] = $schedule['string'][$name].' -1 '.$interval; |
|
96 | 96 | } |
97 | 97 | |
98 | - foreach($schedule['string'] as $string) { |
|
98 | + foreach ($schedule['string'] as $string) { |
|
99 | 99 | $timestamp = strtotime($string); |
100 | 100 | $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string)); |
101 | 101 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | $prev_run = 0; |
129 | 129 | $next_run = 0; |
130 | - foreach($possible_schedules as $timestamp => $string_date) { |
|
130 | + foreach ($possible_schedules as $timestamp => $string_date) { |
|
131 | 131 | $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run; |
132 | 132 | $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run; |
133 | 133 | // pdump($schedule, '$schedule ' . date(FMT_DATE_TIME_SQL, $schedule)); |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | $ts_var_stat_update = strtotime(classSupernova::$config->db_loadItem('var_stat_update')); |
10 | 10 | $ts_scheduled_update = sys_schedule_get_prev_run(classSupernova::$config->db_loadItem('stats_schedule'), classSupernova::$config->var_stat_update); |
11 | 11 | |
12 | - if(sys_get_param_int('admin_update')) { |
|
12 | + if (sys_get_param_int('admin_update')) { |
|
13 | 13 | define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1); |
14 | - if(USER_LEVEL > 0) { |
|
14 | + if (USER_LEVEL > 0) { |
|
15 | 15 | $is_admin_request = true; |
16 | 16 | $ts_scheduled_update = SN_TIME_NOW; |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - if($ts_scheduled_update > $ts_var_stat_update) { |
|
20 | + if ($ts_scheduled_update > $ts_var_stat_update) { |
|
21 | 21 | lng_include('admin'); |
22 | 22 | sn_db_transaction_start(); |
23 | 23 | $ts_var_stat_update_end = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')); |
24 | - if(SN_TIME_NOW > $ts_var_stat_update_end) { |
|
24 | + if (SN_TIME_NOW > $ts_var_stat_update_end) { |
|
25 | 25 | $old_server_status = classSupernova::$config->db_loadItem('game_disable'); |
26 | 26 | classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_STAT); |
27 | 27 | |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | |
32 | 32 | $msg = $is_admin_request ? 'admin request' : 'scheduler'; |
33 | 33 | $next_run = date(FMT_DATE_TIME_SQL, sys_schedule_get_prev_run(classSupernova::$config->stats_schedule, classSupernova::$config->var_stat_update, true)); |
34 | - $msg = "Running stat updates: {$msg}. Config->var_stat_update = " . classSupernova::$config->var_stat_update . |
|
35 | - ', $ts_scheduled_update = ' . date(FMT_DATE_TIME_SQL, $ts_scheduled_update) . |
|
36 | - ', next_stat_update = ' . $next_run; |
|
34 | + $msg = "Running stat updates: {$msg}. Config->var_stat_update = ".classSupernova::$config->var_stat_update. |
|
35 | + ', $ts_scheduled_update = '.date(FMT_DATE_TIME_SQL, $ts_scheduled_update). |
|
36 | + ', next_stat_update = '.$next_run; |
|
37 | 37 | classSupernova::$debug->warning($msg, 'Stat update', LOG_INFO_STAT_PROCESS); |
38 | 38 | $total_time = microtime(true); |
39 | 39 | |
40 | 40 | // require_once('../includes/sys_stat.php'); |
41 | - require_once(SN_ROOT_PHYSICAL . 'includes/includes/sys_stat.php'); |
|
41 | + require_once(SN_ROOT_PHYSICAL.'includes/includes/sys_stat.php'); |
|
42 | 42 | sys_stat_calculate(); |
43 | 43 | |
44 | 44 | $total_time = microtime(true) - $total_time; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | classSupernova::$config->db_saveItem('var_stat_update_end', SN_TIME_SQL); |
58 | 58 | |
59 | 59 | classSupernova::$config->db_saveItem('game_disable', $old_server_status); |
60 | - } elseif($ts_scheduled_update > $ts_var_stat_update) { |
|
60 | + } elseif ($ts_scheduled_update > $ts_var_stat_update) { |
|
61 | 61 | $timeout = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW; |
62 | 62 | $msg = classSupernova::$config->db_loadItem('var_stat_update_msg'); |
63 | 63 | $msg = "{$msg} ETA {$timeout} seconds. Please wait..."; |
64 | 64 | } |
65 | 65 | sn_db_transaction_rollback(); |
66 | - } elseif($is_admin_request) { |
|
66 | + } elseif ($is_admin_request) { |
|
67 | 67 | $msg = 'Stat is up to date'; |
68 | 68 | } |
69 | 69 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return float|int |
45 | 45 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | - if($cut_extreme) { |
|
46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | + if ($cut_extreme) { |
|
48 | 48 | $range_start--; |
49 | 49 | $range_end++; |
50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $args = func_get_args(); |
62 | 62 | |
63 | - switch(func_num_args()) |
|
63 | + switch (func_num_args()) |
|
64 | 64 | { |
65 | 65 | case 0: |
66 | 66 | // trigger_error('median() requires at least one parameter',E_USER_WARNING); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | // fallthrough |
73 | 73 | |
74 | 74 | default: |
75 | - if(!is_array($args)) |
|
75 | + if (!is_array($args)) |
|
76 | 76 | { |
77 | 77 | // trigger_error('median() requires a list of numbers to operate on or an array of numbers', E_USER_NOTICE); |
78 | 78 | return false; |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | $n = count($args); |
84 | 84 | $h = intval($n / 2); |
85 | 85 | |
86 | - if($n % 2 == 0) |
|
86 | + if ($n % 2 == 0) |
|
87 | 87 | { |
88 | - $median = ($args[$h] + $args[$h-1]) / 2; |
|
88 | + $median = ($args[$h] + $args[$h - 1]) / 2; |
|
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
@@ -103,49 +103,49 @@ discard block |
||
103 | 103 | } |
104 | 104 | function linear_calc(&$linear, $from = 0, $logProcess = false) |
105 | 105 | { |
106 | - for($i = $from; $i < count($linear); $i++) |
|
106 | + for ($i = $from; $i < count($linear); $i++) |
|
107 | 107 | { |
108 | 108 | $eq = &$linear[$i]; |
109 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
109 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
110 | 110 | { |
111 | 111 | $eq[$j] /= $eq[$from]; |
112 | 112 | } |
113 | 113 | } |
114 | - if($logProcess) pdump($linear, 'Нормализовано по х' . $from); |
|
114 | + if ($logProcess) pdump($linear, 'Нормализовано по х'.$from); |
|
115 | 115 | |
116 | - for($i = $from + 1; $i < count($linear); $i++) |
|
116 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
117 | 117 | { |
118 | 118 | $eq = &$linear[$i]; |
119 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
119 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
120 | 120 | { |
121 | 121 | $eq[$j] -= $linear[$from][$j]; |
122 | 122 | } |
123 | 123 | } |
124 | - if($logProcess) pdump($linear, 'Подставили х' . $from); |
|
124 | + if ($logProcess) pdump($linear, 'Подставили х'.$from); |
|
125 | 125 | |
126 | - if($from < count($linear) - 1) |
|
126 | + if ($from < count($linear) - 1) |
|
127 | 127 | { |
128 | 128 | linear_calc($linear, $from + 1, $logProcess); |
129 | 129 | } |
130 | 130 | |
131 | - if($from) |
|
131 | + if ($from) |
|
132 | 132 | { |
133 | - for($i = 0; $i < $from; $i++) |
|
133 | + for ($i = 0; $i < $from; $i++) |
|
134 | 134 | { |
135 | 135 | $eq = &$linear[$i]; |
136 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
136 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
137 | 137 | { |
138 | 138 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
139 | 139 | } |
140 | 140 | } |
141 | - if($logProcess) pdump($linear, 'Подставили обратно х' . $from); |
|
141 | + if ($logProcess) pdump($linear, 'Подставили обратно х'.$from); |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - if($logProcess) pdump($linear, 'Результат' . $from); |
|
146 | - foreach($linear as $index => &$eq) |
|
145 | + if ($logProcess) pdump($linear, 'Результат'.$from); |
|
146 | + foreach ($linear as $index => &$eq) |
|
147 | 147 | { |
148 | - pdump($eq[count($linear)], 'x' . $index); |
|
148 | + pdump($eq[count($linear)], 'x'.$index); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | } |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | if($n % 2 == 0) |
87 | 87 | { |
88 | 88 | $median = ($args[$h] + $args[$h-1]) / 2; |
89 | - } |
|
90 | - else |
|
89 | + } else |
|
91 | 90 | { |
92 | 91 | $median = $args[$h]; |
93 | 92 | } |
@@ -111,7 +110,9 @@ discard block |
||
111 | 110 | $eq[$j] /= $eq[$from]; |
112 | 111 | } |
113 | 112 | } |
114 | - if($logProcess) pdump($linear, 'Нормализовано по х' . $from); |
|
113 | + if($logProcess) { |
|
114 | + pdump($linear, 'Нормализовано по х' . $from); |
|
115 | + } |
|
115 | 116 | |
116 | 117 | for($i = $from + 1; $i < count($linear); $i++) |
117 | 118 | { |
@@ -121,7 +122,9 @@ discard block |
||
121 | 122 | $eq[$j] -= $linear[$from][$j]; |
122 | 123 | } |
123 | 124 | } |
124 | - if($logProcess) pdump($linear, 'Подставили х' . $from); |
|
125 | + if($logProcess) { |
|
126 | + pdump($linear, 'Подставили х' . $from); |
|
127 | + } |
|
125 | 128 | |
126 | 129 | if($from < count($linear) - 1) |
127 | 130 | { |
@@ -138,11 +141,14 @@ discard block |
||
138 | 141 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
139 | 142 | } |
140 | 143 | } |
141 | - if($logProcess) pdump($linear, 'Подставили обратно х' . $from); |
|
142 | - } |
|
143 | - else |
|
144 | + if($logProcess) { |
|
145 | + pdump($linear, 'Подставили обратно х' . $from); |
|
146 | + } |
|
147 | + } else |
|
144 | 148 | { |
145 | - if($logProcess) pdump($linear, 'Результат' . $from); |
|
149 | + if($logProcess) { |
|
150 | + pdump($linear, 'Результат' . $from); |
|
151 | + } |
|
146 | 152 | foreach($linear as $index => &$eq) |
147 | 153 | { |
148 | 154 | pdump($eq[count($linear)], 'x' . $index); |
@@ -37,7 +37,7 @@ |
||
37 | 37 | /** |
38 | 38 | * @param float $range_start - Начало диапазона |
39 | 39 | * @param float $range_end - Конец диапазона |
40 | - * @param bool|int $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
40 | + * @param boolean $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
41 | 41 | * @param int $strict - В сколько сигм надо уложить результат |
42 | 42 | * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много |
43 | 43 | * |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function debris_add_resource($resource_id, $resource_amount) { |
32 | 32 | // В обломках может быть только металл или кристалл |
33 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
33 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
34 | 34 | return; |
35 | 35 | } |
36 | 36 | $this->debris[$resource_id] += $resource_amount; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param bool $is_simulator |
42 | 42 | */ |
43 | 43 | public function add_wrecks(array $wreckage, $is_simulator) { |
44 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
44 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
45 | 45 | $this->debris_add_resource($resource_id, floor($resource_amount * |
46 | 46 | ($is_simulator |
47 | 47 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param bool $is_simulator |
58 | 58 | */ |
59 | 59 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
60 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
60 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
61 | 61 | $this->debris_add_resource($resource_id, floor($resource_amount * |
62 | 62 | ($is_simulator |
63 | 63 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param $moon_debris_left_part |
97 | 97 | */ |
98 | 98 | public function debris_adjust_proportional($moon_debris_left_part) { |
99 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
99 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
100 | 100 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
101 | 101 | } |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function report_generate_sql() { |
119 | 119 | return " |
120 | - `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ", |
|
121 | - `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ", |
|
122 | - `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal() . ", "; |
|
120 | + `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL).", |
|
121 | + `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL).", |
|
122 | + `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal().", "; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @version 41a6.49 |
12 | 12 | */ |
13 | 13 | public static function unit_dump_header() { |
14 | - if(!defined('DEBUG_UBE')) { |
|
14 | + if (!defined('DEBUG_UBE')) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @version 41a6.49 |
49 | 49 | */ |
50 | 50 | public static function unit_dump(UBEUnit $unit, $desc = '', UBEUnit $before = null) { |
51 | - if(!defined('DEBUG_UBE')) { |
|
51 | + if (!defined('DEBUG_UBE')) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | // print("<td>" . $this->units_lost . "</td>"); |
76 | 76 | // print("<td>" . $this->units_restored . "</td>"); |
77 | 77 | // print("<td>" . $this->capacity . "</td>"); |
78 | - print("<td>" . round($unit->share_of_side_armor, 4) . "</td>"); |
|
78 | + print("<td>".round($unit->share_of_side_armor, 4)."</td>"); |
|
79 | 79 | print('</tr>'); |
80 | 80 | } |
81 | 81 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @version 41a6.49 |
87 | 87 | */ |
88 | 88 | public static function unit_dump_footer() { |
89 | - if(!defined('DEBUG_UBE')) { |
|
89 | + if (!defined('DEBUG_UBE')) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @return UBEUnit |
102 | 102 | */ |
103 | 103 | public static function unit_dump_defender(UBEUnit $attacking_unit_pool, UBEUnit $defending_unit_pool, $defending_fleet_id) { |
104 | - if(!defined('DEBUG_UBE')) { |
|
104 | + if (!defined('DEBUG_UBE')) { |
|
105 | 105 | return null; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $classLocale = classLocale::$lang; |
109 | 109 | |
110 | - print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}" . |
|
111 | - ' attacks ' . |
|
112 | - $defending_fleet_id . '@' . "[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}" . |
|
113 | - ' with ' . pretty_number($defending_unit_pool->attack_income) . |
|
110 | + print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}". |
|
111 | + ' attacks '. |
|
112 | + $defending_fleet_id.'@'."[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}". |
|
113 | + ' with '.pretty_number($defending_unit_pool->attack_income). |
|
114 | 114 | '<br>' |
115 | 115 | ); |
116 | 116 | $before = clone $defending_unit_pool; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @version 41a6.49 |
128 | 128 | */ |
129 | 129 | public static function unit_dump_delta(UBEUnit $unit, $field, UBEUnit $before = null) { |
130 | - if(!defined('DEBUG_UBE')) { |
|
130 | + if (!defined('DEBUG_UBE')) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | print(pretty_number($unit->$field)); |
137 | 137 | print("</td>"); |
138 | 138 | print("<td>"); |
139 | - if(!empty($before)) { |
|
140 | - print('' . pretty_number($unit->$field - $before->$field) . ''); |
|
139 | + if (!empty($before)) { |
|
140 | + print(''.pretty_number($unit->$field - $before->$field).''); |
|
141 | 141 | } |
142 | 142 | print("</td>"); |
143 | 143 | } |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | // Инфа об устройстве и браузере - общая для всех |
90 | 90 | sn_db_transaction_start(); |
91 | 91 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
92 | - if($this->device_cypher) { |
|
92 | + if ($this->device_cypher) { |
|
93 | 93 | $cypher_safe = db_escape($this->device_cypher); |
94 | 94 | $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
95 | - if(!empty($device_id['device_id'])) { |
|
95 | + if (!empty($device_id['device_id'])) { |
|
96 | 96 | $this->device_id = $device_id['device_id']; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if($this->device_id <= 0) { |
|
100 | + if ($this->device_id <= 0) { |
|
101 | 101 | do { |
102 | 102 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
103 | 103 | $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | // self::flog('Вставляем запись системы безопасности'); |
155 | 155 | return doquery( |
156 | 156 | "INSERT IGNORE INTO {{security_player_entry}} (`player_id`, `device_id`, `browser_id`, `user_ip`, `user_proxy`) |
157 | - VALUES ({$user_id_safe}," . $this->device_id . "," . $this->browser_id . "," . |
|
158 | - $this->ip_v4_int . ", '" . db_escape($this->ip_v4_proxy_chain) . "');" |
|
157 | + VALUES ({$user_id_safe},".$this->device_id.",".$this->browser_id.",". |
|
158 | + $this->ip_v4_int.", '".db_escape($this->ip_v4_proxy_chain)."');" |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function db_counter_insert($user_id_unsafe) { |
168 | 168 | global $sys_stop_log_hit; |
169 | 169 | |
170 | - if($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
170 | + if ($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | classSupernova::$db->isWatching = true; |
178 | 178 | doquery( |
179 | 179 | "INSERT INTO {{counter}} SET |
180 | - `visit_time` = '" . SN_TIME_SQL. "', |
|
180 | + `visit_time` = '" . SN_TIME_SQL."', |
|
181 | 181 | `user_id` = {$user_id_safe}, |
182 | 182 | `device_id` = {$this->device_id}, |
183 | 183 | `browser_id` = {$this->browser_id}, |
184 | 184 | `user_ip` = {$this->ip_v4_int}, |
185 | 185 | `user_proxy` = '{$proxy_safe}', |
186 | - `page_url_id` = {$this->page_address_id}" . |
|
187 | - ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ). |
|
186 | + `page_url_id` = {$this->page_address_id}". |
|
187 | + ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : ''). |
|
188 | 188 | ";"); |
189 | 189 | |
190 | 190 | classSupernova::$db->isWatching = false; |
@@ -52,7 +52,7 @@ |
||
52 | 52 | !mysql_select_db($settings['name']) |
53 | 53 | ? classSupernova::$debug->error_fatal('DB error - cannot find DB on server', $this->mysql_error()) |
54 | 54 | : false; |
55 | - !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';') |
|
55 | + !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';') |
|
56 | 56 | ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level', $this->mysql_error()) |
57 | 57 | : false; |
58 | 58 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function _init($group_name = '') { |
27 | 27 | parent::_init($group_name); |
28 | 28 | |
29 | - foreach(static::$_group_unit_id_list as $resource_id) { |
|
29 | + foreach (static::$_group_unit_id_list as $resource_id) { |
|
30 | 30 | static::$_group_pnames[$resource_id] = pname_resource_name($resource_id); |
31 | 31 | } |
32 | 32 | |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | |
49 | 49 | !is_array($resource_array) ? $resource_array = array() : false; |
50 | 50 | |
51 | - foreach($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | - if(!$resource_actual_delta) { |
|
51 | + foreach ($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | + if (!$resource_actual_delta) { |
|
53 | 53 | // No delta - no changes |
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - $result[$prefix . static::$_group_pnames[$resource_id]] = $resource_actual_delta; |
|
57 | + $result[$prefix.static::$_group_pnames[$resource_id]] = $resource_actual_delta; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $result; |
@@ -39,19 +39,19 @@ |
||
39 | 39 | |
40 | 40 | @$this->link = mysqli_connect($settings['server'], $settings['user'], $settings['pass'], $settings['name']); |
41 | 41 | if (!is_object($this->link) || $this->link->connect_error) { |
42 | - classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #' . $this->link->connect_errno, $this->link->connect_error); |
|
42 | + classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #'.$this->link->connect_errno, $this->link->connect_error); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | !$this->mysql_query("/*!40101 SET NAMES 'utf8' */") |
47 | - ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #' . $this->link->errno, $this->link->error) |
|
47 | + ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #'.$this->link->errno, $this->link->error) |
|
48 | 48 | : false; |
49 | 49 | !$this->mysql_query("SET NAMES 'utf8';") |
50 | - ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #' . $this->link->errno, $this->link->error) |
|
50 | + ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #'.$this->link->errno, $this->link->error) |
|
51 | 51 | : false; |
52 | 52 | |
53 | - !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';') |
|
54 | - ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #' . $this->link->errno, $this->link->error) |
|
53 | + !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';') |
|
54 | + ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #'.$this->link->errno, $this->link->error) |
|
55 | 55 | : false; |
56 | 56 | |
57 | 57 | $this->connected = true; |