Test Failed
Branch trunk (d809b8)
by SuperNova.WS
05:48
created
includes/alliance/ali_internal_admin.inc 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  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_admin) {
7
+if (!$user_admin) {
8 8
   messageBox($lang['Denied_access'], $lang['ally_admin']);
9 9
 }
10 10
 
11 11
 $template = gettemplate('ali_admin', $template);
12 12
 
13 13
 $text_list = array(
14
-  1 => array ('db_field' => 'ally_description', 'text_type' => 'Public_text_of_alliance'),
15
-  2 => array ('db_field' => 'ally_text', 'text_type' => 'Internal_text'),
16
-  3 => array ('db_field' => 'ally_request', 'text_type' => 'Show_of_request_text'),
14
+  1 => array('db_field' => 'ally_description', 'text_type' => 'Public_text_of_alliance'),
15
+  2 => array('db_field' => 'ally_text', 'text_type' => 'Internal_text'),
16
+  3 => array('db_field' => 'ally_request', 'text_type' => 'Show_of_request_text'),
17 17
 );
18 18
 
19 19
 $allyTextID = sys_get_param_int('t', 1);
20
-$allyTextID = ($allyTextID<1 || $allyTextID>3) ? 1 : $allyTextID;
20
+$allyTextID = ($allyTextID < 1 || $allyTextID > 3) ? 1 : $allyTextID;
21 21
 
22
-if(sys_get_param_str('isSaveOptions')) {
22
+if (sys_get_param_str('isSaveOptions')) {
23 23
   require_once('includes/includes/sys_avatar.php');
24 24
 
25 25
   $new_image = $ally['ally_image'];
@@ -31,32 +31,32 @@  discard block
 block discarded – undo
31 31
 //  $template->assign_block_vars('result', $avatar_upload_result);
32 32
 
33 33
   $ally_changeset = array();
34
-  if(($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) {
34
+  if (($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) && $new_tag != $ally['ally_tag']) {
35 35
     $new_tag_unsafe = $new_tag;
36 36
     $new_tag = db_escape($new_tag);
37 37
     $isTaggedAllyExists = DBStaticAlly::db_ally_get_by_tag($new_tag);
38
-    if(!empty($isTaggedAllyExists)) {
38
+    if (!empty($isTaggedAllyExists)) {
39 39
       messageBox(sprintf($lang['ally_message_tag_exists'], $new_tag_unsafe), '', 'alliance.php?mode=admin&edit=ally');
40 40
     }
41 41
     $ally_changeset[] = "`ally_tag`='{$new_tag}'";
42 42
     db_user_set_by_id($ally['ally_user_id'], "`username`='[{$new_tag}]'");
43 43
   }
44 44
 
45
-  if(($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) {
45
+  if (($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) && $new_name != $ally['ally_name']) {
46 46
     $new_name_unsafe = $new_name;
47 47
     $new_name = db_escape($new_name);
48 48
     $isTaggedAllyExists = DBStaticAlly::db_ally_get_by_name($new_name);
49
-    if(!empty($isTaggedAllyExists)) {
49
+    if (!empty($isTaggedAllyExists)) {
50 50
       messageBox(sprintf($lang['ally_message_name_exists'], $new_name_unsafe), '', 'alliance.php?mode=admin&edit=ally');
51 51
     }
52 52
     $ally_changeset[] = "`ally_name`='{$new_name}'";
53 53
   }
54 54
 
55
-  if(($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) {
55
+  if (($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) && $new_owner_rank != $ally['ally_owner_range']) {
56 56
     $new_owner_rank = db_escape($new_owner_rank);
57 57
     $ally_changeset[] = "`ally_owner_range` = '{$new_owner_rank}'";
58 58
   }
59
-  if(($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) {
59
+  if (($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) && $new_web != $ally['ally_web']) {
60 60
     $new_web = db_escape($new_web);
61 61
     $ally_changeset[] = "`ally_web` = '{$new_web}'";
62 62
   }
@@ -65,31 +65,31 @@  discard block
 block discarded – undo
65 65
 //  if(($new_request = sys_get_param_int('request_notallow', $ally['ally_request_notallow'])) && $new_request != $ally['ally_request_notallow']) {
66 66
 //    $ally_changeset[] = "`ally_request_notallow` = '{$new_request}'";
67 67
 //  }
68
-  if($new_image != $ally['ally_image']) {
68
+  if ($new_image != $ally['ally_image']) {
69 69
     $new_image = intval($new_image);
70 70
     $ally_changeset[] = "`ally_image` = '{$new_image}'";
71 71
   }
72 72
 
73
-  if(!empty($ally_changeset)) {
73
+  if (!empty($ally_changeset)) {
74 74
     doquery("UPDATE {{alliance}} SET " . implode(',', $ally_changeset) . " WHERE `id`='{$ally['id']}' LIMIT 1;");
75 75
     sys_redirect('alliance.php?mode=admin&edit=ally');
76 76
   }
77 77
 }
78
-elseif(sys_get_param_str('isSaveText'))
78
+elseif (sys_get_param_str('isSaveText'))
79 79
 {
80 80
   $text = sys_get_param_str_both('text');
81 81
   doquery("UPDATE {{alliance}} SET `{$text_list[$allyTextID]['db_field']}`='{$text['safe']}' WHERE `id`='{$ally['id']}';");
82 82
   $ally[$text_list[$allyTextID]['db_field']] = $text['unsafe'];
83 83
 }
84
-elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader'))
84
+elseif (sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader'))
85 85
 {
86
-  if(!$isAllyOwner)
86
+  if (!$isAllyOwner)
87 87
   {
88 88
     messageBox($lang['Denied_access'], $lang['ally_admin']);
89 89
   }
90 90
 
91 91
   $newLeader = db_user_by_id($idNewLeader, false, `ally_id`);
92
-  if($newLeader['ally_id'] == $user['ally_id'])
92
+  if ($newLeader['ally_id'] == $user['ally_id'])
93 93
   {
94 94
     sn_db_transaction_start();
95 95
     db_user_set_by_id($user['id'], "`ally_rank_id`='0'");
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
     sys_redirect('alliance.php');
100 100
   }
101 101
 }
102
-elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband'))
102
+elseif (sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband'))
103 103
 {
104
-  if(!$isAllyOwner)
104
+  if (!$isAllyOwner)
105 105
   {
106 106
     messageBox($lang['Denied_access'], $lang['ally_admin']);
107 107
   }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
   'ally_name' => htmlspecialchars($ally['ally_name']),
125 125
   'ally_tag' => htmlspecialchars($ally['ally_tag']),
126 126
   'ally_web' => htmlspecialchars($ally['ally_web']),
127
-  'ally_request_notallow_0' => (( $ally['ally_request_notallow']) ? ' SELECTED' : ''),
127
+  'ally_request_notallow_0' => (($ally['ally_request_notallow']) ? ' SELECTED' : ''),
128 128
   'ally_request_notallow_1' => ((!$ally['ally_request_notallow']) ? ' SELECTED' : ''),
129 129
   'ally_owner_range' => htmlspecialchars($ally['ally_owner_range']),
130 130
   'hideNotOwner' => $ally['ally_owner'] != $user['id'] ? 'display: hide;' : '',
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 {
134 134
   $userAllyAdmins = db_user_list("`ally_id`= {$ally['id']}", false, '`id`, `username`');
135 135
   unset($tmp);
136
-  foreach($userAllyAdmins as $userAllyAdmin)
136
+  foreach ($userAllyAdmins as $userAllyAdmin)
137 137
   {
138 138
     $tmp .= "<option value={$userAllyAdmin['id']}>{$userAllyAdmin['username']}</option>";
139 139
   }
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
   $template->assign_var('adminMembers', $tmp);
142 142
 }
143 143
 
144
-foreach($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale)
144
+foreach ($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale)
145 145
 {
146
-  if(!$sn_ali_admin_action_locale['title'])
146
+  if (!$sn_ali_admin_action_locale['title'])
147 147
   {
148 148
     continue;
149 149
   }
Please login to merge, or discard this patch.
includes/alliance/ali_info.inc 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  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
 {
5 5
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
6 6
 }
7 7
 
8 8
 $template = gettemplate('ali_info', true);
9 9
 
10
-if($mode == 'exit')
10
+if ($mode == 'exit')
11 11
 {
12 12
   if ($ally['ally_owner'] == $user['id'])
13 13
   {
@@ -24,25 +24,25 @@  discard block
 block discarded – undo
24 24
     messageBox(sprintf($lang['ali_info_leave_success'], $ally['ally_name']), $lang['sys_alliance']);
25 25
   }
26 26
 }
27
-elseif($mode == 'ainfo')
27
+elseif ($mode == 'ainfo')
28 28
 {
29 29
   $tag = sys_get_param_str('tag');
30 30
   $id_ally = sys_get_param_id('a');
31
-  if($tag)
31
+  if ($tag)
32 32
   {
33 33
     $ally = doquery("SELECT * FROM {{alliance}} WHERE ally_tag='{$tag}' LIMIT 1;", '', true);
34 34
   }
35
-  elseif($id_ally)
35
+  elseif ($id_ally)
36 36
   {
37 37
     $ally = doquery("SELECT * FROM {{alliance}} WHERE id='{$id_ally}' LIMIT 1;", '', true);
38 38
   }
39 39
 
40
-  if(!$ally)
40
+  if (!$ally)
41 41
   {
42 42
     messageBox($lang['ali_sys_notFound'], $lang['Ally_info_1']);
43 43
   }
44 44
 
45
-  if(!$ally['ally_description'])
45
+  if (!$ally['ally_description'])
46 46
   {
47 47
     $ally['ally_description'] = $lang['Ally_nodescription'];
48 48
   }
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
     'EXTERNAL'     => true,
52 52
     'USER_ALLY_ID' => $user['ally_id'],
53 53
   ));
54
-  $page_header          = $lang['sys_alliance'];
54
+  $page_header = $lang['sys_alliance'];
55 55
 }
56 56
 else
57 57
 {
58 58
   $page_header = $lang['your_alliance'];
59 59
 
60
-  if($ally['ally_owner'] == $user['id'])
60
+  if ($ally['ally_owner'] == $user['id'])
61 61
   {
62 62
     $range = $ally['ally_owner_range'] ? $ally['ally_owner_range'] : $lang['Founder'];
63 63
   }
64
-  elseif($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name']))
64
+  elseif ($user['ally_rank_id'] != 0 && isset($ranks[$user['ally_rank_id']]['name']))
65 65
   {
66 66
     $range = $ranks[$user['ally_rank_id']]['name'];
67 67
   }
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 ));
106 106
 
107 107
 $relations = ali_relations($ally['id']);
108
-foreach($relations as $relation)
108
+foreach ($relations as $relation)
109 109
 {
110
-  if($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id'])
110
+  if ($relation['alliance_diplomacy_contr_ally_id'] && $relation['alliance_diplomacy_ally_id'])
111 111
   {
112 112
     $template->assign_block_vars('relation', array(
113 113
       'NAME'     => $relation['alliance_diplomacy_contr_ally_name'],
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
   }
118 118
 }
119 119
 
120
-function ali_render(){$func_args = func_get_args();return sn_function_call(__FUNCTION__, $func_args);}
120
+function ali_render() {$func_args = func_get_args(); return sn_function_call(__FUNCTION__, $func_args); }
121 121
 ali_render();
122 122
 
123 123
 display($template, "{$lang['alliance']} [{$ally['ally_name']}]");
Please login to merge, or discard this patch.
includes/alliance/ali_external_request.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
4 4
 {
5 5
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
6 6
 }
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     sys_redirect('alliance.php');
21 21
   }
22 22
 
23
-  if($user_request['request_denied'])
23
+  if ($user_request['request_denied'])
24 24
   {
25 25
     $lang['request_text'] = sprintf($lang['ali_req_deny_msg'], $ally['ally_tag'], $user_request['request_text']);
26 26
   }
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 
44 44
 $ally = doquery("SELECT * FROM {{alliance}} WHERE `id` ='{$id_ally}'", true);
45 45
 
46
-if(!$ally)
46
+if (!$ally)
47 47
 {
48 48
   messageBox($lang['ali_sys_notFound'], $lang['ali_req_title']);
49 49
 }
50 50
 
51
-if($ally['ally_request_notallow'])
51
+if ($ally['ally_request_notallow'])
52 52
 {
53 53
   messageBox($lang['ali_req_not_allowed'], $lang['ali_req_title']);
54 54
 }
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_diplomacy.inc 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use \DBAL\DbQuery;
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)
6 6
 {
7 7
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
8 8
 }
@@ -16,28 +16,28 @@  discard block
 block discarded – undo
16 16
 
17 17
 $ally_name_safe = db_escape($user['ally_name']);
18 18
 
19
-if(sys_get_param_str('ali_dip_offer_make'))
19
+if (sys_get_param_str('ali_dip_offer_make'))
20 20
 {
21 21
   $alliance_negotiation_relation = sys_get_param_str('alliance_negotiation_relation');
22
-  if(!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list))
22
+  if (!array_key_exists($alliance_negotiation_relation, $sn_diplomacy_relation_list))
23 23
   {
24 24
     messageBox($lang['ali_dip_err_wrong_offer'], $page_title);
25 25
   }
26 26
 
27 27
   $alliance_negotiation_contr_ally_id = sys_get_param_id('alliance_negotiation_contr_ally_id');
28
-  if($alliance_negotiation_contr_ally_id == $user['ally_id'])
28
+  if ($alliance_negotiation_contr_ally_id == $user['ally_id'])
29 29
   {
30 30
     messageBox($lang['ali_dip_err_same_ally'], $page_title);
31 31
   }
32 32
 
33 33
   $contr_ally_row = doquery("SELECT `ally_name` FROM {{alliance}} WHERE `id` = {$alliance_negotiation_contr_ally_id} LIMIT 1;", '', true);
34
-  if(!$contr_ally_row)
34
+  if (!$contr_ally_row)
35 35
   {
36 36
     messageBox($lang['ali_dip_err_no_ally'], $page_title);
37 37
   }
38 38
 
39 39
   $relation_current_id = ali_relation($user['ally_id'], $alliance_negotiation_contr_ally_id);
40
-  if($alliance_negotiation_relation == $relation_current_id)
40
+  if ($alliance_negotiation_relation == $relation_current_id)
41 41
   {
42 42
     messageBox(sprintf($lang['ali_dip_err_offer_same'], $lang['ali_dip_relations'][$alliance_negotiation_relation]), $page_title);
43 43
   }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
   $relation_new = $sn_diplomacy_relation_list[$alliance_negotiation_relation];
51 51
   $relation_current = $sn_diplomacy_relation_list[$relation_current_id];
52
-  if($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1)
52
+  if ($relation_new['enter_delay'] == -1 || $relation_current['exit_delay'] == -1)
53 53
   {
54 54
     DbQuery::build()
55 55
       ->setTable('alliance_negotiation')
@@ -82,39 +82,39 @@  discard block
 block discarded – undo
82 82
 else
83 83
 {
84 84
   $offer_id = sys_get_param_id('offer_id');
85
-  if($offer_id)
85
+  if ($offer_id)
86 86
   {
87 87
     $offer_answer = sys_get_param_str('answer');
88 88
 
89 89
     $negotiation = doquery("SELECT * FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;", '', true);
90
-    if(!$negotiation)
90
+    if (!$negotiation)
91 91
     {
92 92
       messageBox($lang['ali_dip_err_offer_none'], $page_title);
93 93
     }
94
-    elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
94
+    elseif ($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id'])
95 95
     {
96 96
       // TODO: Add log of hack attempt
97 97
       messageBox($lang['ali_dip_err_offer_alien'], $page_title);
98 98
     }
99
-    elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
99
+    elseif ($negotiation['alliance_negotiation_ally_id'] == $user['ally_id'])
100 100
     {
101
-      if($offer_answer == 'accept')
101
+      if ($offer_answer == 'accept')
102 102
       {
103 103
         // TODO: Add log of hack attempt
104 104
         messageBox($lang['ali_dip_err_offer_accept_own'], $page_title);
105 105
       }
106
-      elseif($offer_answer == 'deny')
106
+      elseif ($offer_answer == 'deny')
107 107
       {
108 108
         doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;");
109 109
       }
110 110
     }
111 111
     else
112 112
     {
113
-      if($offer_answer == 'accept')
113
+      if ($offer_answer == 'accept')
114 114
       {
115 115
         $accept_offer = true;
116 116
       }
117
-      elseif($offer_answer == 'deny')
117
+      elseif ($offer_answer == 'deny')
118 118
       {
119 119
         DBStaticAlly::db_ally_negotiation_update_status_1($offer_id);
120 120
       }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
   }
123 123
 }
124 124
 
125
-if($accept_offer)
125
+if ($accept_offer)
126 126
 {
127 127
   sn_db_transaction_start();
128 128
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
   sn_db_transaction_commit();
162 162
 }
163 163
 
164
-foreach($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation)
164
+foreach ($sn_diplomacy_relation_list as $diplomacy_relation_id => $diplomacy_relation)
165 165
 {
166 166
   $template->assign_block_vars('relation', array(
167 167
     'ID'   => $diplomacy_relation_id,
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 }
171 171
 
172 172
 $query = doquery("SELECT id, ally_name, ally_tag FROM {{alliance}} WHERE `id` != {$user['ally_id']} ORDER BY ally_name;");
173
-while($alliance = db_fetch($query))
173
+while ($alliance = db_fetch($query))
174 174
 {
175 175
   $template->assign_block_vars('alliance', array(
176 176
     'ID'   => $alliance['id'],
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
   WHERE
190 190
     alliance_negotiation_ally_id = {$user['ally_id']} OR alliance_negotiation_contr_ally_id = {$user['ally_id']};"
191 191
 );
192
-while($offer = db_fetch($query))
192
+while ($offer = db_fetch($query))
193 193
 {
194 194
   $template->assign_block_vars('offer', array(
195 195
     'ID'       => $offer['alliance_negotiation_id'],
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
 {
7 7
   $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
8 8
 }
@@ -12,15 +12,15 @@  discard block
 block discarded – undo
12 12
 $ally_name_raw = sys_get_param_str_unsafe('name');
13 13
 $ally_name     = db_escape($ally_name_raw);
14 14
 
15
-if($ally_tag)
15
+if ($ally_tag)
16 16
 {
17
-  if(!$ally_name_raw || !$ally_tag_raw)
17
+  if (!$ally_name_raw || !$ally_tag_raw)
18 18
   {
19 19
     messageBox($lang['have_not_name'], $lang['make_alliance']);
20 20
   }
21 21
 
22 22
   $query = doquery("SELECT ally_tag FROM {{alliance}} WHERE `ally_tag` = '{$ally_tag}' or `ally_name` = '{$ally_name}' LIMIT 1;", true);
23
-  if($query)
23
+  if ($query)
24 24
   {
25 25
     messageBox(str_replace('%s', $query['ally_tag'] == $ally_tag_raw ? $ally_tag_raw : $ally_name_raw, $lang['always_exist']), $lang['make_alliance']);
26 26
   }
Please login to merge, or discard this patch.
includes/functions/eco_queue.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 function que_get_unit_que($unit_id) {
4 4
   $que_type = false;
5
-  foreach(sn_get_groups('ques') as $que_id => $que_data) {
6
-    if(in_array($unit_id, $que_data['unit_list'])) {
5
+  foreach (sn_get_groups('ques') as $que_id => $que_data) {
6
+    if (in_array($unit_id, $que_data['unit_list'])) {
7 7
       $que_type = $que_id;
8 8
       break;
9 9
     }
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 function que_get_max_que_length($user, $planet, $que_id, $que_data = null) {
17 17
   global $config;
18 18
 
19
-  if(empty($que_data)) {
19
+  if (empty($que_data)) {
20 20
     $que_data = sn_get_groups('ques');
21 21
     $que_data = $que_data[$que_id];
22 22
   }
23 23
 
24 24
 
25 25
   $que_length = 1;
26
-  switch($que_id) {
26
+  switch ($que_id) {
27 27
     case QUE_RESEARCH:
28 28
       $que_length = $config->server_que_length_research + mrc_get_level($user, '', UNIT_PREMIUM); // TODO - вынести в модуль
29 29
     break;
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
 function eco_que_str2arr($que_str) {
39 39
   $que_arr = explode(';', $que_str);
40
-  foreach($que_arr as $que_index => &$que_item) {
41
-    if($que_item) {
40
+  foreach ($que_arr as $que_index => &$que_item) {
41
+    if ($que_item) {
42 42
       $que_item = explode(',', $que_item);
43 43
     } else {
44 44
       unset($que_arr[$que_index]);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 function eco_que_arr2str($que_arr) {
51
-  foreach($que_arr as &$que_item) {
51
+  foreach ($que_arr as &$que_item) {
52 52
     $que_item = implode(',', $que_item);
53 53
   }
54 54
   return implode(';', $que_arr);
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
   global $lang, $config;
60 60
 
61 61
   $is_autoconvert = false;
62
-  if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) {
62
+  if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) {
63 63
     $build_mode = BUILD_CREATE;
64 64
     $is_autoconvert = true;
65 65
   }
66 66
 
67 67
   $unit_amount_qued = 0;
68 68
   try {
69
-    if(!$user['id']) {
69
+    if (!$user['id']) {
70 70
       throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
71 71
     }
72 72
 
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
       foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break;
78 78
     }
79 79
     */
80
-    if(!$unit_id) {
80
+    if (!$unit_id) {
81 81
       throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
82 82
     }
83 83
 
84 84
     $que_id = que_get_unit_que($unit_id);
85
-    if(!$que_id) {
85
+    if (!$que_id) {
86 86
       throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
87 87
     }
88 88
 
89
-    if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) {
89
+    if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) {
90 90
       throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION
91 91
     }
92 92
 
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
     $que_data = $que_data[$que_id];
95 95
 
96 96
     // TODO Переделать под подочереди
97
-    if($que_id == QUE_STRUCTURES) {
97
+    if ($que_id == QUE_STRUCTURES) {
98 98
       $sn_groups_build_allow = sn_get_groups('build_allow');
99 99
       $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']];
100 100
 
101
-      if(!isset($que_data['unit_list'][$unit_id])) {
101
+      if (!isset($que_data['unit_list'][$unit_id])) {
102 102
         throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION
103 103
       }
104 104
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     // Это нужно, что бы заблокировать пользователя и работу с очередями
120 120
     $user = db_user_by_id($user['id']);
121 121
     // Это нужно, что бы заблокировать планету от списания ресурсов
122
-    if(isset($planet['id']) && $planet['id']) {
122
+    if (isset($planet['id']) && $planet['id']) {
123 123
       $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true);
124 124
     } else {
125 125
       $planet['id'] = 0;
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
     $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id];
132 132
     $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data);
133 133
     // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей
134
-    if(count($in_que) >= $que_max_length) {
134
+    if (count($in_que) >= $que_max_length) {
135 135
       throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION
136 136
     }
137 137
 
138 138
     // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов
139
-    switch(eco_can_build_unit($user, $planet, $unit_id)) {
139
+    switch (eco_can_build_unit($user, $planet, $unit_id)) {
140 140
       case BUILD_ALLOWED: break;
141 141
       case BUILD_UNIT_BUSY: throw new exception('{Строение занято}', ERR_ERROR); break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading
142 142
       // case BUILD_REQUIRE_NOT_MEET:
143 143
       default:
144
-        if($build_mode == BUILD_CREATE) {
144
+        if ($build_mode == BUILD_CREATE) {
145 145
           throw new exception('{Требования не удовлетворены}', ERR_ERROR);
146 146
         }
147 147
         break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     $unit_amount_qued = $unit_amount;
152 152
     $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0;
153 153
     $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued;
154
-    if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
155
-      if($unit_level >= $unit_max) {
154
+    if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) {
155
+      if ($unit_level >= $unit_max) {
156 156
         throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
157 157
       }
158 158
       $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level));
159 159
     }
160 160
 
161
-    if($unit_amount < 1) {
161
+    if ($unit_amount < 1) {
162 162
       throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION
163 163
     }
164 164
 
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
     //  {
175 175
     //    die('Unit busy'); // TODO EXCEPTION
176 176
     //  }
177
-    if(get_unit_param($unit_id, P_STACKABLE)) {
177
+    if (get_unit_param($unit_id, P_STACKABLE)) {
178 178
       // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь
179
-      if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) {
179
+      if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) {
180 180
         // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита
181 181
         $used_silo = 0;
182
-        foreach($group_missile as $missile_id) {
182
+        foreach ($group_missile as $missile_id) {
183 183
           $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0;
184 184
           $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE);
185 185
         }
186 186
         $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo;
187
-        if($free_silo <= 0) {
187
+        if ($free_silo <= 0) {
188 188
           throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION
189 189
         }
190 190
         $unit_size = get_unit_param($unit_id, P_UNIT_SIZE);
191
-        if($free_silo < $unit_size) {
191
+        if ($free_silo < $unit_size) {
192 192
           throw new exception("{В ракетной шахте нет места для {$lang['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION
193 193
         }
194 194
         $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size)));
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
       $unit_level = $new_unit_level = 0;
197 197
     } else {
198 198
       $unit_amount = 1;
199
-      if($que_id == QUE_STRUCTURES) {
199
+      if ($que_id == QUE_STRUCTURES) {
200 200
         // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0)
201 201
         $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0;
202
-        if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0)
202
+        if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0)
203 203
         {
204 204
           throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION
205 205
         }
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
 
218 218
     $exchange = array();
219 219
     $market_get_autoconvert_cost = market_get_autoconvert_cost();
220
-    if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
220
+    if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) {
221 221
       $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
222
-      if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
222
+      if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) {
223 223
         throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION
224 224
       }
225 225
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
       $resource_exchange_rates = array();
230 230
       $resource_diff = array();
231 231
       $all_positive = true;
232
-      foreach($resources_loot as $resource_id) {
232
+      foreach ($resources_loot as $resource_id) {
233 233
         $resource_db_name = pname_resource_name($resource_id);
234 234
         $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id));
235 235
         $resource_exchange_rates[$resource_id] = $config->__get("rpg_exchange_{$resource_db_name}");
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
         $all_positive = $all_positive && ($resource_diff[$resource_id] > 0);
238 238
       }
239 239
       // Нужна автоконвертация
240
-      if($all_positive) {
240
+      if ($all_positive) {
241 241
         $is_autoconvert = false;
242 242
       } else {
243
-        foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) {
244
-          if($resource_diff_amount >= 0) {
243
+        foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) {
244
+          if ($resource_diff_amount >= 0) {
245 245
             continue;
246 246
           }
247
-          foreach($resource_diff as $resource_got_id => &$resource_got_amount) {
248
-            if($resource_got_amount <= 0) {
247
+          foreach ($resource_diff as $resource_got_id => &$resource_got_amount) {
248
+            if ($resource_got_amount <= 0) {
249 249
               continue;
250 250
             }
251 251
             $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id];
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         $is_autoconvert_ok = true;
264
-        foreach($resource_diff as $resource_diff_amount2) {
265
-          if($resource_diff_amount2 < 0) {
264
+        foreach ($resource_diff as $resource_diff_amount2) {
265
+          if ($resource_diff_amount2 < 0) {
266 266
             $is_autoconvert_ok = false;
267 267
             break;
268 268
           }
269 269
         }
270 270
 
271
-        if($is_autoconvert_ok) {
271
+        if ($is_autoconvert_ok) {
272 272
           $build_data['RESULT'][$build_mode] = BUILD_ALLOWED;
273 273
           $build_data['CAN'][$build_mode] = $unit_amount;
274 274
         } else {
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
       }
278 278
     }
279 279
     $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount);
280
-    if($unit_amount <= 0) {
280
+    if ($unit_amount <= 0) {
281 281
       throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION
282 282
     }
283 283
 
284
-    if($new_unit_level < 0) {
284
+    if ($new_unit_level < 0) {
285 285
       throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION
286 286
     }
287 287
 
288
-    if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
288
+    if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) {
289 289
       throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION
290 290
     }
291 291
 
292
-    if($is_autoconvert) {
292
+    if ($is_autoconvert) {
293 293
       ksort($exchange);
294 294
       ksort($resource_got);
295 295
       db_change_units($user, $planet, array(
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     }
305 305
 
306 306
     $unit_amount_qued = 0;
307
-    while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
307
+    while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) {
308 308
       $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW);
309 309
       que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode);
310 310
       $unit_amount -= $place;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
     sn_db_transaction_commit();
316 316
 
317
-    if($redirect) {
317
+    if ($redirect) {
318 318
       sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id'));
319 319
     }
320 320
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
       'STATUS'  => ERR_NONE,
323 323
       'MESSAGE' => '{Строительство начато}',
324 324
     );
325
-  } catch(exception $e) {
325
+  } catch (exception $e) {
326 326
     sn_db_transaction_rollback();
327 327
     $operation_result = array(
328 328
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     );
331 331
   }
332 332
 
333
-  if(!empty($operation_result['MESSAGE'])) {
333
+  if (!empty($operation_result['MESSAGE'])) {
334 334
     $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . $lang['tech'][$unit_id] . ']';
335 335
   }
336 336
 
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 function que_recalculate($old_que) {
345 345
   $new_que = array();
346 346
 
347
-  if(!is_array($old_que['items'])) {
347
+  if (!is_array($old_que['items'])) {
348 348
     return $new_que;
349 349
   }
350
-  foreach($old_que['items'] as $row) {
351
-    if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
350
+  foreach ($old_que['items'] as $row) {
351
+    if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) {
352 352
       continue;
353 353
     }
354 354
 
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 
360 360
     $last_id = count($new_que['items']) - 1;
361 361
 
362
-    if($row['que_planet_id']) {
362
+    if ($row['que_planet_id']) {
363 363
       $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id];
364
-    } elseif($row['que_type'] == QUE_RESEARCH) {
364
+    } elseif ($row['que_type'] == QUE_RESEARCH) {
365 365
       $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id];
366 366
     }
367 367
     $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id];
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
   $que_type = que_get_unit_que($unit_id);
397 397
   $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL';
398 398
   $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin;
399
-  if(is_numeric($planet_id)) {
399
+  if (is_numeric($planet_id)) {
400 400
     DBStaticPlanet::db_planet_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())");
401
-  } elseif(is_numeric($user['id'])) {
401
+  } elseif (is_numeric($user['id'])) {
402 402
     db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
403 403
   }
404 404
 
@@ -428,17 +428,17 @@  discard block
 block discarded – undo
428 428
   $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0;
429 429
   $global_que = que_get($user['id'], $planet['id'], $que_type, true);
430 430
 
431
-  if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
431
+  if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) {
432 432
     $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]);
433 433
 
434
-    foreach($que as $que_item) {
434
+    foreach ($que as $que_item) {
435 435
       DBStaticQue::db_que_delete_by_id($que_item['que_id']);
436 436
 
437
-      if($que_item['que_planet_id_origin']) {
437
+      if ($que_item['que_planet_id_origin']) {
438 438
         $planet['id'] = $que_item['que_planet_id_origin'];
439 439
       }
440 440
 
441
-      if(!isset($planets_locked[$planet['id']])) {
441
+      if (!isset($planets_locked[$planet['id']])) {
442 442
         $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet;
443 443
       }
444 444
 
@@ -450,15 +450,15 @@  discard block
 block discarded – undo
450 450
         RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'],
451 451
       ));
452 452
 
453
-      if(!$clear) {
453
+      if (!$clear) {
454 454
         break;
455 455
       }
456 456
     }
457 457
 
458
-    if(is_numeric($planet['id'])) {
458
+    if (is_numeric($planet['id'])) {
459 459
       DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())");
460 460
     }
461
-    elseif(is_numeric($user['id'])) {
461
+    elseif (is_numeric($user['id'])) {
462 462
       db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
463 463
     }
464 464
 
@@ -503,21 +503,21 @@  discard block
 block discarded – undo
503 503
   // TODO: Переделать для $que_type === false
504 504
   $planet['id'] = $planet['id'] ? $planet['id'] : 0;
505 505
 
506
-  if(!is_array($que)) {
506
+  if (!is_array($que)) {
507 507
     $que = que_get($user['id'], $planet['id'], $que_type);
508 508
   }
509 509
 
510
-  if(is_array($que) && isset($que['items'])) {
510
+  if (is_array($que) && isset($que['items'])) {
511 511
     $que = $que['ques'][$que_type][$user['id']][$planet['id']];
512 512
   }
513 513
 
514
-  if($que) {
515
-    foreach($que as $que_element) {
514
+  if ($que) {
515
+    foreach ($que as $que_element) {
516 516
       $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names));
517 517
     }
518 518
   }
519 519
 
520
-  if($que_type == QUE_RESEARCH) {
520
+  if ($que_type == QUE_RESEARCH) {
521 521
     // TODO Исправить
522 522
 //    $template->assign_var('RESEARCH_ONGOING', count($global_que[QUE_RESEARCH][0]) >= $config->server_que_length_research);
523 523
   }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
   $user = db_user_by_id($user['id'], true);
546 546
 
547 547
   $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']);
548
-  if($planet === null && !$time_left[$user['id']][0]) {
548
+  if ($planet === null && !$time_left[$user['id']][0]) {
549 549
     // TODO
550 550
     return $que;
551 551
   }
@@ -554,12 +554,12 @@  discard block
 block discarded – undo
554 554
   $que_type_id = $planet === null ? QUE_RESEARCH : false;
555 555
   $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false
556 556
   $que = que_get($user['id'], $planet, $que_type_id, true);
557
-  if(empty($que['items'])) {
557
+  if (empty($que['items'])) {
558 558
     return $que;
559 559
   }
560 560
 
561 561
   $planet_list = array();
562
-  if($planet !== null) {
562
+  if ($planet !== null) {
563 563
     // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них
564 564
     // TODO - от них не надо ничего, кроме ID и que_processed
565 565
     $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet);
@@ -568,21 +568,21 @@  discard block
 block discarded – undo
568 568
   }
569 569
 
570 570
   // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты
571
-  if(array_sum($time_left[$user['id']]) == 0) {
571
+  if (array_sum($time_left[$user['id']]) == 0) {
572 572
     return $que;
573 573
   }
574 574
 
575 575
   $db_changeset = array();
576 576
   $unit_changes = array();
577
-  foreach($que['items'] as &$que_item) {
577
+  foreach ($que['items'] as &$que_item) {
578 578
     $que_player_id = &$que_item['que_player_id'];
579 579
     $que_planet_id = intval($que_item['que_planet_id']);
580 580
 
581 581
     $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']];
582
-    if(!isset($que_time_left)) {
582
+    if (!isset($que_time_left)) {
583 583
       $que_time_left = $time_left[$que_player_id][$que_planet_id];
584 584
     }
585
-    if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
585
+    if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) {
586 586
       continue;
587 587
     }
588 588
     // Дальше мы идем, если только осталось время в очереди И юниты к постройке
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
     // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля
596 596
 
597 597
     // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит
598
-    if($que_time_left >= $que_item['que_time_left']) {
598
+    if ($que_time_left >= $que_item['que_time_left']) {
599 599
       // Увеличиваем количество отстроенных юнитов
600 600
       $unit_processed++;
601 601
       // Вычитаем из времени очереди потраченное на постройку время
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
     $que_item['que_unit_amount'] -= $unit_processed;
609 609
 
610 610
     // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита
611
-    if($que_item['que_unit_amount'] > 0) {
611
+    if ($que_item['que_unit_amount'] > 0) {
612 612
       $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left;
613 613
       $que_time_left = 0;
614 614
     }
615 615
 
616
-    if($que_item['que_unit_amount'] <= 0) {
616
+    if ($que_item['que_unit_amount'] <= 0) {
617 617
       $db_changeset['que'][] = array(
618 618
         'action' => SQL_OP_DELETE,
619 619
         P_VERSION => 1,
@@ -639,14 +639,14 @@  discard block
 block discarded – undo
639 639
       );
640 640
     }
641 641
 
642
-    if($unit_processed) {
642
+    if ($unit_processed) {
643 643
       $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1);
644 644
       $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta;
645 645
     }
646 646
   }
647 647
 
648
-  foreach($time_left as $player_id => $planet_data) {
649
-    foreach($planet_data as $planet_id => $time_on_planet) {
648
+  foreach ($time_left as $player_id => $planet_data) {
649
+    foreach ($planet_data as $planet_id => $time_on_planet) {
650 650
       $table = $planet_id ? 'planets' : 'users';
651 651
       $id = $planet_id ? $planet_id : $player_id;
652 652
       $db_changeset[$table][] = array(
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
         ),
663 663
       );
664 664
 
665
-      if(is_array($unit_changes[$player_id][$planet_id])) {
666
-        foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
665
+      if (is_array($unit_changes[$player_id][$planet_id])) {
666
+        foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) {
667 667
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null);
668 668
         }
669 669
       }
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
   $que = que_recalculate($que);
674 674
 
675 675
   // TODO: Re-enable quests for Alliances
676
-  if(!empty($unit_changes) && !$user['user_as_ally']) {
676
+  if (!empty($unit_changes) && !$user['user_as_ally']) {
677 677
     $quest_list = qst_get_quests($user['id'], QUEST_STATUS_ALL);
678 678
     $quest_triggers = qst_active_triggers($quest_list);
679 679
     $quest_rewards = array();
@@ -681,26 +681,26 @@  discard block
 block discarded – undo
681 681
 
682 682
 
683 683
     $xp_incoming = array();
684
-    foreach($unit_changes as $user_id => $planet_changes) {
685
-      foreach($planet_changes as $planet_id => $changes) {
684
+    foreach ($unit_changes as $user_id => $planet_changes) {
685
+      foreach ($planet_changes as $planet_id => $changes) {
686 686
         $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array();
687
-        foreach($changes as $unit_id => $unit_value) {
687
+        foreach ($changes as $unit_id => $unit_value) {
688 688
           $que_id = que_get_unit_que($unit_id);
689 689
           $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value;
690
-          if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
690
+          if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) {
691 691
             $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1);
692 692
             $build_data = $build_data[BUILD_CREATE];
693
-            foreach(sn_get_groups('resources_loot') as $resource_id) {
693
+            foreach (sn_get_groups('resources_loot') as $resource_id) {
694 694
               $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена
695 695
             }
696 696
           }
697 697
 
698
-          if(is_array($quest_triggers)) {
698
+          if (is_array($quest_triggers)) {
699 699
             // TODO: Check mutiply condition quests
700 700
             $quest_trigger_list = array_keys($quest_triggers, $unit_id);
701 701
 
702
-            if(is_array($quest_trigger_list)) {
703
-              foreach($quest_trigger_list as $quest_id) {
702
+            if (is_array($quest_trigger_list)) {
703
+              foreach ($quest_trigger_list as $quest_id) {
704 704
                 if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE) {
705 705
                   if ($quest_list[$quest_id]['quest_unit_amount'] <= $unit_level_new) {
706 706
                     $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list'];
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч
719 719
     qst_reward($user, $quest_rewards, $quest_list, $quest_statuses);
720 720
 
721
-    foreach($xp_incoming as $que_id => $xp) {
721
+    foreach ($xp_incoming as $que_id => $xp) {
722 722
       rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000);
723 723
     }
724 724
   }
Please login to merge, or discard this patch.
includes/pages/imperator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 //    $same_user = false;
48 48
 //  }
49 49
 
50
-  if(!$user_data) {
50
+  if (!$user_data) {
51 51
     messageBox($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10);
52 52
     die();
53 53
   }
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
   $stat_array = array();
59 59
   $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;");
60 60
   $stat_count = classSupernova::$db->db_affected_rows();
61
-  while($row = db_fetch($query)) {
62
-    foreach($stat_fields as $field_db_name => $field_template_name) {
61
+  while ($row = db_fetch($query)) {
62
+    foreach ($stat_fields as $field_db_name => $field_template_name) {
63 63
       // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS
64 64
       $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name];
65 65
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
   $stat_array_date = $stat_array['STAT_DATE'];
69 69
   empty($stat_array_date['DATA']) ? $stat_array_date['DATA'] = array() : false;
70
-  foreach($stat_array_date['DATA'] as $key => $value) {
70
+  foreach ($stat_array_date['DATA'] as $key => $value) {
71 71
     $template->assign_block_vars('stat_date', array(
72 72
       'ID' => $key,
73 73
       'VALUE' => $value,
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 
78 78
   unset($stat_array['STAT_DATE']);
79 79
   $template_data = array();
80
-  foreach($stat_array as $stat_type => &$stat_type_data) {
80
+  foreach ($stat_array as $stat_type => &$stat_type_data) {
81 81
     $reverse_min_max = strpos($stat_type, '_RANK') !== false;
82 82
     $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']);
83 83
     $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']);
84 84
     $stat_type_data['AVG'] = average($stat_type_data['DATA']);
85
-    foreach($stat_type_data['DATA'] as $key => $value) {
85
+    foreach ($stat_type_data['DATA'] as $key => $value) {
86 86
       $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100;
87 87
       $template_data[$stat_type][$key]['ID'] = $key;
88 88
       $template_data[$stat_type][$key]['VALUE'] = $value;
89
-      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN']  - $value : $value - $stat_type_data['MAX']);
89
+      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']);
90 90
       $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key];
91 91
     }
92 92
   }
93 93
 
94
-  foreach($template_data as $stat_type => $stat_type_data) {
94
+  foreach ($template_data as $stat_type => $stat_type_data) {
95 95
     $template->assign_block_vars('stat', array(
96 96
       'TYPE' => $stat_type,
97 97
       'TEXT' => $lang['imp_stat_types'][$stat_type],
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
       'MAX' => $stat_array[$stat_type]['MAX'],
100 100
       'AVG' => $stat_array[$stat_type]['AVG'],
101 101
     ));
102
-    foreach($stat_type_data as $stat_entry) {
102
+    foreach ($stat_type_data as $stat_entry) {
103 103
       $template->assign_block_vars('stat.entry', $stat_entry);
104 104
     }
105 105
   }
106 106
 
107 107
 
108
-  if($same_user) {
108
+  if ($same_user) {
109 109
     rpg_level_up($user, RPG_STRUCTURE);
110 110
     rpg_level_up($user, RPG_RAID);
111 111
     rpg_level_up($user, RPG_TECH);
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
     'builder_xp'           => pretty_number($user_data['xpminier']),
140 140
     'builder_lvl'          => pretty_number($user_data['lvl_minier']),
141 141
     'builder_lvl_st'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])),
142
-    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)),
142
+    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)),
143 143
     'raid_xp'              => pretty_number($user_data['xpraid']),
144 144
     'raid_lvl'             => pretty_number($user_data['lvl_raid']),
145
-    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)),
145
+    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)),
146 146
     'raids'                => pretty_number($user_data['raids']),
147 147
     'raidswin'             => pretty_number($user_data['raidswin']),
148 148
     'raidsloose'           => pretty_number($user_data['raidsloose']),
149 149
     'tech_xp'              => pretty_number($user_data['player_rpg_tech_xp']),
150 150
     'tech_lvl'             => pretty_number($user_data['player_rpg_tech_level']),
151 151
     'tech_lvl_st'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])),
152
-    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)),
152
+    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)),
153 153
 
154 154
     'explore_xp'           => pretty_number($user_data['player_rpg_explore_xp']),
155 155
     'explore_lvl'          => pretty_number($user_data['player_rpg_explore_level']),
156 156
     'explore_lvl_st'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])),
157
-    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)),
158
-
159
-    'build_points'         => pretty_number( $StatRecord['build_points'] ),
160
-    'tech_points'          => pretty_number( $StatRecord['tech_points'] ),
161
-    'fleet_points'         => pretty_number( $StatRecord['fleet_points'] ),
162
-    'defs_points'          => pretty_number( $StatRecord['defs_points'] ),
163
-    'res_points'           => pretty_number( $StatRecord['res_points'] ),
164
-    'total_points'         => pretty_number( $StatRecord['total_points'] ),
157
+    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)),
158
+
159
+    'build_points'         => pretty_number($StatRecord['build_points']),
160
+    'tech_points'          => pretty_number($StatRecord['tech_points']),
161
+    'fleet_points'         => pretty_number($StatRecord['fleet_points']),
162
+    'defs_points'          => pretty_number($StatRecord['defs_points']),
163
+    'res_points'           => pretty_number($StatRecord['res_points']),
164
+    'total_points'         => pretty_number($StatRecord['total_points']),
165 165
     'user_rank'            => $StatRecord['total_rank'],
166 166
     'RANK_DIFF'            => $StatRecord['total_old_rank'] - $StatRecord['total_rank'],
167 167
 
Please login to merge, or discard this patch.
includes/pages/options.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
   $language_new = sys_get_param_str('langer', $user['lang']);
13 13
 
14
-  if($language_new != $user['lang']) {
14
+  if ($language_new != $user['lang']) {
15 15
     $lang->lng_switch($language_new);
16 16
   }
17 17
 
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
 
21 21
   $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
22 22
 
23
-  if(sys_get_param_str('mode') == 'change') {
24
-    if($user['authlevel'] > 0) {
23
+  if (sys_get_param_str('mode') == 'change') {
24
+    if ($user['authlevel'] > 0) {
25 25
       $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0;
26 26
       DBStaticPlanet::db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'");
27 27
       db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'");
28 28
       $user['admin_protection'] = $planet_protection;
29 29
     }
30 30
 
31
-    if(sys_get_param_int('vacation') && !$config->user_vacation_disable) {
31
+    if (sys_get_param_int('vacation') && !$config->user_vacation_disable) {
32 32
       sn_db_transaction_start();
33
-      if($user['authlevel'] < 3) {
34
-        if($user['vacation_next'] > SN_TIME_NOW) {
33
+      if ($user['authlevel'] < 3) {
34
+        if ($user['vacation_next'] > SN_TIME_NOW) {
35 35
           messageBox($lang['opt_vacation_err_timeout'], $lang['Error'], 'index.php?page=options', 5);
36 36
           die();
37 37
         }
38 38
 
39
-        if(fleet_count_flying($user['id'])) {
39
+        if (fleet_count_flying($user['id'])) {
40 40
           messageBox($lang['opt_vacation_err_your_fleet'], $lang['Error'], 'index.php?page=options', 5);
41 41
           die();
42 42
         }
43 43
 
44 44
         $que = que_get($user['id'], false);
45
-        if(!empty($que)) {
45
+        if (!empty($que)) {
46 46
           messageBox($lang['opt_vacation_err_que'], $lang['Error'], 'index.php?page=options', 5);
47 47
           die();
48 48
         }
49 49
 
50 50
         $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}");
51
-        foreach($query as $planet) {
51
+        foreach ($query as $planet) {
52 52
           DBStaticPlanet::db_planet_set_by_id($planet['id'],
53 53
             "last_update = " . SN_TIME_NOW . ", energy_used = '0', energy_max = '0',
54 54
             metal_perhour = '{$config->metal_basic_income}', crystal_perhour = '{$config->crystal_basic_income}', deuterium_perhour = '{$config->deuterium_basic_income}',
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
       sn_db_transaction_commit();
64 64
     }
65 65
 
66
-    foreach($user_option_list as $option_group_id => $option_group) {
67
-      foreach($option_group as $option_name => $option_value) {
68
-        if($user[$option_name] !== null) {
66
+    foreach ($user_option_list as $option_group_id => $option_group) {
67
+      foreach ($option_group as $option_name => $option_value) {
68
+        if ($user[$option_name] !== null) {
69 69
           $user[$option_name] = sys_get_param_str($option_name);
70 70
         } else {
71 71
           $user[$option_name] = $option_value;
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 
77 77
 
78 78
     $player_options = sys_get_param('options');
79
-    if(!empty($player_options)) {
80
-      if($player_options[PLAYER_OPTION_TUTORIAL_CURRENT] == classSupernova::$config->tutorial_first_item) {
79
+    if (!empty($player_options)) {
80
+      if ($player_options[PLAYER_OPTION_TUTORIAL_CURRENT] == classSupernova::$config->tutorial_first_item) {
81 81
         $player_options[PLAYER_OPTION_TUTORIAL_FINISHED] = 0;
82 82
       }
83 83
 
84
-      array_walk($player_options, function (&$value) {
84
+      array_walk($player_options, function(&$value) {
85 85
         // TODO - Когда будет больше параметров - сделать больше проверок
86 86
         $value = intval($value);
87 87
       });
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 
91 91
     $username = substr(sys_get_param_str_unsafe('username'), 0, 32);
92 92
     $username_safe = db_escape($username);
93
-    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)) {
93
+    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)) {
94 94
       // проверка на корректность
95 95
       sn_db_transaction_start();
96 96
       $name_check = doquery("SELECT * FROM {{player_name_history}} WHERE `player_name` LIKE \"{$username_safe}\" LIMIT 1 FOR UPDATE;", true);
97
-      if(!$name_check || $name_check['player_id'] == $user['id']) {
97
+      if (!$name_check || $name_check['player_id'] == $user['id']) {
98 98
         $user = db_user_by_id($user['id'], true);
99
-        switch($config->game_user_changename) {
99
+        switch ($config->game_user_changename) {
100 100
           case SERVER_PLAYER_NAME_CHANGE_PAY:
101
-            if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) {
101
+            if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) {
102 102
               $template_result['.']['result'][] = array(
103 103
                 'STATUS'  => ERR_ERROR,
104 104
                 'MESSAGE' => $lang['opt_msg_name_change_err_no_dm'],
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
128 128
       sn_db_transaction_commit();
129 129
     }
130 130
 
131
-    if($new_password = sys_get_param('newpass1')) {
131
+    if ($new_password = sys_get_param('newpass1')) {
132 132
       try {
133
-        if($new_password != sys_get_param('newpass2')) {
133
+        if ($new_password != sys_get_param('newpass2')) {
134 134
           throw new Exception($lang['opt_err_pass_unmatched'], ERR_WARNING);
135 135
         }
136 136
 
137
-        if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
137
+        if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
138 138
           throw new Exception($lang['opt_err_pass_wrong'], ERR_WARNING);
139 139
         }
140 140
 
141 141
         throw new Exception($lang['opt_msg_pass_changed'], ERR_NONE);
142
-      } catch(Exception $e) {
142
+      } catch (Exception $e) {
143 143
         $template_result['.']['result'][] = array(
144 144
           'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
145 145
           'MESSAGE' => $e->getMessage()
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
     $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender'];
161 161
 
162 162
     try {
163
-      if($user['birthday']) {
163
+      if ($user['birthday']) {
164 164
         throw new exception();
165 165
       }
166 166
 
167 167
       $user_birthday = sys_get_param_str_unsafe('user_birthday');
168
-      if(!$user_birthday || $user_birthday == $FMT_DATE) {
168
+      if (!$user_birthday || $user_birthday == $FMT_DATE) {
169 169
         throw new exception();
170 170
       }
171 171
 
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
       $pos['Y'] = strpos(FMT_DATE, 'Y');
176 176
       asort($pos);
177 177
       $i = 0;
178
-      foreach($pos as &$position) {
178
+      foreach ($pos as &$position) {
179 179
         $position = ++$i;
180 180
       }
181 181
 
182 182
       $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/";
183
-      if(!preg_match($regexp, $user_birthday, $match)) {
183
+      if (!preg_match($regexp, $user_birthday, $match)) {
184 184
         throw new exception();
185 185
       }
186 186
 
187
-      if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
187
+      if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
188 188
         throw new exception();
189 189
       }
190 190
 
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
       // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format
193 193
 
194 194
       $year = date('Y', SN_TIME_NOW);
195
-      if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
195
+      if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
196 196
         $year--;
197 197
       }
198 198
       $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}");
199 199
 
200 200
       $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'";
201
-    } catch(exception $e) {
201
+    } catch (exception $e) {
202 202
       $user_birthday = '';
203 203
     }
204 204
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
     $template_result['.']['result'][] = $avatar_upload_result;
209 209
 
210 210
     $user_time_diff = playerTimeDiff::user_time_diff_get();
211
-    if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
211
+    if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
212 212
       playerTimeDiff::user_time_diff_set(array(
213 213
         PLAYER_OPTION_TIME_DIFF              => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'),
214 214
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
215 215
         PLAYER_OPTION_TIME_DIFF_FORCED       => 1,
216 216
         PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL,
217 217
       ));
218
-    } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
218
+    } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
219 219
       playerTimeDiff::user_time_diff_set(array(
220 220
         PLAYER_OPTION_TIME_DIFF              => '',
221 221
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
       'STATUS'  => ERR_NONE,
236 236
       'MESSAGE' => $lang['opt_msg_saved']
237 237
     );
238
-  } elseif(sys_get_param_str('result') == 'ok') {
238
+  } elseif (sys_get_param_str('result') == 'ok') {
239 239
     $template_result['.']['result'][] = array(
240 240
       'STATUS'  => ERR_NONE,
241 241
       'MESSAGE' => $lang['opt_msg_saved']
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
   $template = gettemplate('options', $template);
259 259
 
260 260
   $dir = dir(SN_ROOT_PHYSICAL . 'skins');
261
-  while(($entry = $dir->read()) !== false) {
262
-    if(is_dir("skins/{$entry}") && $entry[0] != '.') {
261
+  while (($entry = $dir->read()) !== false) {
262
+    if (is_dir("skins/{$entry}") && $entry[0] != '.') {
263 263
       $template_result['.']['skin_list'][] = array(
264 264
         'VALUE'    => $entry,
265 265
         'NAME'     => $entry,
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
   }
270 270
   $dir->close();
271 271
 
272
-  foreach($lang['opt_planet_sort_options'] as $key => &$value) {
272
+  foreach ($lang['opt_planet_sort_options'] as $key => &$value) {
273 273
     $template_result['.']['planet_sort_options'][] = array(
274 274
       'VALUE'    => $key,
275 275
       'NAME'     => $value,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     );
278 278
   }
279 279
 
280
-  foreach($lang['sys_gender_list'] as $key => $value) {
280
+  foreach ($lang['sys_gender_list'] as $key => $value) {
281 281
     $template_result['.']['gender_list'][] = array(
282 282
       'VALUE'    => $key,
283 283
       'NAME'     => $value,
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
   }
287 287
 
288 288
   $lang_list = lng_get_list();
289
-  foreach($lang_list as $lang_id => $lang_data) {
289
+  foreach ($lang_list as $lang_id => $lang_data) {
290 290
     $template_result['.']['languages'][] = array(
291 291
       'VALUE'    => $lang_id,
292 292
       'NAME'     => $lang_data['LANG_NAME_NATIVE'],
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
   }
296 296
 
297 297
 
298
-  if(isset($lang['menu_customize_show_hide_button_state'])) {
299
-    foreach($lang['menu_customize_show_hide_button_state'] as $key => $value) {
298
+  if (isset($lang['menu_customize_show_hide_button_state'])) {
299
+    foreach ($lang['menu_customize_show_hide_button_state'] as $key => $value) {
300 300
       $template->assign_block_vars('menu_customize_show_hide_button_state', array(
301 301
         'ID'   => $key,
302 302
         'NAME' => $value,
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
     'PAGE_HEADER' => $lang['opt_header'],
408 408
   ));
409 409
 
410
-  foreach($user_option_list as $option_group_id => $option_group) {
411
-    if($option_group_id == OPT_MESSAGE) {
412
-      foreach($sn_message_class_list as $message_class_id => $message_class_data) {
413
-        if($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
410
+  foreach ($user_option_list as $option_group_id => $option_group) {
411
+    if ($option_group_id == OPT_MESSAGE) {
412
+      foreach ($sn_message_class_list as $message_class_id => $message_class_data) {
413
+        if ($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
414 414
           $option_name = $message_class_data['name'];
415 415
 
416 416
           $template->assign_block_vars("options_{$option_group_id}", array(
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
         }
423 423
       }
424 424
     } else {
425
-      foreach($option_group as $option_name => $option_value) {
426
-        if(array_key_exists($option_name, $user_option_types)) {
425
+      foreach ($option_group as $option_name => $option_value) {
426
+        if (array_key_exists($option_name, $user_option_types)) {
427 427
           $option_type = $user_option_types[$option_name];
428 428
         } else {
429 429
           $option_type = 'switch';
Please login to merge, or discard this patch.
includes/includes/flt_page1.inc 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@  discard block
 block discarded – undo
4 4
 // @version 1.0
5 5
 // @copyright 2008 by Chlorel for XNova
6 6
 
7
-if(SN_IN_FLEET !== true) {
7
+if (SN_IN_FLEET !== true) {
8 8
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
9 9
 }
10 10
 
11 11
 $template = gettemplate('fleet1', true);
12 12
 
13 13
 $ships = sys_get_param('ships', array());
14
-if(!is_array($ships)) {
14
+if (!is_array($ships)) {
15 15
   $ships = array();
16 16
 }
17 17
 
18
-foreach(array(PT_PLANET, PT_DEBRIS, PT_MOON) as $possible_planet_type_id) {
18
+foreach (array(PT_PLANET, PT_DEBRIS, PT_MOON) as $possible_planet_type_id) {
19 19
   $template->assign_block_vars('possible_planet_type_id', array(
20 20
     'ID' => $possible_planet_type_id,
21 21
     'NAME' => $lang['sys_planet_type_sh'][$possible_planet_type_id],
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
   'START_NAME'         => $planetrow['name'],
29 29
 );
30 30
 
31
-if(!empty($TargetPlanet)) {
31
+if (!empty($TargetPlanet)) {
32 32
   $template_route += array(
33 33
     'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
34 34
     'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 $template->assign_block_vars('fleets', $template_route);
40 40
 
41 41
 $sn_groups_fleet = sn_get_groups('fleet');
42
-foreach($ships as $ship_id => $ship_count) {
43
-  if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
42
+foreach ($ships as $ship_id => $ship_count) {
43
+  if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
44 44
     $ship_info = get_unit_param($ship_id);
45
-    if($ship_count > mrc_get_level($user, $planetrow, $ship_id, false, true)) {
45
+    if ($ship_count > mrc_get_level($user, $planetrow, $ship_id, false, true)) {
46 46
       $page .= $lang['fl_noenought'];
47 47
     } else {
48 48
       $fleet['fleetarray'][$ship_id]  = $ship_count;
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
   }
62 62
 }
63 63
 
64
-if(empty($fleet['fleetarray'])) {
64
+if (empty($fleet['fleetarray'])) {
65 65
   messageBox($lang['fl_err_no_ships'], $lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
66 66
 }
67 67
 
68 68
 // Building list of shortcuts
69 69
 $query = doquery("SELECT * FROM {{notes}} WHERE `owner` = {$user['id']} AND `galaxy` <> 0 AND `system` <> 0 AND `planet` <> 0 ORDER BY `priority` DESC, `galaxy`, `system`, `planet`, `planet_type`;");
70
-while($shortcut = db_fetch($query)) {
70
+while ($shortcut = db_fetch($query)) {
71 71
   $template->assign_block_vars('shortcut', array(
72 72
     'NAME'       => $shortcut['title'],
73 73
     'GALAXY'     => $shortcut['galaxy'],
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 }
82 82
 
83 83
 // Building list of own planets & moons
84
-$colonies = DBStaticPlanet::db_planet_list_sorted ( $user );
85
-if(count($colonies) > 1) {
84
+$colonies = DBStaticPlanet::db_planet_list_sorted($user);
85
+if (count($colonies) > 1) {
86 86
   // while($row = db_fetch($colonies))
87
-  foreach($colonies as $row) {
87
+  foreach ($colonies as $row) {
88 88
     $template->assign_block_vars('colonies', array(
89 89
       'NAME'       => $row['name'],
90 90
       'GALAXY'     => $row['galaxy'],
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 //ACS Start
100 100
 //Need to look for acs attacks.
101 101
 $aks_madnessred = doquery('SELECT * FROM {{aks}};');
102
-while($row = db_fetch($aks_madnessred)) {
102
+while ($row = db_fetch($aks_madnessred)) {
103 103
   $members = explode(',', $row['eingeladen']);
104
-  foreach($members as $a => $b) {
104
+  foreach ($members as $a => $b) {
105 105
     if ($b == $user['id']) {
106 106
       $template->assign_block_vars('acss', array(
107 107
         'ID'         => $row['id'],
Please login to merge, or discard this patch.