Completed
Push — work-fleets ( 4d76fa...c97fe0 )
by SuperNova.WS
05:17
created
includes/functions/msg_send_simple_message.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 
23 23
   $list = '';
24 24
   $query = db_user_list(
25
-    "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
25
+    "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
26 26
     false, 'id, username');
27 27
   // while ($u = db_fetch($query))
28
-  foreach($query as $u) {
28
+  foreach ($query as $u) {
29 29
     $sendList[] = $u['id'];
30 30
     $list .= "<br>{$u['username']} ";
31 31
   }
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = false, $force = false) {
39 39
   global $user, $sn_message_class_list;
40 40
 
41
-  if(!$owners) {
41
+  if (!$owners) {
42 42
     return;
43 43
   }
44 44
 
45 45
   $timestamp = $timestamp ? $timestamp : SN_TIME_NOW;
46 46
   $sender = intval($sender);
47
-  if(!is_array($owners)) {
47
+  if (!is_array($owners)) {
48 48
     $owners = array($owners);
49 49
   }
50 50
 
51
-  if(!$escaped) {
51
+  if (!$escaped) {
52 52
     $from = db_escape($from);
53 53
     $subject = db_escape($subject);
54 54
     $text = db_escape($text);
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 
64 64
   $message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name'];
65 65
 
66
-  if($owners[0] == '*') {
67
-    if($user['authlevel'] < 3) {
66
+  if ($owners[0] == '*') {
67
+    if ($user['authlevel'] < 3) {
68 68
       return false;
69 69
     }
70 70
     // TODO Добавить $timestamp - рассылка может быть и отсроченной
@@ -73,26 +73,26 @@  discard block
 block discarded – undo
73 73
     $owners = array();
74 74
   } else {
75 75
     $insert_values = array();
76
-    $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')");
76
+    $insert_template = "('%u',".str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')");
77 77
 
78
-    foreach($owners as $owner) {
79
-      if($user['id'] != $owner) {
78
+    foreach ($owners as $owner) {
79
+      if ($user['id'] != $owner) {
80 80
         $owner_row = db_user_by_id($owner);
81 81
       } else {
82 82
         $owner_row = $user;
83 83
       }
84 84
       sys_user_options_unpack($owner_row);
85 85
 
86
-      if($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) {
86
+      if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) {
87 87
         $insert_values[] = sprintf($insert_template, $owner);
88 88
       }
89 89
 
90
-      if($message_class_email && classSupernova::$config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) {
90
+      if ($message_class_email && classSupernova::$config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) {
91 91
         @$result = mymail($owner_row['email'], $subject, $text_unescaped, '', true);
92 92
       }
93 93
     }
94 94
 
95
-    if(empty($insert_values)) {
95
+    if (empty($insert_values)) {
96 96
       return;
97 97
     }
98 98
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
   }
101 101
   db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1");
102 102
 
103
-  if(in_array($user['id'], $owners) || $owners[0] == '*') {
103
+  if (in_array($user['id'], $owners) || $owners[0] == '*') {
104 104
     $user[$message_class_name]++;
105 105
     $user[$message_class_name_total]++;
106 106
   }
Please login to merge, or discard this patch.
includes/functions/_news.php 1 patch
Spacing   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
   $announce_list = db_news_list_get_by_query($template, $query_where, $query_limit);
12 12
 
13 13
   $users = array();
14
-  while($announce = db_fetch($announce_list)) {
15
-    if($announce['user_id'] && !isset($users[$announce['user_id']])) {
14
+  while ($announce = db_fetch($announce_list)) {
15
+    if ($announce['user_id'] && !isset($users[$announce['user_id']])) {
16 16
       $users[$announce['user_id']] = db_user_by_id($announce['user_id']);
17 17
     }
18 18
 
19 19
     $survey_vote = array('survey_vote_id' => 1);
20 20
     $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW;
21 21
 
22
-    if($announce['survey_id'] && !empty($user['id'])) {
22
+    if ($announce['survey_id'] && !empty($user['id'])) {
23 23
       $survey_vote = !$survey_complete ? db_survey_get_vote($announce, $user) : array();
24 24
     }
25 25
 
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
       'ANNOUNCE'        => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])),
32 32
       'DETAIL_URL'      => $announce['detail_url'],
33 33
       'USER_NAME'       =>
34
-        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) :
35
-          js_safe_string($announce['user_name']),
34
+        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']),
36 35
       'NEW'             => $announce['unix_time'] + classSupernova::$config->game_news_actual >= SN_TIME_NOW,
37 36
       'FUTURE'          => $announce['unix_time'] > SN_TIME_NOW,
38 37
       'SURVEY_ID'       => $announce['survey_id'],
@@ -42,25 +41,25 @@  discard block
 block discarded – undo
42 41
       'SURVEY_UNTIL'    => $announce['survey_until'],
43 42
     ));
44 43
 
45
-    foreach($announce_exploded as $announce_paragraph) {
44
+    foreach ($announce_exploded as $announce_paragraph) {
46 45
       $template->assign_block_vars('announces.paragraph', array(
47 46
         'TEXT' => $announce_paragraph,
48 47
       ));
49 48
     }
50 49
 
51
-    if($announce['survey_id']) {
50
+    if ($announce['survey_id']) {
52 51
       $survey_query = db_survey_get_answer_texts($announce);
53 52
       $survey_vote_result = array();
54 53
       $total_votes = 0;
55
-      while($row = db_fetch($survey_query)) {
54
+      while ($row = db_fetch($survey_query)) {
56 55
         $survey_vote_result[] = $row;
57 56
         $total_votes += $row['VOTES'];
58 57
       }
59 58
 
60
-      if(empty($survey_vote) && !$survey_complete) {
59
+      if (empty($survey_vote) && !$survey_complete) {
61 60
         // Can vote
62 61
         $survey_query = db_survey_answers_get_list_by_parent($announce);
63
-        while($row = db_fetch($survey_query)) {
62
+        while ($row = db_fetch($survey_query)) {
64 63
           $template->assign_block_vars('announces.survey_answers', array(
65 64
             'ID'   => $row['survey_answer_id'],
66 65
             'TEXT' => $row['survey_answer_text'],
@@ -68,7 +67,7 @@  discard block
 block discarded – undo
68 67
         }
69 68
       } else {
70 69
         // Show result
71
-        foreach($survey_vote_result as &$vote_result) {
70
+        foreach ($survey_vote_result as &$vote_result) {
72 71
           $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0;
73 72
           $vote_result['PERCENT'] = $vote_percent;
74 73
           $vote_result['PERCENT_TEXT'] = round($vote_percent, 1);
@@ -85,8 +84,8 @@  discard block
 block discarded – undo
85 84
 }
86 85
 
87 86
 function nws_mark_read(&$user) {
88
-  if(isset($user['id'])) {
89
-    db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW);
87
+  if (isset($user['id'])) {
88
+    db_user_set_by_id($user['id'], '`news_lastread` = '.SN_TIME_NOW);
90 89
     $user['news_lastread'] = SN_TIME_NOW;
91 90
   }
92 91
 
@@ -94,17 +93,17 @@  discard block
 block discarded – undo
94 93
 }
95 94
 
96 95
 function survey_vote(&$user) {
97
-  if(empty($user['id'])) {
96
+  if (empty($user['id'])) {
98 97
     return true;
99 98
   }
100 99
 
101 100
   sn_db_transaction_start();
102 101
   $survey_id = sys_get_param_id('survey_id');
103 102
   $is_voted = db_survey_vote_get($user, $survey_id);
104
-  if(empty($is_voted)) {
103
+  if (empty($is_voted)) {
105 104
     $survey_vote_id = sys_get_param_id('survey_vote');
106 105
     $is_answer_exists = db_survey_answer_get($survey_id, $survey_vote_id);
107
-    if(!empty($is_answer_exists)) {
106
+    if (!empty($is_answer_exists)) {
108 107
       $user_name_safe = db_escape($user['username']);
109 108
       db_survey_vote_insert($user, $survey_id, $survey_vote_id, $user_name_safe);
110 109
     }
Please login to merge, or discard this patch.
includes/functions/lng_language.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 // ----------------------------------------------------------------------------------------------------------------
4 4
 function lng_try_filepath($path, $file_path_relative)
5 5
 {
6
-  $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative;
6
+  $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative;
7 7
   return file_exists($file_path) ? $file_path : false;
8 8
 }
9 9
 
Please login to merge, or discard this patch.
includes/functions/int_banner_create.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 // banner.php?id=<userid>&type=<banner|userbar>&format=<png>
16 16
   $id = intval($id);
17 17
 
18
-  switch($type) {
18
+  switch ($type) {
19 19
     case 'banner':
20 20
       $img_name = classSupernova::$config->int_banner_background;
21 21
     break;
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
       $img_name = classSupernova::$config->int_userbar_background;
25 25
     break;
26 26
   }
27
-  $size = getimagesize(SN_ROOT_PHYSICAL . $img_name);
28
-  $im = imagecreatefrompng(SN_ROOT_PHYSICAL . $img_name);
27
+  $size = getimagesize(SN_ROOT_PHYSICAL.$img_name);
28
+  $im = imagecreatefrompng(SN_ROOT_PHYSICAL.$img_name);
29 29
   $image = imagecreatetruecolor($size[0], $size[1]);
30 30
   imagecopy($image, $im, 0, 0, 0, 0, $size[0], $size[1]);
31 31
   imagedestroy($im);
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
   $txt_color2 = imagecolorallocatealpha($image, 255, 255, 255, 40);
43 43
 
44 44
   $fonts = array(
45
-    'userbar'  => SN_ROOT_PHYSICAL . "design/fonts/" . classSupernova::$config->int_userbar_font,
46
-    'universe' => SN_ROOT_PHYSICAL . "design/fonts/" . classSupernova::$config->int_banner_fontUniverse,
47
-    'raids'    => SN_ROOT_PHYSICAL . "design/fonts/" . classSupernova::$config->int_banner_fontRaids,
48
-    'info'     => SN_ROOT_PHYSICAL . "design/fonts/" . classSupernova::$config->int_banner_fontInfo,
45
+    'userbar'  => SN_ROOT_PHYSICAL."design/fonts/".classSupernova::$config->int_userbar_font,
46
+    'universe' => SN_ROOT_PHYSICAL."design/fonts/".classSupernova::$config->int_banner_fontUniverse,
47
+    'raids'    => SN_ROOT_PHYSICAL."design/fonts/".classSupernova::$config->int_banner_fontRaids,
48
+    'info'     => SN_ROOT_PHYSICAL."design/fonts/".classSupernova::$config->int_banner_fontInfo,
49 49
   );
50 50
 
51
-  if($id) {
51
+  if ($id) {
52 52
     // Querys
53 53
     $user = db_user_by_id($id);
54 54
     $planet_row = db_planet_by_id($user['id_planet']);
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
     $b_user = $user['username'];
58 58
     $b_ally = $user['ally_name'];
59 59
     $b_planet = $planet_row['name'];
60
-    $b_xyz = "[" . $planet_row['galaxy'] . ":" . $planet_row['system'] . ":" . $planet_row['planet'] . "]";
61
-    $b_lvl = ($user['total_rank'] ? $user['total_rank'] : classSupernova::$config->users_amount) . "/" . classSupernova::$config->users_amount;
60
+    $b_xyz = "[".$planet_row['galaxy'].":".$planet_row['system'].":".$planet_row['planet']."]";
61
+    $b_lvl = ($user['total_rank'] ? $user['total_rank'] : classSupernova::$config->users_amount)."/".classSupernova::$config->users_amount;
62 62
   } else {
63 63
     $b_user = classLocale::$lang['ov_banner_empty_id'];
64 64
   }
65 65
 
66 66
   $b_univ = classSupernova::$config->game_name;
67
-  switch($type) {
67
+  switch ($type) {
68 68
     case 'banner':
69 69
       // Banner size 416 x 58
70 70
       $fsize = 15;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
       imagettftext($image, 11, 0, 8, 26, $txt_shadow, $fonts['info'], $b_user);
78 78
       imagettftext($image, 11, 0, 6, 23, $txt_color, $fonts['info'], $b_user);
79 79
 
80
-      if($id) {
80
+      if ($id) {
81 81
         // Player level - right-alligned
82 82
         $is = imagettfbbox(11, 0, $fonts['info'], $b_lvl);
83 83
         imagettftext($image, 11, 0, $size[0] - 4 - $is[2], 25, $txt_shadow, $fonts['info'], $b_lvl);
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
         imagettftext($image, 9, 0, 410 - $is[2], 35, $txt_color, $fonts['info'], $b_ally);
90 90
 
91 91
         // Player b_planet
92
-        imagettftext($image, 6, 0, 8, 10, $txt_shadow2, $fonts['raids'], $b_planet . " " . $b_xyz);
93
-        imagettftext($image, 6, 0, 6, 9, $txt_color2, $fonts['raids'], $b_planet . " " . $b_xyz);
92
+        imagettftext($image, 6, 0, 8, 10, $txt_shadow2, $fonts['raids'], $b_planet." ".$b_xyz);
93
+        imagettftext($image, 6, 0, 6, 9, $txt_color2, $fonts['raids'], $b_planet." ".$b_xyz);
94 94
 
95 95
         //StatPoint
96
-        $b_points = classLocale::$lang['ov_points'] . ": " . pretty_number($user['total_points']);
96
+        $b_points = classLocale::$lang['ov_points'].": ".pretty_number($user['total_points']);
97 97
         $is = imagettfbbox(8, 0, $fonts['info'], $b_points);
98 98
         imagettftext($image, 8, 0, 412 - $is[2], 11, $txt_shadow, $fonts['info'], $b_points);
99 99
         imagettftext($image, 8, 0, 410 - $is[2], 9, $txt_color, $fonts['info'], $b_points);
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
         //Raids Total
102 102
         imagettftext($image, 6, 0, 8, 37, $txt_shadow2, $fonts['raids'], classLocale::$lang['NumberOfRaids']);
103 103
         imagettftext($image, 6, 0, 6, 35, $txt_color2, $fonts['raids'], classLocale::$lang['NumberOfRaids']);
104
-        $b_points = ": " . pretty_number($user['raids']);
104
+        $b_points = ": ".pretty_number($user['raids']);
105 105
         imagettftext($image, 6, 0, 61, 37, $txt_shadow2, $fonts['raids'], $b_points);
106 106
         imagettftext($image, 6, 0, 59, 35, $txt_color2, $fonts['raids'], $b_points);
107 107
 
108 108
         //Raids Won
109 109
         imagettftext($image, 6, 0, 8, 47, $txt_shadow2, $fonts['raids'], classLocale::$lang['RaidsWin']);
110 110
         imagettftext($image, 6, 0, 6, 45, $txt_color2, $fonts['raids'], classLocale::$lang['RaidsWin']);
111
-        $b_points = ": " . pretty_number($user['raidswin']);
111
+        $b_points = ": ".pretty_number($user['raidswin']);
112 112
         imagettftext($image, 6, 0, 61, 47, $txt_shadow2, $fonts['raids'], $b_points);
113 113
         imagettftext($image, 6, 0, 59, 45, $txt_color2, $fonts['raids'], $b_points);
114 114
 
115 115
         //Raids Lost
116 116
         imagettftext($image, 6, 0, 8, 57, $txt_shadow2, $fonts['raids'], classLocale::$lang['RaidsLoose']);
117 117
         imagettftext($image, 6, 0, 6, 55, $txt_color2, $fonts['raids'], classLocale::$lang['RaidsLoose']);
118
-        $b_points = ": " . pretty_number($user['raidsloose']);
118
+        $b_points = ": ".pretty_number($user['raidsloose']);
119 119
         imagettftext($image, 6, 0, 61, 57, $txt_shadow2, $fonts['raids'], $b_points);
120 120
         imagettftext($image, 6, 0, 59, 55, $txt_color2, $fonts['raids'], $b_points);
121 121
       }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
       imagettftext($image, 9, 0, 4, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_user);
136 136
       imagettftext($image, 9, 0, 2, $size[1] - 6, $txt_color, $fonts['userbar'], $b_user);
137 137
 
138
-      if($id) {
138
+      if ($id) {
139 139
         // Player level - right-alligned
140 140
         $isp = imagettfbbox(9, 0, $fonts['userbar'], $b_lvl);
141 141
         imagettftext($image, 9, 0, $is - $isp[2] - 10, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_lvl);
Please login to merge, or discard this patch.
includes/functions/sys_maintenance.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
     ),
23 23
   );
24 24
 
25
-  foreach($queries as &$query) {
26
-    if(!empty($query['query'])) {
25
+  foreach ($queries as &$query) {
26
+    if (!empty($query['query'])) {
27 27
       $query['result'] = doquery($query['query']);
28
-    } elseif(!empty($query['callable']) && is_callable($query['callable'])) {
28
+    } elseif (!empty($query['callable']) && is_callable($query['callable'])) {
29 29
       call_user_func($query['callable']);
30 30
     }
31 31
     $query['error'] = classSupernova::$db->db_error();
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
   $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
70 70
 //  pdump($prev_run_array);
71 71
   $scheduleList = explode(',', $scheduleList);
72
-  array_walk($scheduleList, function (&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
72
+  array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
73 73
     // pdump($schedule);
74 74
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
75 75
 
@@ -81,21 +81,21 @@  discard block
 block discarded – undo
81 81
     */
82 82
     // pdump($schedule);
83 83
 
84
-    foreach($prev_run_array as $index => $date_part) {
84
+    foreach ($prev_run_array as $index => $date_part) {
85 85
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
86 86
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
87 87
     }
88
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
88
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
89 89
       unset($schedule['array']['now']);
90 90
     }
91 91
 
92
-    foreach($schedule['array'] as $name => $array) {
92
+    foreach ($schedule['array'] as $name => $array) {
93 93
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
94
-      $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
95
-      $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
94
+      $schedule['string'][$name.'_next'] = $schedule['string'][$name].' +1 '.$interval;
95
+      $schedule['string'][$name.'_prev'] = $schedule['string'][$name].' -1 '.$interval;
96 96
     }
97 97
 
98
-    foreach($schedule['string'] as $string) {
98
+    foreach ($schedule['string'] as $string) {
99 99
       $timestamp = strtotime($string);
100 100
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
101 101
     }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
   $prev_run = 0;
129 129
   $next_run = 0;
130
-  foreach($possible_schedules as $timestamp => $string_date) {
130
+  foreach ($possible_schedules as $timestamp => $string_date) {
131 131
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
132 132
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
133 133
 //    pdump($schedule, '$schedule ' . date(FMT_DATE_TIME_SQL, $schedule));
Please login to merge, or discard this patch.
includes/functions/sys_bbcode.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,23 +107,23 @@
 block discarded – undo
107 107
 
108 108
   !empty(classSupernova::$config->url_faq) ? $msg = str_replace('faq://', classSupernova::$config->url_faq, $msg) : false;
109 109
 
110
-  foreach($supernova->design['bbcodes'] as $auth_level => $replaces) {
111
-    if($auth_level > $author_auth) {
110
+  foreach ($supernova->design['bbcodes'] as $auth_level => $replaces) {
111
+    if ($auth_level > $author_auth) {
112 112
       continue;
113 113
     }
114 114
 
115
-    foreach($replaces as $key => $html) {
115
+    foreach ($replaces as $key => $html) {
116 116
       $msg = preg_replace(''.$key.'', $html, $msg);
117 117
     }
118 118
   }
119 119
 
120
-  foreach($supernova->design['smiles'] as $auth_level => $replaces) {
121
-    if($auth_level > $author_auth) {
120
+  foreach ($supernova->design['smiles'] as $auth_level => $replaces) {
121
+    if ($auth_level > $author_auth) {
122 122
       continue;
123 123
     }
124 124
 
125
-    foreach($replaces as $key => $imgName) {
126
-      $msg = preg_replace("#" . addcslashes($key, '()[]{}') . "#isU","<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">",$msg);
125
+    foreach ($replaces as $key => $imgName) {
126
+      $msg = preg_replace("#".addcslashes($key, '()[]{}')."#isU", "<img src=\"design/images/smileys/".$imgName.".gif\" align=\"absmiddle\" title=\"".$key."\" alt=\"".$key."\">", $msg);
127 127
     }
128 128
   }
129 129
 
Please login to merge, or discard this patch.
includes/functions/flt_mission_missile.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
   $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
15 15
   $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100));
16
-  foreach($structures as $key => $structure)
16
+  foreach ($structures as $key => $structure)
17 17
   {
18 18
     $unit_info = get_unit_param($key);
19 19
     $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
   {
32 32
     //attacking only selected structure
33 33
     $damageDone = $structures[$targetedStructure][$damageTo];
34
-    $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
34
+    $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]);
35 35
     $structures[$targetedStructure][0] -= $structsDestroyed;
36
-    $MIPDamage -= $structsDestroyed*$damageDone;
36
+    $MIPDamage -= $structsDestroyed * $damageDone;
37 37
   }
38 38
   else
39 39
   {
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     do
45 45
     {
46 46
       // finding is there any structure that can be damaged with leftovers of $MIPDamage
47
-      foreach($can_be_damaged as $key => $unit_id)
47
+      foreach ($can_be_damaged as $key => $unit_id)
48 48
       {
49 49
 //debug($structures[$unit_id][0]);
50 50
 //debug($structures[$unit_id][$damageTo], $MIPDamage);
51
-        if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
51
+        if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
52 52
         {
53 53
           unset($can_be_damaged[$key]);
54 54
         }
55 55
       }
56
-      if(empty($can_be_damaged))
56
+      if (empty($can_be_damaged))
57 57
       {
58 58
         break;
59 59
       }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //debug($destroyed, 'Actually destroyed');
73 73
 
74 74
 //print('<hr>');
75
-    } while($MIPDamage > 0 && !empty($can_be_damaged));
75
+    } while ($MIPDamage > 0 && !empty($can_be_damaged));
76 76
 //debug($MIPDamage, 'MIPDamage left');
77 77
   }
78 78
 //debug($structures);//die();
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4;
88 88
   }
89 89
 
90
-  $return['structures'] = $structures;     // Structures left after attack
91
-  $return['metal']      = floor($metal);   // Metal scraps
90
+  $return['structures'] = $structures; // Structures left after attack
91
+  $return['metal']      = floor($metal); // Metal scraps
92 92
   $return['crystal']    = floor($crystal); // Crystal scraps
93 93
 
94 94
   return $return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
   $iraks = db_missile_list_by_arrival();
114 114
 
115
-  while($fleetRow = db_fetch($iraks)) {
115
+  while ($fleetRow = db_fetch($iraks)) {
116 116
     set_time_limit(15);
117 117
     $db_changeset = array();
118 118
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
     $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
130 130
 
131
-    if($target_planet_row['id']) {
131
+    if ($target_planet_row['id']) {
132 132
       $planetDefense = array();
133
-      foreach(sn_get_groups('defense_active') as $unit_id) {
133
+      foreach (sn_get_groups('defense_active') as $unit_id) {
134 134
         $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
135 135
       }
136 136
 
@@ -141,24 +141,24 @@  discard block
 block discarded – undo
141 141
         $message = classLocale::$lang['mip_all_destroyed'];
142 142
         $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
143 143
       } else {
144
-        if($interceptors) {
144
+        if ($interceptors) {
145 145
           $message = sprintf(classLocale::$lang['mip_destroyed'], $interceptors);
146 146
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
147 147
         }
148 148
 
149 149
         $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
150 150
 
151
-        foreach($attackResult['structures'] as $key => $structure) {
151
+        foreach ($attackResult['structures'] as $key => $structure) {
152 152
           $destroyed = $planetDefense[$key][0] - $structure[0];
153
-          if($destroyed) {
153
+          if ($destroyed) {
154 154
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($key, -$destroyed, $targetUser, $target_planet_row['id']);
155 155
 
156 156
             $message .= "&nbsp;&nbsp;{$classLocale['tech'][$key]} - {$destroyed} {$classLocale['quantity']}<br>";
157 157
           }
158 158
         }
159 159
 
160
-        if(!empty($message)) {
161
-          $message = classLocale::$lang['mip_defense_destroyed'] . $message . "{$classLocale['mip_recycled']}{$classLocale['Metal']}: {$attackResult['metal']}, {$classLocale['Crystal']}: {$attackResult['crystal']}<br>";
160
+        if (!empty($message)) {
161
+          $message = classLocale::$lang['mip_defense_destroyed'].$message."{$classLocale['mip_recycled']}{$classLocale['Metal']}: {$attackResult['metal']}, {$classLocale['Crystal']}: {$attackResult['crystal']}<br>";
162 162
 
163 163
           db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
164 164
         }
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 
176 176
       empty($message) ? $message = classLocale::$lang['mip_no_defense'] : false;
177 177
 
178
-      msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
179
-      msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
178
+      msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage.$message);
179
+      msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage.$message);
180 180
     }
181 181
     db_missile_delete($fleetRow);
182 182
   }
Please login to merge, or discard this patch.
includes/functions/tpl_helpers.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 // Compare function to sort fleet in time order
4 4
 function tpl_assign_fleet_compare($a, $b) {
5
-  if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) {
6
-    if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) {
5
+  if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) {
6
+    if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) {
7 7
       return 0;
8 8
     }
9 9
 
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
  * @param string   $js_name
20 20
  */
21 21
 function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') {
22
-  if(!$fleets) {
22
+  if (!$fleets) {
23 23
     return;
24 24
   }
25 25
 
26 26
   usort($fleets, 'tpl_assign_fleet_compare');
27 27
 
28
-  foreach($fleets as $fleet_data) {
28
+  foreach ($fleets as $fleet_data) {
29 29
     $template->assign_block_vars($js_name, $fleet_data['fleet']);
30 30
 
31
-    if($fleet_data['ships']) {
32
-      foreach($fleet_data['ships'] as $ship_data) {
31
+    if ($fleet_data['ships']) {
32
+      foreach ($fleet_data['ships'] as $ship_data) {
33 33
         $template->assign_block_vars("{$js_name}.ships", $ship_data);
34 34
       }
35 35
     }
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
     'DEUTERIUM' => $fleet[RES_DEUTERIUM],
51 51
   );
52 52
 
53
-  foreach($fleet as $ship_id => $ship_amount) {
54
-    if(in_array($ship_id, sn_get_groups('fleet'))) {
53
+  foreach ($fleet as $ship_id => $ship_amount) {
54
+    if (in_array($ship_id, sn_get_groups('fleet'))) {
55 55
       $single_ship_data = get_ship_data($ship_id, $user_data);
56 56
       $return['ships'][$ship_id] = array(
57 57
         'ID'          => $ship_id,
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 
91 91
   $result = array();
92 92
 
93
-  if(!$user_data) {
93
+  if (!$user_data) {
94 94
     $user_data = $user;
95 95
   }
96 96
 
97
-  if(!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) {
97
+  if (!$objFleet->isReturning() && $objFleet->mission_type == MT_ACS) {
98 98
     $aks = db_acs_get_by_group_id($objFleet->group_id);
99 99
   }
100 100
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     'MISSION'      => $objFleet->mission_type,
114 114
     'MISSION_NAME' => classLocale::$lang['type_mission'][$objFleet->mission_type],
115 115
     'ACS'          => !empty($aks['name']) ? $aks['name'] : (!empty($objFleet->group_id) ? $objFleet->group_id : ''),
116
-    'AMOUNT'       => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()) . (array_sum($fleet_resources) ? '+' : '')) : '?',
116
+    'AMOUNT'       => $spy_level >= 4 ? (pretty_number($objFleet->shipsGetTotal()).(array_sum($fleet_resources) ? '+' : '')) : '?',
117 117
 
118 118
     'METAL'     => $spy_level >= 8 ? $fleet_resources[RES_METAL] : 0,
119 119
     'CRYSTAL'   => $spy_level >= 8 ? $fleet_resources[RES_CRYSTAL] : 0,
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
     'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW),
136 136
   );
137 137
 
138
-  if(property_exists($objFleet, 'fleet_start_name')) {
138
+  if (property_exists($objFleet, 'fleet_start_name')) {
139 139
     $result['START_NAME'] = $objFleet->fleet_start_name;
140 140
   }
141
-  if(property_exists($objFleet, 'fleet_end_name')) {
141
+  if (property_exists($objFleet, 'fleet_end_name')) {
142 142
     $result['END_NAME'] = $objFleet->fleet_end_name;
143 143
   }
144 144
 
145
-  if(property_exists($objFleet, 'event_time')) {
145
+  if (property_exists($objFleet, 'event_time')) {
146 146
     $result['fleet'] = array_merge($result['fleet'], array(
147 147
       'OV_LABEL'        => $objFleet->ov_label,
148 148
       'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '',
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
   $ship_id = 0;
157 157
   $result['ships'] = array();
158
-  if($spy_level >= 6) {
159
-    foreach($ship_list_fully_parsed as $ship_sn_id => $ship_amount) {
160
-      if($spy_level >= 10) {
158
+  if ($spy_level >= 6) {
159
+    foreach ($ship_list_fully_parsed as $ship_sn_id => $ship_amount) {
160
+      if ($spy_level >= 10) {
161 161
         $single_ship_data = get_ship_data($ship_sn_id, $user_data);
162 162
         $result['ships'][$ship_sn_id] = array(
163 163
           'ID'          => $ship_sn_id,
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 function tpl_parse_planet_que($que, $planet, $que_id) {
191 191
   $hangar_que = array();
192 192
   $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']];
193
-  if(!empty($que_hangar)) {
194
-    foreach($que_hangar as $que_item) {
193
+  if (!empty($que_hangar)) {
194
+    foreach ($que_hangar as $que_item) {
195 195
       $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']);
196 196
       $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount'];
197 197
     }
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
     'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK),
252 252
   );
253 253
 
254
-  if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) {
254
+  if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) {
255 255
     $result['building_que'] = array();
256 256
     $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']];
257
-    foreach($building_que as $que_element) {
257
+    foreach ($building_que as $que_element) {
258 258
       $result['building_que'][] = que_tpl_parse_element($que_element);
259 259
     }
260 260
   }
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
 function flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet) {
271 271
   global $user;
272 272
 
273
-  if(empty($array_of_Fleet)) {
273
+  if (empty($array_of_Fleet)) {
274 274
     return false;
275 275
   }
276 276
 
277 277
   $fleet_list = array();
278
-  foreach($array_of_Fleet as $fleet) {
279
-    if($fleet->playerOwnerId == $user['id']) {
280
-      if($fleet->mission_type == MT_MISSILE) {
278
+  foreach ($array_of_Fleet as $fleet) {
279
+    if ($fleet->playerOwnerId == $user['id']) {
280
+      if ($fleet->mission_type == MT_MISSILE) {
281 281
         continue;
282 282
       }
283 283
       $fleet_ownage = 'own';
284 284
     } else {
285
-      switch($fleet->mission_type) {
285
+      switch ($fleet->mission_type) {
286 286
         case MT_ATTACK:
287 287
         case MT_ACS:
288 288
         case MT_DESTROY:
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 
300 300
     $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet;
301 301
 
302
-    if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) {
302
+    if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) {
303 303
       $fleet_sn = $fleet->shipsGetArray();
304
-      foreach($fleet_sn as $ship_id => $ship_amount) {
305
-        if(in_array($ship_id, sn_get_groups('fleet'))) {
304
+      foreach ($fleet_sn as $ship_id => $ship_amount) {
305
+        if (in_array($ship_id, sn_get_groups('fleet'))) {
306 306
           $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount;
307 307
         }
308 308
       }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
   return $fleet_list;
320 320
 }
321 321
 
322
-function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) {
322
+function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) {
323 323
   $template->assign_vars(array(
324 324
     'RESOURCE_ROUNDING' => $round,
325 325
 
Please login to merge, or discard this patch.
includes/functions/scheduler_process.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@  discard block
 block discarded – undo
9 9
   $ts_var_stat_update = strtotime(classSupernova::$config->db_loadItem('var_stat_update'));
10 10
   $ts_scheduled_update = sys_schedule_get_prev_run(classSupernova::$config->db_loadItem('stats_schedule'), classSupernova::$config->var_stat_update);
11 11
 
12
-  if(sys_get_param_int('admin_update')) {
12
+  if (sys_get_param_int('admin_update')) {
13 13
     define('USER_LEVEL', isset($user['authlevel']) ? $user['authlevel'] : -1);
14
-    if(USER_LEVEL > 0) {
14
+    if (USER_LEVEL > 0) {
15 15
       $is_admin_request = true;
16 16
       $ts_scheduled_update = SN_TIME_NOW;
17 17
     }
18 18
   }
19 19
 
20
-  if($ts_scheduled_update > $ts_var_stat_update) {
20
+  if ($ts_scheduled_update > $ts_var_stat_update) {
21 21
     lng_include('admin');
22 22
     sn_db_transaction_start();
23 23
     $ts_var_stat_update_end = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end'));
24
-    if(SN_TIME_NOW > $ts_var_stat_update_end) {
24
+    if (SN_TIME_NOW > $ts_var_stat_update_end) {
25 25
       $old_server_status = classSupernova::$config->db_loadItem('game_disable');
26 26
       classSupernova::$config->db_saveItem('game_disable', GAME_DISABLE_STAT);
27 27
 
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 
32 32
       $msg = $is_admin_request ? 'admin request' : 'scheduler';
33 33
       $next_run = date(FMT_DATE_TIME_SQL, sys_schedule_get_prev_run(classSupernova::$config->stats_schedule, classSupernova::$config->var_stat_update, true));
34
-      $msg = "Running stat updates: {$msg}. Config->var_stat_update = " . classSupernova::$config->var_stat_update .
35
-        ', $ts_scheduled_update = ' . date(FMT_DATE_TIME_SQL, $ts_scheduled_update) .
36
-        ', next_stat_update = ' . $next_run;
34
+      $msg = "Running stat updates: {$msg}. Config->var_stat_update = ".classSupernova::$config->var_stat_update.
35
+        ', $ts_scheduled_update = '.date(FMT_DATE_TIME_SQL, $ts_scheduled_update).
36
+        ', next_stat_update = '.$next_run;
37 37
       classSupernova::$debug->warning($msg, 'Stat update', LOG_INFO_STAT_PROCESS);
38 38
       $total_time = microtime(true);
39 39
 
40 40
       // require_once('../includes/sys_stat.php');
41
-      require_once(SN_ROOT_PHYSICAL . 'includes/includes/sys_stat.php');
41
+      require_once(SN_ROOT_PHYSICAL.'includes/includes/sys_stat.php');
42 42
       sys_stat_calculate();
43 43
 
44 44
       $total_time = microtime(true) - $total_time;
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
       classSupernova::$config->db_saveItem('var_stat_update_end', SN_TIME_SQL);
58 58
 
59 59
       classSupernova::$config->db_saveItem('game_disable', $old_server_status);
60
-    } elseif($ts_scheduled_update > $ts_var_stat_update) {
60
+    } elseif ($ts_scheduled_update > $ts_var_stat_update) {
61 61
       $timeout = strtotime(classSupernova::$config->db_loadItem('var_stat_update_end')) - SN_TIME_NOW;
62 62
       $msg = classSupernova::$config->db_loadItem('var_stat_update_msg');
63 63
       $msg = "{$msg} ETA {$timeout} seconds. Please wait...";
64 64
     }
65 65
     sn_db_transaction_rollback();
66
-  } elseif($is_admin_request) {
66
+  } elseif ($is_admin_request) {
67 67
     $msg = 'Stat is up to date';
68 68
   }
69 69
 
Please login to merge, or discard this patch.