Completed
Push — work-fleets ( 74a0d7...680ce4 )
by SuperNova.WS
05:04
created
simulator.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
   $sym_defender = $unpacked['D'];
23 23
   $sym_attacker = $unpacked['A'];
24
-}
25
-else
24
+} else
26 25
 {
27 26
   $sym_defender = array(0 => $sym_defender);
28 27
   $sym_attacker = array(1 => $sym_attacker);
@@ -56,8 +55,7 @@  discard block
 block discarded – undo
56 55
   $template = gettemplate('ube_combat_report', true);
57 56
   $template->assign_recursive($template_result);
58 57
   display($template, '', false, '', false, false, true);
59
-}
60
-else
58
+} else
61 59
 {
62 60
   $template = gettemplate('simulator', true);
63 61
   $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if(sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG'))
5
+if (sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG'))
6 6
 {
7 7
   define('BE_DEBUG', true);
8 8
 }
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 $sym_defender = $_POST['defender'] ? $_POST['defender'] : array();
15 15
 $sym_attacker = $_POST['attacker'] ? $_POST['attacker'] : array();
16 16
 
17
-if($replay)
17
+if ($replay)
18 18
 {
19 19
   $unpacked = sn_ube_simulator_decode_replay($replay);
20 20
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
   $sym_attacker = array(1 => $sym_attacker);
28 28
 }
29 29
 
30
-if($_POST['submit'] || $execute)
30
+if ($_POST['submit'] || $execute)
31 31
 {
32 32
   $replay = sn_ube_simulator_encode_replay($sym_defender, 'D');
33 33
   $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A');
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
   $template = gettemplate('simulator', true);
41 41
   $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL);
42 42
 
43
-  foreach($techs_and_officers as $tech_id)
43
+  foreach ($techs_and_officers as $tech_id)
44 44
   {
45
-    if(!$sym_attacker[1][$tech_id])
45
+    if (!$sym_attacker[1][$tech_id])
46 46
     {
47 47
       $sym_attacker[1][$tech_id] = mrc_get_level($user, false, $tech_id);
48 48
     }
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
     UNIT_GOVERNORS => array(MRC_FORTIFIER),
57 57
     UNIT_DEFENCE => sn_get_groups('defense_active'),
58 58
   );
59
-  foreach($show_groups as $unit_group_id => $unit_group)
59
+  foreach ($show_groups as $unit_group_id => $unit_group)
60 60
   {
61 61
     $template->assign_block_vars('simulator', array(
62 62
       'GROUP' => $unit_group_id,
63 63
       'NAME' => $lang['tech'][$unit_group_id],
64 64
     ));
65 65
 
66
-    foreach($unit_group as $unit_id)
66
+    foreach ($unit_group as $unit_id)
67 67
     {
68 68
       $tab++;
69 69
 
Please login to merge, or discard this patch.
login.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 
16 16
 include('includes/init.' . substr(strrchr(__FILE__, '.'), 1));
17 17
 // die();
18
-if($template_result[F_USER_IS_AUTHORIZED]) {
18
+if ($template_result[F_USER_IS_AUTHORIZED]) {
19 19
   sys_redirect('index' . DOT_PHP_EX);
20 20
 }
21 21
 lng_include('login');
Please login to merge, or discard this patch.
market.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 $newstock = $stock;
27 27
 $intError = MARKET_DEAL;
28 28
 
29
-switch($mode)
29
+switch ($mode)
30 30
 {
31 31
   case MARKET_RESOURCES: // Resource trader
32 32
     require('includes/includes/market_trader.inc');
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 }
83 83
 
84 84
 $message_id = sys_get_param_int('message');
85
-if($message_id != MARKET_NOTHING)
85
+if ($message_id != MARKET_NOTHING)
86 86
 {
87 87
   $template->assign_block_vars('result', array('MESSAGE' => $lang['eco_mrk_errors'][$message_id]));
88 88
 }
89 89
 
90
-if($message)
90
+if ($message)
91 91
 {
92 92
   $template->assign_block_vars('result', array('MESSAGE' => $message));
93 93
 }
Please login to merge, or discard this patch.
language/en/system.mo.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -961,7 +961,7 @@
 block discarded – undo
961 961
     REGISTER_ERROR_USERNAME_WRONG => 'Некорректное имя игрока',
962 962
     REGISTER_ERROR_ACCOUNT_NAME_EXISTS => 'Имя учётной записи уже занято. Попробуйте войти с этим именем и вашим паролем или воспользоваться сбросом пароля',
963 963
     REGISTER_ERROR_PASSWORD_INSECURE => 'Неправильный пароль. Пароль должен состоять минимум из ' . PASSWORD_LENGTH_MIN . ' символов',
964
-    REGISTER_ERROR_USERNAME_SHORT => 'Слишком короткое имя. Имя должно состоять минимум из ' . LOGIN_LENGTH_MIN. ' символов',
964
+    REGISTER_ERROR_USERNAME_SHORT => 'Слишком короткое имя. Имя должно состоять минимум из ' . LOGIN_LENGTH_MIN . ' символов',
965 965
     REGISTER_ERROR_PASSWORD_DIFFERENT => 'Пароль и проверочный пароль не совпадают. Проверьте правильность ввода',
966 966
     REGISTER_ERROR_EMAIL_EMPTY => 'Е-Мейл не может быть пустым',
967 967
     REGISTER_ERROR_EMAIL_WRONG => 'Введенный Е-Мейл не является допустимым адресом электронной почты. Проверьте написание Е-Мейла или используйте другой адрес почтового ящика',
Please login to merge, or discard this patch.
admin/planet_compensate.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,8 +115,7 @@
 block discarded – undo
115 115
     ));
116 116
 
117 117
     display($template, $lang['tech'][STRUC_MOON_GATE]);
118
-  }
119
-  else
118
+  } else
120 119
   {
121 120
     message($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10);
122 121
   }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('INSIDE'  , true);
3
-define('INSTALL' , false);
2
+define('INSIDE', true);
3
+define('INSTALL', false);
4 4
 define('IN_ADMIN', true);
5 5
 
6 6
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
7 7
 
8
-if($user['authlevel'] < 3)
8
+if ($user['authlevel'] < 3)
9 9
 {
10 10
   AdminMessage(classLocale::$lang['adm_err_denied']);
11 11
 }
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 $username_unsafe = sys_get_param_str_unsafe('username');
26 26
 $username = sys_get_param_escaped('username');
27 27
 
28
-if($galaxy_src)
28
+if ($galaxy_src)
29 29
 {
30 30
   sn_db_transaction_start();
31 31
   $errors = array();
@@ -35,41 +35,41 @@  discard block
 block discarded – undo
35 35
   $planet = sys_o_get_updated($owner, array('galaxy' => $galaxy_src, 'system' => $system_src, 'planet' => $planet_src, 'planet_type' => 1), SN_TIME_NOW);
36 36
   $que    = $planet['que'];
37 37
   $planet = $planet['planet'];
38
-  if(!$planet)
38
+  if (!$planet)
39 39
   {
40 40
     $errors[] = classLocale::$lang['adm_pl_comp_err_0'];
41 41
   }
42 42
 
43
-  if($planet['destruyed'])
43
+  if ($planet['destruyed'])
44 44
   {
45 45
     $errors[] = classLocale::$lang['adm_pl_comp_err_1'];
46 46
   }
47 47
 
48
-  if($planet['id_owner'] != $owner['id'] || !$username)
48
+  if ($planet['id_owner'] != $owner['id'] || !$username)
49 49
   {
50 50
     $errors[] = classLocale::$lang['adm_pl_comp_err_4'];
51 51
   }
52 52
 
53 53
   $destination = sys_o_get_updated($owner, array('galaxy' => $galaxy_dst, 'system' => $system_dst, 'planet' => $planet_dst, 'planet_type' => 1), SN_TIME_NOW);
54 54
   $destination = $destination['planet'];
55
-  if(!$destination)
55
+  if (!$destination)
56 56
   {
57 57
     $errors[] = classLocale::$lang['adm_pl_comp_err_2'];
58 58
   }
59 59
 
60
-  if($planet['id'] == $destination['id'])
60
+  if ($planet['id'] == $destination['id'])
61 61
   {
62 62
     $errors[] = classLocale::$lang['adm_pl_comp_err_5'];
63 63
   }
64 64
 
65
-  if($planet['id_owner'] != $destination['id_owner'])
65
+  if ($planet['id_owner'] != $destination['id_owner'])
66 66
   {
67 67
     $errors[] = classLocale::$lang['adm_pl_comp_err_3'];
68 68
   }
69 69
 
70
-  if(!empty($errors))
70
+  if (!empty($errors))
71 71
   {
72
-    foreach($errors as $error)
72
+    foreach ($errors as $error)
73 73
     {
74 74
       $template->assign_block_vars('error', array(
75 75
         'TEXT' => $error,
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
     killer_add_planet($planet);
84 84
 
85 85
     $moon = db_planet_by_gspt($galaxy_src, $system_src, $planet_src, PT_MOON, true);
86
-    if($moon)
86
+    if ($moon)
87 87
     {
88 88
       $moon = sys_o_get_updated($owner, $moon, SN_TIME_NOW);
89 89
       $moon = $moon['planet'];
90 90
       killer_add_planet($moon);
91 91
     }
92 92
 
93
-    foreach(sn_get_groups('resources_loot') as $resource_id)
93
+    foreach (sn_get_groups('resources_loot') as $resource_id)
94 94
     {
95 95
       $resource_name = pname_resource_name($resource_id);
96 96
       $template->assign_var("{$resource_name}_cost", $final_cost[$resource_id]);
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
       $template->assign_var("{$resource_name}_bonus", $final_cost[$resource_id]);
99 99
     }
100 100
 
101
-    if($_GET['btn_confirm'])
101
+    if ($_GET['btn_confirm'])
102 102
     {
103 103
       $time = SN_TIME_NOW + PERIOD_DAY;
104 104
 
105 105
       db_unit_list_delete($planet['id_owner'], LOC_PLANET, $planet['id']);
106 106
       db_planet_set_by_id($planet['id'], "id_owner = 0, destruyed = {$time}");
107
-      if($moon)
107
+      if ($moon)
108 108
       {
109 109
         db_unit_list_delete($planet['id_owner'], LOC_PLANET, $moon['id']);
110 110
         db_planet_set_by_id($moon['id'], "id_owner = 0, destruyed = {$time}");
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
   'username' => $username,
132 132
 ));
133 133
 
134
-display(parsetemplate($template, $parse), classLocale::$lang['adm_pl_comp_title'], false, '', true );
134
+display(parsetemplate($template, $parse), classLocale::$lang['adm_pl_comp_title'], false, '', true);
135 135
 
136 136
 function killer_add_planet($planet)
137 137
 {
@@ -146,34 +146,34 @@  discard block
 block discarded – undo
146 146
   }
147 147
   */
148 148
 
149
-  foreach(sn_get_groups('structures') as $unit_id)
149
+  foreach (sn_get_groups('structures') as $unit_id)
150 150
   {
151 151
     $build_level = mrc_get_level($user, $planet, $unit_id, true, true);
152
-    if($build_level > 0)
152
+    if ($build_level > 0)
153 153
     {
154 154
       $unit_cost = get_unit_param($unit_id, 'cost');
155 155
       $build_factor = $unit_cost['factor'] != 1 ? (1 - pow($unit_cost['factor'], $build_level)) / (1 - $unit_cost['factor']) : $unit_cost['factor'];
156
-      foreach($sn_group_resources_loot as $resource_id)
156
+      foreach ($sn_group_resources_loot as $resource_id)
157 157
       {
158 158
         $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $build_factor) : 0;
159 159
       }
160 160
     }
161 161
   }
162 162
 
163
-  foreach(sn_get_groups(array('defense', 'fleet')) as $unit_id)
163
+  foreach (sn_get_groups(array('defense', 'fleet')) as $unit_id)
164 164
   {
165 165
     $unit_count = mrc_get_level($user, $planet, $unit_id, true, true);
166
-    if($unit_count > 0)
166
+    if ($unit_count > 0)
167 167
     {
168 168
       $unit_cost = get_unit_param($unit_id, 'cost');
169
-      foreach($sn_group_resources_loot as $resource_id)
169
+      foreach ($sn_group_resources_loot as $resource_id)
170 170
       {
171 171
         $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $unit_count) : 0;
172 172
       }
173 173
     }
174 174
   }
175 175
 
176
-  foreach($sn_group_resources_loot as $resource_id)
176
+  foreach ($sn_group_resources_loot as $resource_id)
177 177
   {
178 178
     $final_cost[$resource_id] += floor(mrc_get_level($user, $planet, $resource_id, true, true));
179 179
   }
Please login to merge, or discard this patch.
includes/functions/flt_mission_missile.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,8 +115,7 @@
 block discarded – undo
115 115
     ));
116 116
 
117 117
     display($template, $lang['tech'][STRUC_MOON_GATE]);
118
-  }
119
-  else
118
+  } else
120 119
   {
121 120
     message($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10);
122 121
   }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
   $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
15 15
   $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100));
16
-  foreach($structures as $key => $structure)
16
+  foreach ($structures as $key => $structure)
17 17
   {
18 18
     $unit_info = get_unit_param($key);
19 19
     $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
   {
32 32
     //attacking only selected structure
33 33
     $damageDone = $structures[$targetedStructure][$damageTo];
34
-    $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
34
+    $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]);
35 35
     $structures[$targetedStructure][0] -= $structsDestroyed;
36
-    $MIPDamage -= $structsDestroyed*$damageDone;
36
+    $MIPDamage -= $structsDestroyed * $damageDone;
37 37
   }
38 38
   else
39 39
   {
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     do
45 45
     {
46 46
       // finding is there any structure that can be damaged with leftovers of $MIPDamage
47
-      foreach($can_be_damaged as $key => $unit_id)
47
+      foreach ($can_be_damaged as $key => $unit_id)
48 48
       {
49 49
 //debug($structures[$unit_id][0]);
50 50
 //debug($structures[$unit_id][$damageTo], $MIPDamage);
51
-        if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
51
+        if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
52 52
         {
53 53
           unset($can_be_damaged[$key]);
54 54
         }
55 55
       }
56
-      if(empty($can_be_damaged))
56
+      if (empty($can_be_damaged))
57 57
       {
58 58
         break;
59 59
       }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //debug($destroyed, 'Actually destroyed');
73 73
 
74 74
 //print('<hr>');
75
-    } while($MIPDamage > 0 && !empty($can_be_damaged));
75
+    } while ($MIPDamage > 0 && !empty($can_be_damaged));
76 76
 //debug($MIPDamage, 'MIPDamage left');
77 77
   }
78 78
 //debug($structures);//die();
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4;
88 88
   }
89 89
 
90
-  $return['structures'] = $structures;     // Structures left after attack
91
-  $return['metal']      = floor($metal);   // Metal scraps
90
+  $return['structures'] = $structures; // Structures left after attack
91
+  $return['metal']      = floor($metal); // Metal scraps
92 92
   $return['crystal']    = floor($crystal); // Crystal scraps
93 93
 
94 94
   return $return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
   $iraks = db_missile_list_by_arrival();
114 114
 
115
-  while($fleetRow = db_fetch($iraks)) {
115
+  while ($fleetRow = db_fetch($iraks)) {
116 116
     set_time_limit(15);
117 117
     $db_changeset = array();
118 118
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
     $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
130 130
 
131
-    if($target_planet_row['id']) {
131
+    if ($target_planet_row['id']) {
132 132
       $planetDefense = array();
133
-      foreach(sn_get_groups('defense_active') as $unit_id) {
133
+      foreach (sn_get_groups('defense_active') as $unit_id) {
134 134
         $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
135 135
       }
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $message = classLocale::$lang['mip_all_destroyed'];
142 142
         $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
143 143
       } else {
144
-        if($interceptors) {
144
+        if ($interceptors) {
145 145
           $message = sprintf(classLocale::$lang['mip_destroyed'], $interceptors);
146 146
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
147 147
         }
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 
150 150
         $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
151 151
 
152
-        foreach($attackResult['structures'] as $key => $structure) {
152
+        foreach ($attackResult['structures'] as $key => $structure) {
153 153
           $destroyed = $planetDefense[$key][0] - $structure[0];
154
-          if($destroyed) {
154
+          if ($destroyed) {
155 155
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($key, -$destroyed, $targetUser, $target_planet_row['id']);
156 156
 
157 157
             $message .= "&nbsp;&nbsp;{$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>";
158 158
           }
159 159
         }
160 160
 
161
-        if(!empty($message)) {
161
+        if (!empty($message)) {
162 162
           $message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>";
163 163
 
164 164
           db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
       empty($message) ? $message = classLocale::$lang['mip_no_defense'] : false;
179 179
       // empty($message) && ($message = $lang['mip_no_defense']);
180 180
 
181
-      msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
182
-      msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
181
+      msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message);
182
+      msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message);
183 183
     }
184 184
     db_missile_delete($fleetRow);
185 185
   }
Please login to merge, or discard this patch.
includes/functions/int_banner_create.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,8 +115,7 @@
 block discarded – undo
115 115
     ));
116 116
 
117 117
     display($template, $lang['tech'][STRUC_MOON_GATE]);
118
-  }
119
-  else
118
+  } else
120 119
   {
121 120
     message($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10);
122 121
   }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,29 +30,29 @@  discard block
 block discarded – undo
30 30
   }
31 31
   $size = getimagesize(SN_ROOT_PHYSICAL . $img_name);
32 32
   $im = imagecreatefrompng(SN_ROOT_PHYSICAL . $img_name);
33
-  $image = imagecreatetruecolor($size[0],$size[1]);
34
-  imagecopy($image,$im,0,0,0,0,$size[0],$size[1]);
33
+  $image = imagecreatetruecolor($size[0], $size[1]);
34
+  imagecopy($image, $im, 0, 0, 0, 0, $size[0], $size[1]);
35 35
   imagedestroy($im);
36 36
 
37 37
   // Colors
38 38
   $color = "FFFFFF";
39
-  $red = hexdec(substr($color,0,2));
40
-  $green = hexdec(substr($color,2,4));
41
-  $blue = hexdec(substr($color,4,6));
42
-  $select = imagecolorallocate($image,$red,$green,$blue);
39
+  $red = hexdec(substr($color, 0, 2));
40
+  $green = hexdec(substr($color, 2, 4));
41
+  $blue = hexdec(substr($color, 4, 6));
42
+  $select = imagecolorallocate($image, $red, $green, $blue);
43 43
   $txt_shadow = imagecolorallocatealpha($image, 255, 255, 255, 255);
44 44
   $txt_color = imagecolorallocatealpha($image, 255, 255, 255, 2);
45 45
   $txt_shadow2 = imagecolorallocatealpha($image, 255, 255, 255, 255);
46 46
   $txt_color2 = imagecolorallocatealpha($image, 255, 255, 255, 40);
47 47
 
48
-  $fonts = array (
48
+  $fonts = array(
49 49
     'userbar' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_userbar_font,
50 50
     'universe' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontUniverse,
51 51
     'raids' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontRaids,
52 52
     'info' => SN_ROOT_PHYSICAL . "design/fonts/" . $config->int_banner_fontInfo,
53 53
   );
54 54
 
55
-  if($id)
55
+  if ($id)
56 56
   {
57 57
     // Querys
58 58
     $user = db_user_by_id($id);
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
     $b_user = $user['username'];
63 63
     $b_ally = $user['ally_name'];
64 64
     $b_planet = $planet_row['name'];
65
-    $b_xyz = "[".$planet_row['galaxy'].":".$planet_row['system'].":".$planet_row['planet']."]";
66
-    $b_lvl = ($user['total_rank'] ? $user['total_rank'] : $config->users_amount) ."/{$config->users_amount}";
65
+    $b_xyz = "[" . $planet_row['galaxy'] . ":" . $planet_row['system'] . ":" . $planet_row['planet'] . "]";
66
+    $b_lvl = ($user['total_rank'] ? $user['total_rank'] : $config->users_amount) . "/{$config->users_amount}";
67 67
   }
68 68
   else
69 69
   {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
       imagettftext($image, 11, 0, 8, 26, $txt_shadow, $fonts['info'], $b_user);
86 86
       imagettftext($image, 11, 0, 6, 23, $txt_color, $fonts['info'], $b_user);
87 87
 
88
-      if($id)
88
+      if ($id)
89 89
       {
90 90
         // Player level - right-alligned
91 91
         $is = imagettfbbox(11, 0, $fonts['info'], $b_lvl);
@@ -94,37 +94,37 @@  discard block
 block discarded – undo
94 94
 
95 95
         // Ally name
96 96
         $is = imagettfbbox(9, 0, $fonts['info'], $b_ally);
97
-        imagettftext($image, 9, 0, 412-$is[2], 37, $txt_shadow, $fonts['info'], $b_ally);
98
-        imagettftext($image, 9, 0, 410-$is[2], 35, $txt_color, $fonts['info'], $b_ally);
97
+        imagettftext($image, 9, 0, 412 - $is[2], 37, $txt_shadow, $fonts['info'], $b_ally);
98
+        imagettftext($image, 9, 0, 410 - $is[2], 35, $txt_color, $fonts['info'], $b_ally);
99 99
 
100 100
         // Player b_planet
101
-        imagettftext($image, 6, 0, 8, 10, $txt_shadow2, $fonts['raids'], $b_planet." ".$b_xyz);
102
-        imagettftext($image, 6, 0, 6, 9, $txt_color2, $fonts['raids'], $b_planet." ".$b_xyz);
101
+        imagettftext($image, 6, 0, 8, 10, $txt_shadow2, $fonts['raids'], $b_planet . " " . $b_xyz);
102
+        imagettftext($image, 6, 0, 6, 9, $txt_color2, $fonts['raids'], $b_planet . " " . $b_xyz);
103 103
 
104 104
         //StatPoint
105
-        $b_points = classLocale::$lang['ov_points'].": ".pretty_number($user['total_points']);
105
+        $b_points = classLocale::$lang['ov_points'] . ": " . pretty_number($user['total_points']);
106 106
         $is = imagettfbbox(8, 0, $fonts['info'], $b_points);
107
-        imagettftext($image, 8, 0, 412-$is[2], 11, $txt_shadow, $fonts['info'], $b_points);
108
-        imagettftext($image, 8, 0, 410-$is[2], 9, $txt_color, $fonts['info'], $b_points);
107
+        imagettftext($image, 8, 0, 412 - $is[2], 11, $txt_shadow, $fonts['info'], $b_points);
108
+        imagettftext($image, 8, 0, 410 - $is[2], 9, $txt_color, $fonts['info'], $b_points);
109 109
 
110 110
         //Raids Total
111 111
         imagettftext($image, 6, 0, 8, 37, $txt_shadow2, $fonts['raids'], classLocale::$lang['NumberOfRaids']);
112 112
         imagettftext($image, 6, 0, 6, 35, $txt_color2, $fonts['raids'], classLocale::$lang['NumberOfRaids']);
113
-        $b_points = ": ".pretty_number($user['raids']);
113
+        $b_points = ": " . pretty_number($user['raids']);
114 114
         imagettftext($image, 6, 0, 61, 37, $txt_shadow2, $fonts['raids'], $b_points);
115 115
         imagettftext($image, 6, 0, 59, 35, $txt_color2, $fonts['raids'], $b_points);
116 116
 
117 117
         //Raids Won
118 118
         imagettftext($image, 6, 0, 8, 47, $txt_shadow2, $fonts['raids'], classLocale::$lang['RaidsWin']);
119 119
         imagettftext($image, 6, 0, 6, 45, $txt_color2, $fonts['raids'], classLocale::$lang['RaidsWin']);
120
-        $b_points = ": ".pretty_number($user['raidswin']);
120
+        $b_points = ": " . pretty_number($user['raidswin']);
121 121
         imagettftext($image, 6, 0, 61, 47, $txt_shadow2, $fonts['raids'], $b_points);
122 122
         imagettftext($image, 6, 0, 59, 45, $txt_color2, $fonts['raids'], $b_points);
123 123
 
124 124
         //Raids Lost
125 125
         imagettftext($image, 6, 0, 8, 57, $txt_shadow2, $fonts['raids'], classLocale::$lang['RaidsLoose']);
126 126
         imagettftext($image, 6, 0, 6, 55, $txt_color2, $fonts['raids'], classLocale::$lang['RaidsLoose']);
127
-        $b_points = ": ".pretty_number($user['raidsloose']);
127
+        $b_points = ": " . pretty_number($user['raidsloose']);
128 128
         imagettftext($image, 6, 0, 61, 57, $txt_shadow2, $fonts['raids'], $b_points);
129 129
         imagettftext($image, 6, 0, 59, 55, $txt_color2, $fonts['raids'], $b_points);
130 130
       }
@@ -137,25 +137,25 @@  discard block
 block discarded – undo
137 137
       $is = imagettfbbox(9, 0, $fonts['userbar'], $b_univ);
138 138
       $is = $size[0] - $is[2] - 2;
139 139
       imagettftext($image, 9, 0, $is, $size[1] - 3, $txt_shadow, $fonts['userbar'], $b_univ);
140
-      imagettftext($image, 9, 0, $is-1, $size[1] - 5, $txt_color, $fonts['userbar'], $b_univ);
141
-      imagettftext($image, 22, 0, $is-8, $size[1], $txt_color, $fonts['userbar'], '/');
140
+      imagettftext($image, 9, 0, $is - 1, $size[1] - 5, $txt_color, $fonts['userbar'], $b_univ);
141
+      imagettftext($image, 22, 0, $is - 8, $size[1], $txt_color, $fonts['userbar'], '/');
142 142
 
143 143
       // Player name
144 144
       imagettftext($image, 9, 0, 4, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_user);
145 145
       imagettftext($image, 9, 0, 2, $size[1] - 6, $txt_color, $fonts['userbar'], $b_user);
146 146
 
147
-      if($id)
147
+      if ($id)
148 148
       {
149 149
         // Player level - right-alligned
150 150
         $isp = imagettfbbox(9, 0, $fonts['userbar'], $b_lvl);
151
-        imagettftext($image, 9, 0, $is-$isp[2] - 10, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_lvl);
152
-        imagettftext($image, 9, 0, $is-$isp[2] - 10 - 1, $size[1] - 4 - 1, $txt_color, $fonts['userbar'], $b_lvl);
151
+        imagettftext($image, 9, 0, $is - $isp[2] - 10, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_lvl);
152
+        imagettftext($image, 9, 0, $is - $isp[2] - 10 - 1, $size[1] - 4 - 1, $txt_color, $fonts['userbar'], $b_lvl);
153 153
       }
154 154
   }
155 155
 
156 156
   //And now convert it back to PNG-8
157
-  $im_result = imagecreate($size[0],$size[1]);
158
-  imagecopy($im_result,$image,0,0,0,0,$size[0],$size[1]);
157
+  $im_result = imagecreate($size[0], $size[1]);
158
+  imagecopy($im_result, $image, 0, 0, 0, 0, $size[0], $size[1]);
159 159
   imagedestroy($image);
160 160
   //And save it
161 161
   $imagetypes = imagetypes();
Please login to merge, or discard this patch.
includes/classes/Bonus.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
   /**
25 25
    * Добавляет юнит к списку бонусов
26 26
    *
27
-   * @param $unit_id
27
+   * @param integer $unit_id
28 28
    * @param $unit_level
29 29
    */
30 30
   public function add_unit_by_snid($unit_id, $unit_level) {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
    *
68 68
    * Выдает финальный бонус в виде множителя
69 69
    *
70
-   * @param string|int $param - ИД бонуса
70
+   * @param string $param - ИД бонуса
71 71
    *
72 72
    * @return float
73 73
    */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
    * @param $unit_level
29 29
    */
30 30
   public function add_unit_by_snid($unit_id, $unit_level) {
31
-    if(!$unit_level) {
31
+    if (!$unit_level) {
32 32
       return;
33 33
     }
34 34
 
35
-    foreach(static::$_bonus_group as $param_name => $unit_list) {
36
-      if(!empty($unit_list[$unit_id])) {
35
+    foreach (static::$_bonus_group as $param_name => $unit_list) {
36
+      if (!empty($unit_list[$unit_id])) {
37 37
         // Простейший вариант - мультипликатор по базе
38 38
         // Общий мультипликатор добавляется в конец
39 39
         $this->grants[$param_name][$unit_id] = $unit_level;
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 //    $this->grants[$param_name][$unit_id] = $unit_level * get_unit_param($unit_id, P_BONUS_VALUE) / 100;;
83 83
     $value_add = floatval($base_value);
84 84
     $cumulative = 1.0; // Для случая BONUS_PERCENT
85
-    if(!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
-      foreach($this->grants[$param] as $unit_id => $unit_level) {
85
+    if (!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
+      foreach ($this->grants[$param] as $unit_id => $unit_level) {
87 87
         $unit_bonus = 0;
88
-        if($unit_id < 0) {
88
+        if ($unit_id < 0) {
89 89
           // Meta-unit - leave as is
90 90
         } else {
91 91
           // TODO - Подумать, что будет при смешивании разных бонусов и как этого избежать
92 92
           $bonus_value = get_unit_param($unit_id, P_BONUS_VALUE);
93 93
           $bonus_type = get_unit_param($unit_id, P_BONUS_TYPE);
94
-          switch($bonus_type) {
94
+          switch ($bonus_type) {
95 95
             case BONUS_PERCENT:
96 96
               $unit_bonus = $unit_level * $bonus_value / 100;
97 97
               $cumulative += $unit_bonus;
Please login to merge, or discard this patch.
includes/classes/supernova.php 3 patches
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
    *   <p>null - транзакция НЕ должна быть запущена</p>
324 324
    *   <p>true - транзакция должна быть запущена - для совместимости с $for_update</p>
325 325
    *   <p>false - всё равно - для совместимости с $for_update</p>
326
-   * @return bool Текущий статус транзакции
326
+   * @return null|boolean Текущий статус транзакции
327 327
    */
328 328
   public static function db_transaction_check($status = null) {
329 329
     $error_msg = false;
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
   /**
400 400
    * Блокирует указанные таблицу/список таблиц
401 401
    *
402
-   * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
402
+   * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов
403 403
    * <p>string - название таблицы для блокировки</p>
404 404
    * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p>
405 405
    */
@@ -587,6 +587,9 @@  discard block
 block discarded – undo
587 587
     return $result;
588 588
   }
589 589
 
590
+  /**
591
+   * @param integer $location_type
592
+   */
590 593
   public static function db_ins_field_set($location_type, $field_set, $serialize = false) {
591 594
     // TODO multiinsert
592 595
     !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false;
@@ -809,7 +812,7 @@  discard block
 block discarded – undo
809 812
    * @param     $location_type
810 813
    * @param     $location_id
811 814
    *
812
-   * @return array|bool
815
+   * @return boolean
813 816
    */
814 817
   public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id)
815 818
   {
Please login to merge, or discard this patch.
Spacing   +103 added lines, -105 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
 
204 204
   public static function log_file($message, $spaces = 0) {
205
-    if(self::$debug) {
205
+    if (self::$debug) {
206 206
       self::$debug->log_file($message, $spaces);
207 207
     }
208 208
   }
@@ -214,16 +214,16 @@  discard block
 block discarded – undo
214 214
   // Перепаковывает массив на заданную глубину, убирая поля с null
215 215
   public static function array_repack(&$array, $level = 0) {
216 216
     // TODO $lock_table не нужна тут
217
-    if(!is_array($array)) {
217
+    if (!is_array($array)) {
218 218
       return;
219 219
     }
220 220
 
221
-    foreach($array as $key => &$value) {
222
-      if($value === null) {
221
+    foreach ($array as $key => &$value) {
222
+      if ($value === null) {
223 223
         unset($array[$key]);
224
-      } elseif($level > 0 && is_array($value)) {
224
+      } elseif ($level > 0 && is_array($value)) {
225 225
         static::array_repack($value, $level - 1);
226
-        if(empty($value)) {
226
+        if (empty($value)) {
227 227
           unset($array[$key]);
228 228
         }
229 229
       }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
   // TODO Вынести в отдельный объект
235 235
   public static function cache_repack($location_type, $record_id = 0) {
236 236
     // Если есть $user_id - проверяем, а надо ли перепаковывать?
237
-    if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) {
237
+    if ($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) {
238 238
       return;
239 239
     }
240 240
 
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 
246 246
   public static function cache_clear($location_type, $hard = true) {
247 247
     //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />");
248
-    if($hard && !empty(static::$data[$location_type])) {
248
+    if ($hard && !empty(static::$data[$location_type])) {
249 249
       // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях
250
-      array_walk(static::$data[$location_type], function (&$item) { $item = null; });
250
+      array_walk(static::$data[$location_type], function(&$item) { $item = null; });
251 251
     }
252 252
     static::$locator[$location_type] = array();
253 253
     static::$queries[$location_type] = array();
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
   public static function cache_clear_all($hard = true) {
258 258
     //print('<br />CACHE CLEAR ALL<br />');
259
-    if($hard) {
259
+    if ($hard) {
260 260
       static::$data = array();
261 261
       static::cache_lock_unset_all();
262 262
     }
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
   */
286 286
   public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) {
287 287
     // нет идентификатора - выход
288
-    if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) {
288
+    if (!($record_id = $record[static::$location_info[$location_type][P_ID]])) {
289 289
       return;
290 290
     }
291 291
 
292 292
     $in_transaction = static::db_transaction_check(false);
293
-    if(
293
+    if (
294 294
       $force_overwrite
295 295
       ||
296 296
       // Не заменяются заблокированные записи во время транзакции
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
       !static::cache_isset($location_type, $record_id)
301 301
     ) {
302 302
       static::$data[$location_type][$record_id] = $record;
303
-      if($in_transaction && !$skip_lock) {
303
+      if ($in_transaction && !$skip_lock) {
304 304
         static::cache_lock_set($location_type, $record_id);
305 305
       }
306 306
     }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 
309 309
   public static function cache_unset($cache_id, $safe_record_id) {
310 310
     // $record_id должен быть проверен заранее !
311
-    if(isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
311
+    if (isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) {
312 312
       // Выставляем запись в null
313 313
       static::$data[$cache_id][$safe_record_id] = null;
314 314
       // Очищаем кэш мягко - что бы удалить очистить связанные данные - кэш локаций и кэш запоросов и всё, что потребуется впредь
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
   }
326 326
 
327 327
   public static function cache_lock_unset($location_type, $record_id) {
328
-    if(isset(static::$locks[$location_type][$record_id])) {
328
+    if (isset(static::$locks[$location_type][$record_id])) {
329 329
       unset(static::$locks[$location_type][$record_id]);
330 330
     }
331 331
 
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
    */
360 360
   public static function db_transaction_check($status = null) {
361 361
     $error_msg = false;
362
-    if($status && !static::$db_in_transaction) {
362
+    if ($status && !static::$db_in_transaction) {
363 363
       $error_msg = 'No transaction started for current operation';
364
-    } elseif($status === null && static::$db_in_transaction) {
364
+    } elseif ($status === null && static::$db_in_transaction) {
365 365
       $error_msg = 'Transaction is already started';
366 366
     }
367 367
 
368
-    if($error_msg) {
368
+    if ($error_msg) {
369 369
       // TODO - Убрать позже
370 370
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>');
371 371
       $backtrace = debug_backtrace();
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
     static::$transaction_id++;
388 388
     doquery('START TRANSACTION');
389 389
 
390
-    if($config->db_manual_lock_enabled) {
390
+    if ($config->db_manual_lock_enabled) {
391 391
       $config->db_loadItem('var_db_manually_locked');
392 392
       $config->db_saveItem('var_db_manually_locked', SN_TIME_SQL);
393 393
     }
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
   public static function db_transaction_commit() {
405 405
     static::db_transaction_check(true);
406 406
 
407
-    if(!empty(static::$delayed_changset)) {
407
+    if (!empty(static::$delayed_changset)) {
408 408
       static::db_changeset_apply(static::$delayed_changset, true);
409 409
       // pdump(static::$delayed_changset);
410 410
     }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
   public static function db_transaction_rollback() {
422 422
     // static::db_transaction_check(true); // TODO - вообще-то тут тоже надо проверять есть ли транзакция
423
-    if(!empty(static::$delayed_changset)) {
423
+    if (!empty(static::$delayed_changset)) {
424 424
       static::db_changeset_revert();
425 425
     }
426 426
     static::$delayed_changset = array();
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
    */
444 444
   public static function db_lock_tables($tables) {
445 445
     $tables = is_array($tables) ? $tables : array($tables => '');
446
-    foreach($tables as $table_name => $condition) {
446
+    foreach ($tables as $table_name => $condition) {
447 447
       self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : ''));
448 448
     }
449 449
   }
@@ -486,17 +486,17 @@  discard block
 block discarded – undo
486 486
     //pdump($filter, 'Выбираем ' . $location_type);
487 487
     $query_cache = &static::$queries[$location_type][$filter];
488 488
 
489
-    if(!isset($query_cache) || $query_cache === null) {
489
+    if (!isset($query_cache) || $query_cache === null) {
490 490
       // pdump($filter, 'Кэш пустой, начинаем возню');
491 491
       $location_info = &static::$location_info[$location_type];
492 492
       $id_field = $location_info[P_ID];
493 493
       $query_cache = array();
494 494
 
495
-      if(static::db_transaction_check(false)) {
495
+      if (static::db_transaction_check(false)) {
496 496
         //pdump($filter, 'Транзакция - блокируем ' . $location_type);
497 497
         // Проходим по всем родителям данной записи
498 498
         // foreach($location_info[P_OWNER_INFO] as $owner_location_type => $owner_data)
499
-        foreach($location_info[P_OWNER_INFO] as $owner_data) {
499
+        foreach ($location_info[P_OWNER_INFO] as $owner_data) {
500 500
           $owner_location_type = $owner_data[P_LOCATION];
501 501
           //pdump($filter, 'Транзакция - блокируем родителя ' . $owner_location_type);
502 502
           $parent_id_list = array();
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
             ($fetch ? ' LIMIT 1' : ''), false, true);
510 510
 
511 511
           //pdump($q, 'Запрос блокировки');
512
-          while($row = db_fetch($query)) {
512
+          while ($row = db_fetch($query)) {
513 513
             // Исключаем из списка родительских ИД уже заблокированные записи
514
-            if(!static::cache_lock_get($owner_location_type, $row['parent_id'])) {
514
+            if (!static::cache_lock_get($owner_location_type, $row['parent_id'])) {
515 515
               $parent_id_list[$row['parent_id']] = $row['parent_id'];
516 516
             }
517 517
           }
518 518
           //pdump($parent_id_list, 'Выбраны родители');
519 519
           // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы
520
-          if($indexes_str = implode(',', $parent_id_list)) {
520
+          if ($indexes_str = implode(',', $parent_id_list)) {
521 521
             //pdump($indexes_str, '$indexes_str');
522 522
             $parent_id_field = static::$location_info[$owner_location_type][P_ID];
523 523
             static::db_get_record_list($owner_location_type,
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
         "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" .
533 533
         (($filter = trim($filter)) ? " WHERE {$filter}" : '')
534 534
       );
535
-      while($row = db_fetch($query)) {
535
+      while ($row = db_fetch($query)) {
536 536
         // static::db_get_record_by_id($location_type, $row[$id_field]);
537 537
         static::cache_set($location_type, $row[$id_field], $row);
538 538
         $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]];
@@ -540,14 +540,14 @@  discard block
 block discarded – undo
540 540
       }
541 541
     }
542 542
 
543
-    if($no_return) {
543
+    if ($no_return) {
544 544
       return true;
545 545
     } else {
546 546
       $result = false;
547
-      if(is_array($query_cache)) {
548
-        foreach($query_cache as $key => $value) {
547
+      if (is_array($query_cache)) {
548
+        foreach ($query_cache as $key => $value) {
549 549
           $result[$key] = $value;
550
-          if($fetch) {
550
+          if ($fetch) {
551 551
             break;
552 552
           }
553 553
         }
@@ -566,16 +566,16 @@  discard block
 block discarded – undo
566 566
    */
567 567
   public static function db_upd_record_by_id($location_type, $record_id, $set) {
568 568
     //if(!($record_id = intval($record_id)) || !($set = trim($set))) return false;
569
-    if(!($record_id = idval($record_id)) || !($set = trim($set))) {
569
+    if (!($record_id = idval($record_id)) || !($set = trim($set))) {
570 570
       return false;
571 571
     }
572 572
 
573 573
     $location_info = &static::$location_info[$location_type];
574 574
     $id_field = $location_info[P_ID];
575 575
     $table_name = $location_info[P_TABLE_NAME];
576
-    if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
576
+    if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
577 577
     {
578
-      if(static::$db->db_affected_rows()) {
578
+      if (static::$db->db_affected_rows()) {
579 579
         // Обновляем данные только если ряд был затронут
580 580
         // TODO - переделать под работу со структурированными $set
581 581
 
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
   }
592 592
 
593 593
   public static function db_upd_record_list($location_type, $condition, $set) {
594
-    if(!($set = trim($set))) {
594
+    if (!($set = trim($set))) {
595 595
       return false;
596 596
     }
597 597
 
@@ -600,9 +600,9 @@  discard block
 block discarded – undo
600 600
 
601 601
 //static::db_get_record_list($location_type, $condition, false, true);
602 602
 
603
-    if($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
603
+    if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) {
604 604
 
605
-      if(static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
605
+      if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут
606 606
         // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью
607 607
         // TODO - когда будет структурированный $condition и $set - перепаковывать данные
608 608
         static::cache_clear($location_type, true);
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
   public static function db_ins_record($location_type, $set) {
622 622
     $set = trim($set);
623 623
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
624
-    if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
625
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
624
+    if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
625
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
626 626
       {
627 627
         $record_id = db_insert_id();
628 628
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
     $fields = implode(',', array_keys($field_set));
645 645
 
646 646
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
647
-    if($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) {
648
-      if(static::$db->db_affected_rows()) {
647
+    if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) {
648
+      if (static::$db->db_affected_rows()) {
649 649
         // Обновляем данные только если ряд был затронут
650 650
         $record_id = db_insert_id();
651 651
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
@@ -661,15 +661,15 @@  discard block
 block discarded – undo
661 661
 
662 662
   public static function db_del_record_by_id($location_type, $safe_record_id) {
663 663
     // if(!($safe_record_id = intval($safe_record_id))) return false;
664
-    if(!($safe_record_id = idval($safe_record_id))) {
664
+    if (!($safe_record_id = idval($safe_record_id))) {
665 665
       return false;
666 666
     }
667 667
 
668 668
     $location_info = &static::$location_info[$location_type];
669 669
     $id_field = $location_info[P_ID];
670 670
     $table_name = $location_info[P_TABLE_NAME];
671
-    if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) {
672
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
671
+    if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) {
672
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
673 673
       {
674 674
         static::cache_unset($location_type, $safe_record_id);
675 675
       }
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
   }
680 680
 
681 681
   public static function db_del_record_list($location_type, $condition) {
682
-    if(!($condition = trim($condition))) {
682
+    if (!($condition = trim($condition))) {
683 683
       return false;
684 684
     }
685 685
 
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 
689 689
 //static::db_get_record_list($location_type, $condition, false, true);
690 690
 
691
-    if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) {
692
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
691
+    if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) {
692
+      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
693 693
       {
694 694
         // Обнуление кэша, потому что непонятно, что поменялось
695 695
         // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям
@@ -736,20 +736,20 @@  discard block
 block discarded – undo
736 736
 
737 737
   public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) {
738 738
     // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ?
739
-    if(!($username_unsafe = trim($username_unsafe))) {
739
+    if (!($username_unsafe = trim($username_unsafe))) {
740 740
       return false;
741 741
     }
742 742
 
743 743
     $user = null;
744
-    if(is_array(static::$data[LOC_USER])) {
745
-      foreach(static::$data[LOC_USER] as $user_id => $user_data) {
746
-        if(is_array($user_data) && isset($user_data['username'])) {
744
+    if (is_array(static::$data[LOC_USER])) {
745
+      foreach (static::$data[LOC_USER] as $user_id => $user_data) {
746
+        if (is_array($user_data) && isset($user_data['username'])) {
747 747
           // проверяем поле
748 748
           // TODO Возможно есть смысл всегда искать по strtolower - но может игрок захочет переименоваться с другим регистром? Проверить!
749
-          if((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) {
749
+          if ((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) {
750 750
             // $user_as_ally = intval($user_data['user_as_ally']);
751 751
             $user_as_ally = idval($user_data['user_as_ally']);
752
-            if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) {
752
+            if ($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) {
753 753
               $user = $user_data;
754 754
               break;
755 755
             }
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
       }
759 759
     }
760 760
 
761
-    if($user === null) {
761
+    if ($user === null) {
762 762
       // Вытаскиваем запись
763 763
       $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет
764 764
 
@@ -776,17 +776,17 @@  discard block
 block discarded – undo
776 776
 
777 777
   // UNUSED
778 778
   public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') {
779
-    if(!($email_unsafe = strtolower(trim($email_unsafe)))) {
779
+    if (!($email_unsafe = strtolower(trim($email_unsafe)))) {
780 780
       return false;
781 781
     }
782 782
 
783 783
     $user = null;
784 784
     // TODO переделать на индексы
785
-    if(is_array(static::$data[LOC_USER])) {
786
-      foreach(static::$data[LOC_USER] as $user_id => $user_data) {
787
-        if(is_array($user_data) && isset($user_data['email_2'])) {
785
+    if (is_array(static::$data[LOC_USER])) {
786
+      foreach (static::$data[LOC_USER] as $user_id => $user_data) {
787
+        if (is_array($user_data) && isset($user_data['email_2'])) {
788 788
           // проверяем поле
789
-          if(strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
789
+          if (strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) {
790 790
             $user = $user_data;
791 791
             break;
792 792
           }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
       }
795 795
     }
796 796
 
797
-    if($user === null) {
797
+    if ($user === null) {
798 798
       // Вытаскиваем запись
799 799
       $email_safe = db_escape($email_unsafe);
800 800
       $user = static::db_query(
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
     $user = null;
814 814
     // TODO переделать на индексы
815 815
 
816
-    if($user === null && !empty($where_safe)) {
816
+    if ($user === null && !empty($where_safe)) {
817 817
       // Вытаскиваем запись
818 818
       $user = static::db_query("SELECT * FROM {{users}} WHERE {$where_safe}", true);
819 819
 
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
   public static function db_get_unit_by_id($unit_id, $for_update = false, $fields = '*') {
836 836
     // TODO запихивать в $data[LOC_LOCATION][$location_type][$location_id]
837 837
     $unit = static::db_get_record_by_id(LOC_UNIT, $unit_id, $for_update, $fields);
838
-    if(is_array($unit)) {
838
+    if (is_array($unit)) {
839 839
       static::$locator[LOC_UNIT][$unit['unit_location_type']][$unit['unit_location_id']][$unit['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
840 840
     }
841 841
 
@@ -851,15 +851,15 @@  discard block
 block discarded – undo
851 851
    */
852 852
   public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id) {
853 853
     //if(!($location_type = intval($location_type)) || !($location_id = intval($location_id))) return false;
854
-    if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) {
854
+    if (!($location_type = idval($location_type)) || !($location_id = idval($location_id))) {
855 855
       return false;
856 856
     }
857 857
 
858 858
     $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id];
859
-    if(!isset($query_cache)) {
859
+    if (!isset($query_cache)) {
860 860
       $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions());
861
-      if(is_array($got_data)) {
862
-        foreach($got_data as $unit_id => $unit_data) {
861
+      if (is_array($got_data)) {
862
+        foreach ($got_data as $unit_id => $unit_data) {
863 863
           // static::$data[LOC_LOCATION][$location_type][$location_id][$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
864 864
           $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id];
865 865
         }
@@ -867,8 +867,8 @@  discard block
 block discarded – undo
867 867
     }
868 868
 
869 869
     $result = false;
870
-    if(is_array($query_cache)) {
871
-      foreach($query_cache as $key => $value) {
870
+    if (is_array($query_cache)) {
871
+      foreach ($query_cache as $key => $value) {
872 872
         $result[$key] = $value;
873 873
       }
874 874
     }
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
    *
904 904
    */
905 905
   public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false) {
906
-    if(!$user_id) {
906
+    if (!$user_id) {
907 907
       pdump(debug_backtrace());
908 908
       die('No user_id for que_get_que()');
909 909
     }
@@ -913,16 +913,16 @@  discard block
 block discarded – undo
913 913
     $query = array();
914 914
 
915 915
     // if($user_id = intval($user_id))
916
-    if($user_id = idval($user_id)) {
916
+    if ($user_id = idval($user_id)) {
917 917
       $query[] = "`que_player_id` = {$user_id}";
918 918
     }
919 919
 
920
-    if($que_type == QUE_RESEARCH || $planet_id === null) {
920
+    if ($que_type == QUE_RESEARCH || $planet_id === null) {
921 921
       $query[] = "`que_planet_id` IS NULL";
922
-    } elseif($planet_id) {
922
+    } elseif ($planet_id) {
923 923
       $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")";
924 924
     }
925
-    if($que_type) {
925
+    if ($que_type) {
926 926
       $query[] = "`que_type` = {$que_type}";
927 927
     }
928 928
 
@@ -955,13 +955,13 @@  discard block
 block discarded – undo
955 955
 
956 956
 
957 957
   public static function db_changeset_prepare_unit($unit_id, $unit_value, $user, $planet_id = null) {
958
-    if(!is_array($user)) {
958
+    if (!is_array($user)) {
959 959
       // TODO - remove later
960 960
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>');
961 961
       pdump(debug_backtrace());
962 962
       die('USER is not ARRAY');
963 963
     }
964
-    if(!isset($user['id']) || !$user['id']) {
964
+    if (!isset($user['id']) || !$user['id']) {
965 965
       // TODO - remove later
966 966
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>');
967 967
       pdump($user);
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 
977 977
     $db_changeset = array();
978 978
     $temp = db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
979
-    if($temp['unit_id']) {
979
+    if ($temp['unit_id']) {
980 980
       $db_changeset = array(
981 981
         'action'  => SQL_OP_UPDATE,
982 982
         P_VERSION => 1,
@@ -1045,9 +1045,9 @@  discard block
 block discarded – undo
1045 1045
   }
1046 1046
 
1047 1047
   public function db_changeset_condition_compile(&$conditions, &$table_name = '') {
1048
-    if(!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
1048
+    if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) {
1049 1049
       $conditions[P_LOCATION] = LOC_NONE;
1050
-      switch($table_name) {
1050
+      switch ($table_name) {
1051 1051
         case 'users':
1052 1052
         case LOC_USER:
1053 1053
           $conditions[P_TABLE_NAME] = $table_name = 'users';
@@ -1069,18 +1069,18 @@  discard block
 block discarded – undo
1069 1069
     }
1070 1070
 
1071 1071
     $conditions[P_FIELDS_STR] = '';
1072
-    if($conditions['fields']) {
1072
+    if ($conditions['fields']) {
1073 1073
       $fields = array();
1074
-      foreach($conditions['fields'] as $field_name => $field_data) {
1074
+      foreach ($conditions['fields'] as $field_name => $field_data) {
1075 1075
         $condition = "`{$field_name}` = ";
1076 1076
         $value = '';
1077
-        if($field_data['delta']) {
1077
+        if ($field_data['delta']) {
1078 1078
           $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
1079
-        } elseif($field_data['set']) {
1079
+        } elseif ($field_data['set']) {
1080 1080
           $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
1081 1081
         }
1082 1082
 
1083
-        if($value) {
1083
+        if ($value) {
1084 1084
           $fields[] = $condition . $value;
1085 1085
         }
1086 1086
       }
@@ -1088,16 +1088,14 @@  discard block
 block discarded – undo
1088 1088
     }
1089 1089
 
1090 1090
     $conditions[P_WHERE_STR] = '';
1091
-    if(!empty($conditions['where'])) {
1092
-      if($conditions[P_VERSION] == 1) {
1091
+    if (!empty($conditions['where'])) {
1092
+      if ($conditions[P_VERSION] == 1) {
1093 1093
         $the_conditions = array();
1094
-        foreach($conditions['where'] as $field_id => $field_value) {
1094
+        foreach ($conditions['where'] as $field_id => $field_value) {
1095 1095
           // Простое условие - $field_id = $field_value
1096
-          if(is_string($field_id)) {
1096
+          if (is_string($field_id)) {
1097 1097
             $field_value =
1098
-              $field_value === null ? 'NULL' :
1099
-                (is_string($field_value) ? "'" . db_escape($field_value) . "'" :
1100
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
1098
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value));
1101 1099
             $the_conditions[] = "`{$field_id}` = {$field_value}";
1102 1100
           } else {
1103 1101
             die('Неподдерживаемый тип условия');
@@ -1114,7 +1112,7 @@  discard block
 block discarded – undo
1114 1112
       $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions);
1115 1113
     }
1116 1114
 
1117
-    switch($conditions['action']) {
1115
+    switch ($conditions['action']) {
1118 1116
       case SQL_OP_DELETE:
1119 1117
         $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}");
1120 1118
       break;
@@ -1134,11 +1132,11 @@  discard block
 block discarded – undo
1134 1132
 
1135 1133
   public static function db_changeset_apply($db_changeset, $flush_delayed = false) {
1136 1134
     $result = true;
1137
-    if(!is_array($db_changeset) || empty($db_changeset)) {
1135
+    if (!is_array($db_changeset) || empty($db_changeset)) {
1138 1136
       return $result;
1139 1137
     }
1140 1138
 
1141
-    foreach($db_changeset as $table_name => &$table_data) {
1139
+    foreach ($db_changeset as $table_name => &$table_data) {
1142 1140
       // TODO - delayed changeset
1143 1141
       /*
1144 1142
       if(static::db_transaction_check(false) && !$flush_delayed && ($table_name == 'users' || $table_name == 'planets' || $table_name == 'unit'))
@@ -1147,19 +1145,19 @@  discard block
 block discarded – undo
1147 1145
         continue;
1148 1146
       }
1149 1147
       */
1150
-      foreach($table_data as $record_id => &$conditions) {
1148
+      foreach ($table_data as $record_id => &$conditions) {
1151 1149
         static::db_changeset_condition_compile($conditions, $table_name);
1152 1150
 
1153
-        if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) {
1151
+        if ($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) {
1154 1152
           continue;
1155 1153
         }
1156
-        if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) {
1154
+        if ($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) {
1157 1155
           continue;
1158 1156
         } // Защита от случайного удаления всех данных в таблице
1159 1157
 
1160
-        if($conditions[P_LOCATION] != LOC_NONE) {
1158
+        if ($conditions[P_LOCATION] != LOC_NONE) {
1161 1159
           //die('spec ops supernova.php line 928 Добавить работу с кэшем юнитов итд');
1162
-          switch($conditions['action']) {
1160
+          switch ($conditions['action']) {
1163 1161
             case SQL_OP_DELETE:
1164 1162
               $result = self::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result;
1165 1163
             break;
@@ -1241,13 +1239,13 @@  discard block
 block discarded – undo
1241 1239
   public static function init_0_prepare() {
1242 1240
     // Отключаем magic_quotes
1243 1241
     ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false;
1244
-    if(@get_magic_quotes_gpc()) {
1242
+    if (@get_magic_quotes_gpc()) {
1245 1243
       $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
1246
-      array_walk_recursive($gpcr, function (&$value, $key) {
1244
+      array_walk_recursive($gpcr, function(&$value, $key) {
1247 1245
         $value = stripslashes($value);
1248 1246
       });
1249 1247
     }
1250
-    if(function_exists('set_magic_quotes_runtime')) {
1248
+    if (function_exists('set_magic_quotes_runtime')) {
1251 1249
       @set_magic_quotes_runtime(0);
1252 1250
       @ini_set('magic_quotes_runtime', 0);
1253 1251
       @ini_set('magic_quotes_sybase', 0);
@@ -1325,7 +1323,7 @@  discard block
 block discarded – undo
1325 1323
   }
1326 1324
 
1327 1325
   public static function init_debug_state() {
1328
-    if($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) {
1326
+    if ($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) {
1329 1327
       define('BE_DEBUG', true);
1330 1328
     }
1331 1329
 // define('DEBUG_SQL_ONLINE', true); // Полный дамп запросов в рил-тайме. Подойдет любое значение
@@ -1337,7 +1335,7 @@  discard block
 block discarded – undo
1337 1335
     defined('DEBUG_SQL_ERROR') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false;
1338 1336
     defined('DEBUG_SQL_COMMENT_LONG') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false;
1339 1337
 
1340
-    if(defined('BE_DEBUG') || static::$config->debug) {
1338
+    if (defined('BE_DEBUG') || static::$config->debug) {
1341 1339
       @define('BE_DEBUG', true);
1342 1340
       @ini_set('display_errors', 1);
1343 1341
       @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -573,7 +573,8 @@  discard block
 block discarded – undo
573 573
     $location_info = &static::$location_info[$location_type];
574 574
     $id_field = $location_info[P_ID];
575 575
     $table_name = $location_info[P_TABLE_NAME];
576
-    if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
576
+    if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) {
577
+      // TODO Как-то вернуть может быть LIMIT 1 ?
577 578
     {
578 579
       if(static::$db->db_affected_rows()) {
579 580
         // Обновляем данные только если ряд был затронут
@@ -581,6 +582,7 @@  discard block
 block discarded – undo
581 582
 
582 583
         // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее
583 584
         static::$data[$location_type][$record_id] = null;
585
+    }
584 586
         // Вытаскиваем обновленную запись
585 587
         static::db_get_record_by_id($location_type, $record_id);
586 588
         static::cache_clear($location_type, false); // Мягкий сброс - только $queries
@@ -622,9 +624,11 @@  discard block
 block discarded – undo
622 624
     $set = trim($set);
623 625
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
624 626
     if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
625
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
627
+      if(static::$db->db_affected_rows()) {
628
+        // Обновляем данные только если ряд был затронут
626 629
       {
627 630
         $record_id = db_insert_id();
631
+      }
628 632
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
629 633
         $result = static::db_get_record_by_id($location_type, $record_id);
630 634
         // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего
@@ -669,10 +673,12 @@  discard block
 block discarded – undo
669 673
     $id_field = $location_info[P_ID];
670 674
     $table_name = $location_info[P_TABLE_NAME];
671 675
     if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) {
672
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
676
+      if(static::$db->db_affected_rows()) {
677
+        // Обновляем данные только если ряд был затронут
673 678
       {
674 679
         static::cache_unset($location_type, $safe_record_id);
675 680
       }
681
+      }
676 682
     }
677 683
 
678 684
     return $result;
@@ -689,12 +695,14 @@  discard block
 block discarded – undo
689 695
 //static::db_get_record_list($location_type, $condition, false, true);
690 696
 
691 697
     if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) {
692
-      if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
698
+      if(static::$db->db_affected_rows()) {
699
+        // Обновляем данные только если ряд был затронут
693 700
       {
694 701
         // Обнуление кэша, потому что непонятно, что поменялось
695 702
         // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям
696 703
         static::cache_clear($location_type);
697 704
       }
705
+      }
698 706
     }
699 707
 
700 708
     return $result;
Please login to merge, or discard this patch.