Passed
Push — trunk ( 72cafa...79712a )
by SuperNova.WS
03:36
created
includes/includes/market_info.inc 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
3
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
4 4
 {
5 5
   $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
6 6
 }
@@ -15,50 +15,50 @@  discard block
 block discarded – undo
15 15
 ));
16 16
 
17 17
 $info_action = sys_get_param_int('action');
18
-if($info_action)
18
+if ($info_action)
19 19
 {
20 20
   try
21 21
   {
22 22
     sn_db_transaction_start();
23 23
 
24 24
     $user = db_user_by_id($user['id'], true);
25
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info)
25
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $config->rpg_cost_info)
26 26
     {
27 27
       throw new Exception(MARKET_NO_DM, ERR_ERROR);
28 28
     }
29 29
 
30
-    switch($info_action)
30
+    switch ($info_action)
31 31
     {
32 32
       case MARKET_INFO_PLAYER:
33 33
         $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name');
34
-        if(!$user_info_name_unsafe)
34
+        if (!$user_info_name_unsafe)
35 35
         {
36 36
           throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR);
37 37
         }
38 38
 
39
-        if(is_id($user_info_name_unsafe))
39
+        if (is_id($user_info_name_unsafe))
40 40
         {
41 41
           $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true);
42 42
         }
43
-        if(!is_array($user_info))
43
+        if (!is_array($user_info))
44 44
         {
45 45
           $user_info = db_user_by_username($user_info_name_unsafe, true);
46 46
         }
47
-        if(!is_array($user_info))
47
+        if (!is_array($user_info))
48 48
         {
49 49
           throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR);
50 50
         }
51
-        if($user_info['id'] == $user['id'])
51
+        if ($user_info['id'] == $user['id'])
52 52
         {
53 53
           throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
54 54
         }
55 55
 
56 56
         $msg_text = array();
57
-        foreach(sn_get_groups('mercenaries') as $mercenary_id)
57
+        foreach (sn_get_groups('mercenaries') as $mercenary_id)
58 58
         {
59 59
           $msg_text[] = "{$lang['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, false, $mercenary_id)) ? "{$lang['sys_level']} {$mercenary_level}" : $lang['eco_mrk_info_not_hired']);
60 60
         }
61
-        if($mercenary_level = mrc_get_level($user_info, false, UNIT_PREMIUM))
61
+        if ($mercenary_level = mrc_get_level($user_info, false, UNIT_PREMIUM))
62 62
         {
63 63
           $msg_text[] = "{$lang['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$lang['sys_level']}";
64 64
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
       break;
73 73
     }
74 74
 
75
-    if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$lang['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
75
+    if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -$config->rpg_cost_info, "Using Black Market page {$lang['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
76 76
     {
77 77
       // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
78 78
     }
Please login to merge, or discard this patch.
buddy.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -18,39 +18,39 @@  discard block
 block discarded – undo
18 18
 {
19 19
   sn_db_transaction_start();
20 20
 
21
-  if($buddy_id = sys_get_param_id('buddy_id'))
21
+  if ($buddy_id = sys_get_param_id('buddy_id'))
22 22
   {
23 23
     $buddy_row = doquery("SELECT BUDDY_SENDER_ID, BUDDY_OWNER_ID, BUDDY_STATUS FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1 FOR UPDATE;", true);
24
-    if(!is_array($buddy_row))
24
+    if (!is_array($buddy_row))
25 25
     {
26 26
       throw new exception('buddy_err_not_exist', ERR_ERROR);
27 27
     }
28 28
 
29
-    switch($mode = sys_get_param_str('mode'))
29
+    switch ($mode = sys_get_param_str('mode'))
30 30
     {
31 31
       case 'accept':
32
-        if($buddy_row['BUDDY_SENDER_ID'] == $user['id'])
32
+        if ($buddy_row['BUDDY_SENDER_ID'] == $user['id'])
33 33
         {
34 34
           throw new exception('buddy_err_accept_own', ERR_ERROR);
35 35
         }
36 36
 
37
-        if($buddy_row['BUDDY_OWNER_ID'] != $user['id'])
37
+        if ($buddy_row['BUDDY_OWNER_ID'] != $user['id'])
38 38
         {
39 39
           throw new exception('buddy_err_accept_alien', ERR_ERROR);
40 40
         }
41 41
 
42
-        if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE)
42
+        if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE)
43 43
         {
44 44
           throw new exception('buddy_err_accept_already', ERR_WARNING);
45 45
         }
46 46
 
47
-        if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED)
47
+        if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED)
48 48
         {
49 49
           throw new exception('buddy_err_accept_denied', ERR_ERROR);
50 50
         }
51 51
 
52 52
         doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_ACTIVE . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;");
53
-        if(classSupernova::$db->db_affected_rows())
53
+        if (classSupernova::$db->db_affected_rows())
54 54
         {
55 55
           msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_accept_title'],
56 56
             sprintf($lang['buddy_msg_accept_text'], $user['username']));
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
       break;
65 65
 
66 66
       case 'delete':
67
-        if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id'])
67
+        if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id'])
68 68
         {
69 69
           throw new exception('buddy_err_delete_alien', ERR_ERROR);
70 70
         }
71 71
 
72
-        if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship
72
+        if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship
73 73
         {
74 74
           $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID'];
75 75
 
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
           sn_db_transaction_commit();
81 81
           throw new exception('buddy_err_unfriend_none', ERR_NONE);
82 82
         }
83
-        elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting
83
+        elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting
84 84
         {
85 85
           doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;");
86 86
           sn_db_transaction_commit();
87 87
           throw new exception('buddy_err_delete_own', ERR_NONE);
88 88
         }
89
-        elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request
89
+        elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request
90 90
         {
91 91
           msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'],
92 92
             sprintf($lang['buddy_msg_deny_text'], $user['username']));
@@ -101,24 +101,24 @@  discard block
 block discarded – undo
101 101
 
102 102
   // New request?
103 103
   // Checking for user ID - in case if it was request from outside buddy system
104
-  if($new_friend_id = sys_get_param_id('request_user_id'))
104
+  if ($new_friend_id = sys_get_param_id('request_user_id'))
105 105
   {
106 106
     $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`');
107 107
   }
108
-  elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name'))
108
+  elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name'))
109 109
   {
110 110
     $new_friend_row = db_user_by_username($new_friend_name);
111 111
     $new_friend_name = db_escape($new_friend_name);
112 112
   }
113 113
 
114
-  if($new_friend_row['id'] == $user['id'])
114
+  if ($new_friend_row['id'] == $user['id'])
115 115
   {
116 116
     unset($new_friend_row);
117 117
     throw new exception('buddy_err_adding_self', ERR_ERROR);
118 118
   }
119 119
 
120 120
   // Checking for user name & request text - in case if it was request to adding new request
121
-  if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text')))
121
+  if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text')))
122 122
   {
123 123
     $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE
124 124
       (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']})
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
       (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']})
127 127
       LIMIT 1 FOR UPDATE;"
128 128
     , true);
129
-    if(isset($check_relation['BUDDY_ID']))
129
+    if (isset($check_relation['BUDDY_ID']))
130 130
     {
131 131
       throw new exception('buddy_err_adding_exists', ERR_WARNING);
132 132
     }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     throw new exception('buddy_err_adding_none', ERR_NONE);
140 140
   }
141 141
 }
142
-catch(exception $e)
142
+catch (exception $e)
143 143
 {
144 144
   $result[] = array(
145 145
     'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 sn_db_transaction_rollback();
151 151
 
152 152
 $query = db_buddy_list_by_user($user['id']);
153
-while($row = db_fetch($query))
153
+while ($row = db_fetch($query))
154 154
 {
155 155
   $row['BUDDY_REQUEST'] = HelperString::nl2br($row['BUDDY_REQUEST']);
156 156
 
Please login to merge, or discard this patch.
includes/functions/sys_maintenance.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     array('query' => "DELETE FROM `{{planets}}` WHERE `id_owner` = 0 AND `destruyed` < UNIX_TIMESTAMP();", 'result' => false, 'error' => '', 'affected_rows' => 0),
18 18
   );
19 19
 
20
-  foreach($queries as &$query)
20
+  foreach ($queries as &$query)
21 21
   {
22 22
     $query['result'] = doquery($query['query']);
23 23
     $query['error']  = classSupernova::$db->db_error();
24
-    $query['affected_rows']  = classSupernova::$db->db_affected_rows();
24
+    $query['affected_rows'] = classSupernova::$db->db_affected_rows();
25 25
   }
26 26
 
27 27
   return $queries;
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
   $recorded_run = strtotime($recorded_run);
54 54
 
55 55
   $prev_run_array = getdate($recorded_run);
56
-  $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']);
56
+  $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']);
57 57
   $today_array = getdate(SN_TIME_NOW);
58
-  $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']);
58
+  $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
59 59
   $scheduleList = explode(',', $scheduleList);
60 60
   array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
61 61
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
62 62
 
63 63
     $interval = $date_part_names_reverse[count($schedule['schedule_array'])];
64 64
 
65
-    foreach($prev_run_array as $index => $date_part) {
65
+    foreach ($prev_run_array as $index => $date_part) {
66 66
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
67 67
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
68 68
     }
69
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
69
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
70 70
       unset($schedule['array']['now']);
71 71
     }
72 72
 
73
-    foreach($schedule['array'] as $name => $array) {
73
+    foreach ($schedule['array'] as $name => $array) {
74 74
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
75 75
       $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
76 76
       $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
77 77
     }
78 78
 
79
-    foreach($schedule['string'] as $string) {
79
+    foreach ($schedule['string'] as $string) {
80 80
       $timestamp = strtotime($string);
81 81
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
82 82
     }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
   $prev_run = 0;
88 88
   $next_run = 0;
89
-  foreach($possible_schedules as $timestamp => $string_date) {
89
+  foreach ($possible_schedules as $timestamp => $string_date) {
90 90
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
91 91
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
92 92
   }
Please login to merge, or discard this patch.
classes/OldDbChangeSet.php 1 patch
Spacing   +24 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
    */
26 26
   public static function db_changeset_prepare_unit($unit_id, $unit_value, $user, $planet_id = null)
27 27
   {
28
-    if(!is_array($user))
28
+    if (!is_array($user))
29 29
     {
30 30
       // TODO - remove later
31 31
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: OldDbChangeSet::db_changeset_prepare_unit() - USER is not ARRAY</h1>');
32 32
       pdump(debug_backtrace());
33 33
       die('USER is not ARRAY');
34 34
     }
35
-    if(!isset($user['id']) || !$user['id'])
35
+    if (!isset($user['id']) || !$user['id'])
36 36
     {
37 37
       // TODO - remove later
38 38
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: OldDbChangeSet::db_changeset_prepare_unit() - USER[id] пустой</h1>');
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $location_id = $location_id ? $location_id : 'NULL';
48 48
 
49 49
     $temp = DBStaticUnit::db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id);
50
-    if(!empty($temp['unit_id']))
50
+    if (!empty($temp['unit_id']))
51 51
     {
52 52
       $db_changeset = array(
53 53
         'action' => SQL_OP_UPDATE,
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
   }
94 94
 
95 95
   public static function db_changeset_condition_compile(&$conditions, &$table_name = '') {
96
-    if(!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
96
+    if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
97 97
       $conditions[P_LOCATION] = LOC_NONE;
98
-      switch($table_name) {
98
+      switch ($table_name) {
99 99
         case 'users':
100 100
         case LOC_USER:
101 101
           $conditions[P_TABLE_NAME] = $table_name = 'users';
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
     }
118 118
 
119 119
     $conditions[P_FIELDS_STR] = '';
120
-    if($conditions['fields']) {
120
+    if ($conditions['fields']) {
121 121
       $fields = array();
122
-      foreach($conditions['fields'] as $field_name => $field_data) {
122
+      foreach ($conditions['fields'] as $field_name => $field_data) {
123 123
         $condition = "`{$field_name}` = ";
124 124
         $value = '';
125
-        if($field_data['delta']) {
125
+        if ($field_data['delta']) {
126 126
           $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
127
-        } elseif($field_data['set']) {
128
-          $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']);
127
+        } elseif ($field_data['set']) {
128
+          $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
129 129
         }
130 130
 
131
-        if($value) {
131
+        if ($value) {
132 132
           $fields[] = $condition . $value;
133 133
         }
134 134
       }
@@ -136,16 +136,14 @@  discard block
 block discarded – undo
136 136
     }
137 137
 
138 138
     $conditions[P_WHERE_STR] = '';
139
-    if(!empty($conditions['where'])) {
140
-      if($conditions[P_VERSION] == 1) {
139
+    if (!empty($conditions['where'])) {
140
+      if ($conditions[P_VERSION] == 1) {
141 141
         $the_conditions = array();
142
-        foreach($conditions['where'] as $field_id => $field_value) {
142
+        foreach ($conditions['where'] as $field_id => $field_value) {
143 143
           // Простое условие - $field_id = $field_value
144
-          if(is_string($field_id)) {
144
+          if (is_string($field_id)) {
145 145
             $field_value =
146
-              $field_value === null ? 'NULL' :
147
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
148
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
146
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value));
149 147
             $the_conditions[] = "`{$field_id}` = {$field_value}";
150 148
           } else {
151 149
             die('Неподдерживаемый тип условия');
@@ -157,7 +155,7 @@  discard block
 block discarded – undo
157 155
       $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions);
158 156
     }
159 157
 
160
-    switch($conditions['action']) {
158
+    switch ($conditions['action']) {
161 159
       case SQL_OP_DELETE: $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}"); break;
162 160
       case SQL_OP_UPDATE: $conditions[P_ACTION_STR] = ("UPDATE {{{$table_name}}} SET"); break;
163 161
       case SQL_OP_INSERT: $conditions[P_ACTION_STR] = ("INSERT INTO {{{$table_name}}} SET"); break;
@@ -176,17 +174,17 @@  discard block
 block discarded – undo
176 174
    */
177 175
   public static function db_changeset_apply($db_changeset) {
178 176
     $result = true;
179
-    if(!is_array($db_changeset) || empty($db_changeset)) return $result;
177
+    if (!is_array($db_changeset) || empty($db_changeset)) return $result;
180 178
 
181
-    foreach($db_changeset as $table_name => &$table_data) {
182
-      foreach($table_data as $record_id => &$conditions) {
179
+    foreach ($db_changeset as $table_name => &$table_data) {
180
+      foreach ($table_data as $record_id => &$conditions) {
183 181
         OldDbChangeSet::db_changeset_condition_compile($conditions, $table_name);
184 182
 
185
-        if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue;
186
-        if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице
183
+        if ($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue;
184
+        if ($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице
187 185
 
188
-        if($conditions[P_LOCATION] != LOC_NONE) {
189
-          switch($conditions['action'])
186
+        if ($conditions[P_LOCATION] != LOC_NONE) {
187
+          switch ($conditions['action'])
190 188
           {
191 189
             case SQL_OP_DELETE: $result = classSupernova::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result; break;
192 190
             case SQL_OP_UPDATE: $result = classSupernova::db_upd_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR], $conditions[P_FIELDS_STR]) && $result; break;
Please login to merge, or discard this patch.
classes/sn_module.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
     // Trying to load configuration from file
128 128
     $config_exists = false;
129 129
     // Конфигурация может лежать в config_path в манифеста или в корне модуля
130
-    if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
130
+    if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
131 131
       $config_exists = true;
132
-    } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) {
132
+    } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) {
133 133
       $config_exists = true;
134 134
     }
135 135
 
136
-    if($config_exists) {
136
+    if ($config_exists) {
137 137
       include($config_filename);
138 138
       $module_config_array = $class_module_name . '_config';
139 139
       $this->config = $$module_config_array;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
   }
145 145
 
146 146
   protected function __patch_menu(&$sn_menu_extra, &$menu_patch) {
147
-    if(isset($menu_patch) && is_array($menu_patch) && !empty($menu_patch)) {
148
-      foreach($menu_patch as $menu_item_name => $menu_item_data) {
147
+    if (isset($menu_patch) && is_array($menu_patch) && !empty($menu_patch)) {
148
+      foreach ($menu_patch as $menu_item_name => $menu_item_data) {
149 149
         $sn_menu_extra[$menu_item_name] = $menu_item_data;
150 150
       }
151 151
     }
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
   public function initialize() {
156 156
     // Checking module status - is it installed and active
157 157
     $this->check_status();
158
-    if(!$this->manifest['active']) {
158
+    if (!$this->manifest['active']) {
159 159
       return;
160 160
     }
161 161
 
162 162
     // Setting constants - if any
163
-    if(isset($this->manifest['constants']) && is_array($this->manifest['constants']) && !empty($this->manifest['constants'])) {
164
-      foreach($this->manifest['constants'] as $constant_name => $constant_value) {
163
+    if (isset($this->manifest['constants']) && is_array($this->manifest['constants']) && !empty($this->manifest['constants'])) {
164
+      foreach ($this->manifest['constants'] as $constant_name => $constant_value) {
165 165
         defined($constant_name) or define($constant_name, $constant_value);
166 166
       }
167 167
     }
@@ -172,34 +172,34 @@  discard block
 block discarded – undo
172 172
     // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays)
173 173
     // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]'
174 174
     $this->manifest['vars'] = $this->__assign_vars();
175
-    if(!empty($this->manifest['vars'])) {
175
+    if (!empty($this->manifest['vars'])) {
176 176
       $vars_assigned = array();
177
-      foreach($this->manifest['vars'] as $var_name => $var_value) {
177
+      foreach ($this->manifest['vars'] as $var_name => $var_value) {
178 178
         $sub_vars = explode('[', str_replace(']', '', $var_name));
179 179
         $var_name = $sub_vars[0];
180 180
 
181
-        if(!isset($vars_assigned[$var_name])) {
181
+        if (!isset($vars_assigned[$var_name])) {
182 182
           $vars_assigned[$var_name] = true;
183 183
           global $$var_name;
184 184
         }
185 185
 
186 186
         $pointer = &$$var_name;
187
-        if(($n = count($sub_vars)) > 1) {
188
-          for($i = 1; $i < $n; $i++) {
189
-            if(defined($sub_vars[$i])) {
187
+        if (($n = count($sub_vars)) > 1) {
188
+          for ($i = 1; $i < $n; $i++) {
189
+            if (defined($sub_vars[$i])) {
190 190
               $sub_vars[$i] = constant($sub_vars[$i]);
191 191
             }
192 192
 
193
-            if(!isset($pointer[$sub_vars[$i]]) && $i != $n) {
193
+            if (!isset($pointer[$sub_vars[$i]]) && $i != $n) {
194 194
               $pointer[$sub_vars[$i]] = array();
195 195
             }
196 196
             $pointer = &$pointer[$sub_vars[$i]];
197 197
           }
198 198
         }
199 199
 
200
-        if(!isset($pointer) || !is_array($pointer)) {
200
+        if (!isset($pointer) || !is_array($pointer)) {
201 201
           $pointer = $var_value;
202
-        } elseif(is_array($$var_name)) {
202
+        } elseif (is_array($$var_name)) {
203 203
           $pointer = array_merge_recursive_numeric($pointer, $var_value);
204 204
         }
205 205
       }
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
     global $functions;
210 210
     sn_sys_handler_add($functions, $this->manifest['functions'], $this);
211 211
 
212
-    foreach($this->functions as $functionName => $callableList) {
212
+    foreach ($this->functions as $functionName => $callableList) {
213 213
       !is_array($callableList) ? $callableList = [$callableList] : false;
214
-      foreach($callableList as $callable) {
214
+      foreach ($callableList as $callable) {
215 215
         sys_handler_add_one($functions, $functionName, $callable, static::class, '');
216 216
       }
217 217
     }
@@ -222,50 +222,50 @@  discard block
 block discarded – undo
222 222
     isset($this->manifest['menu_admin']) and $this->__patch_menu($sn_menu_admin_extra, $this->manifest['menu_admin']);
223 223
 
224 224
     global $sn_mvc;
225
-    foreach($sn_mvc as $handler_type => &$handler_data) {
225
+    foreach ($sn_mvc as $handler_type => &$handler_data) {
226 226
       sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type);
227 227
     }
228 228
 
229
-    if(isset($this->manifest['i18n']) && is_array($this->manifest['i18n']) && !empty($this->manifest['i18n'])) {
230
-      foreach($this->manifest['i18n'] as $i18n_page_name => &$i18n_file_list) {
231
-        foreach($i18n_file_list as &$i18n_file_data) {
232
-          if(is_array($i18n_file_data) && !$i18n_file_data['path']) {
229
+    if (isset($this->manifest['i18n']) && is_array($this->manifest['i18n']) && !empty($this->manifest['i18n'])) {
230
+      foreach ($this->manifest['i18n'] as $i18n_page_name => &$i18n_file_list) {
231
+        foreach ($i18n_file_list as &$i18n_file_data) {
232
+          if (is_array($i18n_file_data) && !$i18n_file_data['path']) {
233 233
             $i18n_file_data['path'] = $this->manifest['root_relative'];
234 234
           }
235 235
         }
236
-        if(!isset($sn_mvc['i18n'][$i18n_page_name])) {
236
+        if (!isset($sn_mvc['i18n'][$i18n_page_name])) {
237 237
           $sn_mvc['i18n'][$i18n_page_name] = array();
238 238
         }
239 239
         $sn_mvc['i18n'][$i18n_page_name] += $i18n_file_list;
240 240
       }
241 241
     }
242 242
 
243
-    if(!empty($this->manifest['javascript']) && is_array($this->manifest['javascript'])) {
244
-      foreach($this->manifest['javascript'] as $javascript_page_name => &$javascript_list) {
243
+    if (!empty($this->manifest['javascript']) && is_array($this->manifest['javascript'])) {
244
+      foreach ($this->manifest['javascript'] as $javascript_page_name => &$javascript_list) {
245 245
         !isset($sn_mvc['javascript'][$javascript_page_name]) ? $sn_mvc['javascript'][$javascript_page_name] = array() : false;
246
-        foreach($javascript_list as $script_name => &$script_content) {
246
+        foreach ($javascript_list as $script_name => &$script_content) {
247 247
           $sn_mvc['javascript'][$javascript_page_name][$script_name] = $script_content;
248 248
         }
249 249
       }
250 250
     }
251 251
 
252
-    if(!empty($this->manifest['css']) && is_array($this->manifest['css'])) {
253
-      foreach($this->manifest['css'] as $javascript_page_name => &$javascript_list) {
252
+    if (!empty($this->manifest['css']) && is_array($this->manifest['css'])) {
253
+      foreach ($this->manifest['css'] as $javascript_page_name => &$javascript_list) {
254 254
         !isset($sn_mvc['css'][$javascript_page_name]) ? $sn_mvc['css'][$javascript_page_name] = array() : false;
255
-        foreach($javascript_list as $script_name => &$script_content) {
255
+        foreach ($javascript_list as $script_name => &$script_content) {
256 256
           $sn_mvc['css'][$javascript_page_name][$script_name] = $script_content;
257 257
         }
258 258
       }
259 259
     }
260 260
 
261
-    if(!empty($this->manifest['navbar_prefix_button']) && is_array($this->manifest['navbar_prefix_button'])) {
262
-      foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
261
+    if (!empty($this->manifest['navbar_prefix_button']) && is_array($this->manifest['navbar_prefix_button'])) {
262
+      foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
263 263
         $sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative;
264 264
       }
265 265
     }
266 266
 
267
-    if(!empty($this->manifest['navbar_main_button']) && is_array($this->manifest['navbar_main_button'])) {
268
-      foreach($this->manifest['navbar_main_button'] as $button_image => $button_url_relative) {
267
+    if (!empty($this->manifest['navbar_main_button']) && is_array($this->manifest['navbar_main_button'])) {
268
+      foreach ($this->manifest['navbar_main_button'] as $button_image => $button_url_relative) {
269 269
         $sn_mvc['navbar_main_button'][$button_image] = $button_url_relative;
270 270
       }
271 271
     }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
    */
282 282
   protected function __mvcRegisterPagesOld($pages) {
283 283
     !is_array($this->manifest['mvc']['pages']) ? $this->manifest['mvc']['pages'] = array() : false;
284
-    if(is_array($pages) && !empty($pages)) {
284
+    if (is_array($pages) && !empty($pages)) {
285 285
       $this->manifest['mvc']['pages'] = array_merge($this->manifest['mvc']['pages'], $pages);
286 286
     }
287 287
   }
Please login to merge, or discard this patch.
admin/adm_payment.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 
19 19
 messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR);
20 20
 
21
-$template  = gettemplate('admin/adm_payment', true);
21
+$template = gettemplate('admin/adm_payment', true);
22 22
 
23 23
 $payer_list = array(
24 24
   -1 => $lang['adm_pay_filter_all'],
25 25
 );
26 26
 $query = doquery("SELECT payment_user_id, payment_user_name FROM `{{payment}}` GROUP BY payment_user_id ORDER BY payment_user_name");
27
-while($row = db_fetch($query)) {
27
+while ($row = db_fetch($query)) {
28 28
   $payer_list[$row['payment_user_id']] = '[' . $row['payment_user_id'] . '] ' . $row['payment_user_name'];
29 29
 }
30 30
 tpl_assign_select($template, 'payer', $payer_list);
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
   '' => $lang['adm_pay_filter_all'],
34 34
 );
35 35
 $query = doquery("SELECT distinct payment_module_name FROM `{{payment}}` ORDER BY payment_module_name");
36
-while($row = db_fetch($query)) {
36
+while ($row = db_fetch($query)) {
37 37
   $module_list[$row['payment_module_name']] = $row['payment_module_name'];
38 38
 }
39 39
 tpl_assign_select($template, 'module', $module_list);
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 
70 70
 
71 71
 //while($row = db_fetch($query)) {
72
-foreach($query as $row) {
72
+foreach ($query as $row) {
73 73
   $row2 = array();
74
-  foreach($row as $key => $value) {
74
+  foreach ($row as $key => $value) {
75 75
     $row2[strtoupper($key)] = $value;
76 76
   }
77 77
   $template->assign_block_vars('payment', $row2);
Please login to merge, or discard this patch.
classes/Account.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
     $this->secret_word = classSupernova::$sn_secret_word;
90 90
 
91 91
     $snTableNames = $this->db->schema()->getSnTables();
92
-    foreach($this->table_check as $table_name) {
93
-      if(empty($snTableNames[$table_name])) {
92
+    foreach ($this->table_check as $table_name) {
93
+      if (empty($snTableNames[$table_name])) {
94 94
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
95 95
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
96 96
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
    */
115 115
   // OK v4.6
116 116
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
117
-    if(!$this->password_check($old_password_unsafe)) {
117
+    if (!$this->password_check($old_password_unsafe)) {
118 118
       return false;
119 119
     }
120 120
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
   // OK v4.5
136 136
   public function assign_from_db_row($row) {
137 137
     $this->reset();
138
-    if(empty($row) || !is_array($row)) {
138
+    if (empty($row) || !is_array($row)) {
139 139
       return false;
140 140
     }
141 141
     $this->account_id = $row['account_id'];
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     $this->reset();
201 201
 
202 202
     $email_safe = $this->db->db_escape($email_unsafe);
203
-    if($email_safe) {
203
+    if ($email_safe) {
204 204
       $account_row = $this->db->doquery("SELECT * FROM {{account}} WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true);
205 205
 
206 206
       return $this->assign_from_db_row($account_row);
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
         `account_email` = LOWER('{$email_safe}'),
274 274
         `account_language` = '{$language_safe}'"
275 275
     );
276
-    if(!$result) {
276
+    if (!$result) {
277 277
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
278 278
     }
279 279
 
280
-    if(!($account_id = $this->db->db_insert_id())) {
280
+    if (!($account_id = $this->db->db_insert_id())) {
281 281
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
282 282
     }
283 283
 
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
       WHERE `account_id` = '{$account_id_safe}'"
308 308
     ) ? true : false;
309 309
 
310
-    if($result) {
310
+    if ($result) {
311 311
       $result = $this->db_get_by_id($this->account_id);
312 312
     }
313 313
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
   public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) {
397 397
     global $debug, $mm_change_legit, $config, $sn_module;
398 398
 
399
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
399
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
400 400
       $debug->error('Ошибка при попытке манипуляции с ММ');
401 401
       return false;
402 402
     }
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 
406 406
     $mm_change_legit = true;
407 407
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
408
-    if($already_changed) {
408
+    if ($already_changed) {
409 409
       $metamatter_total_delta = 0;
410 410
       $result = -1;
411 411
     } else {
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
           ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal} AND `account_immortal` IS NULL, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
419 419
         " WHERE `account_id` = {$account_id_safe}"
420 420
       );
421
-      if(!$result) {
421
+      if (!$result) {
422 422
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
423 423
       }
424 424
       $result = classSupernova::$db->db_affected_rows();
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
       $this->awardImmortal($metamatter, $config, $sn_module);
427 427
     }
428 428
 
429
-    if(empty(core_auth::$user['id'])) {
429
+    if (empty(core_auth::$user['id'])) {
430 430
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
431 431
       reset($user_list);
432 432
       $user_id_unsafe = key($user_list);
@@ -435,30 +435,30 @@  discard block
 block discarded – undo
435 435
     }
436 436
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
437 437
 
438
-    if(!$result) {
438
+    if (!$result) {
439 439
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
440 440
     }
441 441
 
442
-    if(!$already_changed) {
442
+    if (!$already_changed) {
443 443
       $this->account_metamatter += $metamatter;
444 444
       $this->account_metamatter_total += $metamatter_total_delta;
445 445
     }
446 446
 
447
-    if(is_array($comment)) {
447
+    if (is_array($comment)) {
448 448
       $comment = call_user_func_array('sprintf', $comment);
449 449
     }
450 450
 
451 451
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
452 452
 
453
-    if($metamatter > 0 && !empty($user_id_safe)) {
453
+    if ($metamatter > 0 && !empty($user_id_safe)) {
454 454
       $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true);
455
-      if($old_referral['id']) {
455
+      if ($old_referral['id']) {
456 456
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
457 457
         doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;");
458 458
         $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1;", '', true);
459 459
 
460 460
         $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0);
461
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
461
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) {
462 462
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
463 463
         }
464 464
       }
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
    * @throws Exception
475 475
    */
476 476
   public function cookieSet($rememberMe = false, $domain = null) {
477
-    if(!$this->is_exists) {
477
+    if (!$this->is_exists) {
478 478
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
479 479
     }
480 480
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
   // OK v4.1
494 494
   public function cookieClear($domain = null) {
495 495
     // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё
496
-    if(!empty($_COOKIE[$this->cookie_name_impersonate])) {
496
+    if (!empty($_COOKIE[$this->cookie_name_impersonate])) {
497 497
       sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain);
498 498
       sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain);
499 499
     } else {
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 
504 504
   public function cookieLogin(&$rememberMe = false) {
505 505
     // Пытаемся войти по куке
506
-    if(!empty($_COOKIE[$this->cookie_name])) {
507
-      if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
506
+    if (!empty($_COOKIE[$this->cookie_name])) {
507
+      if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) {
508 508
         list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]);
509 509
       } else {
510 510
         list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]);
511 511
       }
512 512
 
513
-      if(
513
+      if (
514 514
         $this->db_get_by_id($account_id_unsafe)
515 515
         && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted)
516 516
       ) {
Please login to merge, or discard this patch.
classes/Helpers/PagingRenderer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@
 block discarded – undo
114 114
       $this->addFirstLast();
115 115
     }
116 116
 
117
-    if(!empty($this->result)) {
117
+    if (!empty($this->result)) {
118 118
       $template = gettemplate('_paging');
119 119
       $template->assign_recursive([
120 120
         'PAGING_ROOT' => $this->rootUrl,
Please login to merge, or discard this patch.
classes/Helpers/URLHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
       }
20 20
     }
21 21
 
22
-    if(!empty($paramList)) {
22
+    if (!empty($paramList)) {
23 23
       $strParams = implode('&', $paramList);
24 24
     }
25 25
 
Please login to merge, or discard this patch.