Completed
Push — work-fleets ( 094cef...4ec5b3 )
by SuperNova.WS
06:12
created
includes/classes/classSupernova.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@
 block discarded – undo
112 112
   public static function init_3_load_config_file() {
113 113
     $dbsettings = array();
114 114
 
115
-    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
115
+    require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX);
116 116
     self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix'];
117 117
     self::$db_name = $dbsettings['name'];
118 118
     self::$sn_secret_word = $dbsettings['secretword'];
Please login to merge, or discard this patch.
includes/classes/Common/ContainerPlus.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
    * @return bool
39 39
    */
40 40
   public function isEmpty() {
41
-    throw new \Exception(get_class() . '::isEmpty() not implemented - inherited from ContainerPlus');
41
+    throw new \Exception(get_class().'::isEmpty() not implemented - inherited from ContainerPlus');
42 42
   }
43 43
 
44 44
   /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
    * @return mixed
48 48
    */
49 49
   public function clear() {
50
-    throw new \Exception(get_class() . '::clear() not implemented - inherited from ContainerPlus');
50
+    throw new \Exception(get_class().'::clear() not implemented - inherited from ContainerPlus');
51 51
   }
52 52
 
53 53
 }
Please login to merge, or discard this patch.
includes/classes/DbRowDirectOperator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
       ->setIdField($cModel->getIdFieldName())
14 14
       ->field('*')
15 15
       ->from($cModel->getTableName())
16
-      ->where($cModel->getIdFieldName() . ' = "' . $dbId . '"');
16
+      ->where($cModel->getIdFieldName().' = "'.$dbId.'"');
17 17
 
18 18
     return $stmt->selectRow();
19 19
   }
Please login to merge, or discard this patch.
includes/classes/ContainerAccessors.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
     if (is_callable($callable)) {
130 130
       $this->{$type}[$varName] = $callable;
131 131
     } else {
132
-      throw new Exception('Error assigning callable in ' . get_called_class() . '! Callable typed [' . $type . '] is not a callable or not accessible in the scope');
132
+      throw new Exception('Error assigning callable in '.get_called_class().'! Callable typed ['.$type.'] is not a callable or not accessible in the scope');
133 133
     }
134 134
   }
135 135
 
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/classCache.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
   public function __set($name, $value) {
97 97
     switch (self::$mode) {
98 98
       case CACHER_NO_CACHE:
99
-        self::$data[$this->prefix . $name] = $value;
99
+        self::$data[$this->prefix.$name] = $value;
100 100
       break;
101 101
 
102 102
       case CACHER_XCACHE:
103
-        xcache_set($this->prefix . $name, $value);
103
+        xcache_set($this->prefix.$name, $value);
104 104
       break;
105 105
     }
106 106
   }
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
   public function __get($name) {
109 109
     switch (self::$mode) {
110 110
       case CACHER_NO_CACHE:
111
-        return self::$data[$this->prefix . $name];
111
+        return self::$data[$this->prefix.$name];
112 112
       break;
113 113
 
114 114
       case CACHER_XCACHE:
115
-        return xcache_get($this->prefix . $name);
115
+        return xcache_get($this->prefix.$name);
116 116
       break;
117 117
     }
118 118
 
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
   public function __isset($name) {
123 123
     switch (self::$mode) {
124 124
       case CACHER_NO_CACHE:
125
-        return isset(self::$data[$this->prefix . $name]);
125
+        return isset(self::$data[$this->prefix.$name]);
126 126
       break;
127 127
 
128 128
       case CACHER_XCACHE:
129
-        return xcache_isset($this->prefix . $name) && ($this->__get($name) !== null);
129
+        return xcache_isset($this->prefix.$name) && ($this->__get($name) !== null);
130 130
       break;
131 131
     }
132 132
 
@@ -136,25 +136,25 @@  discard block
 block discarded – undo
136 136
   public function __unset($name) {
137 137
     switch (self::$mode) {
138 138
       case CACHER_NO_CACHE:
139
-        unset(self::$data[$this->prefix . $name]);
139
+        unset(self::$data[$this->prefix.$name]);
140 140
       break;
141 141
 
142 142
       case CACHER_XCACHE:
143
-        xcache_unset($this->prefix . $name);
143
+        xcache_unset($this->prefix.$name);
144 144
       break;
145 145
     }
146 146
   }
147 147
 
148 148
   public function unset_by_prefix($prefix_unset = '') {
149 149
     static $array_clear;
150
-    !$array_clear ? $array_clear = function (&$v, $k, $p) {
150
+    !$array_clear ? $array_clear = function(&$v, $k, $p) {
151 151
       strpos($k, $p) === 0 ? $v = null : false;
152 152
     } : false;
153 153
 
154 154
     switch (self::$mode) {
155 155
       case CACHER_NO_CACHE:
156 156
 //        array_walk(self::$data, create_function('&$v,$k,$p', 'if(strpos($k, $p) === 0)$v = NULL;'), $this->prefix.$prefix_unset);
157
-        array_walk(self::$data, $array_clear, $this->prefix . $prefix_unset);
157
+        array_walk(self::$data, $array_clear, $this->prefix.$prefix_unset);
158 158
 
159 159
         return true;
160 160
       break;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
           return false;
165 165
         }
166 166
 
167
-        return xcache_unset_by_prefix($this->prefix . $prefix_unset);
167
+        return xcache_unset_by_prefix($this->prefix.$prefix_unset);
168 168
       break;
169 169
     }
170 170
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     if ($this->$name[0] === null) {
203 203
       for ($i = count($name) - 1; $i > 0; $i--) {
204 204
         $cName = "{$name[$i]}_COUNT";
205
-        $cName1 = "{$name[$i-1]}_COUNT";
205
+        $cName1 = "{$name[$i - 1]}_COUNT";
206 206
         if ($this->$cName1 == null || $i == 1) {
207 207
           $this->$cName++;
208 208
         }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
     for ($i = 1; $i < count($name); $i++) {
249 249
       $cName = "{$name[$i]}_COUNT";
250
-      $cName1 = "{$name[$i-1]}_COUNT";
250
+      $cName1 = "{$name[$i - 1]}_COUNT";
251 251
 
252 252
       if ($i == 1 || $this->$cName1 === null) {
253 253
         $this->$cName--;
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 1 patch
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.
includes/classes/classLocale.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
 
36 36
     $this->container = array();
37 37
 
38
-    if(classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) {
38
+    if (classSupernova::$cache->getMode() != CACHER_NO_CACHE && !classSupernova::$config->locale_cache_disable) {
39 39
       $this->cache = classSupernova::$cache;
40 40
       classSupernova::log_file('locale.__constructor: Cache is present');
41 41
 //$this->cache->unset_by_prefix($this->cache_prefix); // TODO - remove? 'cause debug!
42 42
     }
43 43
 
44
-    if($enable_stat_usage && empty($this->stat_usage)) {
44
+    if ($enable_stat_usage && empty($this->stat_usage)) {
45 45
       $this->enable_stat_usage = $enable_stat_usage;
46 46
       $this->usage_stat_load();
47 47
       // TODO shutdown function
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
     unset($fallback[$this->active]);
68 68
 
69 69
     // Проходим по оставшимся локалям
70
-    foreach($fallback as $try_language) {
70
+    foreach ($fallback as $try_language) {
71 71
       // Если нет такой строки - пытаемся вытащить из кэша
72
-      if(!isset($this->container[$try_language][$offset]) && $this->cache) {
73
-        $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix . $try_language . '_' . $offset);
72
+      if (!isset($this->container[$try_language][$offset]) && $this->cache) {
73
+        $this->container[$try_language][$offset] = $this->cache->__get($this->cache_prefix.$try_language.'_'.$offset);
74 74
 // Записываем результат работы кэша
75 75
 $locale_cache_statistic['queries']++;
76 76
 isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['hits']++ : $locale_cache_statistic['misses']++;
77
-!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix . $try_language . '_' . $offset : false;
77
+!isset($this->container[$try_language][$offset]) ? $locale_cache_statistic['missed_str'][] = $this->cache_prefix.$try_language.'_'.$offset : false;
78 78
       }
79 79
 
80 80
       // Если мы как-то где-то нашли строку...
81
-      if(isset($this->container[$try_language][$offset])) {
81
+      if (isset($this->container[$try_language][$offset])) {
82 82
         // ...значит она получена в результате фоллбэка и записываем её в кэш и контейнер
83 83
         $this[$offset] = $this->container[$try_language][$offset];
84 84
         $locale_cache_statistic['fallbacks']++;
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
       $this->container[$this->active][] = $value;
95 95
     } else {
96 96
       $this->container[$this->active][$offset] = $value;
97
-      if($this->cache) {
98
-        $this->cache->__set($this->cache_prefix_lang . $offset, $value);
97
+      if ($this->cache) {
98
+        $this->cache->__set($this->cache_prefix_lang.$offset, $value);
99 99
       }
100 100
     }
101 101
   }
102 102
   public function offsetExists($offset) {
103 103
     // Шорткат если у нас уже есть строка в памяти PHP
104
-    if(!isset($this->container[$this->active][$offset])) {
104
+    if (!isset($this->container[$this->active][$offset])) {
105 105
 //        pdump($this->cache_prefix_lang . $offset);
106
-      if(!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang . $offset))) {
106
+      if (!$this->cache || !($this->container[$this->active][$offset] = $this->cache->__get($this->cache_prefix_lang.$offset))) {
107 107
 //        pdump($this->cache_prefix_lang . $offset);
108 108
         // Если нету такой строки - делаем фоллбэк
109 109
         $this->locale_string_fallback($offset);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   }
120 120
   public function offsetGet($offset) {
121 121
     $value = $this->offsetExists($offset) ? $this->container[$this->active][$offset] : null;
122
-    if($this->enable_stat_usage) {
122
+    if ($this->enable_stat_usage) {
123 123
       $this->usage_stat_log($offset, $value);
124 124
     }
125 125
     return $value;
@@ -134,23 +134,23 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
   public function usage_stat_load() {
137
-    $this->stat_usage = classSupernova::$cache->lng_stat_usage  = array();
138
-    if(empty($this->stat_usage)) {
137
+    $this->stat_usage = classSupernova::$cache->lng_stat_usage = array();
138
+    if (empty($this->stat_usage)) {
139 139
       $query = classSupernova::$db->doSelect("SELECT * FROM `{{lng_usage_stat}}`");
140
-      while($row = db_fetch($query)) {
141
-        $this->stat_usage[$row['lang_code'] . ':' . $row['string_id'] . ':' . $row['file'] . ':' . $row['line']] = $row['is_empty'];
140
+      while ($row = db_fetch($query)) {
141
+        $this->stat_usage[$row['lang_code'].':'.$row['string_id'].':'.$row['file'].':'.$row['line']] = $row['is_empty'];
142 142
       }
143 143
     }
144 144
   }
145 145
   public function usage_stat_save() {
146
-    if(!empty($this->stat_usage_new)) {
146
+    if (!empty($this->stat_usage_new)) {
147 147
       classSupernova::$cache->lng_stat_usage = $this->stat_usage;
148 148
       classSupernova::$db->doSelect("SELECT 1 FROM `{{lng_usage_stat}}` LIMIT 1");
149
-      foreach($this->stat_usage_new as &$value) {
150
-        foreach($value as &$value2) {
151
-          $value2 = '"' . db_escape($value2) . '"';
149
+      foreach ($this->stat_usage_new as &$value) {
150
+        foreach ($value as &$value2) {
151
+          $value2 = '"'.db_escape($value2).'"';
152 152
         }
153
-        $value = '(' . implode(',', $value) .')';
153
+        $value = '('.implode(',', $value).')';
154 154
       }
155 155
       classSupernova::$gc->db->doReplaceValuesDeprecated(
156 156
         'lng_usage_stat',
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 
174 174
     $file = str_replace('\\', '/', substr($trace[1]['file'], strlen(SN_ROOT_PHYSICAL) - 1));
175 175
 
176
-    $string_id = $this->active . ':' . $offset . ':' . $file . ':' . $trace[1]['line'];
177
-    if(!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) {
176
+    $string_id = $this->active.':'.$offset.':'.$file.':'.$trace[1]['line'];
177
+    if (!isset($this->stat_usage[$string_id]) || $this->stat_usage[$string_id] != empty($value)) {
178 178
       $this->stat_usage[$string_id] = empty($value);
179 179
       $this->stat_usage_new[] = array(
180 180
         'lang_code' => $this->active,
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
         'file' => $file,
183 183
         'line' => $trace[1]['line'],
184 184
         'is_empty' => intval(empty($value)),
185
-        'locale' => '' . $value,
185
+        'locale' => ''.$value,
186 186
       );
187 187
     }
188 188
   }
189 189
 
190 190
 
191 191
   protected function lng_try_filepath($path, $file_path_relative) {
192
-    $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative;
192
+    $file_path = SN_ROOT_PHYSICAL.($path && file_exists(SN_ROOT_PHYSICAL.$path.$file_path_relative) ? $path : '').$file_path_relative;
193 193
     return file_exists($file_path) ? $file_path : false;
194 194
   }
195 195
 
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 
212 212
     classSupernova::log_file("locale.include: Loading data from domain '{$filename}'", 1);
213 213
 
214
-    $cache_file_key = $this->cache_prefix_lang . '__' . $filename;
214
+    $cache_file_key = $this->cache_prefix_lang.'__'.$filename;
215 215
 
216 216
     // Подключен ли внешний кэш?
217
-    if($this->cache) {
217
+    if ($this->cache) {
218 218
       // Загружен ли уже данный файл?
219 219
       $cache_file_status = $this->cache->__get($cache_file_key);
220
-      classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is " . ($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0);
221
-      if($cache_file_status) {
220
+      classSupernova::log_file("locale.include: Cache - '{$filename}' has key '{$cache_file_key}' and is ".($cache_file_status ? 'already loaded - EXIT' : 'EMPTY'), $cache_file_status ? -1 : 0);
221
+      if ($cache_file_status) {
222 222
         // Если да - повторять загрузку нет смысла
223 223
         return null;
224 224
       }
@@ -232,47 +232,47 @@  discard block
 block discarded – undo
232 232
     $this->make_fallback($language);
233 233
 
234 234
     $file_path = '';
235
-    foreach($this->fallback as $lang_try) {
236
-      if(!$lang_try /* || isset($language_tried[$lang_try]) */) {
235
+    foreach ($this->fallback as $lang_try) {
236
+      if (!$lang_try /* || isset($language_tried[$lang_try]) */) {
237 237
         continue;
238 238
       }
239 239
 
240
-      if($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) {
240
+      if ($file_path = $this->lng_try_filepath($path, "language/{$lang_try}/{$filename_ext}")) {
241 241
         break;
242 242
       }
243 243
 
244
-      if($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) {
244
+      if ($file_path = $this->lng_try_filepath($path, "language/{$filename}_{$lang_try}{$ext}")) {
245 245
         break;
246 246
       }
247 247
 
248 248
       $file_path = '';
249 249
     }
250 250
 
251
-    if($file_path) {
251
+    if ($file_path) {
252 252
       $a_lang_array = array();
253 253
       include($file_path);
254 254
 
255
-      if(!empty($a_lang_array)) {
255
+      if (!empty($a_lang_array)) {
256 256
         $this->merge($a_lang_array);
257 257
 
258 258
         // Загрузка данных из файла в кэш
259
-        if($this->cache) {
259
+        if ($this->cache) {
260 260
           classSupernova::log_file("Locale: loading '{$filename}' into cache");
261
-          foreach($a_lang_array as $key => $value) {
262
-            $value_cache_key = $this->cache_prefix_lang . $key;
263
-            if($this->cache->__isset($value_cache_key)) {
264
-              if(is_array($value)) {
261
+          foreach ($a_lang_array as $key => $value) {
262
+            $value_cache_key = $this->cache_prefix_lang.$key;
263
+            if ($this->cache->__isset($value_cache_key)) {
264
+              if (is_array($value)) {
265 265
                 $alt_value = $this->cache->__get($value_cache_key);
266 266
                 $value = array_replace_recursive($alt_value, $value);
267 267
                 // pdump($alt_value, $alt_value);
268 268
               }
269 269
             }
270
-            $this->cache->__set($this->cache_prefix_lang . $key, $value);
270
+            $this->cache->__set($this->cache_prefix_lang.$key, $value);
271 271
           }
272 272
         }
273 273
       }
274 274
 
275
-      if($this->cache) {
275
+      if ($this->cache) {
276 276
         $this->cache->__set($cache_file_key, true);
277 277
       }
278 278
 
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
   }
286 286
 
287 287
   public function lng_load_i18n($i18n) {
288
-    if(!isset($i18n)) {
288
+    if (!isset($i18n)) {
289 289
       return;
290 290
     }
291 291
 
292
-    foreach($i18n as $i18n_data) {
293
-      if(is_string($i18n_data)) {
292
+    foreach ($i18n as $i18n_data) {
293
+      if (is_string($i18n_data)) {
294 294
         $this->lng_include($i18n_data);
295
-      } elseif(is_array($i18n_data)) {
295
+      } elseif (is_array($i18n_data)) {
296 296
         $this->lng_include($i18n_data['file'], $i18n_data['path']);
297 297
       }
298 298
     }
@@ -310,27 +310,27 @@  discard block
 block discarded – undo
310 310
 
311 311
     classSupernova::log_file("locale.switch: Trying to switch language to '{$language_new}'");
312 312
 
313
-    if($language_new == $this->active) {
313
+    if ($language_new == $this->active) {
314 314
       classSupernova::log_file("locale.switch: New language '{$language_new}' is equal to current language '{$this->active}' - EXIT", -1);
315 315
       return false;
316 316
     }
317 317
 
318 318
     $this->active = $language = $language_new;
319
-    $this->cache_prefix_lang = $this->cache_prefix . $this->active . '_';
319
+    $this->cache_prefix_lang = $this->cache_prefix.$this->active.'_';
320 320
 
321 321
     $this['LANG_INFO'] = $this->lng_get_info($this->active);
322 322
     $this->make_fallback($this->active);
323 323
 
324
-    if($this->cache) {
325
-      $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang . '__INIT');
326
-      classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is " . ($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0);
327
-      if($cache_lang_init_status) {
324
+    if ($this->cache) {
325
+      $cache_lang_init_status = $this->cache->__get($this->cache_prefix_lang.'__INIT');
326
+      classSupernova::log_file("locale.switch: Cache for '{$this->active}' prefixed '{$this->cache_prefix_lang}' is ".($cache_lang_init_status ? 'already loaded. Doing nothing - EXIT' : 'EMPTY'), $cache_lang_init_status ? -1 : 0);
327
+      if ($cache_lang_init_status) {
328 328
         return false;
329 329
       }
330 330
 
331 331
       // Чистим текущие локализации из кэша. Достаточно почистить только флаги инициализации языкового кэша и загрузки файлов - они начинаются с '__'
332 332
       classSupernova::log_file("locale.switch: Cache - invalidating data");
333
-      $this->cache->unset_by_prefix($this->cache_prefix_lang . '__');
333
+      $this->cache->unset_by_prefix($this->cache_prefix_lang.'__');
334 334
     }
335 335
 
336 336
     $this->lng_include('system');
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
     // Loading global language files
341 341
     $this->lng_load_i18n(classSupernova::$sn_mvc['i18n']['']);
342 342
 
343
-    if($this->cache) {
344
-      classSupernova::log_file("locale.switch: Cache - setting flag " . $this->cache_prefix_lang . '__INIT');
345
-      $this->cache->__set($this->cache_prefix_lang . '__INIT', true);
343
+    if ($this->cache) {
344
+      classSupernova::log_file("locale.switch: Cache - setting flag ".$this->cache_prefix_lang.'__INIT');
345
+      $this->cache->__set($this->cache_prefix_lang.'__INIT', true);
346 346
     }
347 347
 
348 348
     classSupernova::log_file("locale.switch: Complete - EXIT");
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 
353 353
 
354 354
   public function lng_get_info($entry) {
355
-    $file_name = SN_ROOT_PHYSICAL . 'language/' . $entry . '/language.mo.php';
355
+    $file_name = SN_ROOT_PHYSICAL.'language/'.$entry.'/language.mo.php';
356 356
     $lang_info = array();
357
-    if(file_exists($file_name)) {
357
+    if (file_exists($file_name)) {
358 358
       include($file_name);
359 359
     }
360 360
 
@@ -362,15 +362,15 @@  discard block
 block discarded – undo
362 362
   }
363 363
 
364 364
   public function lng_get_list() {
365
-    if(empty($this->lang_list)) {
365
+    if (empty($this->lang_list)) {
366 366
       $this->lang_list = array();
367 367
 
368
-      $path = SN_ROOT_PHYSICAL . 'language/';
368
+      $path = SN_ROOT_PHYSICAL.'language/';
369 369
       $dir = dir($path);
370
-      while(false !== ($entry = $dir->read())) {
371
-        if(is_dir($path . $entry) && $entry[0] != '.') {
370
+      while (false !== ($entry = $dir->read())) {
371
+        if (is_dir($path.$entry) && $entry[0] != '.') {
372 372
           $lang_info = $this->lng_get_info($entry);
373
-          if($lang_info['LANG_NAME_ISO2'] == $entry) {
373
+          if ($lang_info['LANG_NAME_ISO2'] == $entry) {
374 374
             $this->lang_list[$lang_info['LANG_NAME_ISO2']] = $lang_info;
375 375
           }
376 376
         }
Please login to merge, or discard this patch.