Completed
Push — work-fleets ( 070fe2...d6c2ef )
by SuperNova.WS
05:43
created
admin/adm_payment.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
16 16
 
17
-if($user['authlevel'] < 3) {
17
+if ($user['authlevel'] < 3) {
18 18
   AdminMessage($lang['adm_err_denied']);
19 19
 }
20 20
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 );
26 26
 
27 27
 $query = db_payment_list_payers();
28
-while($row = db_fetch($query)) {
28
+while ($row = db_fetch($query)) {
29 29
   $payer_list[$row['payment_user_id']] = '[' . $row['payment_user_id'] . '] ' . $row['payment_user_name'];
30 30
 }
31 31
 tpl_assign_select($template, 'payer', $payer_list);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 );
36 36
 
37 37
 $query = db_payment_list_modules();
38
-while($row = db_fetch($query)) {
38
+while ($row = db_fetch($query)) {
39 39
   $module_list[$row['payment_module_name']] = $row['payment_module_name'];
40 40
 }
41 41
 tpl_assign_select($template, 'module', $module_list);
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
 $query = db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module);
52 52
 
53
-while($row = db_fetch($query)) {
53
+while ($row = db_fetch($query)) {
54 54
   $row2 = array();
55
-  foreach($row as $key => $value) {
55
+  foreach ($row as $key => $value) {
56 56
     $row2[strtoupper($key)] = $value;
57 57
   }
58 58
   $template->assign_block_vars('payment', $row2);
Please login to merge, or discard this patch.
notes.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,34 +15,34 @@  discard block
 block discarded – undo
15 15
 $template = gettemplate('notes', true);
16 16
 
17 17
 $result = array();
18
-if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) {
18
+if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) {
19 19
   $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]);
20 20
 }
21 21
 
22 22
 $note_id_edit = sys_get_param_id('note_id_edit');
23
-if(sys_get_param('note_delete')) {
23
+if (sys_get_param('note_delete')) {
24 24
   try {
25 25
     $not = '';
26 26
     $query_where = '';
27
-    switch(sys_get_param_str('note_delete_range')) {
27
+    switch (sys_get_param_str('note_delete_range')) {
28 28
       case 'all':
29 29
       break;
30 30
 
31 31
       case 'marked_not':
32 32
         $not = 'NOT';
33 33
       case 'marked':
34
-        if(!is_array($notes_marked = sys_get_param('note'))) {
34
+        if (!is_array($notes_marked = sys_get_param('note'))) {
35 35
           throw new Exception('note_err_none_selected', ERR_WARNING);
36 36
         }
37 37
 
38 38
         $notes_marked_filtered = array();
39
-        foreach($notes_marked as $note_id => $note_select) {
40
-          if($note_select == 'on' && $note_id = idval($note_id)) {
39
+        foreach ($notes_marked as $note_id => $note_select) {
40
+          if ($note_select == 'on' && $note_id = idval($note_id)) {
41 41
             $notes_marked_filtered[] = $note_id;
42 42
           }
43 43
         }
44 44
 
45
-        if(empty($notes_marked_filtered)) {
45
+        if (empty($notes_marked_filtered)) {
46 46
           throw new Exception('note_err_none_selected', ERR_WARNING);
47 47
         }
48 48
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     db_note_list_delete($user, $query_where);
60 60
     sn_db_transaction_commit();
61 61
     throw new Exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
62
-  } catch(Exception $e) {
62
+  } catch (Exception $e) {
63 63
     $note_id_edit = 0;
64 64
     sn_db_transaction_rollback();
65 65
     $result[] = array(
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
       'MESSAGE' => $lang[$e->getMessage()],
68 68
     );
69 69
   }
70
-} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
70
+} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
71 71
   $note_title == db_escape($lang['note_new_title']) ? $note_title = '' : false;
72 72
   ($note_text = sys_get_param_str('note_text')) == db_escape($lang['note_new_text']) ? $note_text = '' : false;
73 73
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     $note_system = max(0, min(sys_get_param_id('note_system'), $config->game_maxSystem));
77 77
     $note_planet = max(0, min(sys_get_param_id('note_planet'), $config->game_maxPlanet + 1));
78 78
 
79
-    if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
79
+    if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
80 80
       throw new exception('note_err_note_empty', ERR_WARNING);
81 81
     }
82 82
 
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
     $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0;
86 86
 
87 87
     sn_db_transaction_start();
88
-    if($note_id_edit) {
88
+    if ($note_id_edit) {
89 89
       $check_note_id = db_note_get_id_and_owner($note_id_edit);
90
-      if(!$check_note_id) {
90
+      if (!$check_note_id) {
91 91
         throw new Exception('note_err_note_not_found', ERR_ERROR);
92 92
       }
93 93
     }
94 94
 
95
-    if($note_id_edit) {
96
-      if($check_note_id['owner'] != $user['id']) {
95
+    if ($note_id_edit) {
96
+      if ($check_note_id['owner'] != $user['id']) {
97 97
         throw new Exception('note_err_owner_wrong', ERR_ERROR);
98 98
       }
99 99
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     sn_db_transaction_commit();
106 106
     sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added'));
107 107
 //    throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
108
-  } catch(Exception $e) {
108
+  } catch (Exception $e) {
109 109
     $note_id_edit = 0;
110 110
     sn_db_transaction_rollback();
111 111
     $result[] = array(
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
   }
116 116
 }
117 117
 
118
-if(!$note_id_edit) {
118
+if (!$note_id_edit) {
119 119
   note_assign($template, array(
120 120
     'id'          => 0,
121 121
     'time'        => SN_TIME_NOW,
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 
129 129
 $note_exist = false;
130 130
 $notes_query = db_note_list_by_owner($user['id']);
131
-while($note_row = db_fetch($notes_query)) {
131
+while ($note_row = db_fetch($notes_query)) {
132 132
   note_assign($template, $note_row);
133 133
   $note_exist = $note_exist || $note_row['id'] == $note_id_edit;
134 134
 }
135 135
 $note_id_edit = $note_exist ? $note_id_edit : 0;
136 136
 
137
-foreach($note_priority_classes as $note_priority_id => $note_priority_class) {
137
+foreach ($note_priority_classes as $note_priority_id => $note_priority_class) {
138 138
   $template->assign_block_vars('note_priority', array(
139 139
     'ID'    => $note_priority_id,
140 140
     'CLASS' => $note_priority_classes[$note_priority_id],
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
   ));
143 143
 }
144 144
 
145
-foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
145
+foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
146 146
   $template->assign_block_vars('planet_type', array(
147 147
     'ID'   => $planet_type_id,
148 148
     'TEXT' => $planet_type_string,
149 149
   ));
150 150
 }
151 151
 
152
-foreach($result as $result_data) {
152
+foreach ($result as $result_data) {
153 153
   $template->assign_block_vars('result', $result_data);
154 154
 }
155 155
 
Please login to merge, or discard this patch.
flotenajax.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
   $target_mission = sys_get_param_int('mission');
38 38
   $sn_group_missions = sn_get_groups('missions');
39
-  if(empty($sn_group_missions[$target_mission]['AJAX'])) {
39
+  if (empty($sn_group_missions[$target_mission]['AJAX'])) {
40 40
     die($lang['gs_c00']);
41 41
   }
42 42
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
   );
52 52
   // fleet_ajax now can send fleets only to existing planets/moons
53 53
   // TODO - sending colonization and expeditions in 1 click
54
-  if(!uni_coordinates_valid($target_coord)) {
54
+  if (!uni_coordinates_valid($target_coord)) {
55 55
     die($lang['gs_c02']);
56 56
   }
57 57
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
   // TODO - DEADLOCK CAN BE HERE!!!! We should lock SOURCE and TARGET owners in one query
64 64
   $target_row = db_planet_by_vector($target_coord);
65
-  if(empty($target_row)) {
65
+  if (empty($target_row)) {
66 66
     $target_row = $target_coord;
67 67
     $target_row['id_owner'] = 0;
68 68
     // If fleet destination is PT_DEBRIS - then it's actually destination is PT_PLANET // TODO - REMOVE! Debris should be valid DESTINATION planet_type!
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
   }
74 74
 
75 75
   $fleet_array = array();
76
-  switch($target_mission) {
76
+  switch ($target_mission) {
77 77
     case MT_SPY:
78 78
       $fleet_array[SHIP_SPY] = min(mrc_get_level($user, $planetrow, SHIP_SPY), abs(classSupernova::$user_options[PLAYER_OPTION_FLEET_SPY_DEFAULT]));
79 79
       $unit_group = 'flt_spies';
80 80
     break;
81 81
 
82 82
     case MT_RECYCLE:
83
-      foreach(sn_get_groups('flt_recyclers') as $unit_id) {
84
-        if($unit_count = mrc_get_level($user, $planetrow, $unit_id)) {
83
+      foreach (sn_get_groups('flt_recyclers') as $unit_id) {
84
+        if ($unit_count = mrc_get_level($user, $planetrow, $unit_id)) {
85 85
           $fleet_array[$unit_id] = $unit_count;
86 86
         }
87 87
       }
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
       'target_structure' => $target_structure = sys_get_param_int('structures'),
107 107
     )
108 108
   );
109
-  if($isAttackAllowed != ATTACK_ALLOWED) {
109
+  if ($isAttackAllowed != ATTACK_ALLOWED) {
110 110
     die($lang['fl_attack_error'][$isAttackAllowed]);
111 111
   }
112 112
 
113 113
   $db_changeset = array();
114
-  foreach($fleet_array as $unit_id => $unit_count) {
114
+  foreach ($fleet_array as $unit_id => $unit_count) {
115 115
     $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$unit_count, $user, $planetrow);
116 116
   }
117 117
 
118
-  if($target_mission == MT_MISSILE) {
118
+  if ($target_mission == MT_MISSILE) {
119 119
     $distance = abs($target_coord['system'] - $planetrow['system']);
120 120
     $duration = round((30 + (60 * $distance)) / flt_server_flight_speed_multiplier());
121 121
     $arrival = SN_TIME_NOW + $duration;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   } else {
126 126
     $travel_data = flt_travel_data($user, $planetrow, $target_coord, $fleet_array, 10);
127 127
 
128
-    if($planetrow['deuterium'] < $travel_data['consumption']) {
128
+    if ($planetrow['deuterium'] < $travel_data['consumption']) {
129 129
       die($lang['gs_c13']);
130 130
     }
131 131
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
   $ships_sent = array();
148 148
   $ships_sent_js = 0;
149
-  foreach($fleet_array as $unit_id => $unit_count) {
149
+  foreach ($fleet_array as $unit_id => $unit_count) {
150 150
     $ships_sent[] = "{$unit_count} {$lang['tech'][$unit_id]}";
151 151
     $ships_sent_js += mrc_get_level($user, $planetrow, $unit_id, false, true);
152 152
   }
Please login to merge, or discard this patch.
metamatter.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 include_once('common.' . substr(strrchr(__FILE__, '.'), 1));
10 10
 
11
-if(!sn_module_get_active_count('payment')) {
11
+if (!sn_module_get_active_count('payment')) {
12 12
   sys_redirect('dark_matter.php');
13 13
   die();
14 14
 }
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 
66 66
 // Таблица скидок
67 67
 $prev_discount = 0;
68
-if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
69
-  foreach(sn_module_payment::$bonus_table as $sum => $discount) {
70
-    if($discount && $discount != $prev_discount) {
68
+if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
69
+  foreach (sn_module_payment::$bonus_table as $sum => $discount) {
70
+    if ($discount && $discount != $prev_discount) {
71 71
       $template->assign_block_vars('discount', array(
72 72
         'SUM'          => $sum,
73 73
         'DISCOUNT'     => $discount * 100,
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 }
81 81
 
82 82
 // Результат платежа
83
-if($payment_id = sys_get_param_id('payment_id')) {
83
+if ($payment_id = sys_get_param_id('payment_id')) {
84 84
   $payment = db_payment_get($payment_id);
85
-  if($payment && $payment['payment_user_id'] == $user['id']) {
86
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
85
+  if ($payment && $payment['payment_user_id'] == $user['id']) {
86
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
87 87
       $template->assign_block_vars('result', array('MESSAGE' => sprintf($lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained'])));
88 88
     }
89
-    if($payment['payment_status'] == PAYMENT_STATUS_NONE) {
89
+    if ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
90 90
       $template->assign_block_vars('result', array(
91 91
         'MESSAGE' => sprintf($lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']),
92 92
         'STATUS'  => 1,
93 93
       ));
94 94
     }
95
-    if($payment['payment_test']) {
95
+    if ($payment['payment_test']) {
96 96
       $template->assign_block_vars('result', array(
97 97
         'MESSAGE' => sprintf($lang['pay_msg_mm_purchase_test']),
98 98
         'STATUS'  => -1,
@@ -107,28 +107,28 @@  discard block
 block discarded – undo
107 107
   'metamatter' => sys_get_param_float('metamatter'),
108 108
 );
109 109
 
110
-if(!$request['metamatter']) {
110
+if (!$request['metamatter']) {
111 111
   unset($_POST);
112 112
 }
113 113
 
114 114
 $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null));
115
-array_walk($payment_methods_available, function (&$value, $index) {
115
+array_walk($payment_methods_available, function(&$value, $index) {
116 116
   $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value;
117 117
 });
118 118
 
119 119
 // pdump($payment_methods_available);
120 120
 $payment_module_valid = false;
121 121
 $payment_module = sys_get_param_str('payment_module');
122
-foreach($sn_module_list['payment'] as $module_name => $module) {
123
-  if(!is_object($module) || !$module->manifest['active']) {
122
+foreach ($sn_module_list['payment'] as $module_name => $module) {
123
+  if (!is_object($module) || !$module->manifest['active']) {
124 124
     continue;
125 125
   }
126 126
 
127 127
   lng_include($module_name, $module->manifest['root_relative']);
128 128
 
129
-  foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
130
-    foreach($available_methods as $payment_method => $payment_currency) {
131
-      if(isset($module->manifest['payment_method'][$payment_method])) {
129
+  foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
130
+    foreach ($available_methods as $payment_method => $payment_currency) {
131
+      if (isset($module->manifest['payment_method'][$payment_method])) {
132 132
         $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method];
133 133
       }
134 134
     }
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 
140 140
 global $template_result;
141 141
 // Доступные платежные методы
142
-foreach($payment_methods_available as $payment_type_id => $payment_methods) {
143
-  if(empty($payment_methods)) {
142
+foreach ($payment_methods_available as $payment_type_id => $payment_methods) {
143
+  if (empty($payment_methods)) {
144 144
     continue;
145 145
   }
146 146
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
     'ID'   => $payment_type_id,
149 149
     'NAME' => $lang['pay_methods'][$payment_type_id],
150 150
   );
151
-  foreach($payment_methods as $payment_method_id => $module_list) {
152
-    if(empty($module_list)) {
151
+  foreach ($payment_methods as $payment_method_id => $module_list) {
152
+    if (empty($module_list)) {
153 153
       continue;
154 154
     }
155 155
     $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array(
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
       'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']),
161 161
       'BUTTON'     => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']),
162 162
     );
163
-    foreach($module_list as $payment_module_name => $payment_module_method_details) {
163
+    foreach ($module_list as $payment_module_name => $payment_module_method_details) {
164 164
       $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array(
165 165
         'MODULE' => $payment_module_name,
166 166
       );
167 167
     }
168 168
   }
169 169
 
170
-  if(empty($template_result['.']['payment'][$payment_type_id]['.'])) {
170
+  if (empty($template_result['.']['payment'][$payment_type_id]['.'])) {
171 171
     unset($template_result['.']['payment'][$payment_type_id]);
172 172
   }
173 173
 }
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
 $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name]));
181 181
 
182 182
 // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it
183
-if($payment_module_valid) {
183
+if ($payment_module_valid) {
184 184
   // $payment_module = $payment_module; // Really - do nothing
185
-} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
185
+} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
186 186
   reset($payment_methods_available[$payment_type_selected][$payment_method_selected]);
187 187
   $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]);
188
-} elseif(count($sn_module_list['payment']) == 1) {
188
+} elseif (count($sn_module_list['payment']) == 1) {
189 189
   $payment_module = $module_name;
190 190
 } else {
191 191
   $payment_module = '';
192 192
 }
193 193
 
194
-if($payment_type_selected && $payment_method_selected) {
195
-  foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
194
+if ($payment_type_selected && $payment_method_selected) {
195
+  foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
196 196
     $template->assign_block_vars('payment_module', array(
197 197
       'ID'          => $module_name,
198 198
       'NAME'        => $lang["module_{$module_name}_name"],
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
   }
202 202
 }
203 203
 
204
-foreach($lang['pay_currency_list'] as $key => $value) {
204
+foreach ($lang['pay_currency_list'] as $key => $value) {
205 205
   $course = get_exchange_rate($key);
206 206
 //  if(!$course || $key == $config->payment_currency_default) {
207
-  if(!$course) {
207
+  if (!$course) {
208 208
     continue;
209 209
   }
210 210
   $template->assign_block_vars('exchange', array(
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
   ));
220 220
 }
221 221
 
222
-if($request['metamatter'] && $payment_module) {
222
+if ($request['metamatter'] && $payment_module) {
223 223
   try {
224 224
     // Any possible errors about generating paylink should be raised in module!
225 225
     $pay_link = $sn_module[$payment_module]->compile_request($request);
226 226
 
227 227
     // Поддержка дополнительной информации
228
-    if(is_array($pay_link['RENDER'])) {
229
-      foreach($pay_link['RENDER'] as $html_data) {
228
+    if (is_array($pay_link['RENDER'])) {
229
+      foreach ($pay_link['RENDER'] as $html_data) {
230 230
         $template->assign_block_vars('render', $html_data);
231
-        if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
232
-          foreach($html_data['VALUE'] as $value_id => $value_value) {
231
+        if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
232
+          foreach ($html_data['VALUE'] as $value_id => $value_value) {
233 233
             $template->assign_block_vars('render.value', array(
234 234
               'FIELD' => $value_id,
235 235
               'VALUE' => $value_value,
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
     }
241 241
 
242 242
     // Поддержка передачи данных для многошаговых платежных систем
243
-    if(is_array($pay_link['DATA'])) {
244
-      foreach($pay_link['DATA'] as $key => $value) {
243
+    if (is_array($pay_link['DATA'])) {
244
+      foreach ($pay_link['DATA'] as $key => $value) {
245 245
         $template->assign_block_vars('pay_link_data', array(
246 246
           'FIELD' => $key,
247 247
           'VALUE' => $value,
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
       }
250 250
     }
251 251
 
252
-    if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
252
+    if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
253 253
       // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте
254 254
       $template->assign_vars(array(
255 255
         'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'],
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     } else {
259 259
       throw new exception($lang['pay_msg_request_paylink_unsupported'], ERR_ERROR);
260 260
     }
261
-  } catch(exception $e) {
261
+  } catch (exception $e) {
262 262
     $template->assign_block_vars('result', $response = array(
263 263
       'STATUS'  => $e->getCode(),
264 264
       'MESSAGE' => $e->getMessage(),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 }
269 269
 
270 270
 // Прегенерированные пакеты
271
-foreach($unit_available_amount_list as $unit_amount => $discount) {
271
+foreach ($unit_available_amount_list as $unit_amount => $discount) {
272 272
   $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency);
273 273
   $template->assign_block_vars('mm_amount', array(
274 274
     'VALUE'            => $unit_amount,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
   'PLAYER_CURRENCY'              => $player_currency,
304 304
   'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10),
305 305
 
306
-  'UNIT_AMOUNT'                 => (float)$request['metamatter'],
306
+  'UNIT_AMOUNT'                 => (float) $request['metamatter'],
307 307
   'UNIT_AMOUNT_TEXT'            => pretty_number($request['metamatter']),
308 308
   'UNIT_AMOUNT_BONUS_PERCENT'   => $bonus_percent,
309 309
   'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text,
Please login to merge, or discard this patch.
announce.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,39 +23,39 @@  discard block
 block discarded – undo
23 23
 $mode = sys_get_param_str('mode');
24 24
 
25 25
 $announce = array();
26
-if($user['authlevel'] >= 3) {
27
-  if(!empty($text)) {
26
+if ($user['authlevel'] >= 3) {
27
+  if (!empty($text)) {
28 28
     $announce_time = strtotime($announce_time, SN_TIME_NOW);
29 29
     $announce_time = $announce_time ? $announce_time : SN_TIME_NOW;
30 30
 
31
-    if($mode == 'edit') {
31
+    if ($mode == 'edit') {
32 32
       db_news_update_set($announce_time, $text, $detail_url, $announce_id);
33 33
       db_survey_delete_by_id($announce_id);
34 34
     } else {
35 35
       db_news_insert_set($announce_time, $text, $detail_url, $user);
36 36
       $announce_id = db_insert_id();
37 37
     }
38
-    if(($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) {
38
+    if (($survey_question = sys_get_param_str('survey_question')) && ($survey_answers = sys_get_param('survey_answers'))) {
39 39
       $survey_answers = explode("\r\n", $survey_answers);
40 40
       $survey_until = strtotime($survey_until = sys_get_param_str('survey_until'), SN_TIME_NOW);
41 41
       $survey_until = date(FMT_DATE_TIME_SQL, $survey_until ? $survey_until : SN_TIME_NOW + PERIOD_DAY * 1);
42 42
       db_survey_insert($announce_id, $survey_question, $survey_until);
43 43
       $survey_id = db_insert_id();
44
-      foreach($survey_answers as $survey_answer) {
44
+      foreach ($survey_answers as $survey_answer) {
45 45
         $survey_answer = db_escape(trim($survey_answer));
46
-        if(empty($survey_answer)) {
46
+        if (empty($survey_answer)) {
47 47
           continue;
48 48
         }
49 49
         db_survey_answer_insert($survey_id, $survey_answer);
50 50
       }
51 51
     }
52 52
 
53
-    if($announce_time <= SN_TIME_NOW) {
54
-      if($announce_time > $config->var_news_last && $announce_time == SN_TIME_NOW) {
53
+    if ($announce_time <= SN_TIME_NOW) {
54
+      if ($announce_time > $config->var_news_last && $announce_time == SN_TIME_NOW) {
55 55
         $config->db_saveItem('var_news_last', $announce_time);
56 56
       }
57 57
 
58
-      if(sys_get_param_int('news_mass_mail')) {
58
+      if (sys_get_param_int('news_mass_mail')) {
59 59
         $text = sys_get_param('text') . ($detail_url ? " <a href=\"{$detail_url}\"><span class=\"positive\">{$lang['news_more']}</span></a>" : '');
60 60
         msg_send_simple_message('*', 0, 0, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['news_title'], $text);
61 61
       }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
   }
67 67
 
68 68
   $survey_answers = '';
69
-  switch($mode) {
69
+  switch ($mode) {
70 70
     case 'del':
71 71
       db_news_delete_by_id($announce_id);
72 72
       $mode = '';
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
       $template->assign_var('ID', $announce_id);
77 77
     case 'copy':
78 78
       $announce = db_news_with_survey_select_by_id($announce_id);
79
-      if($announce['survey_id']) {
79
+      if ($announce['survey_id']) {
80 80
         $query = db_survey_answer_text_select_by_news($announce);
81
-        while($row = db_fetch($query)) {
81
+        while ($row = db_fetch($query)) {
82 82
           $survey_answers[] = $row['survey_answer_text'];
83 83
         }
84 84
         $survey_answers = implode("\r\n", $survey_answers);
Please login to merge, or discard this patch.
includes/pages/options.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
   $language_new = sys_get_param_str('langer', $user['lang']);
24 24
 
25
-  if($language_new != $user['lang']) {
25
+  if ($language_new != $user['lang']) {
26 26
     $lang->lng_switch($language_new);
27 27
   }
28 28
 
@@ -31,35 +31,35 @@  discard block
 block discarded – undo
31 31
 
32 32
   $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
33 33
 
34
-  if(sys_get_param_str('mode') == 'change') {
35
-    if($user['authlevel'] > 0) {
34
+  if (sys_get_param_str('mode') == 'change') {
35
+    if ($user['authlevel'] > 0) {
36 36
       $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0;
37 37
       db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'");
38 38
       db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'");
39 39
       $user['admin_protection'] = $planet_protection;
40 40
     }
41 41
 
42
-    if(sys_get_param_int('vacation') && !$config->user_vacation_disable) {
42
+    if (sys_get_param_int('vacation') && !$config->user_vacation_disable) {
43 43
       sn_db_transaction_start();
44
-      if($user['authlevel'] < 3) {
45
-        if($user['vacation_next'] > SN_TIME_NOW) {
44
+      if ($user['authlevel'] < 3) {
45
+        if ($user['vacation_next'] > SN_TIME_NOW) {
46 46
           message($lang['opt_vacation_err_timeout'], $lang['Error'], 'index.php?page=options', 5);
47 47
           die();
48 48
         }
49 49
 
50
-        if(FleetList::fleet_count_flying($user['id'])) {
50
+        if (FleetList::fleet_count_flying($user['id'])) {
51 51
           message($lang['opt_vacation_err_your_fleet'], $lang['Error'], 'index.php?page=options', 5);
52 52
           die();
53 53
         }
54 54
 
55 55
         $que = que_get($user['id'], false);
56
-        if(!empty($que)) {
56
+        if (!empty($que)) {
57 57
           message($lang['opt_vacation_err_que'], $lang['Error'], 'index.php?page=options', 5);
58 58
           die();
59 59
         }
60 60
 
61 61
         $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}");
62
-        foreach($query as $planet) {
62
+        foreach ($query as $planet) {
63 63
           // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW);
64 64
           // $planet = $planet['planet'];
65 65
 
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
       sn_db_transaction_commit();
78 78
     }
79 79
 
80
-    foreach($user_option_list as $option_group_id => $option_group) {
81
-      foreach($option_group as $option_name => $option_value) {
82
-        if($user[$option_name] !== null) {
80
+    foreach ($user_option_list as $option_group_id => $option_group) {
81
+      foreach ($option_group as $option_name => $option_value) {
82
+        if ($user[$option_name] !== null) {
83 83
           $user[$option_name] = sys_get_param_str($option_name);
84 84
         } else {
85 85
           $user[$option_name] = $option_value;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 
91 91
 
92 92
     $player_options = sys_get_param('options');
93
-    if(!empty($player_options)) {
94
-      array_walk($player_options, function (&$value) {
93
+    if (!empty($player_options)) {
94
+      array_walk($player_options, function(&$value) {
95 95
         // TODO - Когда будет больше параметров - сделать больше проверок
96 96
         $value = intval($value);
97 97
       });
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
 
103 103
     $username = substr(sys_get_param_str_unsafe('username'), 0, 32);
104 104
     $username_safe = db_escape($username);
105
-    if($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
105
+    if ($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
106 106
       // проверка на корректность
107 107
       sn_db_transaction_start();
108 108
       $name_check = db_player_name_history_get_name_by_name($username_safe);
109
-      if(!$name_check || $name_check['player_id'] == $user['id']) {
109
+      if (!$name_check || $name_check['player_id'] == $user['id']) {
110 110
         $user = db_user_by_id($user['id'], true);
111
-        switch($config->game_user_changename) {
111
+        switch ($config->game_user_changename) {
112 112
           case SERVER_PLAYER_NAME_CHANGE_PAY:
113
-            if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) {
113
+            if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) {
114 114
               $template_result['.']['result'][] = array(
115 115
                 'STATUS'  => ERR_ERROR,
116 116
                 'MESSAGE' => $lang['opt_msg_name_change_err_no_dm'],
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
       sn_db_transaction_commit();
141 141
     }
142 142
 
143
-    if($new_password = sys_get_param('newpass1')) {
143
+    if ($new_password = sys_get_param('newpass1')) {
144 144
       try {
145
-        if($new_password != sys_get_param('newpass2')) {
145
+        if ($new_password != sys_get_param('newpass2')) {
146 146
           throw new Exception($lang['opt_err_pass_unmatched'], ERR_WARNING);
147 147
         }
148 148
 
149
-        if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
149
+        if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
150 150
           throw new Exception($lang['opt_err_pass_wrong'], ERR_WARNING);
151 151
         }
152 152
 
153 153
         throw new Exception($lang['opt_msg_pass_changed'], ERR_NONE);
154
-      } catch(Exception $e) {
154
+      } catch (Exception $e) {
155 155
         $template_result['.']['result'][] = array(
156 156
           'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
157 157
           'MESSAGE' => $e->getMessage()
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
     $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender'];
193 193
 
194 194
     try {
195
-      if($user['birthday']) {
195
+      if ($user['birthday']) {
196 196
         throw new exception();
197 197
       }
198 198
 
199 199
       $user_birthday = sys_get_param_str_unsafe('user_birthday');
200
-      if(!$user_birthday || $user_birthday == $FMT_DATE) {
200
+      if (!$user_birthday || $user_birthday == $FMT_DATE) {
201 201
         throw new exception();
202 202
       }
203 203
 
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
       $pos['Y'] = strpos(FMT_DATE, 'Y');
208 208
       asort($pos);
209 209
       $i = 0;
210
-      foreach($pos as &$position) {
210
+      foreach ($pos as &$position) {
211 211
         $position = ++$i;
212 212
       }
213 213
 
214 214
       $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/";
215
-      if(!preg_match($regexp, $user_birthday, $match)) {
215
+      if (!preg_match($regexp, $user_birthday, $match)) {
216 216
         throw new exception();
217 217
       }
218 218
 
219
-      if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
219
+      if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
220 220
         throw new exception();
221 221
       }
222 222
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
       // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format
225 225
 
226 226
       $year = date('Y', SN_TIME_NOW);
227
-      if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
227
+      if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
228 228
         $year--;
229 229
       }
230 230
       $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}");
231 231
 
232 232
       $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'";
233
-    } catch(exception $e) {
233
+    } catch (exception $e) {
234 234
       $user_birthday = '';
235 235
     }
236 236
 
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
     $template_result['.']['result'][] = $avatar_upload_result;
241 241
 
242 242
     $user_time_diff = playerTimeDiff::user_time_diff_get();
243
-    if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
243
+    if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
244 244
       playerTimeDiff::user_time_diff_set(array(
245 245
         PLAYER_OPTION_TIME_DIFF              => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'),
246 246
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
247 247
         PLAYER_OPTION_TIME_DIFF_FORCED       => 1,
248 248
         PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL,
249 249
       ));
250
-    } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
250
+    } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
251 251
       playerTimeDiff::user_time_diff_set(array(
252 252
         PLAYER_OPTION_TIME_DIFF              => '',
253 253
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
       'STATUS'  => ERR_NONE,
268 268
       'MESSAGE' => $lang['opt_msg_saved']
269 269
     );
270
-  } elseif(sys_get_param_str('result') == 'ok') {
270
+  } elseif (sys_get_param_str('result') == 'ok') {
271 271
     $template_result['.']['result'][] = array(
272 272
       'STATUS'  => ERR_NONE,
273 273
       'MESSAGE' => $lang['opt_msg_saved']
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 //  );
296 296
 
297 297
   $dir = dir(SN_ROOT_PHYSICAL . 'skins');
298
-  while(($entry = $dir->read()) !== false) {
299
-    if(is_dir("skins/{$entry}") && $entry[0] != '.') {
298
+  while (($entry = $dir->read()) !== false) {
299
+    if (is_dir("skins/{$entry}") && $entry[0] != '.') {
300 300
       $template_result['.']['skin_list'][] = array(
301 301
         'VALUE'    => $entry,
302 302
         'NAME'     => $entry,
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
   }
307 307
   $dir->close();
308 308
 
309
-  foreach($lang['opt_planet_sort_options'] as $key => &$value) {
309
+  foreach ($lang['opt_planet_sort_options'] as $key => &$value) {
310 310
     $template_result['.']['planet_sort_options'][] = array(
311 311
       'VALUE'    => $key,
312 312
       'NAME'     => $value,
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
       );
323 323
     }
324 324
   */
325
-  foreach($lang['sys_gender_list'] as $key => $value) {
325
+  foreach ($lang['sys_gender_list'] as $key => $value) {
326 326
     $template_result['.']['gender_list'][] = array(
327 327
       'VALUE'    => $key,
328 328
       'NAME'     => $value,
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
   }
332 332
 
333 333
   $lang_list = lng_get_list();
334
-  foreach($lang_list as $lang_id => $lang_data) {
334
+  foreach ($lang_list as $lang_id => $lang_data) {
335 335
     $template_result['.']['languages'][] = array(
336 336
       'VALUE'    => $lang_id,
337 337
       'NAME'     => $lang_data['LANG_NAME_NATIVE'],
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
   }
341 341
 
342 342
 
343
-  if(isset($lang['menu_customize_show_hide_button_state'])) {
344
-    foreach($lang['menu_customize_show_hide_button_state'] as $key => $value) {
343
+  if (isset($lang['menu_customize_show_hide_button_state'])) {
344
+    foreach ($lang['menu_customize_show_hide_button_state'] as $key => $value) {
345 345
       $template->assign_block_vars('menu_customize_show_hide_button_state', array(
346 346
         'ID'   => $key,
347 347
         'NAME' => $value,
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
     'PAGE_HEADER' => $lang['opt_header'],
452 452
   ));
453 453
 
454
-  foreach($user_option_list as $option_group_id => $option_group) {
455
-    if($option_group_id == OPT_MESSAGE) {
456
-      foreach($sn_message_class_list as $message_class_id => $message_class_data) {
457
-        if($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
454
+  foreach ($user_option_list as $option_group_id => $option_group) {
455
+    if ($option_group_id == OPT_MESSAGE) {
456
+      foreach ($sn_message_class_list as $message_class_id => $message_class_data) {
457
+        if ($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
458 458
           $option_name = $message_class_data['name'];
459 459
 
460 460
           $template->assign_block_vars("options_{$option_group_id}", array(
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
         }
467 467
       }
468 468
     } else {
469
-      foreach($option_group as $option_name => $option_value) {
470
-        if(array_key_exists($option_name, $user_option_types)) {
469
+      foreach ($option_group as $option_name => $option_value) {
470
+        if (array_key_exists($option_name, $user_option_types)) {
471 471
           $option_type = $user_option_types[$option_name];
472 472
         } else {
473 473
           $option_type = 'switch';
Please login to merge, or discard this patch.
includes/pages/chat.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * chat.php
4
- * Main chat window
5
- *
6
- * Changelog:
7
- * 4.0 copyright © 2009-2012 Gorlum for http://supernova.ws
8
- * [!] Another rewrite
9
- * [+] preMVC-compatible
10
- * 3.0 copyright © 2009-2011 Gorlum for http://supernova.ws
11
- * [!] Almost full rewrote
12
- * [+] Complies with PCG1
13
- * 2.0 copyright © 2009-2010 Gorlum for http://supernova.ws
14
- * [+] Rewrote to remove unnecessary code dupes
15
- * 1.5 copyright © 2009-2010 Gorlum for http://supernova.ws
16
- * [~] More DDoS-realted fixes
17
- * 1.4 copyright © 2009-2010 Gorlum for http://supernova.ws
18
- * [~] DDoS-realted fixes
19
- * 1.3 copyright © 2009-2010 Gorlum for http://supernova.ws
20
- * [~] Security checks for SQL-injection
21
- * 1.2 by Ihor
22
- * 1.0 Shoutbox copyright © 2008 by e-Zobar for XNova
23
- **/
3
+   * chat.php
4
+   * Main chat window
5
+   *
6
+   * Changelog:
7
+   * 4.0 copyright © 2009-2012 Gorlum for http://supernova.ws
8
+   * [!] Another rewrite
9
+   * [+] preMVC-compatible
10
+   * 3.0 copyright © 2009-2011 Gorlum for http://supernova.ws
11
+   * [!] Almost full rewrote
12
+   * [+] Complies with PCG1
13
+   * 2.0 copyright © 2009-2010 Gorlum for http://supernova.ws
14
+   * [+] Rewrote to remove unnecessary code dupes
15
+   * 1.5 copyright © 2009-2010 Gorlum for http://supernova.ws
16
+   * [~] More DDoS-realted fixes
17
+   * 1.4 copyright © 2009-2010 Gorlum for http://supernova.ws
18
+   * [~] DDoS-realted fixes
19
+   * 1.3 copyright © 2009-2010 Gorlum for http://supernova.ws
20
+   * [~] Security checks for SQL-injection
21
+   * 1.2 by Ihor
22
+   * 1.0 Shoutbox copyright © 2008 by e-Zobar for XNova
23
+   **/
24 24
 /*
25 25
 $sn_mvc['model']['chat'][] = 'sn_chat_model';
26 26
 $sn_mvc['model']['chat_add'][] = 'sn_chat_add_model';
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
   $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS;
37 37
 
38 38
   $mode = sys_get_param_int('mode');
39
-  switch($mode) {
39
+  switch ($mode) {
40 40
     case CHAT_MODE_ALLY:
41 41
       $template_result['ALLY'] = intval($user['ally_id']);
42 42
       $page_title = $lang['chat_ally'];
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
   }
50 50
 
51 51
   $template_result['.']['smiles'] = array();
52
-  foreach($supernova->design['smiles'] as $auth_level => $replaces) {
53
-    if($auth_level > $user_auth_level) {
52
+  foreach ($supernova->design['smiles'] as $auth_level => $replaces) {
53
+    if ($auth_level > $user_auth_level) {
54 54
       continue;
55 55
     }
56 56
 
57
-    foreach($replaces as $bbcode => $filename) {
57
+    foreach ($replaces as $bbcode => $filename) {
58 58
       $template_result['.']['smiles'][] = array(
59 59
         'BBCODE'   => $bbcode,
60 60
         'FILENAME' => $filename,
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
   define('IN_AJAX', true);
78 78
   $skip_fleet_update = true;
79 79
 
80
-  if($config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) {
80
+  if ($config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) {
81 81
     die();
82 82
   }
83 83
 
84
-  if(($message = sys_get_param_str('message')) && $user['username']) {
84
+  if (($message = sys_get_param_str('message')) && $user['username']) {
85 85
     $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
86 86
     $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id))));
87 87
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
   $skip_fleet_update = true;
103 103
 
104 104
   $history = sys_get_param_str('history');
105
-  if(!$history) {
105
+  if (!$history) {
106 106
     $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO);
107 107
   }
108 108
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
   $last_message = '';
111 111
   $alliance = 0;
112 112
   $template_result['.']['chat'] = array();
113
-  if(!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) {
113
+  if (!$history && $config->_MODE != CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) {
114 114
     $result['disable'] = true;
115 115
     $template_result['.']['chat'][] = array(
116 116
       'TIME'    => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')),
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 
124 124
     $where_add = '';
125 125
     $last_message = 0;
126
-    if($history) {
126
+    if ($history) {
127 127
       $rows = db_chat_message_count_by_ally($alliance);
128 128
       $page_count = ceil($rows['CNT'] / $page_limit);
129 129
 
130
-      for($i = 0; $i < $page_count; $i++) {
130
+      for ($i = 0; $i < $page_count; $i++) {
131 131
         $template_result['.']['page'][] = array(
132 132
           'NUMBER' => $i
133 133
         );
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
 
142 142
     $start_row = $page * $page_limit;
143 143
     $query = db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit);
144
-    while($chat_row = db_fetch($query)) {
144
+    while ($chat_row = db_fetch($query)) {
145 145
       // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
146 146
       $chat_row['user'] = player_nick_render_to_html($chat_row['user']);
147 147
       $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8');
148 148
       $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']);
149
-      if(!$history) {
149
+      if (!$history) {
150 150
         $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>";
151 151
       }
152 152
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
   $template = gettemplate('chat_messages', $template);
172 172
   $template->assign_recursive($template_result);
173 173
 
174
-  if($history) {
174
+  if ($history) {
175 175
     display($template, "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true);
176 176
   } else {
177 177
     $result['last_message'] = $last_message;
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_diplomacy.inc 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
4 4
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
5 5
 }
6 6
 
7
-if(!$user_can_negotiate) {
7
+if (!$user_can_negotiate) {
8 8
   message($lang['Denied_access'], $lang['ali_dip_title']);
9 9
 }
10 10
 
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
 
16 16
 
17 17
 
18
-if(sys_get_param_str('ali_dip_offer_make')) {
18
+if (sys_get_param_str('ali_dip_offer_make')) {
19 19
   $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation');
20
-  if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) {
20
+  if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list)) {
21 21
     message($lang['ali_dip_err_wrong_offer'], $page_title);
22 22
   }
23 23
 
24 24
   $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id');
25
-  if($alliance_negotiation_contr_ally_id == $user['ally_id']) {
25
+  if ($alliance_negotiation_contr_ally_id == $user['ally_id']) {
26 26
     message($lang['ali_dip_err_same_ally'], $page_title);
27 27
   }
28 28
 
29 29
   $contr_ally_row = db_ally_get_by_id($alliance_negotiation_contr_ally_id);
30
-  if(!$contr_ally_row) {
30
+  if (!$contr_ally_row) {
31 31
     message($lang['ali_dip_err_no_ally'], $page_title);
32 32
   }
33 33
 
34 34
   $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id);
35
-  if($alliance_negotiation_relation == $relation_current_id) {
35
+  if ($alliance_negotiation_relation == $relation_current_id) {
36 36
     message(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title);
37 37
   }
38 38
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
   $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation];
45 45
   $relation_current = $sn_diplomacy_relation_list[$relation_current_id];
46
-  if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) {
46
+  if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1) {
47 47
     sn_db_perform('{{alliance_negotiation}}',
48 48
       array(
49 49
         'alliance_negotiation_ally_id'         => $user['ally_id'],
@@ -70,33 +70,33 @@  discard block
 block discarded – undo
70 70
   }
71 71
 } else {
72 72
   $offer_id = sys_get_param_id('offer_id');
73
-  if($offer_id) {
73
+  if ($offer_id) {
74 74
     $offer_answer = sys_get_param_str('answer');
75 75
 
76 76
     $negotiation = db_ally_negotiation_get_by_offer_id($offer_id);
77
-    if(!$negotiation) {
77
+    if (!$negotiation) {
78 78
       message($lang['ali_dip_err_offer_none'], $page_title);
79
-    } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) {
79
+    } elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) {
80 80
       // TODO: Add log of hack attempt
81 81
       message($lang['ali_dip_err_offer_alien'], $page_title);
82
-    } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) {
83
-      if($offer_answer == 'accept') {
82
+    } elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) {
83
+      if ($offer_answer == 'accept') {
84 84
         // TODO: Add log of hack attempt
85 85
         message($lang['ali_dip_err_offer_accept_own'], $page_title);
86
-      } elseif($offer_answer == 'deny') {
86
+      } elseif ($offer_answer == 'deny') {
87 87
         db_ally_negotiation_delete_by_offer_id($offer_id);
88 88
       }
89 89
     } else {
90
-      if($offer_answer == 'accept') {
90
+      if ($offer_answer == 'accept') {
91 91
         $accept_offer = true;
92
-      } elseif($offer_answer == 'deny') {
92
+      } elseif ($offer_answer == 'deny') {
93 93
         db_ally_negotiation_update_status_1($offer_id);
94 94
       }
95 95
     }
96 96
   }
97 97
 }
98 98
 
99
-if($accept_offer) {
99
+if ($accept_offer) {
100 100
   sn_db_transaction_start();
101 101
 
102 102
   // TODO: Make sn_db_perform() multirow
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   sn_db_transaction_commit();
126 126
 }
127 127
 
128
-foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) {
128
+foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation) {
129 129
   $template->assign_block_vars('relation', array(
130 130
     'ID'   => $diplomacy_relation_id,
131 131
     'TEXT' => $lang['ali_dip_relations'][$diplomacy_relation_id],
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
 $query = db_ally_list_get_by_not_user_ally($user);
137
-while($alliance = db_fetch($query)) {
137
+while ($alliance = db_fetch($query)) {
138 138
   $template->assign_block_vars('alliance', array(
139 139
     'ID'   => $alliance['id'],
140 140
     'NAME' => js_safe_string($alliance['ally_name']),
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 }
144 144
 
145 145
 $query = db_ally_negotiation_list($user);
146
-while($offer = db_fetch($query)) {
146
+while ($offer = db_fetch($query)) {
147 147
   $template->assign_block_vars('offer', array(
148 148
     'ID'       => $offer['alliance_negotiation_id'],
149 149
     'NAME'     => $offer['ally_name'],
Please login to merge, or discard this patch.
includes/alliance/ali_external_create_ally.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 // Pretty Safe
3 3
 // TODO: Add ally_tag to usertable
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6 6
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
@@ -11,13 +11,13 @@  discard block
 block discarded – undo
11 11
 $ally_name_raw = sys_get_param_str_unsafe('name');
12 12
 $ally_name = db_escape($ally_name_raw);
13 13
 
14
-if($ally_tag) {
15
-  if(!$ally_name_raw || !$ally_tag_raw) {
14
+if ($ally_tag) {
15
+  if (!$ally_name_raw || !$ally_tag_raw) {
16 16
     message($lang['have_not_name'], $lang['make_alliance']);
17 17
   }
18 18
 
19 19
   $query = db_ally_get_by_name_or_tag($ally_tag, $ally_name);
20
-  if($query) {
20
+  if ($query) {
21 21
     message(str_replace('%s', $query['ally_tag'] == $ally_tag_raw ? $ally_tag_raw : $ally_name_raw, $lang['always_exist']), $lang['make_alliance']);
22 22
   }
23 23
 
Please login to merge, or discard this patch.