Completed
Branch trunk (78000f)
by SuperNova.WS
25:55 queued 09:00
created
classes/userOptions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -151,6 +151,9 @@
 block discarded – undo
151 151
   }
152 152
 
153 153
 
154
+  /**
155
+   * @param integer $user_id
156
+   */
154 157
   public function __construct($user_id) {
155 158
     $this->user_change($user_id);
156 159
   }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 
123 123
     $update_cache = false;
124 124
 
125
-    if(!empty($this->to_write)) {
126
-      foreach($this->to_write as $key => $cork) {
125
+    if (!empty($this->to_write)) {
126
+      foreach ($this->to_write as $key => $cork) {
127 127
         $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД
128 128
         $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')";
129 129
       }
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
       $update_cache = true;
135 135
     }
136 136
 
137
-    if(!empty($this->to_delete)) {
138
-      foreach($this->to_delete as $key => &$value) {
139
-        $value = is_string($key) ? "'". db_escape($key) . "'" : $key;
137
+    if (!empty($this->to_delete)) {
138
+      foreach ($this->to_delete as $key => &$value) {
139
+        $value = is_string($key) ? "'" . db_escape($key) . "'" : $key;
140 140
       }
141 141
 
142
-      doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") ");
142
+      doquery("DELETE FROM {{player_options}} WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") ");
143 143
 
144 144
       $this->to_delete = array();
145 145
       $update_cache = true;
146 146
     }
147 147
 
148
-    if($update_cache) {
148
+    if ($update_cache) {
149 149
       global $sn_cache;
150 150
 
151 151
       $field_name = $this->cached_name();
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
   protected function load() {
173 173
     global $sn_cache;
174 174
 
175
-    if($this->loaded) {
175
+    if ($this->loaded) {
176 176
       return;
177 177
     }
178 178
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     $this->to_write = array();
181 181
     $this->to_delete = array();
182 182
 
183
-    if(!$this->user_id) {
183
+    if (!$this->user_id) {
184 184
       $this->loaded = true;
185 185
       return;
186 186
     }
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
     $field_name = $this->cached_name();
189 189
     $a_data = $sn_cache->$field_name;
190 190
 
191
-    if(!empty($a_data)) {
191
+    if (!empty($a_data)) {
192 192
       $this->data = array_replace_recursive($this->data, $a_data);
193 193
       return;
194 194
     }
195 195
 
196 196
     $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
197
-    while($row = db_fetch($query)) {
197
+    while ($row = db_fetch($query)) {
198 198
       // $this->data[$row['option_id']] = $row['value'];
199 199
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
200 200
     }
Please login to merge, or discard this patch.
classes/auth_abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
    */
36 36
   // OK 4.9
37 37
   public function __construct($filename = __FILE__) {
38
-    if($this->provider_id == ACCOUNT_PROVIDER_NONE) {
38
+    if ($this->provider_id == ACCOUNT_PROVIDER_NONE) {
39 39
       die('У всех провайдеров должен быть $provider_id!');
40 40
     }
41 41
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
   // OK 4.6
134 134
   public function player_name_suggest() {
135 135
     $name = '';
136
-    if(is_object($this->account) && !empty($this->account->account_email)) {
136
+    if (is_object($this->account) && !empty($this->account->account_email)) {
137 137
       list($name) = explode('@', $this->account->account_email);
138 138
     }
139 139
 
Please login to merge, or discard this patch.
classes/Pimple/Container.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 
240 240
         $factory = $this->values[$id];
241 241
 
242
-        $extended = function ($c) use ($callable, $factory) {
242
+        $extended = function($c) use ($callable, $factory) {
243 243
             return $callable($factory($c), $c);
244 244
         };
245 245
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
  *
32 32
  * @author  Fabien Potencier
33 33
  */
34
-class Container implements \ArrayAccess
35
-{
34
+class Container implements \ArrayAccess {
36 35
     private $values = array();
37 36
     private $factories;
38 37
     private $protected;
@@ -47,8 +46,7 @@  discard block
 block discarded – undo
47 46
      *
48 47
      * @param array $values The parameters or objects.
49 48
      */
50
-    public function __construct(array $values = array())
51
-    {
49
+    public function __construct(array $values = array()) {
52 50
         $this->factories = new \SplObjectStorage();
53 51
         $this->protected = new \SplObjectStorage();
54 52
 
@@ -71,8 +69,7 @@  discard block
 block discarded – undo
71 69
      *
72 70
      * @throws \RuntimeException Prevent override of a frozen service
73 71
      */
74
-    public function offsetSet($id, $value)
75
-    {
72
+    public function offsetSet($id, $value) {
76 73
         if (isset($this->frozen[$id])) {
77 74
             throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id));
78 75
         }
@@ -90,8 +87,7 @@  discard block
 block discarded – undo
90 87
      *
91 88
      * @throws \InvalidArgumentException if the identifier is not defined
92 89
      */
93
-    public function offsetGet($id)
94
-    {
90
+    public function offsetGet($id) {
95 91
         if (!isset($this->keys[$id])) {
96 92
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
97 93
         }
@@ -125,8 +121,7 @@  discard block
 block discarded – undo
125 121
      *
126 122
      * @return bool
127 123
      */
128
-    public function offsetExists($id)
129
-    {
124
+    public function offsetExists($id) {
130 125
         return isset($this->keys[$id]);
131 126
     }
132 127
 
@@ -135,8 +130,7 @@  discard block
 block discarded – undo
135 130
      *
136 131
      * @param string $id The unique identifier for the parameter or object
137 132
      */
138
-    public function offsetUnset($id)
139
-    {
133
+    public function offsetUnset($id) {
140 134
         if (isset($this->keys[$id])) {
141 135
             if (is_object($this->values[$id])) {
142 136
                 unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]);
@@ -155,8 +149,7 @@  discard block
 block discarded – undo
155 149
      *
156 150
      * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
157 151
      */
158
-    public function factory($callable)
159
-    {
152
+    public function factory($callable) {
160 153
         if (!method_exists($callable, '__invoke')) {
161 154
             throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.');
162 155
         }
@@ -177,8 +170,7 @@  discard block
 block discarded – undo
177 170
      *
178 171
      * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
179 172
      */
180
-    public function protect($callable)
181
-    {
173
+    public function protect($callable) {
182 174
         if (!method_exists($callable, '__invoke')) {
183 175
             throw new \InvalidArgumentException('Callable is not a Closure or invokable object.');
184 176
         }
@@ -197,8 +189,7 @@  discard block
 block discarded – undo
197 189
      *
198 190
      * @throws \InvalidArgumentException if the identifier is not defined
199 191
      */
200
-    public function raw($id)
201
-    {
192
+    public function raw($id) {
202 193
         if (!isset($this->keys[$id])) {
203 194
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
204 195
         }
@@ -223,8 +214,7 @@  discard block
 block discarded – undo
223 214
      *
224 215
      * @throws \InvalidArgumentException if the identifier is not defined or not a service definition
225 216
      */
226
-    public function extend($id, $callable)
227
-    {
217
+    public function extend($id, $callable) {
228 218
         if (!isset($this->keys[$id])) {
229 219
             throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
230 220
         }
@@ -256,8 +246,7 @@  discard block
 block discarded – undo
256 246
      *
257 247
      * @return array An array of value names
258 248
      */
259
-    public function keys()
260
-    {
249
+    public function keys() {
261 250
         return array_keys($this->values);
262 251
     }
263 252
 
@@ -269,8 +258,7 @@  discard block
 block discarded – undo
269 258
      *
270 259
      * @return static
271 260
      */
272
-    public function register(ServiceProviderInterface $provider, array $values = array())
273
-    {
261
+    public function register(ServiceProviderInterface $provider, array $values = array()) {
274 262
         $provider->register($this);
275 263
 
276 264
         foreach ($values as $key => $value) {
Please login to merge, or discard this patch.
classes/PlayerToAccountTranslate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   protected static $is_init = false;
20 20
 
21 21
   protected static function init() {
22
-    if(!empty(static::$db)) {
22
+    if (!empty(static::$db)) {
23 23
       return;
24 24
     }
25 25
     static::$db = classSupernova::$db;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     $provider_id_safe = intval($provider_id_unsafe);
67 67
     !is_array($account_list) ? $account_list = array($account_list) : false;
68 68
 
69
-    foreach($account_list as $provider_account_id_unsafe) {
69
+    foreach ($account_list as $provider_account_id_unsafe) {
70 70
       $provider_account_id_safe = intval($provider_account_id_unsafe);
71 71
 
72 72
       // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером
73 73
       $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE");
74
-      while($row = static::$db->db_fetch($query)) {
74
+      while ($row = static::$db->db_fetch($query)) {
75 75
         $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true;
76 76
       }
77 77
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
       "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92 92
       ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
93 93
       "ORDER BY `timestamp` FOR UPDATE");
94
-    while($row = static::$db->db_fetch($query)) {
94
+    while ($row = static::$db->db_fetch($query)) {
95 95
       $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row;
96 96
     }
97 97
 
Please login to merge, or discard this patch.
classes/classCache.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
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
 
@@ -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.
classes/Pimple/ServiceProviderInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@
 block discarded – undo
32 32
  * @author  Fabien Potencier
33 33
  * @author  Dominik Zogg
34 34
  */
35
-interface ServiceProviderInterface
36
-{
35
+interface ServiceProviderInterface {
37 36
     /**
38 37
      * Registers services on the given container.
39 38
      *
Please login to merge, or discard this patch.
classes/auth_local.php 2 patches
Doc Comments   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -138,7 +138,6 @@  discard block
 block discarded – undo
138 138
    * Попытка залогиниться с использованием метода $method
139 139
    * @version 4.5
140 140
    *
141
-   * @param string $method_name
142 141
    */
143 142
   public function login() {
144 143
     // TODO Проверяем поддерживаемость метода
@@ -163,7 +162,7 @@  discard block
 block discarded – undo
163 162
    *
164 163
    * @param      $old_password_unsafe
165 164
    * @param      $new_password_unsafe
166
-   * @param null $salt_unsafe
165
+   * @param string $salt_unsafe
167 166
    *
168 167
    * @return array|bool|resource
169 168
    */
@@ -176,6 +175,9 @@  discard block
 block discarded – undo
176 175
     return $result;
177 176
   }
178 177
 
178
+  /**
179
+   * @param Account $account_to_impersonate
180
+   */
179 181
   public function impersonate($account_to_impersonate) {
180 182
     $this->cookie_set($account_to_impersonate);
181 183
   }
@@ -662,6 +664,10 @@  discard block
 block discarded – undo
662 664
   protected function make_random_password() {
663 665
     return core_auth::make_random_password();
664 666
   }
667
+
668
+  /**
669
+   * @param string $message
670
+   */
665 671
   protected function flog($message, $die = false) {
666 672
     if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
667 673
       return;
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
     $this->prepare();
97 97
 
98 98
     $this->manifest['active'] = false;
99
-    if(!empty($this->config) && is_array($this->config['db'])) {
99
+    if (!empty($this->config) && is_array($this->config['db'])) {
100 100
       // БД, отличная от стандартной
101 101
       $this->db = new db_mysql();
102 102
 
103 103
       $this->db->sn_db_connect($this->config['db']);
104
-      if($this->manifest['active'] = $this->db->connected) {
104
+      if ($this->manifest['active'] = $this->db->connected) {
105 105
         $this->provider_id = ACCOUNT_PROVIDER_CENTRAL;
106 106
 
107 107
         $this->domain = $this->config['domain'];
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     // Fallback to local DB
118
-    if(!$this->manifest['active']) {
118
+    if (!$this->manifest['active']) {
119 119
       $this->db = classSupernova::$db;
120 120
 
121 121
       $this->provider_id = ACCOUNT_PROVIDER_LOCAL;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
    */
170 170
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
171 171
     $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe);
172
-    if($result) {
172
+    if ($result) {
173 173
       $this->cookie_set();
174 174
     }
175 175
 
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
   protected function password_reset_send_code() {
199 199
     global $lang, $config;
200 200
 
201
-    if(!$this->is_password_reset) {
201
+    if (!$this->is_password_reset) {
202 202
       return $this->account_login_status;
203 203
     }
204 204
 
205 205
     // Проверяем поддержку сброса пароля
206
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
206
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
207 207
       return $this->account_login_status;
208 208
     }
209 209
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
       unset($this->account);
214 214
       $this->account = new Account($this->db);
215 215
 
216
-      if(!$this->account->db_get_by_email($email_unsafe)) {
216
+      if (!$this->account->db_get_by_email($email_unsafe)) {
217 217
         throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR);
218 218
         // return $this->account_login_status;
219 219
       }
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 
224 224
       // TODO - Проверять уровень доступа аккаунта!
225 225
       // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ!
226
-      foreach($user_list as $user_id => $user_data) {
227
-        if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
226
+      foreach ($user_list as $user_id => $user_data) {
227
+        if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
228 228
           throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR);
229 229
         }
230 230
       }
231 231
 
232 232
       $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5
233
-      if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
233
+      if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
234 234
         throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR);
235 235
       }
236 236
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
       $confirm_code_unsafe = $this->confirmation->db_confirmation_get_unique_code_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5
242 242
       sn_db_transaction_commit();
243 243
 
244
-      if(!is_email($email_unsafe)) {
244
+      if (!is_email($email_unsafe)) {
245 245
         classSupernova::$debug->error("Email is invalid: '{$email_unsafe}'", 'Invalid email for password restoration');
246 246
       }
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
       );
252 252
 
253 253
       $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING;
254
-    } catch(Exception $e) {
254
+    } catch (Exception $e) {
255 255
       sn_db_transaction_rollback();
256 256
       $result = $e->getMessage();
257 257
     }
@@ -266,46 +266,46 @@  discard block
 block discarded – undo
266 266
   protected function password_reset_confirm() {
267 267
     global $lang, $config;
268 268
 
269
-    if(!$this->is_password_reset_confirm) {
269
+    if (!$this->is_password_reset_confirm) {
270 270
       return $this->account_login_status;
271 271
     }
272 272
 
273
-    if($this->account_login_status != LOGIN_UNDEFINED) {
273
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
274 274
       return $this->account_login_status;
275 275
     }
276 276
 
277 277
     // Проверяем поддержку сброса пароля
278
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
278
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
279 279
       return $this->account_login_status;
280 280
     }
281 281
 
282 282
     try {
283 283
       $code_unsafe = sys_get_param_str_unsafe('password_reset_code');
284
-      if(empty($code_unsafe)) {
284
+      if (empty($code_unsafe)) {
285 285
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR);
286 286
       }
287 287
 
288 288
       sn_db_transaction_start();
289 289
       $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5
290 290
 
291
-      if(empty($confirmation)) {
291
+      if (empty($confirmation)) {
292 292
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR);
293 293
       }
294 294
 
295
-      if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
295
+      if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
296 296
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR);
297 297
       }
298 298
 
299 299
       unset($this->account);
300 300
       $this->account = new Account($this->db);
301 301
 
302
-      if(!$this->account->db_get_by_email($confirmation['email'])) {
302
+      if (!$this->account->db_get_by_email($confirmation['email'])) {
303 303
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR);
304 304
       }
305 305
 
306 306
       $new_password_unsafe = $this->make_random_password();
307 307
       $salt_unsafe = $this->password_salt_generate();
308
-      if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
308
+      if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
309 309
         // Ошибка смены пароля
310 310
         throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR);
311 311
       }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
       $this->cookie_set();
316 316
       $this->login_cookie();
317 317
 
318
-      if($this->account_login_status == LOGIN_SUCCESS) {
318
+      if ($this->account_login_status == LOGIN_SUCCESS) {
319 319
         // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!!
320 320
         $message_header = sprintf($lang['log_lost_email_title'], $config->game_name);
321 321
         $message = sprintf($lang['log_lost_email_pass'], $config->game_name, $this->account->account_name, $new_password_unsafe);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
         // $users_translated = classSupernova::$auth->db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5
325 325
         $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5
326
-        if(!empty($users_translated)) {
326
+        if (!empty($users_translated)) {
327 327
           // Отправляем в лички письмо о сбросе пароля
328 328
 
329 329
           // ПО ОПРЕДЕЛЕНИЮ в $users_translated только
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
           $message = HelperString::nl2br($message) . '<br><br>';
336 336
           // msg_send_simple_message($found_provider->data[F_USER_ID], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
337 337
 
338
-          foreach($users_translated as $user_id => $providers_list) {
338
+          foreach ($users_translated as $user_id => $providers_list) {
339 339
             msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
340 340
           }
341 341
         } else {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id);
389 389
 
390 390
     try {
391
-      if(!$this->is_register) {
391
+      if (!$this->is_register) {
392 392
         $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем');
393 393
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
394 394
       }
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
       // $this->account_check_duplicate_name_or_email($this->input_login_unsafe, $this->input_email_unsafe);
401 401
 
402 402
       $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe);
403
-      if($this->account->is_exists) {
404
-        if($this->account->account_email == $this->input_email_unsafe) {
403
+      if ($this->account->is_exists) {
404
+        if ($this->account->account_email == $this->input_email_unsafe) {
405 405
           throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR);
406 406
         } else {
407 407
           throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR);
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
       // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth
441 441
       // $this->register_account();
442 442
       sn_db_transaction_commit();
443
-    } catch(Exception $e) {
443
+    } catch (Exception $e) {
444 444
       sn_db_transaction_rollback();
445 445
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
446 446
     }
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
    * @return int Результат попытки
456 456
    */
457 457
   protected function login_cookie() {
458
-    if($this->account_login_status != LOGIN_UNDEFINED) {
458
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
459 459
       return $this->account_login_status;
460 460
     }
461 461
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 //      $this->cookie_clear();
482 482
 //    }
483 483
 
484
-    if($this->account->cookieLogin($rememberMe)) {
484
+    if ($this->account->cookieLogin($rememberMe)) {
485 485
         $this->account_login_status = LOGIN_SUCCESS;
486 486
         $this->remember_me = intval($rememberMe);
487 487
     }
@@ -498,13 +498,13 @@  discard block
 block discarded – undo
498 498
   protected function login_username() {
499 499
     // TODO - Логин по старым именам
500 500
     try {
501
-      if(!$this->is_login) {
501
+      if (!$this->is_login) {
502 502
         $this->flog('Логин: не выставлен флаг входа в игру - это не логин');
503 503
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
504 504
       }
505 505
 
506 506
       // TODO Пустое имя аккаунта
507
-      if(!$this->input_login_unsafe) {
507
+      if (!$this->input_login_unsafe) {
508 508
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
509 509
       }
510 510
 
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 //      if(empty($account)) {
515 515
 //        throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR);
516 516
 //      }
517
-      if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
517
+      if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
518 518
         throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR);
519 519
       }
520 520
 
521
-      if(!$this->account->password_check($this->input_login_password_raw)) {
521
+      if (!$this->account->password_check($this->input_login_password_raw)) {
522 522
         throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR);
523 523
       }
524 524
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
       $this->cookie_set();
528 528
       $this->account_login_status = LOGIN_SUCCESS;
529
-    } catch(Exception $e) {
529
+    } catch (Exception $e) {
530 530
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
531 531
     }
532 532
 
@@ -547,11 +547,11 @@  discard block
 block discarded – undo
547 547
   protected function cookie_set($account_to_impersonate = null) {
548 548
     $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account;
549 549
 
550
-    if(!is_object($this_account) || !$this_account->is_exists) {
550
+    if (!is_object($this_account) || !$this_account->is_exists) {
551 551
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
552 552
     }
553 553
 
554
-    if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
554
+    if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
555 555
       sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain);
556 556
     }
557 557
 
@@ -588,10 +588,10 @@  discard block
 block discarded – undo
588 588
   protected function login_validate_input() {
589 589
     // Проверяем, что бы в начале и конце не было пустых символов
590 590
     // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию!
591
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
591
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
592 592
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
593 593
     }
594
-    if(!$this->input_login_password_raw) {
594
+    if (!$this->input_login_password_raw) {
595 595
       throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR);
596 596
     }
597 597
   }
@@ -606,37 +606,37 @@  discard block
 block discarded – undo
606 606
     $this->login_validate_input();
607 607
 
608 608
     // Если нет имени пользователя - NO GO!
609
-    if(!$this->input_login_unsafe) {
609
+    if (!$this->input_login_unsafe) {
610 610
       throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR);
611 611
     }
612 612
     // Если логин имеет запрещенные символы - NO GO!
613
-    if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
613
+    if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
614 614
       throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR);
615 615
     }
616 616
     // Если логин меньше минимальной длины - NO GO!
617
-    if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
617
+    if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
618 618
       throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR);
619 619
     }
620 620
     // Если пароль меньше минимальной длины - NO GO!
621
-    if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
621
+    if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
622 622
       throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR);
623 623
     }
624 624
     // Если пароль имеет пробельные символы в начале или конце - NO GO!
625
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
625
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
626 626
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
627 627
     }
628 628
     // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше
629 629
     //Если они есть у повтора - значит пароль и повтор не совпадут
630
-    if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
630
+    if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
631 631
       throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR);
632 632
     }
633 633
     // Если нет емейла - NO GO!
634 634
     // TODO - регистрация без емейла
635
-    if(!$this->input_email_unsafe) {
635
+    if (!$this->input_email_unsafe) {
636 636
       throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR);
637 637
     }
638 638
     // Если емейл не является емейлом - NO GO!
639
-    if(!is_email($this->input_email_unsafe)) {
639
+    if (!is_email($this->input_email_unsafe)) {
640 640
       throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR);
641 641
     }
642 642
   }
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     return core_auth::make_random_password();
668 668
   }
669 669
   protected function flog($message, $die = false) {
670
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
670
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
671 671
       return;
672 672
     }
673 673
     list($called, $caller) = debug_backtrace(false);
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
682 682
 
683 683
     classSupernova::log_file("$message - $caller_name");
684
-    if($die) {
684
+    if ($die) {
685 685
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
686 686
     }
687 687
   }
Please login to merge, or discard this patch.
classes/core_auth.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -829,10 +829,17 @@
 block discarded – undo
829 829
 
830 830
   // OK v4.5
831 831
   // TODO - REMEMBER_ME
832
+
833
+  /**
834
+   * @param integer $period
835
+   */
832 836
   protected static function cookie_set($value, $impersonate = false, $period = null) {
833 837
     sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE);
834 838
   }
835 839
 
840
+  /**
841
+   * @param string $message
842
+   */
836 843
   protected static function flog($message, $die = false) {
837 844
     if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
838 845
       return;
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
     // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ
206 206
     // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно
207 207
 
208
-    if(sys_get_param('login_player_register_logout')) {
208
+    if (sys_get_param('login_player_register_logout')) {
209 209
       $this->logout();
210 210
     }
211 211
 
212 212
     $original_suggest = '';
213 213
     // Смотрим - есть ли у нас данные от пользователя
214
-    if(($player_name_submitted = sys_get_param('submit_player_name'))) {
214
+    if (($player_name_submitted = sys_get_param('submit_player_name'))) {
215 215
       // Попытка регистрации нового игрока из данных, введенных пользователем
216 216
       $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name');
217 217
     } else {
218
-      foreach($this->providers_authorised as $provider) {
219
-        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
218
+      foreach ($this->providers_authorised as $provider) {
219
+        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
220 220
           $original_suggest = $provider->player_name_suggest();
221 221
           break;
222 222
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру
227
-    if(!$this->player_suggested_name) {
227
+    if (!$this->player_suggested_name) {
228 228
       $max_user_id = db_player_get_max_id(); // 4.5
229 229
       // TODO - предлагать имя игрока по локали
230 230
 
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
         sn_db_transaction_rollback();
234 234
         $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
235 235
         sn_db_transaction_start();
236
-      } while(db_player_name_exists($this->player_suggested_name));
236
+      } while (db_player_name_exists($this->player_suggested_name));
237 237
 
238 238
     }
239 239
 
240
-    if($player_name_submitted) {
240
+    if ($player_name_submitted) {
241 241
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
242
-      if($this->register_status == LOGIN_SUCCESS) {
242
+      if ($this->register_status == LOGIN_SUCCESS) {
243 243
         sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
244
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
244
+      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
245 245
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
246 246
       }
247 247
 //      if(self::$login_status != LOGIN_SUCCESS) {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         : false
266 266
       );
267 267
 
268
-    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
268
+    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
269 269
       $prohibited_characters = array_map(function($value) {
270 270
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
271 271
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
     global $sn_module_list, $lang;
298 298
 
299 299
     // !self::$is_init ? self::init() : false;
300
-    if(empty($sn_module_list['auth'])) {
300
+    if (empty($sn_module_list['auth'])) {
301 301
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
302 302
     }
303 303
 
304 304
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
305 305
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
306
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
306
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
307 307
 
308 308
     $this->auth_reset(); // OK v4.5
309 309
 
310 310
     $this->providers = array();
311
-    foreach($sn_module_list['auth'] as $module_name => $module) {
311
+    foreach ($sn_module_list['auth'] as $module_name => $module) {
312 312
       $this->providers[$module->provider_id] = $module;
313 313
     }
314 314
 
315 315
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
316 316
 //pdump($this->providers);
317
-    foreach($this->providers as $provider_id => $provider) {
317
+    foreach ($this->providers as $provider_id => $provider) {
318 318
       $login_status = $provider->login(); // OK v4.5
319 319
       self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
320
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
320
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
321 321
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
322 322
 
323 323
         $this->user_id_to_provider = array_replace_recursive(
@@ -325,20 +325,20 @@  discard block
 block discarded – undo
325 325
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
326 326
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
327 327
         );
328
-      } elseif($login_status != LOGIN_UNDEFINED) {
328
+      } elseif ($login_status != LOGIN_UNDEFINED) {
329 329
         $this->provider_error_list[$provider_id] = $login_status;
330 330
       }
331 331
     }
332 332
 
333
-    if(empty($this->providers_authorised)) {
333
+    if (empty($this->providers_authorised)) {
334 334
       // Ни один аккаунт не авторизирован
335 335
       // Проверяем - есть ли у нас ошибки в аккаунтах?
336
-      if(!empty($this->provider_error_list)) {
336
+      if (!empty($this->provider_error_list)) {
337 337
         // Если есть - выводим их
338 338
         self::$login_status = reset($this->provider_error_list);
339 339
         $providerError = $this->providers[key($this->provider_error_list)]->account_login_message;
340 340
 
341
-        if(!empty($providerError)) {
341
+        if (!empty($providerError)) {
342 342
           self::$login_message = $providerError;
343 343
         }
344 344
       }
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
354 354
 
355 355
       // Остались ли у нас в списке доступные игроки?
356
-      if(empty($this->accessible_user_row_list)) {
356
+      if (empty($this->accessible_user_row_list)) {
357 357
         // Нет ни одного игрока ни на одном авторизированном аккаунте
358 358
         // Надо регать нового игрока
359 359
 
360 360
         // Сейчас происходит процесс регистрации игрока?
361
-        if(!$this->is_player_register) {
361
+        if (!$this->is_player_register) {
362 362
           // Нет - отправляем на процесс регистрации
363 363
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
364 364
           sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         // Да, есть доступные игроки, которые так же прописаны в базе
368 368
         $this->get_active_user(); // 4.5
369 369
 
370
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
370
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
371 371
           $a_user = db_user_by_id($this->is_impersonating);
372 372
           $this->impersonator_username = $a_user['username'];
373 373
         }
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
 
376 376
         //Прописываем текущего игрока на все авторизированные аккаунты
377 377
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
378
-        if(empty($this->is_impersonating)) {
379
-          foreach($this->providers_authorised as $provider_id => $provider) {
380
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
378
+        if (empty($this->is_impersonating)) {
379
+          foreach ($this->providers_authorised as $provider_id => $provider) {
380
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
381 381
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
382 382
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
383 383
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
       }
388 388
     }
389 389
 
390
-    if(empty(self::$user['id'])) {
390
+    if (empty(self::$user['id'])) {
391 391
       self::cookie_set(''); // OK 4.5
392
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
392
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
393 393
       self::cookie_set(self::$user['id']); // OK 4.5
394 394
     }
395 395
 
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
    */
409 409
   // OK v4.7
410 410
   public function logout($redirect = true) {
411
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
411
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
412 412
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
413 413
       self::cookie_set(0, true);
414 414
       self::$main_provider->logout();
415 415
     } else {
416
-      foreach($this->providers as $provider_name => $provider) {
416
+      foreach ($this->providers as $provider_name => $provider) {
417 417
         $provider->logout();
418 418
       }
419 419
 
420 420
       self::cookie_set(0);
421 421
     }
422 422
 
423
-    if($redirect === true) {
423
+    if ($redirect === true) {
424 424
       sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
425
-    } elseif($redirect !== false) {
425
+    } elseif ($redirect !== false) {
426 426
       sys_redirect($redirect);
427 427
     }
428 428
   }
@@ -433,15 +433,15 @@  discard block
 block discarded – undo
433 433
    * @param $user_selected
434 434
    */
435 435
   public function impersonate($user_selected) {
436
-    if($_COOKIE[SN_COOKIE_U_I]) {
436
+    if ($_COOKIE[SN_COOKIE_U_I]) {
437 437
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
438 438
     }
439 439
 
440
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
440
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
441 441
       die('You can\'t impersonate - too low level'); // TODO: Log it
442 442
     }
443 443
 
444
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
444
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
445 445
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
446 446
     }
447 447
 
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
450 450
     $account_to_impersonate = new Account(self::$main_provider->db);
451 451
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
452
-    if(!$account_to_impersonate->is_exists) {
452
+    if (!$account_to_impersonate->is_exists) {
453 453
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
454 454
     }
455 455
     self::$main_provider->impersonate($account_to_impersonate);
@@ -475,12 +475,12 @@  discard block
 block discarded – undo
475 475
   public function password_check($password_unsafe) {
476 476
     $result = false;
477 477
 
478
-    if(empty($this->providers_authorised)) {
478
+    if (empty($this->providers_authorised)) {
479 479
       // TODO - такого быть не может!
480 480
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
481 481
     } else {
482
-      foreach($this->providers_authorised as $provider_id => $provider) {
483
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
482
+      foreach ($this->providers_authorised as $provider_id => $provider) {
483
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
484 484
           $result = $result || $provider->password_check($password_unsafe);
485 485
         }
486 486
       }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
   public function password_change($old_password_unsafe, $new_password_unsafe) {
502 502
     global $lang;
503 503
 
504
-    if(empty($this->providers_authorised)) {
504
+    if (empty($this->providers_authorised)) {
505 505
       // TODO - такого быть не может!
506 506
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
507 507
       return false;
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
     $salt_unsafe = self::password_salt_generate();
515 515
 
516 516
     $providers_changed_password = array();
517
-    foreach($this->providers_authorised as $provider_id => $provider) {
518
-      if(
517
+    foreach ($this->providers_authorised as $provider_id => $provider) {
518
+      if (
519 519
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
520 520
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
521 521
       ) {
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
528 528
 
529 529
       // Рассылаем уведомления о смене пароля в ЛС
530
-      foreach($account_translation as $user_id => $provider_info) {
530
+      foreach ($account_translation as $user_id => $provider_info) {
531 531
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
532 532
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
533 533
           $lang['sys_administration'], $lang['sys_login_register_message_title'],
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
       sn_db_transaction_start();
575 575
       // Проверить наличие такого имени в истории имён
576 576
 
577
-      if(db_player_name_exists($player_name_unsafe)) {
577
+      if (db_player_name_exists($player_name_unsafe)) {
578 578
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
579 579
       }
580 580
 
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
       $player_language = '';
583 583
       $player_email = '';
584 584
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
585
-      foreach($this->providers_authorised as $provider) {
586
-        if(!$player_language && $provider->account->account_language) {
585
+      foreach ($this->providers_authorised as $provider) {
586
+        if (!$player_language && $provider->account->account_language) {
587 587
           $player_language = $provider->account->account_language;
588 588
         }
589
-        if(!$player_email && $provider->account->account_email) {
589
+        if (!$player_email && $provider->account->account_email) {
590 590
           $player_email = $provider->account->account_email;
591 591
         }
592 592
       }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
       ));
603 603
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
604 604
       $a_user = self::$user;
605
-      foreach($this->providers_authorised as $provider) {
605
+      foreach ($this->providers_authorised as $provider) {
606 606
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
607 607
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
608 608
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 
615 615
       sn_db_transaction_commit();
616 616
       $this->register_status = LOGIN_SUCCESS;
617
-    } catch(Exception $e) {
617
+    } catch (Exception $e) {
618 618
       sn_db_transaction_rollback();
619 619
 
620 620
       // Если старое имя занято
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
634 634
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
635 635
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
636
-    foreach($this->user_id_to_provider as $user_id => $cork) {
636
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
637 637
       $user = db_user_by_id($user_id);
638 638
       // Если записи игрока в БД не существует?
639
-      if(empty($user['id'])) {
639
+      if (empty($user['id'])) {
640 640
         // Удаляем этого и переходим к следующему
641 641
         unset($this->user_id_to_provider[$user_id]);
642 642
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
   // OK v4.5
658 658
   protected function get_active_user() {
659 659
     // Проверяем куку "текущего игрока" из браузера
660
-    if(
660
+    if (
661 661
       // Кука не пустая
662 662
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
663 663
       // И в куке находится ID
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     }
683 683
 
684 684
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
685
-    if(empty(self::$user['id'])) {
685
+    if (empty(self::$user['id'])) {
686 686
       // Берем первого из доступных
687 687
       // TODO - default_user
688 688
       self::$user = reset($this->accessible_user_row_list);
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 
707 707
     $result = array();
708 708
 
709
-    if($user_id && empty($this->is_impersonating)) {
709
+    if ($user_id && empty($this->is_impersonating)) {
710 710
       // self::db_counter_insert();
711 711
       self::$device->db_counter_insert($user_id);
712 712
 
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
 
715 715
       sys_user_options_unpack($user);
716 716
 
717
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
717
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
718 718
         $user['banaday'] = 0;
719 719
         $user['vacation'] = SN_TIME_NOW;
720 720
       }
721 721
 
722
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
722
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
723 723
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
724 724
 
725 725
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
       );
734 734
     }
735 735
 
736
-    if($extra = $config->security_ban_extra) {
736
+    if ($extra = $config->security_ban_extra) {
737 737
       $extra = explode(',', $extra);
738
-      array_walk($extra,'trim');
738
+      array_walk($extra, 'trim');
739 739
       in_array(self::$device->device_id, $extra) and die();
740 740
     }
741 741
 
742
-    if(self::$login_message) {
742
+    if (self::$login_message) {
743 743
       $result[F_LOGIN_MESSAGE] = self::$login_message;
744 744
     }
745 745
 
@@ -775,21 +775,21 @@  discard block
 block discarded – undo
775 775
   protected function register_player_name_validate($player_name_unsafe) {
776 776
     // TODO - переделать под RAW-строки
777 777
     // Если имя игрока пустое - NO GO!
778
-    if(trim($player_name_unsafe) == '') {
778
+    if (trim($player_name_unsafe) == '') {
779 779
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
780 780
     }
781 781
     // Проверяем, что бы в начале и конце не было пустых символов
782
-    if($player_name_unsafe != trim($player_name_unsafe)) {
782
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
783 783
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
784 784
     }
785 785
     // Если логин имеет запрещенные символы - NO GO!
786
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
786
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
787 787
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
788 788
       // TODO - заранее извещать игрока, какие символы являются запрещенными
789 789
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
790 790
     }
791 791
     // Если логин меньше минимальной длины - NO GO!
792
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
792
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
793 793
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
794 794
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
795 795
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
   }
848 848
 
849 849
   protected static function flog($message, $die = false) {
850
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
850
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
851 851
       return;
852 852
     }
853 853
     list($called, $caller) = debug_backtrace(false);
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
861 861
 
862 862
     classSupernova::log_file("$message - $caller_name");
863
-    if($die) {
863
+    if ($die) {
864 864
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
865 865
     }
866 866
   }
Please login to merge, or discard this patch.
classes/db_mysql.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -180,6 +180,9 @@  discard block
 block discarded – undo
180 180
   }
181 181
 
182 182
 
183
+  /**
184
+   * @param string $query
185
+   */
183 186
   function security_watch_user_queries($query) {
184 187
     // TODO Заменить это на новый логгер
185 188
     global $config, $is_watching, $user, $debug;
@@ -202,6 +205,9 @@  discard block
 block discarded – undo
202 205
   }
203 206
 
204 207
 
208
+  /**
209
+   * @param string $query
210
+   */
205 211
   function security_query_check_bad_words($query) {
206 212
     global $user, $dm_change_legit, $mm_change_legit;
207 213
 
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
   }
65 65
 
66 66
   public function schema() {
67
-    if(!isset(self::$schema)) {
67
+    if (!isset(self::$schema)) {
68 68
       self::$schema = new \DBAL\Schema($this);
69 69
     }
70 70
 
@@ -82,23 +82,23 @@  discard block
 block discarded – undo
82 82
   function sn_db_connect($external_db_settings = null) {
83 83
     $this->db_disconnect();
84 84
 
85
-    if(!empty($external_db_settings) && is_array($external_db_settings)) {
85
+    if (!empty($external_db_settings) && is_array($external_db_settings)) {
86 86
       $this->dbsettings = $external_db_settings;
87 87
     }
88 88
 
89
-    if(empty($this->dbsettings)) {
89
+    if (empty($this->dbsettings)) {
90 90
       $this->load_db_settings();
91 91
     }
92 92
 
93 93
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
94
-    if(!empty($this->dbsettings)) {
94
+    if (!empty($this->dbsettings)) {
95 95
       $driver_name = empty($this->dbsettings['sn_driver']) ? 'db_mysql_v5' : $this->dbsettings['sn_driver'];
96 96
       $this->driver = new $driver_name();
97 97
       $this->db_prefix = $this->dbsettings['prefix'];
98 98
 
99 99
       $this->connected = $this->connected || $this->driver_connect();
100 100
 
101
-      if($this->connected && empty($this->schema()->getSnTables())) {
101
+      if ($this->connected && empty($this->schema()->getSnTables())) {
102 102
         die('DB error - cannot find any table. Halting...');
103 103
       }
104 104
     } else {
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
   function driver_connect() {
112 112
     global $debug;
113 113
 
114
-    if(!is_object($this->driver)) {
114
+    if (!is_object($this->driver)) {
115 115
       $debug->error_fatal('DB Error - No driver for MySQL found!');
116 116
     }
117 117
 
118
-    if(!method_exists($this->driver, 'mysql_connect')) {
118
+    if (!method_exists($this->driver, 'mysql_connect')) {
119 119
       $debug->error_fatal('DB Error - WRONG MySQL driver!');
120 120
     }
121 121
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
   }
124 124
 
125 125
   function db_disconnect() {
126
-    if($this->connected) {
126
+    if ($this->connected) {
127 127
       $this->connected = !$this->driver_disconnect();
128 128
       $this->connected = false;
129 129
     }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
       return false;
147 147
     }
148 148
 
149
-    if(!$alreadyHandled) {
149
+    if (!$alreadyHandled) {
150 150
       print(SN_TIME_SQL . '<br />Server is busy. Please try again in several minutes...<br />Сервер занят. Попробуйте снова через несколько минут...<br />Server zanyat. Poprobujte snova cherez neskolko minut...');
151 151
       $alreadyHandled = true;
152 152
     }
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
   function doquery($query, $table = '', $fetch = false, $skip_query_check = false) {
158 158
     global $numqueries, $debug, $config;
159 159
 
160
-    if(!is_string($table)) {
160
+    if (!is_string($table)) {
161 161
       $fetch = $table;
162 162
     }
163 163
 
164
-    if(!$this->connected) {
164
+    if (!$this->connected) {
165 165
       $this->sn_db_connect();
166 166
     }
167 167
 
@@ -170,30 +170,30 @@  discard block
 block discarded – undo
170 170
     $skip_query_check or $this->security_query_check_bad_words($query);
171 171
 
172 172
     $sql = $query;
173
-    if(strpos($sql, '{{') !== false) {
174
-      foreach($this->schema()->getSnTables() as $tableName) {
173
+    if (strpos($sql, '{{') !== false) {
174
+      foreach ($this->schema()->getSnTables() as $tableName) {
175 175
         $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
176 176
       }
177 177
     }
178 178
 
179
-    if($config->debug) {
179
+    if ($config->debug) {
180 180
       $numqueries++;
181 181
       $arr = debug_backtrace();
182
-      $file = end(explode('/',$arr[0]['file']));
182
+      $file = end(explode('/', $arr[0]['file']));
183 183
       $line = $arr[0]['line'];
184 184
       $debug->add("<tr><th>Query $numqueries: </th><th>$query</th><th>$file($line)</th><th>$table</th><th>$fetch</th></tr>");
185 185
     }
186 186
 
187
-    if(defined('DEBUG_SQL_COMMENT')) {
187
+    if (defined('DEBUG_SQL_COMMENT')) {
188 188
       $backtrace = debug_backtrace();
189 189
       $sql_comment = $debug->compact_backtrace($backtrace, defined('DEBUG_SQL_COMMENT_LONG'));
190 190
 
191 191
       $sql_commented = '/* ' . implode("<br />", $sql_comment) . '<br /> */ ' . preg_replace("/\s+/", ' ', $sql);
192
-      if(defined('DEBUG_SQL_ONLINE')) {
192
+      if (defined('DEBUG_SQL_ONLINE')) {
193 193
         $debug->warning($sql_commented, 'SQL Debug', LOG_DEBUG_SQL);
194 194
       }
195 195
 
196
-      if(defined('DEBUG_SQL_ERROR')) {
196
+      if (defined('DEBUG_SQL_ERROR')) {
197 197
         array_unshift($sql_comment, preg_replace("/\s+/", ' ', $sql));
198 198
         $debug->add_to_array($sql_comment);
199 199
         // $debug->add_to_array($sql_comment . preg_replace("/\s+/", ' ', $sql));
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     }
203 203
 
204 204
     set_error_handler([$this, 'handlerQueryWarning']);
205
-    $sqlquery = $this->db_sql_query($sql) or $debug->error(db_error()."<br />$sql<br />",'SQL Error');
205
+    $sqlquery = $this->db_sql_query($sql) or $debug->error(db_error() . "<br />$sql<br />", 'SQL Error');
206 206
     restore_error_handler();
207 207
 
208 208
     return $fetch ? $this->db_fetch($sqlquery) : $sqlquery;
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
     // TODO Заменить это на новый логгер
223 223
     global $config, $is_watching, $user, $debug;
224 224
 
225
-    if(!$is_watching && $config->game_watchlist_array && in_array($user['id'], $config->game_watchlist_array))
225
+    if (!$is_watching && $config->game_watchlist_array && in_array($user['id'], $config->game_watchlist_array))
226 226
     {
227
-      if(!preg_match('/^(select|commit|rollback|start transaction)/i', $query)) {
227
+      if (!preg_match('/^(select|commit|rollback|start transaction)/i', $query)) {
228 228
         $is_watching = true;
229 229
         $msg = "\$query = \"{$query}\"\n\r";
230
-        if(!empty($_POST)) {
231
-          $msg .= "\n\r" . dump($_POST,'$_POST');
230
+        if (!empty($_POST)) {
231
+          $msg .= "\n\r" . dump($_POST, '$_POST');
232 232
         }
233
-        if(!empty($_GET)) {
234
-          $msg .= "\n\r" . dump($_GET,'$_GET');
233
+        if (!empty($_GET)) {
234
+          $msg .= "\n\r" . dump($_GET, '$_GET');
235 235
         }
236 236
         $debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
237 237
         $is_watching = false;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
   function security_query_check_bad_words($query) {
244 244
     global $user, $dm_change_legit, $mm_change_legit;
245 245
 
246
-    switch(true) {
246
+    switch (true) {
247 247
       case stripos($query, 'RUNCATE TABL') != false:
248 248
       case stripos($query, 'ROP TABL') != false:
249 249
       case stripos($query, 'ENAME TABL') != false:
@@ -254,33 +254,33 @@  discard block
 block discarded – undo
254 254
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
255 255
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
256 256
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
257
-        $report  = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
257
+        $report  = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
258 258
         $report .= ">Database Inforamation\n";
259
-        $report .= "\tID - ".$user['id']."\n";
260
-        $report .= "\tUser - ".$user['username']."\n";
261
-        $report .= "\tAuth level - ".$user['authlevel']."\n";
262
-        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
263
-        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
264
-        $report .= "\tUser IP - ".$user['user_lastip']."\n";
265
-        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
266
-        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
267
-        $report .= "\tCurrent Page - ".$user['current_page']."\n";
268
-        $report .= "\tRegister Time - ".$user['register_time']."\n";
259
+        $report .= "\tID - " . $user['id'] . "\n";
260
+        $report .= "\tUser - " . $user['username'] . "\n";
261
+        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
262
+        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
263
+        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
264
+        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
265
+        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
266
+        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
267
+        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
268
+        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
269 269
         $report .= "\n";
270 270
 
271 271
         $report .= ">Query Information\n";
272
-        $report .= "\tQuery - ".$query."\n";
272
+        $report .= "\tQuery - " . $query . "\n";
273 273
         $report .= "\n";
274 274
 
275 275
         $report .= ">\$_SERVER Information\n";
276
-        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
277
-        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
278
-        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
279
-        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
280
-        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
281
-        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
282
-        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
283
-        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
276
+        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
277
+        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
278
+        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
279
+        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
280
+        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
281
+        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
282
+        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
283
+        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
284 284
 
285 285
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
286 286
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
     $prefixedTableName_safe = $this->db_escape($this->db_prefix . $tableName_unsafe);
313 313
     $q1 = $this->db_sql_query("SHOW FULL COLUMNS FROM `{$prefixedTableName_safe}`;");
314
-    while($r1 = db_fetch($q1)) {
314
+    while ($r1 = db_fetch($q1)) {
315 315
       $result[$r1['Field']] = $r1;
316 316
     }
317 317
     return $result;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
     $prefixedTableName_safe = $this->db_escape($this->db_prefix . $tableName_unsafe);
329 329
     $q1 = $this->db_sql_query("SHOW INDEX FROM {$prefixedTableName_safe};");
330
-    while($r1 = db_fetch($q1)) {
330
+    while ($r1 = db_fetch($q1)) {
331 331
       $indexName = $r1['Key_name'];
332 332
 
333 333
       $result[$indexName]['name'] = $r1['Key_name'];
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 
353 353
     $prefixedTableName_safe = $this->db_escape($this->db_prefix . $tableName_unsafe);
354 354
 
355
-    $q1 = $this->db_sql_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name). "' AND `TABLE_NAME` = '{$prefixedTableName_safe}' AND `REFERENCED_TABLE_NAME` IS NOT NULL;");
356
-    while($r1 = db_fetch($q1)) {
355
+    $q1 = $this->db_sql_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND `TABLE_NAME` = '{$prefixedTableName_safe}' AND `REFERENCED_TABLE_NAME` IS NOT NULL;");
356
+    while ($r1 = db_fetch($q1)) {
357 357
       $indexName = $r1['CONSTRAINT_NAME'];
358 358
 
359 359
       $table_referenced = str_replace($this->db_prefix, '', $r1['REFERENCED_TABLE_NAME']);
Please login to merge, or discard this patch.