Passed
Push — trunk ( e5589f...062c60 )
by SuperNova.WS
06:16
created
classes/template.php 1 patch
Braces   +29 added lines, -58 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 * Base Template class.
23 23
 * @package phpBB3
24 24
 */
25
-class template
26
-{
25
+class template {
27 26
   /** variable that holds all the data we'll be substituting into
28 27
   * the compiled templates. Takes form:
29 28
   * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
@@ -82,8 +81,7 @@  discard block
 block discarded – undo
82 81
   * Set template location
83 82
   * @access public
84 83
   */
85
-  function set_template()
86
-  {
84
+  function set_template() {
87 85
     global $user;
88 86
 
89 87
     if (file_exists($this->rootPhysical. 'styles/' . $user->theme['template_path'] . '/template'))
@@ -108,8 +106,7 @@  discard block
 block discarded – undo
108 106
       {
109 107
         $this->inherit_root = $this->rootPhysical . 'styles/' . $user->theme['template_inherit_path'] . '/template';
110 108
       }
111
-    }
112
-    else
109
+    } else
113 110
     {
114 111
       trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR);
115 112
     }
@@ -123,8 +120,7 @@  discard block
 block discarded – undo
123 120
   * Set custom template location (able to use directory outside of phpBB)
124 121
   * @access public
125 122
   */
126
-  function set_custom_template($template_path, $template_name, $fallback_template_path = false)
127
-  {
123
+  function set_custom_template($template_path, $template_name, $fallback_template_path = false) {
128 124
     global $user;
129 125
 
130 126
     // Make sure $template_path has no ending slash
@@ -145,8 +141,7 @@  discard block
 block discarded – undo
145 141
 
146 142
       $this->inherit_root = $fallback_template_path;
147 143
       $this->orig_tpl_inherits_id = true;
148
-    }
149
-    else
144
+    } else
150 145
     {
151 146
       $this->orig_tpl_inherits_id = false;
152 147
     }
@@ -165,8 +160,7 @@  discard block
 block discarded – undo
165 160
   * should be a hash of handle => filename pairs.
166 161
   * @access public
167 162
   */
168
-  function set_filenames($filename_array)
169
-  {
163
+  function set_filenames($filename_array) {
170 164
     if (!is_array($filename_array))
171 165
     {
172 166
       return false;
@@ -194,8 +188,7 @@  discard block
 block discarded – undo
194 188
   * Destroy template data set
195 189
   * @access public
196 190
   */
197
-  function destroy()
198
-  {
191
+  function destroy() {
199 192
     $this->_tpldata = array('.' => array(0 => array()));
200 193
     $this->_rootref = &$this->_tpldata['.'][0];
201 194
   }
@@ -204,8 +197,7 @@  discard block
 block discarded – undo
204 197
   * Reset/empty complete block
205 198
   * @access public
206 199
   */
207
-  function destroy_block_vars($blockname)
208
-  {
200
+  function destroy_block_vars($blockname) {
209 201
     if (strpos($blockname, '.') !== false)
210 202
     {
211 203
       // Nested block.
@@ -220,8 +212,7 @@  discard block
 block discarded – undo
220 212
       }
221 213
 
222 214
       unset($str[$blocks[$blockcount]]);
223
-    }
224
-    else
215
+    } else
225 216
     {
226 217
       // Top-level block.
227 218
       unset($this->_tpldata[$blockname]);
@@ -234,8 +225,7 @@  discard block
 block discarded – undo
234 225
   * Display handle
235 226
   * @access public
236 227
   */
237
-  function display($handle, $include_once = true)
238
-  {
228
+  function display($handle, $include_once = true) {
239 229
     if (defined('IN_ERROR_HANDLER'))
240 230
     {
241 231
       $is_enotice = error_reporting();
@@ -248,8 +238,7 @@  discard block
 block discarded – undo
248 238
     if ($filename = $this->_tpl_load($handle))
249 239
     {
250 240
       ($include_once) ? include_once($filename) : include($filename);
251
-    }
252
-    else
241
+    } else
253 242
     {
254 243
       $this->evaluate($this->compiled_code[$handle]);
255 244
     }
@@ -261,8 +250,7 @@  discard block
 block discarded – undo
261 250
   * Display the handle and assign the output to a template variable or return the compiled result.
262 251
   * @access public
263 252
   */
264
-  function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
265
-  {
253
+  function assign_display($handle, $template_var = '', $return_content = true, $include_once = false) {
266 254
     ob_start();
267 255
     $this->display($handle, $include_once);
268 256
     $contents = ob_get_clean();
@@ -281,8 +269,7 @@  discard block
 block discarded – undo
281 269
   * Load a compiled template if possible, if not, recompile it
282 270
   * @access private
283 271
   */
284
-  function _tpl_load(&$handle)
285
-  {
272
+  function _tpl_load(&$handle) {
286 273
     global $user, $config;
287 274
 
288 275
     if (!isset($this->filename[$handle]))
@@ -303,8 +290,7 @@  discard block
 block discarded – undo
303 290
     if (!file_exists($filename) || @filesize($filename) === 0)
304 291
     {
305 292
       $recompile = true;
306
-    }
307
-    else if ($config->load_tplcompile)
293
+    } else if ($config->load_tplcompile)
308 294
     {
309 295
       // No way around it: we need to check inheritance here
310 296
       if ($user->theme['template_inherits_id'] && !file_exists($this->files[$handle]))
@@ -387,15 +373,13 @@  discard block
 block discarded – undo
387 373
               $this->files[$row['template_filename']] = $file;
388 374
               $this->files_inherit[$row['template_filename']] = $file;
389 375
               $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
390
-            }
391
-            else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
376
+            } else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
392 377
             {
393 378
               // Ok, we have a situation. There is a file in the subtemplate, but nothing in the DB. We have to fix that.
394 379
               $force_reload = true;
395 380
               $this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
396 381
             }
397
-          }
398
-          else
382
+          } else
399 383
           {
400 384
             $this->files_template[$row['template_filename']] = $user->theme['template_id'];
401 385
           }
@@ -405,8 +389,7 @@  discard block
 block discarded – undo
405 389
             if ($row['template_filename'] == $this->filename[$handle])
406 390
             {
407 391
               $compile->_tpl_load_file($handle, true);
408
-            }
409
-            else
392
+            } else
410 393
             {
411 394
               $this->files[$row['template_filename']] = $file;
412 395
               $this->filename[$row['template_filename']] = $row['template_filename'];
@@ -421,8 +404,7 @@  discard block
 block discarded – undo
421 404
           {
422 405
             $this->compiled_code[$handle] = $compile->compile(trim($row['template_data']));
423 406
             $compile->compile_write($handle, $this->compiled_code[$handle]);
424
-          }
425
-          else
407
+          } else
426 408
           {
427 409
             // Only bother compiling if it doesn't already exist
428 410
             if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . DOT_PHP_EX))
@@ -433,8 +415,7 @@  discard block
 block discarded – undo
433 415
             }
434 416
           }
435 417
         }
436
-      }
437
-      else
418
+      } else
438 419
       {
439 420
         $file = $this->root . '/' . $row['template_filename'];
440 421
 
@@ -461,8 +442,7 @@  discard block
 block discarded – undo
461 442
   * Assign key variable pairs from an array
462 443
   * @access public
463 444
   */
464
-  function assign_vars($vararray)
465
-  {
445
+  function assign_vars($vararray) {
466 446
     foreach ($vararray as $key => $val)
467 447
     {
468 448
       $this->_rootref[$key] = $val;
@@ -475,8 +455,7 @@  discard block
 block discarded – undo
475 455
   * Assign a single variable to a single key
476 456
   * @access public
477 457
   */
478
-  function assign_var($varname, $varval)
479
-  {
458
+  function assign_var($varname, $varval) {
480 459
     $this->_rootref[$varname] = $varval;
481 460
 
482 461
     return true;
@@ -486,8 +465,7 @@  discard block
 block discarded – undo
486 465
   * Assign key variable pairs from an array to a specified block
487 466
   * @access public
488 467
   */
489
-  function assign_block_vars($blockname, $vararray)
490
-  {
468
+  function assign_block_vars($blockname, $vararray) {
491 469
     if (strpos($blockname, '.') !== false)
492 470
     {
493 471
       // Nested block.
@@ -522,8 +500,7 @@  discard block
 block discarded – undo
522 500
       // We're adding a new iteration to this block with the given
523 501
       // variable assignments.
524 502
       $str[$blocks[$blockcount]][] = $vararray;
525
-    }
526
-    else
503
+    } else
527 504
     {
528 505
       // Top-level block.
529 506
       $s_row_count = (isset($this->_tpldata[$blockname])) ? sizeof($this->_tpldata[$blockname]) : 0;
@@ -577,8 +554,7 @@  discard block
 block discarded – undo
577 554
   * @return bool false on error, true on success
578 555
   * @access public
579 556
   */
580
-  function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert')
581
-  {
557
+  function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert') {
582 558
     if (strpos($blockname, '.') !== false)
583 559
     {
584 560
       // Nested blocks are not supported
@@ -623,8 +599,7 @@  discard block
 block discarded – undo
623 599
         $key = sizeof($this->_tpldata[$blockname]);
624 600
         unset($this->_tpldata[$blockname][($key - 1)]['S_LAST_ROW']);
625 601
         $vararray['S_LAST_ROW'] = true;
626
-      }
627
-      else if ($key === 0)
602
+      } else if ($key === 0)
628 603
       {
629 604
         unset($this->_tpldata[$blockname][0]['S_FIRST_ROW']);
630 605
         $vararray['S_FIRST_ROW'] = true;
@@ -663,8 +638,7 @@  discard block
 block discarded – undo
663 638
   * Include a separate template
664 639
   * @access private
665 640
   */
666
-  function _tpl_include($filename, $include = true)
667
-  {
641
+  function _tpl_include($filename, $include = true) {
668 642
     // This is used to access global vars
669 643
     // global $lang, $config, $user; // Not needed!
670 644
 
@@ -694,8 +668,7 @@  discard block
 block discarded – undo
694 668
   * Include a php-file
695 669
   * @access private
696 670
   */
697
-  function _php_include($filename)
698
-  {
671
+  function _php_include($filename) {
699 672
     $file = $this->rootPhysical . $filename;
700 673
 
701 674
     if (!file_exists($file))
@@ -711,8 +684,7 @@  discard block
 block discarded – undo
711 684
   * Assign key variable pairs from an array with block support
712 685
   * @access public
713 686
   */
714
-  function assign_recursive($values, $name = '')
715
-  {
687
+  function assign_recursive($values, $name = '') {
716 688
     if(isset($values['.']))
717 689
     {
718 690
       $values_extra = $values['.'];
@@ -722,8 +694,7 @@  discard block
 block discarded – undo
722 694
     if(!$name)
723 695
     {
724 696
       $this->assign_vars($values);
725
-    }
726
-    else
697
+    } else
727 698
     {
728 699
       $this->assign_block_vars($name, $values);
729 700
     }
Please login to merge, or discard this patch.
includes/general/general_math.php 1 patch
Braces   +18 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,16 +4,14 @@  discard block
 block discarded – undo
4 4
   return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1);
5 5
 }
6 6
 
7
-function sn_floor($value)
8
-{
7
+function sn_floor($value) {
9 8
   return $value >= 0 ? floor($value) : ceil($value);
10 9
 }
11 10
 
12 11
 // Эта функция выдает нормально распределенное случайное число с матожиднием $mu и стандартным отклонением $sigma
13 12
 // $strict - количество $sigma, по которым идет округление функции. Т.е. $strict = 3 означает, что диапазон значений обрезается по +-3 * $sigma
14 13
 // Используется http://ru.wikipedia.org/wiki/Преобразование_Бокса_—_Мюллера
15
-function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false)
16
-{
14
+function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) {
17 15
   // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение
18 16
   // При $mu = 0 (график симметричный, цифры только для половины графика)
19 17
   // От 0 до $sigma ~ 34.1%
@@ -43,7 +41,7 @@  discard block
 block discarded – undo
43 41
  *
44 42
  * @return float|int
45 43
  */
46
-function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false)  {
44
+function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) {
47 45
   if($cut_extreme) {
48 46
     $range_start--;
49 47
     $range_end++;
@@ -98,12 +96,10 @@  discard block
 block discarded – undo
98 96
  *
99 97
  * @return float
100 98
  */
101
-function avg($array)
102
-{
99
+function avg($array) {
103 100
   return is_array($array) && count($array) ? array_sum($array) / count($array) : 0;
104 101
 }
105
-function linear_calc(&$linear, $from = 0, $debug = false)
106
-{
102
+function linear_calc(&$linear, $from = 0, $debug = false) {
107 103
   for($i = $from; $i < count($linear); $i++)
108 104
   {
109 105
     $eq = &$linear[$i];
@@ -112,7 +108,9 @@  discard block
 block discarded – undo
112 108
       $eq[$j] /= $eq[$from];
113 109
     }
114 110
   }
115
-  if($debug) pdump($linear, 'Нормализовано по х' . $from);
111
+  if($debug) {
112
+    pdump($linear, 'Нормализовано по х' . $from);
113
+  }
116 114
 
117 115
   for($i = $from + 1; $i < count($linear); $i++)
118 116
   {
@@ -122,7 +120,9 @@  discard block
 block discarded – undo
122 120
       $eq[$j] -= $linear[$from][$j];
123 121
     }
124 122
   }
125
-  if($debug) pdump($linear, 'Подставили х' . $from);
123
+  if($debug) {
124
+    pdump($linear, 'Подставили х' . $from);
125
+  }
126 126
 
127 127
   if($from < count($linear) - 1)
128 128
   {
@@ -139,11 +139,14 @@  discard block
 block discarded – undo
139 139
         $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j];
140 140
       }
141 141
     }
142
-    if($debug) pdump($linear, 'Подставили обратно х' . $from);
143
-  }
144
-  else
142
+    if($debug) {
143
+      pdump($linear, 'Подставили обратно х' . $from);
144
+    }
145
+  } else
145 146
   {
146
-    if($debug) pdump($linear, 'Результат' . $from);
147
+    if($debug) {
148
+      pdump($linear, 'Результат' . $from);
149
+    }
147 150
     foreach($linear as $index => &$eq)
148 151
     {
149 152
       pdump($eq[count($linear)], 'x' . $index);
Please login to merge, or discard this patch.
includes/general/general_pname.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,12 +2,10 @@
 block discarded – undo
2 2
 
3 3
 // Эти функции будут переписаны по добавлению инфы в БД
4 4
 
5
-function pname_factory_production_field_name($factory_unit_id)
6
-{
5
+function pname_factory_production_field_name($factory_unit_id) {
7 6
   return get_unit_param($factory_unit_id, P_NAME) . '_porcent';
8 7
 }
9 8
 
10
-function pname_resource_name($resource_id)
11
-{
9
+function pname_resource_name($resource_id) {
12 10
   return get_unit_param($resource_id, P_NAME);
13 11
 }
14 12
\ No newline at end of file
Please login to merge, or discard this patch.
includes/includes/flt_mission_hold.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use Fleet\DbFleetStatic;
4 4
 
5
-function flt_mission_hold(&$mission_data)
6
-{
5
+function flt_mission_hold(&$mission_data) {
7 6
   if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
8 7
   {
9 8
     DbFleetStatic::fleet_send_back($mission_data['fleet']);
Please login to merge, or discard this patch.
includes/db/db_queries.php 1 patch
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 require_once('db_queries_users.php');
6 6
 
7 7
 
8
-function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type)
9
-{
8
+function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) {
10 9
   return doquery(
11 10
     "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') .
12 11
     " FROM {{planets}} AS p
@@ -15,8 +14,7 @@  discard block
 block discarded – undo
15 14
     " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}"));
16 15
 }
17 16
 
18
-function db_planet_list_search($searchtext)
19
-{
17
+function db_planet_list_search($searchtext) {
20 18
   return doquery(
21 19
     "SELECT
22 20
       p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name,
@@ -36,8 +34,7 @@  discard block
 block discarded – undo
36 34
 
37 35
 
38 36
 
39
-function db_user_list_search($searchtext)
40
-{
37
+function db_user_list_search($searchtext) {
41 38
   return doquery(
42 39
     "SELECT
43 40
       pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank,
@@ -55,8 +52,7 @@  discard block
 block discarded – undo
55 52
   );
56 53
 }
57 54
 
58
-function db_buddy_list_by_user($user_id)
59
-{
55
+function db_buddy_list_by_user($user_id) {
60 56
 //  return ($user_id = intval($user_id)) ? doquery(
61 57
   return ($user_id = idval($user_id)) ? doquery(
62 58
     "SELECT
@@ -86,8 +82,7 @@  discard block
 block discarded – undo
86 82
 
87 83
 
88 84
 
89
-function db_unit_records_sum($unit_id, $user_skip_list_unit)
90
-{
85
+function db_unit_records_sum($unit_id, $user_skip_list_unit) {
91 86
   return doquery (
92 87
     "SELECT unit_player_id, username, sum(unit_level) as unit_level
93 88
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -98,8 +93,7 @@  discard block
 block discarded – undo
98 93
     , true);
99 94
 }
100 95
 
101
-function db_unit_records_plain($unit_id, $user_skip_list_unit)
102
-{
96
+function db_unit_records_plain($unit_id, $user_skip_list_unit) {
103 97
   return doquery (
104 98
     "SELECT unit_player_id, username, unit_level
105 99
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -183,15 +177,13 @@  discard block
 block discarded – undo
183 177
 }
184 178
 
185 179
 
186
-function db_stat_list_delete_ally_player()
187
-{
180
+function db_stat_list_delete_ally_player() {
188 181
   return doquery('DELETE s FROM `{{statpoints}}` AS s JOIN `{{users}}` AS u ON u.id = s.id_owner WHERE s.id_ally IS NULL AND u.user_as_ally IS NOT NULL');
189 182
 }
190 183
 
191 184
 
192 185
 
193
-function db_chat_player_list_online($chat_refresh_rate, $ally_add)
194
-{
186
+function db_chat_player_list_online($chat_refresh_rate, $ally_add) {
195 187
   $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2;
196 188
 
197 189
   return doquery(
@@ -205,13 +197,11 @@  discard block
 block discarded – undo
205 197
     ORDER BY authlevel DESC, `username`");
206 198
 }
207 199
 
208
-function db_referrals_list_by_id($user_id)
209
-{
200
+function db_referrals_list_by_id($user_id) {
210 201
   return doquery("SELECT r.*, u.username, u.register_time FROM {{referrals}} AS r LEFT JOIN {{users}} AS u ON u.id = r.id WHERE id_partner = {$user_id}");
211 202
 }
212 203
 
213
-function db_message_list_admin_by_type($int_type_selected, $StartRec)
214
-{
204
+function db_message_list_admin_by_type($int_type_selected, $StartRec) {
215 205
   return doquery("SELECT
216 206
   message_id as `ID`,
217 207
   message_from as `FROM`,
@@ -230,8 +220,7 @@  discard block
 block discarded – undo
230 220
 }
231 221
 
232 222
 
233
-function db_message_insert_all($message_type, $from, $subject, $text)
234
-{
223
+function db_message_insert_all($message_type, $from, $subject, $text) {
235 224
   return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
236 225
     "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}");
237 226
 }
Please login to merge, or discard this patch.