Completed
Push — work-fleets ( 9cd586...f0ff6c )
by SuperNova.WS
04:56
created

db_mysql::logQuery()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
eloc 8
nc 2
nop 2
1
<?php
2
3
/**
4
 * User: Gorlum
5
 * Date: 01.09.2015
6
 * Time: 15:58
7
 */
8
class db_mysql {
9
  const DB_MYSQL_TRANSACTION_SERIALIZABLE = 'SERIALIZABLE';
10
  const DB_MYSQL_TRANSACTION_REPEATABLE_READ = 'REPEATABLE READ';
11
  const DB_MYSQL_TRANSACTION_READ_COMMITTED = 'READ COMMITTED';
12
  const DB_MYSQL_TRANSACTION_READ_UNCOMMITTED = 'READ UNCOMMITTED';
13
14
  /**
15
   * Статус соеднения с MySQL
16
   *
17
   * @var bool
18
   */
19
  public $connected = false;
20
  /**
21
   * Префикс названий таблиц в БД
22
   *
23
   * @var string
24
   */
25
  public $db_prefix = '';
26
  /**
27
   * Список таблиц в БД
28
   *
29
   * @var array
30
   */
31
  public $table_list = array();
32
33
  /**
34
   * Настройки БД
35
   *
36
   * @var array
37
   */
38
  protected $dbsettings = array();
39
  /**
40
   * Драйвер для прямого обращения к MySQL
41
   *
42
   * @var db_mysql_v5 $driver
43
   */
44
  public $driver = null;
45
46
  /**
47
   * Общее время запросов
48
   *
49
   * @var float $time_mysql_total
50
   */
51
  public $time_mysql_total = 0.0;
52
53
  /**
54
   * Amount of queries on this DB
55
   *
56
   * @var int
57
   */
58
  public $numqueries = 0;
59
60
  protected $isWatching = false;
61
62
  public function __construct() {
63
  }
64
65
  function load_db_settings() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
66
    $dbsettings = array();
67
68
    require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX);
69
70
    $this->dbsettings = $dbsettings;
71
  }
72
73
  function sn_db_connect($external_db_settings = null) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
74
    $this->db_disconnect();
75
76
    if(!empty($external_db_settings) && is_array($external_db_settings)) {
77
      $this->dbsettings = $external_db_settings;
78
    }
79
80
    if(empty($this->dbsettings)) {
81
      $this->load_db_settings();
82
    }
83
84
    // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
85
    if(!empty($this->dbsettings)) {
86
      $driver_name = empty($this->dbsettings['sn_driver']) ? 'db_mysql_v5' : $this->dbsettings['sn_driver'];
87
      $this->driver = new $driver_name();
88
      $this->db_prefix = $this->dbsettings['prefix'];
89
90
      $this->connected = $this->connected || $this->driver_connect();
91
92
      if($this->connected) {
93
        $this->table_list = $this->db_get_table_list();
94
        // TODO Проверка на пустоту
95
      }
96
    } else {
97
      $this->connected = false;
98
    }
99
100
    return $this->connected;
101
  }
102
103
  function driver_connect() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
104
    global $debug;
105
106
    if(!is_object($this->driver)) {
107
      $debug->error_fatal('DB Error - No driver for MySQL found!');
108
    }
109
110
    if(!method_exists($this->driver, 'mysql_connect')) {
111
      $debug->error_fatal('DB Error - WRONG MySQL driver!');
112
    }
113
114
    return $this->driver->mysql_connect($this->dbsettings);
115
  }
116
117
  function db_disconnect() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
118
    if($this->connected) {
119
      $this->connected = !$this->driver_disconnect();
120
      $this->connected = false;
121
    }
122
123
    return !$this->connected;
124
  }
125
126
  /**
127
   * @param $query
128
   *
129
   * @return mixed
130
   */
131
  public function replaceTablePlaceholders($query) {
132
    $sql = $query;
133
    if(strpos($sql, '{{') !== false) {
134
      foreach($this->table_list as $tableName) {
135
        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
136
      }
137
    }
138
139
    return $sql;
140
  }
141
142
  /**
143
   * @param       $query
144
   * @param       $fetch
145
   */
146
  public function logQuery($query, $fetch) {
147
    if(!classSupernova::$config->debug) {
148
      return;
149
    }
150
151
    $this->numqueries++;
152
    $arr = debug_backtrace();
153
    $file = end(explode('/', $arr[0]['file']));
0 ignored issues
show
Bug introduced by
explode('/', $arr[0]['file']) cannot be passed to end() as the parameter $array expects a reference.
Loading history...
154
    $line = $arr[0]['line'];
155
    classSupernova::$debug->add("<tr><th>Query {$this->numqueries}: </th><th>$query</th><th>{$file} @ {$line}</th><th>&nbsp;</th><th> " . ($fetch ? '+' : '&nbsp;') . " </th></tr>");
156
  }
157
158
159
  /**
160
   * @param $sql
161
   *
162
   * @return void
163
   */
164
  public function commentQuery(&$sql) {
165
    if(!defined('DEBUG_SQL_COMMENT')) {
166
      return;
167
    }
168
    $backtrace = debug_backtrace();
169
    $sql_comment = classSupernova::$debug->compact_backtrace($backtrace, defined('DEBUG_SQL_COMMENT_LONG'));
170
171
    $sql_commented = '/* ' . implode("<br />", $sql_comment) . '<br /> */ ' . preg_replace("/\s+/", ' ', $sql);
172
    if(defined('DEBUG_SQL_ONLINE')) {
173
      classSupernova::$debug->warning($sql_commented, 'SQL Debug', LOG_DEBUG_SQL);
174
    }
175
176
    if(defined('DEBUG_SQL_ERROR')) {
177
      array_unshift($sql_comment, preg_replace("/\s+/", ' ', $sql));
178
      classSupernova::$debug->add_to_array($sql_comment);
179
    }
180
181
    $sql = $sql_commented;
182
  }
183
184
  public function doquery($query, $table = '', $fetch = false, $skip_query_check = false) {
185
    if(!is_string($table)) {
186
      $fetch = $table;
187
    }
188
189
    if(!$this->connected) {
190
      $this->sn_db_connect();
191
    }
192
193
    $query = trim($query);
194
    $this->security_watch_user_queries($query);
195
    !$skip_query_check ? $this->security_query_check_bad_words($query) : false;
196
    $this->logQuery($query, $fetch);
197
198
    $sql = $this->replaceTablePlaceholders($query);
199
    $this->commentQuery($sql);
200
    !($sqlquery = $this->db_sql_query($sql)) ? classSupernova::$debug->error(db_error() . "<br />$sql<br />", 'SQL Error') : false;
201
202
    return $fetch ? $this->db_fetch($sqlquery) : $sqlquery;
203
  }
204
205
206
  // TODO Заменить это на новый логгер
207
  function security_watch_user_queries($query) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
208
    global $user;
209
210
    if(
211
      !$this->isWatching // Not already watching
212
      && !empty(classSupernova::$config->game_watchlist_array) // There is some players in watchlist
213
      && in_array($user['id'], classSupernova::$config->game_watchlist_array) // Current player is in watchlist
214
      && !preg_match('/^(select|commit|rollback|start transaction)/i', $query) // Current query should be watched
215
    ) {
216
      $this->isWatching = true;
217
      $msg = "\$query = \"{$query}\"\n\r";
218
      if(!empty($_POST)) {
219
        $msg .= "\n\r" . dump($_POST, '$_POST');
220
      }
221
      if(!empty($_GET)) {
222
        $msg .= "\n\r" . dump($_GET, '$_GET');
223
      }
224
      classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
0 ignored issues
show
Documentation introduced by
array('base_dump' => true) is of type array<string,boolean,{"base_dump":"boolean"}>, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
225
      $this->isWatching = false;
226
    }
227
  }
228
229
230
  function security_query_check_bad_words($query) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
231
    global $user, $dm_change_legit, $mm_change_legit;
232
233
    switch(true) {
234
      case stripos($query, 'RUNCATE TABL') != false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'RUNCATE TABL') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
235
      case stripos($query, 'ROP TABL') != false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'ROP TABL') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
236
      case stripos($query, 'ENAME TABL') != false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'ENAME TABL') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
237
      case stripos($query, 'REATE DATABAS') != false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'REATE DATABAS') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
238
      case stripos($query, 'REATE TABL') != false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'REATE TABL') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
239
      case stripos($query, 'ET PASSWOR') != false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'ET PASSWOR') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
240
      case stripos($query, 'EOAD DAT') != false:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'EOAD DAT') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
241
      case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'RPG_POINTS') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
242
      case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'METAMATTER') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
243
      case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stripos($query, 'AUTHLEVEL') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
244
        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
245
        $report .= ">Database Inforamation\n";
246
        $report .= "\tID - " . $user['id'] . "\n";
247
        $report .= "\tUser - " . $user['username'] . "\n";
248
        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
249
        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
250
        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
251
        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
252
        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
253
        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
254
        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
255
        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
256
        $report .= "\n";
257
258
        $report .= ">Query Information\n";
259
        $report .= "\tQuery - " . $query . "\n";
260
        $report .= "\n";
261
262
        $report .= ">\$_SERVER Information\n";
263
        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
264
        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
265
        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
266
        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
267
        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
268
        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
269
        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
270
        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
271
272
        $report .= "\n--------------------------------------------------------------------------------------------------\n";
273
274
        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
275
        fwrite($fp, $report);
0 ignored issues
show
Security File Manipulation introduced by
$report can contain request data and is used in file manipulation context(s) leading to a potential security vulnerability.

General Strategies to prevent injection

In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:

if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
    throw new \InvalidArgumentException('This input is not allowed.');
}

For numeric data, we recommend to explicitly cast the data:

$sanitized = (integer) $tainted;
Loading history...
276
        fclose($fp);
277
278
        $message = 'Привет, я не знаю то, что Вы пробовали сделать, но команда, которую Вы только послали базе данных, не выглядела очень дружественной и она была заблокированна.<br /><br />Ваш IP, и другие данные переданны администрации сервера. Удачи!.';
279
        die($message);
280
      break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
281
    }
282
  }
283
284
  /**
285
   * @param bool $prefixed_only
286
   *
287
   * @return array
288
   */
289
  function db_get_table_list($prefixed_only = true) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
290
    $query = $this->mysql_get_table_list();
291
292
    $prefix_length = strlen($this->db_prefix);
293
294
    $tl = array();
295
    while($row = $this->db_fetch($query)) {
296
      foreach($row as $table_name) {
297
        if(strpos($table_name, $this->db_prefix) === 0) {
298
          $table_name = substr($table_name, $prefix_length);
299
        } elseif($prefixed_only) {
300
          continue;
301
        }
302
        // $table_name = str_replace($db_prefix, '', $table_name);
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
303
        $tl[$table_name] = $table_name;
304
      }
305
    }
306
307
    return $tl;
308
  }
309
310
  function mysql_get_table_list() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
311
    return $this->db_sql_query('SHOW TABLES;');
312
  }
313
314
  function mysql_get_innodb_status() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
315
    return $this->db_sql_query('SHOW ENGINE INNODB STATUS;');
316
  }
317
318
319
  /**
320
   * L1 perform the query
321
   *
322
   * @param $query_string
323
   *
324
   * @return bool|mysqli_result
325
   */
326 View Code Duplication
  function db_sql_query($query_string) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
327
    $microtime = microtime(true);
328
    $result = $this->driver->mysql_query($query_string);
329
    $this->time_mysql_total += microtime(true) - $microtime;
330
331
    return $result;
332
  }
333
334
  /**
335
   * L1 fetch assoc array
336
   *
337
   * @param $query
338
   *
339
   * @return array|null
340
   */
341 View Code Duplication
  function db_fetch(&$query) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
342
    $microtime = microtime(true);
343
    $result = $this->driver->mysql_fetch_assoc($query);
344
    $this->time_mysql_total += microtime(true) - $microtime;
345
346
    return $result;
347
  }
348
349
  function db_fetch_row(&$query) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
350
    return $this->driver->mysql_fetch_row($query);
351
  }
352
353
  function db_escape($unescaped_string) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
354
    return $this->driver->mysql_real_escape_string($unescaped_string);
355
  }
356
357
  function driver_disconnect() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
358
    return $this->driver->mysql_close_link();
359
  }
360
361
  function db_error() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
362
    return $this->driver->mysql_error();
363
  }
364
365
  function db_insert_id() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
366
    return $this->driver->mysql_insert_id();
367
  }
368
369
  function db_num_rows(&$result) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
370
    return $this->driver->mysql_num_rows($result);
371
  }
372
373
  function db_affected_rows() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
374
    return $this->driver->mysql_affected_rows();
375
  }
376
377
  /**
378
   * @return string
379
   */
380
  function db_get_client_info() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
381
    return $this->driver->mysql_get_client_info();
382
  }
383
384
  /**
385
   * @return string
386
   */
387
  function db_get_server_info() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
388
    return $this->driver->mysql_get_server_info();
389
  }
390
391
  /**
392
   * @return string
393
   */
394
  function db_get_host_info() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
395
    return $this->driver->mysql_get_host_info();
396
  }
397
398
  function db_get_server_stat() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
399
    $result = array();
400
401
    $status = explode('  ', $this->driver->mysql_stat());
402
    foreach($status as $value) {
403
      $row = explode(': ', $value);
404
      $result[$row[0]] = $row[1];
405
    }
406
407
    return $result;
408
  }
409
410
  function db_core_show_status() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
411
    $result = array();
412
413
    $query = doquery('SHOW STATUS;');
414
    while($row = db_fetch($query)) {
415
      $result[$row['Variable_name']] = $row['Value'];
416
    }
417
418
    return $result;
419
  }
420
421
}
422