Completed
Push — work-fleets ( 094cef...4ec5b3 )
by SuperNova.WS
06:12
created
includes/classes/EntityModel.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -63,6 +63,10 @@
 block discarded – undo
63 63
    */
64 64
   protected $accessors = array();
65 65
 
66
+  /**
67
+   * @param string $varName
68
+   * @param string $type
69
+   */
66 70
   protected function assignAccessor($varName, $type, $callable) {
67 71
     if (empty($callable)) {
68 72
       return;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
     if (is_callable($callable)) {
68 68
       $this->accessors[$varName][$type] = $callable;
69 69
     } else {
70
-      throw new \Exception('Error assigning callable in ' . get_called_class() . '! Callable typed [' . $type . '] is not a callable or not accessible in the scope');
70
+      throw new \Exception('Error assigning callable in '.get_called_class().'! Callable typed ['.$type.'] is not a callable or not accessible in the scope');
71 71
     }
72 72
   }
73 73
 
Please login to merge, or discard this patch.
includes/classes/Buddy/BuddyParams.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@
 block discarded – undo
36 36
 
37 37
     $this->playerArray = $user;
38 38
 
39
-    $this->playerId = function (BuddyParams $cBuddy) {
39
+    $this->playerId = function(BuddyParams $cBuddy) {
40 40
       return $cBuddy->playerArray['id'];
41 41
     };
42
-    $this->playerName = function (BuddyParams $cBuddy) {
42
+    $this->playerName = function(BuddyParams $cBuddy) {
43 43
       return $cBuddy->playerArray['username'];
44 44
     };
45
-    $this->playerNameAndCoordinates = function (BuddyParams $cBuddy) {
46
-      return "{$cBuddy->playerArray['username']} " . uni_render_coordinates($cBuddy->playerArray);
45
+    $this->playerNameAndCoordinates = function(BuddyParams $cBuddy) {
46
+      return "{$cBuddy->playerArray['username']} ".uni_render_coordinates($cBuddy->playerArray);
47 47
     };
48 48
   }
49 49
 
Please login to merge, or discard this patch.
includes/pages/chat.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
   $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS;
37 37
 
38 38
   $mode = sys_get_param_int('mode');
39
-  switch($mode) {
39
+  switch ($mode) {
40 40
     case CHAT_MODE_ALLY:
41 41
       $template_result['ALLY'] = intval($user['ally_id']);
42 42
       $page_title = classLocale::$lang['chat_ally'];
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
   }
50 50
 
51 51
   $template_result['.']['smiles'] = array();
52
-  foreach(classSupernova::$design['smiles'] as $auth_level => $replaces) {
53
-    if($auth_level > $user_auth_level) {
52
+  foreach (classSupernova::$design['smiles'] as $auth_level => $replaces) {
53
+    if ($auth_level > $user_auth_level) {
54 54
       continue;
55 55
     }
56 56
 
57
-    foreach($replaces as $bbcode => $filename) {
57
+    foreach ($replaces as $bbcode => $filename) {
58 58
       $template_result['.']['smiles'][] = array(
59 59
         'BBCODE'   => $bbcode,
60 60
         'FILENAME' => $filename,
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
   define('IN_AJAX', true);
78 78
   $skip_fleet_update = true;
79 79
 
80
-  if(
80
+  if (
81 81
     classSupernova::$config->getMode() != CACHER_NO_CACHE
82 82
     &&
83 83
     classSupernova::$config->chat_timeout
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     die();
88 88
   }
89 89
 
90
-  if(($message = sys_get_param_str('message')) && $user['username']) {
90
+  if (($message = sys_get_param_str('message')) && $user['username']) {
91 91
     $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
92 92
     $nickUnsafe = player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)));
93 93
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
   $skip_fleet_update = true;
110 110
 
111 111
   $history = sys_get_param_str('history');
112
-  if(!$history) {
112
+  if (!$history) {
113 113
     classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO);
114 114
   }
115 115
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
   $last_message = '';
118 118
   $alliance = 0;
119 119
   $template_result['.']['chat'] = array();
120
-  if(
120
+  if (
121 121
     !$history
122 122
     &&
123 123
     classSupernova::$config->getMode() != CACHER_NO_CACHE
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 
139 139
     $where_add = '';
140 140
     $last_message = 0;
141
-    if($history) {
141
+    if ($history) {
142 142
       $rows = DBStaticChat::db_chat_message_count_by_ally($alliance);
143 143
       $page_count = ceil($rows['CNT'] / $page_limit);
144 144
 
145
-      for($i = 0; $i < $page_count; $i++) {
145
+      for ($i = 0; $i < $page_count; $i++) {
146 146
         $template_result['.']['page'][] = array(
147 147
           'NUMBER' => $i
148 148
         );
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
 
157 157
     $start_row = $page * $page_limit;
158 158
     $query = DBStaticChat::db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit);
159
-    while($chat_row = db_fetch($query)) {
159
+    while ($chat_row = db_fetch($query)) {
160 160
       // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
161 161
       $chat_row['user'] = player_nick_render_to_html($chat_row['user']);
162 162
       $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8');
163 163
       $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']);
164
-      if(!$history) {
164
+      if (!$history) {
165 165
         $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>";
166 166
       }
167 167
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
   $template = gettemplate('chat_messages', $template);
187 187
   $template->assign_recursive($template_result);
188 188
 
189
-  if($history) {
189
+  if ($history) {
190 190
     display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true);
191 191
   } else {
192 192
     $result['last_message'] = $last_message;
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
   public function load_db_settings($configFile = '') {
92 92
     $dbsettings = array();
93 93
 
94
-    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false;
94
+    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false;
95 95
 
96 96
     require $configFile;
97 97
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     }
112 112
 
113 113
     if (empty($this->dbsettings)) {
114
-      $this->load_db_settings(SN_ROOT_PHYSICAL . "config.php");
114
+      $this->load_db_settings(SN_ROOT_PHYSICAL."config.php");
115 115
     }
116 116
 
117 117
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     $sql = $query;
164 164
     if (strpos($sql, '{{') !== false) {
165 165
       foreach ($this->table_list as $tableName) {
166
-        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
166
+        $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql);
167 167
       }
168 168
     }
169 169
 
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 
235 235
     $queryResult = null;
236 236
     try {
237
-      $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace));
237
+      $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace));
238 238
       if (!$queryResult) {
239 239
         throw new Exception();
240 240
       }
241 241
     } catch (Exception $e) {
242
-      classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error');
242
+      classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error');
243 243
     }
244 244
 
245 245
     return $queryResult;
@@ -294,16 +294,16 @@  discard block
 block discarded – undo
294 294
     if (!empty($where)) {
295 295
       foreach ($where as $key => &$value) {
296 296
         if (!is_int($key)) {
297
-          $value = "`$key` = '" . $this->db_escape($value) . "'";
297
+          $value = "`$key` = '".$this->db_escape($value)."'";
298 298
         }
299 299
       }
300 300
     }
301 301
 
302 302
     $query =
303
-      "SELECT " . implode(',', $fields) .
304
-      " FROM `{{{$table}}}`" .
305
-      (!empty($where) ? ' WHERE ' . implode(' AND ', $where) : '') .
306
-      ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '') .
303
+      "SELECT ".implode(',', $fields).
304
+      " FROM `{{{$table}}}`".
305
+      (!empty($where) ? ' WHERE '.implode(' AND ', $where) : '').
306
+      ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '').
307 307
       ($forUpdate == DB_SELECT_FOR_UPDATE ? ' FOR UPDATE' : '');
308 308
 
309 309
     return $this->doSql($query);
@@ -609,10 +609,10 @@  discard block
 block discarded – undo
609 609
       $this->isWatching = true;
610 610
       $msg = "\$query = \"{$query}\"\n\r";
611 611
       if (!empty($_POST)) {
612
-        $msg .= "\n\r" . dump($_POST, '$_POST');
612
+        $msg .= "\n\r".dump($_POST, '$_POST');
613 613
       }
614 614
       if (!empty($_GET)) {
615
-        $msg .= "\n\r" . dump($_GET, '$_GET');
615
+        $msg .= "\n\r".dump($_GET, '$_GET');
616 616
       }
617 617
       classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
618 618
       $this->isWatching = false;
@@ -638,37 +638,37 @@  discard block
 block discarded – undo
638 638
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
639 639
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
640 640
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
641
-        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
641
+        $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
642 642
         $report .= ">Database Inforamation\n";
643
-        $report .= "\tID - " . $user['id'] . "\n";
644
-        $report .= "\tUser - " . $user['username'] . "\n";
645
-        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
646
-        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
647
-        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
648
-        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
649
-        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
650
-        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
651
-        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
652
-        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
643
+        $report .= "\tID - ".$user['id']."\n";
644
+        $report .= "\tUser - ".$user['username']."\n";
645
+        $report .= "\tAuth level - ".$user['authlevel']."\n";
646
+        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
647
+        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
648
+        $report .= "\tUser IP - ".$user['user_lastip']."\n";
649
+        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
650
+        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
651
+        $report .= "\tCurrent Page - ".$user['current_page']."\n";
652
+        $report .= "\tRegister Time - ".$user['register_time']."\n";
653 653
         $report .= "\n";
654 654
 
655 655
         $report .= ">Query Information\n";
656
-        $report .= "\tQuery - " . $query . "\n";
656
+        $report .= "\tQuery - ".$query."\n";
657 657
         $report .= "\n";
658 658
 
659 659
         $report .= ">\$_SERVER Information\n";
660
-        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
661
-        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
662
-        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
663
-        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
664
-        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
665
-        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
666
-        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
667
-        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
660
+        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
661
+        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
662
+        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
663
+        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
664
+        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
665
+        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
666
+        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
667
+        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
668 668
 
669 669
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
670 670
 
671
-        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
671
+        $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a');
672 672
         fwrite($fp, $report);
673 673
         fclose($fp);
674 674
 
Please login to merge, or discard this patch.
Doc Comments   +28 added lines, -5 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
   /**
158 158
    * @param string $query
159 159
    *
160
-   * @return mixed|string
160
+   * @return string
161 161
    */
162 162
   public function replaceTablePlaceholders($query) {
163 163
     $sql = $query;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
   }
172 172
 
173 173
   /**
174
-   * @param $query
174
+   * @param string $query
175 175
    */
176 176
   protected function logQuery($query) {
177 177
     if (!classSupernova::$config->debug) {
@@ -286,6 +286,7 @@  discard block
 block discarded – undo
286 286
    * @param array  $fields
287 287
    * @param array  $where
288 288
    * @param bool   $isOneRecord
289
+   * @param boolean $forUpdate
289 290
    *
290 291
    * @return array|bool|mysqli_result|null
291 292
    */
@@ -331,6 +332,11 @@  discard block
 block discarded – undo
331 332
 
332 333
 
333 334
   // INSERT/REPLACE
335
+
336
+  /**
337
+   * @param string $table
338
+   * @param integer $replace
339
+   */
334 340
   protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) {
335 341
     $query = DbQuery::build($this)
336 342
       ->setTable($table)
@@ -368,6 +374,10 @@  discard block
 block discarded – undo
368 374
 
369 375
 
370 376
   // INSERTERS
377
+
378
+  /**
379
+   * @param string $query
380
+   */
371 381
   public function doInsertComplex($query) {
372 382
     return $this->doSql($query);
373 383
   }
@@ -387,7 +397,7 @@  discard block
 block discarded – undo
387 397
    * Values should be passed as-is
388 398
    *
389 399
    * @param string   $table
390
-   * @param array    $fields
400
+   * @param string[]    $fields
391 401
    * @param string[] $values
392 402
    *
393 403
    * @return array|bool|mysqli_result|null
@@ -440,7 +450,7 @@  discard block
 block discarded – undo
440 450
    * Self-contained - means no params used
441 451
    * Such queries usually used to make large amount of in-base calculations
442 452
    *
443
-   * @param $query
453
+   * @param string $query
444 454
    *
445 455
    * @return array|bool|mysqli_result|null
446 456
    */
@@ -457,13 +467,16 @@  discard block
 block discarded – undo
457 467
   }
458 468
 
459 469
   /**
460
-   * @param $DbQuery DbQuery
470
+   * @param DbQuery $DbQuery DbQuery
461 471
    */
462 472
   public function doUpdateDbQueryAdjust($DbQuery) {
463 473
     return $this->doUpdateDbQuery($DbQuery);
464 474
   }
465 475
 
466 476
 
477
+  /**
478
+   * @param boolean $isOneRecord
479
+   */
467 480
   protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) {
468 481
     $query = DbQuery::build($this)
469 482
       ->setTable($table)
@@ -482,6 +495,9 @@  discard block
 block discarded – undo
482 495
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE);
483 496
   }
484 497
 
498
+  /**
499
+   * @param string $table
500
+   */
485 501
   public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) {
486 502
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL);
487 503
   }
@@ -597,6 +613,10 @@  discard block
 block discarded – undo
597 613
   }
598 614
 
599 615
   // TODO Заменить это на новый логгер
616
+
617
+  /**
618
+   * @param string $query
619
+   */
600 620
   protected function security_watch_user_queries($query) {
601 621
     global $user;
602 622
 
@@ -620,6 +640,9 @@  discard block
 block discarded – undo
620 640
   }
621 641
 
622 642
 
643
+  /**
644
+   * @param string $query
645
+   */
623 646
   public function security_query_check_bad_words($query) {
624 647
     if ($this->skipQueryCheck) {
625 648
       return;
Please login to merge, or discard this patch.
includes/classes/Common/GlobalContainer.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -34,56 +34,56 @@
 block discarded – undo
34 34
     $gc = $this;
35 35
 
36 36
     // Default db
37
-    $gc->db = function ($c) {
37
+    $gc->db = function($c) {
38 38
       classSupernova::$db = $db = new \db_mysql($c);
39 39
       $db->sn_db_connect();
40 40
 
41 41
       return $db;
42 42
     };
43 43
 
44
-    $gc->debug = function ($c) {
44
+    $gc->debug = function($c) {
45 45
       return new \debug();
46 46
     };
47 47
 
48
-    $gc->types = function ($c) {
48
+    $gc->types = function($c) {
49 49
       return new \Common\Types();
50 50
     };
51 51
 
52
-    $gc->cache = function ($c) {
52
+    $gc->cache = function($c) {
53 53
       return new \classCache(classSupernova::$cache_prefix);
54 54
     };
55 55
 
56
-    $gc->config = function ($c) {
56
+    $gc->config = function($c) {
57 57
       return new \classConfig(classSupernova::$cache_prefix);
58 58
     };
59 59
 
60
-    $gc->localePlayer = function (GlobalContainer $c) {
60
+    $gc->localePlayer = function(GlobalContainer $c) {
61 61
       return new \classLocale($c->config->server_locale_log_usage);
62 62
     };
63 63
 
64
-    $gc->dbGlobalRowOperator = function (GlobalContainer $c) {
64
+    $gc->dbGlobalRowOperator = function(GlobalContainer $c) {
65 65
       return new \DbRowDirectOperator($c->db);
66 66
     };
67 67
 
68
-    $gc->query = $gc->factory(function (GlobalContainer $c) {
68
+    $gc->query = $gc->factory(function(GlobalContainer $c) {
69 69
       return new \DbQueryConstructor($c->db);
70 70
     });
71 71
 
72
-    $gc->cacheOperator = function (GlobalContainer $gc) {
72
+    $gc->cacheOperator = function(GlobalContainer $gc) {
73 73
       return new \SnDbCachedOperator($gc);
74 74
     };
75 75
 
76 76
     $gc->snCacheClass = 'SnCache';
77
-    $gc->snCache = function (GlobalContainer $gc) {
77
+    $gc->snCache = function(GlobalContainer $gc) {
78 78
       return $gc->db->snCache;
79 79
     };
80 80
 
81 81
     $gc->buddyClass = 'Buddy\BuddyModel';
82
-    $gc->buddyModel = function (GlobalContainer $c) {
82
+    $gc->buddyModel = function(GlobalContainer $c) {
83 83
       return new $c->buddyClass($c);
84 84
     };
85 85
 
86
-    $gc->unitModel = function (GlobalContainer $c) {
86
+    $gc->unitModel = function(GlobalContainer $c) {
87 87
       return new \V2Unit\V2UnitModel($c);
88 88
     };
89 89
   }
Please login to merge, or discard this patch.
includes/classes/Common/snMath.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
    * @param int  $sigma
19 19
    * @param bool $strict
20 20
    *
21
-   * @return int
21
+   * @return double
22 22
    */
23 23
   public static function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) {
24 24
     // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
    *
43 43
    * @param float      $range_start - Начало диапазона
44 44
    * @param float      $range_end - Конец диапазона
45
-   * @param bool|int   $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд
45
+   * @param boolean   $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд
46 46
    * @param int        $strict - В сколько сигм надо уложить результат
47 47
    * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много
48 48
    *
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
       }
130 130
     }
131 131
     if ($logProcess) {
132
-      pdump($linear, 'Нормализовано по х' . $from);
132
+      pdump($linear, 'Нормализовано по х'.$from);
133 133
     }
134 134
 
135 135
     for ($i = $from + 1; $i < count($linear); $i++) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
       }
140 140
     }
141 141
     if ($logProcess) {
142
-      pdump($linear, 'Подставили х' . $from);
142
+      pdump($linear, 'Подставили х'.$from);
143 143
     }
144 144
 
145 145
     if ($from < count($linear) - 1) {
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
         }
155 155
       }
156 156
       if ($logProcess) {
157
-        pdump($linear, 'Подставили обратно х' . $from);
157
+        pdump($linear, 'Подставили обратно х'.$from);
158 158
       }
159 159
     } else {
160 160
       if ($logProcess) {
161
-        pdump($linear, 'Результат' . $from);
161
+        pdump($linear, 'Результат'.$from);
162 162
       }
163 163
       foreach ($linear as $index => &$eq) {
164
-        pdump($eq[count($linear)], 'x' . $index);
164
+        pdump($eq[count($linear)], 'x'.$index);
165 165
       }
166 166
     }
167 167
   }
Please login to merge, or discard this patch.
includes/init/init_functions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // ------------------------------------------------------------------------------------------------------------------------------
4 4
 function sn_sys_load_php_files($dir_name, $load_extension = '.php', $modules = false) {
5
-  if(!file_exists($dir_name) || !is_dir($dir_name)) {
5
+  if (!file_exists($dir_name) || !is_dir($dir_name)) {
6 6
     return;
7 7
   }
8 8
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
       continue;
13 13
     }
14 14
 
15
-    $full_filename = $dir_name . $file;
15
+    $full_filename = $dir_name.$file;
16 16
     if ($modules && is_dir($full_filename)) {
17 17
       if (file_exists($full_filename = "{$full_filename}/{$file}{$load_extension}")) {
18 18
         require_once($full_filename);
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
  *
39 39
  */
40 40
 function init_update() {
41
-  $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX;
42
-  if(file_exists($update_file)) {
43
-    if(filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) {
44
-      if(defined('IN_ADMIN')) {
41
+  $update_file = SN_ROOT_PHYSICAL."includes/update".DOT_PHP_EX;
42
+  if (file_exists($update_file)) {
43
+    if (filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) {
44
+      if (defined('IN_ADMIN')) {
45 45
         sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована
46
-        if(SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) {
46
+        if (SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) {
47 47
           classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW + (classSupernova::$config->upd_lock_time ? classSupernova::$config->upd_lock_time : 300));
48 48
           sn_db_transaction_commit();
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
           $current_time = time();
54 54
           classSupernova::$config->db_saveItem('var_db_update', $current_time);
55 55
           classSupernova::$config->db_saveItem('var_db_update_end', $current_time);
56
-        } elseif(filemtime($update_file) > classSupernova::$config->var_db_update) {
56
+        } elseif (filemtime($update_file) > classSupernova::$config->var_db_update) {
57 57
           $timeout = classSupernova::$config->var_db_update_end - SN_TIME_NOW;
58 58
           die(
59 59
             "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br />
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Защита от двойного инита
4
-if(defined('INIT')) {
4
+if (defined('INIT')) {
5 5
   return;
6 6
 }
7 7
 
@@ -19,22 +19,22 @@  discard block
 block discarded – undo
19 19
 define('SN_DEBUG_PDUMP_CALLER', true);
20 20
 
21 21
 // Бенчмарк
22
-register_shutdown_function(function () {
23
-  if(defined('IN_AJAX')) {
22
+register_shutdown_function(function() {
23
+  if (defined('IN_AJAX')) {
24 24
     return;
25 25
   }
26 26
 
27 27
   global $user, $locale_cache_statistic;
28 28
 
29
-  print('<hr><div class="benchmark">Benchmark ' . (microtime(true) - SN_TIME_MICRO) . 's, memory: ' . number_format(memory_get_usage() - SN_MEM_START) .
30
-    (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') .
31
-    (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') .
29
+  print('<hr><div class="benchmark">Benchmark '.(microtime(true) - SN_TIME_MICRO).'s, memory: '.number_format(memory_get_usage() - SN_MEM_START).
30
+    (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '').
31
+    (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: '.classSupernova::$db->time_mysql_total.'ms' : '').
32 32
     '</div>');
33
-  if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
33
+  if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL.'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL.'badqrys.txt') > 0) {
34 34
     echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>';
35 35
   }
36 36
 
37
-  if(!empty($locale_cache_statistic['misses'])) {
37
+  if (!empty($locale_cache_statistic['misses'])) {
38 38
     print('<!--');
39 39
     pdump($locale_cache_statistic);
40 40
     print('-->');
@@ -54,46 +54,46 @@  discard block
 block discarded – undo
54 54
 
55 55
 define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW));
56 56
 
57
-if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
57
+if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
58 58
   define('SN_GOOGLE', true);
59 59
 }
60 60
 
61 61
 // Эти три строки должны быть В ЭТОМ ФАЙЛЕ, ПО ЭТОМУ ПУТИ и ПЕРЕД ЭТИМ ИНКЛЮДОМ!!!
62
-define('SN_ROOT_PHYSICAL', str_replace(array('\\', '//'), '/', dirname(__DIR__) . '/'));
62
+define('SN_ROOT_PHYSICAL', str_replace(array('\\', '//'), '/', dirname(__DIR__).'/'));
63 63
 define('SN_ROOT_PHYSICAL_STR_LEN', strlen(SN_ROOT_PHYSICAL));
64 64
 $phpbb_root_path = SN_ROOT_PHYSICAL; // Это нужно для работы PTL
65 65
 
66
-$sn_root_relative = str_replace(array('\\', '//'), '/', getcwd() . '/');
66
+$sn_root_relative = str_replace(array('\\', '//'), '/', getcwd().'/');
67 67
 //$sn_root_relative .= $sn_root_relative[strlen($sn_root_relative) - 1] == '/' ? '' : '/';
68 68
 $sn_root_relative = str_replace(SN_ROOT_PHYSICAL, '', $sn_root_relative);
69 69
 $sn_root_relative .= basename($_SERVER['SCRIPT_NAME']);
70 70
 $sn_root_relative = str_replace($sn_root_relative, '', $_SERVER['SCRIPT_NAME']);
71 71
 define('SN_ROOT_RELATIVE', $sn_root_relative);
72 72
 
73
-define('SN_ROOT_VIRTUAL', 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . SN_ROOT_RELATIVE);
73
+define('SN_ROOT_VIRTUAL', 'http'.(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '').'://'.$_SERVER['HTTP_HOST'].SN_ROOT_RELATIVE);
74 74
 define('SN_ROOT_VIRTUAL_PARENT', str_replace('//google.', '//', SN_ROOT_VIRTUAL));
75 75
 
76 76
 $phpEx = strpos($phpEx = substr(strrchr(__FILE__, '.'), 1), '/') === false ? $phpEx : '';
77
-define('DOT_PHP_EX', '.' . $phpEx); // PHP extension on this server
77
+define('DOT_PHP_EX', '.'.$phpEx); // PHP extension on this server
78 78
 
79 79
 
80 80
 header('Content-type: text/html; charset=utf-8');
81 81
 ob_start();
82 82
 ini_set('error_reporting', E_ALL ^ E_NOTICE);
83 83
 
84
-empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL . 'includes/classes/' : false;
85
-spl_autoload_register(function ($class) use ($classRoot) {
84
+empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL.'includes/classes/' : false;
85
+spl_autoload_register(function($class) use ($classRoot) {
86 86
   $class = str_replace('\\', '/', $class);
87
-  if (file_exists($classRoot . $class . '.php')) {
88
-    require_once $classRoot . $class . '.php';
89
-  } elseif (file_exists($classRoot . 'UBE/' . $class . '.php')) {
90
-    require_once $classRoot . 'UBE/' . $class . '.php';
87
+  if (file_exists($classRoot.$class.'.php')) {
88
+    require_once $classRoot.$class.'.php';
89
+  } elseif (file_exists($classRoot.'UBE/'.$class.'.php')) {
90
+    require_once $classRoot.'UBE/'.$class.'.php';
91 91
   }
92 92
 });
93 93
 
94 94
 require_once 'constants.php';
95
-require_once SN_ROOT_PHYSICAL . "includes/db" . DOT_PHP_EX;
96
-require_once(SN_ROOT_PHYSICAL . "includes/init/init_functions" . DOT_PHP_EX);
95
+require_once SN_ROOT_PHYSICAL."includes/db".DOT_PHP_EX;
96
+require_once(SN_ROOT_PHYSICAL."includes/init/init_functions".DOT_PHP_EX);
97 97
 
98 98
 /**
99 99
  * @var classConfig    $config
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 // define('BE_DEBUG', true); // Отладка боевого движка
112 112
 classSupernova::init_debug_state();
113 113
 
114
-require_once(SN_ROOT_PHYSICAL . "includes/vars/vars" . DOT_PHP_EX);
115
-require_once(SN_ROOT_PHYSICAL . "includes/general" . DOT_PHP_EX);
114
+require_once(SN_ROOT_PHYSICAL."includes/vars/vars".DOT_PHP_EX);
115
+require_once(SN_ROOT_PHYSICAL."includes/general".DOT_PHP_EX);
116 116
 
117 117
 init_update();
118 118
 
@@ -121,28 +121,28 @@  discard block
 block discarded – undo
121 121
   ? trim(strip_tags($_GET['page']))
122 122
   : str_replace(DOT_PHP_EX, '', str_replace(SN_ROOT_RELATIVE, '', str_replace('\\', '/', $_SERVER['SCRIPT_NAME'])));
123 123
 define('INITIAL_PAGE', $sn_page_name_original);
124
-define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova') . (defined('SN_GOOGLE') ? '_G' : ''));
125
-define('SN_COOKIE_I', SN_COOKIE . AUTH_COOKIE_IMPERSONATE_SUFFIX);
126
-define('SN_COOKIE_D', SN_COOKIE . '_D');
127
-define('SN_COOKIE_T', SN_COOKIE . '_T'); // Time measure cookie
128
-define('SN_COOKIE_F', SN_COOKIE . '_F'); // Font size cookie
129
-define('SN_COOKIE_U', SN_COOKIE . '_U'); // Current user cookie aka user ID
130
-define('SN_COOKIE_U_I', SN_COOKIE_U . AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID
124
+define('SN_COOKIE', (classSupernova::$config->COOKIE_NAME ? classSupernova::$config->COOKIE_NAME : 'SuperNova').(defined('SN_GOOGLE') ? '_G' : ''));
125
+define('SN_COOKIE_I', SN_COOKIE.AUTH_COOKIE_IMPERSONATE_SUFFIX);
126
+define('SN_COOKIE_D', SN_COOKIE.'_D');
127
+define('SN_COOKIE_T', SN_COOKIE.'_T'); // Time measure cookie
128
+define('SN_COOKIE_F', SN_COOKIE.'_F'); // Font size cookie
129
+define('SN_COOKIE_U', SN_COOKIE.'_U'); // Current user cookie aka user ID
130
+define('SN_COOKIE_U_I', SN_COOKIE_U.AUTH_COOKIE_IMPERSONATE_SUFFIX); // Current impersonator user cookie aka impersonator user ID
131 131
 define('TEMPLATE_NAME', classSupernova::$config->game_default_template ? classSupernova::$config->game_default_template : 'OpenGame');
132
-define('TEMPLATE_PATH', 'design/templates/' . TEMPLATE_NAME);
133
-define('TEMPLATE_DIR', SN_ROOT_PHYSICAL . TEMPLATE_PATH);
132
+define('TEMPLATE_PATH', 'design/templates/'.TEMPLATE_NAME);
133
+define('TEMPLATE_DIR', SN_ROOT_PHYSICAL.TEMPLATE_PATH);
134 134
 define('DEFAULT_SKINPATH', classSupernova::$config->game_default_skin ? classSupernova::$config->game_default_skin : 'skins/EpicBlue/');
135 135
 define('DEFAULT_LANG', classSupernova::$config->game_default_language ? classSupernova::$config->game_default_language : 'ru');
136 136
 define('FMT_DATE', classSupernova::$config->int_format_date ? classSupernova::$config->int_format_date : 'd.m.Y');
137 137
 define('FMT_TIME', classSupernova::$config->int_format_time ? classSupernova::$config->int_format_time : 'H:i:s');
138
-define('FMT_DATE_TIME', FMT_DATE . ' ' . FMT_TIME);
138
+define('FMT_DATE_TIME', FMT_DATE.' '.FMT_TIME);
139 139
 
140 140
 $HTTP_ACCEPT_LANGUAGE = DEFAULT_LANG;
141 141
 
142
-require_once(SN_ROOT_PHYSICAL . "includes/template" . DOT_PHP_EX);
142
+require_once(SN_ROOT_PHYSICAL."includes/template".DOT_PHP_EX);
143 143
 $template_result = array('.' => array('result' => array()));
144 144
 
145
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "includes/functions/", DOT_PHP_EX);
145
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."includes/functions/", DOT_PHP_EX);
146 146
 
147 147
 
148 148
 // Подключаем все модули
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 // Конфиг - часть манифеста?
153 153
 classSupernova::$auth = new core_auth();
154 154
 
155
-sn_sys_load_php_files(SN_ROOT_PHYSICAL . "modules/", DOT_PHP_EX, true);
155
+sn_sys_load_php_files(SN_ROOT_PHYSICAL."modules/", DOT_PHP_EX, true);
156 156
 // Здесь - потому что core_auth модуль лежит в другом каталоге и его нужно инициализировать отдельно
157 157
 
158 158
 // Подключаем дефолтную страницу
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 // Сейчас мы делаем это здесь только для того, что бы содержание дефолтной страницы оказалось вверху. Что не факт, что нужно всегда
161 161
 // Но нужно, пока у нас есть не MVC-страницы
162 162
 $sn_page_data = $sn_data['pages'][$sn_page_name];
163
-$sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
164
-if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
163
+$sn_page_name_file = 'includes/pages/'.$sn_page_data['filename'].DOT_PHP_EX;
164
+if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
165 165
   require_once($sn_page_name_file);
166
-  if(is_array($sn_page_data['options'])) {
166
+  if (is_array($sn_page_data['options'])) {
167 167
     classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']);
168 168
   }
169 169
 }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
 
175 175
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
176
-if(!isset($sn_data['pages'][$sn_page_name])) {
176
+if (!isset($sn_data['pages'][$sn_page_name])) {
177 177
   $sn_page_name = '';
178 178
 }
179 179
 
@@ -181,6 +181,6 @@  discard block
 block discarded – undo
181 181
 classLocale::$lang = $lang = classSupernova::$gc->localePlayer;
182 182
 classLocale::$lang->lng_switch(sys_get_param_str('lang'));
183 183
 
184
-if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
184
+if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
185 185
   require_once "init_secondary.php";
186 186
 }
Please login to merge, or discard this patch.
login.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
 
14 14
 $allow_anonymous = true;
15 15
 
16
-include('includes/init.' . substr(strrchr(__FILE__, '.'), 1));
16
+include('includes/init.'.substr(strrchr(__FILE__, '.'), 1));
17 17
 // die();
18
-if($template_result[F_USER_IS_AUTHORIZED]) {
18
+if ($template_result[F_USER_IS_AUTHORIZED]) {
19 19
   sys_redirect('index.php');
20 20
 }
21 21
 lng_include('login');
Please login to merge, or discard this patch.