Issues (1369)

admin/adm_log_main.php (8 issues)

1
<?php
2
3
/**
4
 * admin/adm_log_main.php
5
 *
6
 * @version 2.0 - full rewrote
7
 * @copyright 2014 by Gorlum for http://supernova.ws
8
 *
9
 */
10
11
define('INSIDE', true);
12
define('INSTALL', false);
13
define('IN_ADMIN', true);
14
15
require('../common.' . substr(strrchr(__FILE__, '.'), 1));
16
17
global $lang, $user;
18
19
SnTemplate::messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR);
20
21
if($delete = sys_get_param_id('delete'))
22
{
23
  doquery("DELETE FROM `{{logs}}` WHERE `log_id` = {$delete} LIMIT 1;");
0 ignored issues
show
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

23
  /** @scrutinizer ignore-deprecated */ doquery("DELETE FROM `{{logs}}` WHERE `log_id` = {$delete} LIMIT 1;");
Loading history...
24
}
25
elseif(sys_get_param_str('delete_update_info'))
26
{
27
  doquery("DELETE FROM `{{logs}}` WHERE `log_code` in (103, 180, 191);");
0 ignored issues
show
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

27
  /** @scrutinizer ignore-deprecated */ doquery("DELETE FROM `{{logs}}` WHERE `log_code` in (103, 180, 191);");
Loading history...
28
}
29
elseif(sys_get_param_str('deleteall') == 'yes')
30
{
31
//  doquery("TRUNCATE TABLE `{{logs}}`");
32
}
33
34
/**
35
 * @param $value
36
 *
37
 * @return string|null
38
 */
39
function admLogRender($value) {
40
  if (is_array($value)) {
41
    $result = '<table class="no_border_image var_in">';
42
    foreach ($value as $key => $val) {
43
      $result .= '<tr><td>' . $key . '</td><td>' . var_export($val, true) . '</td></tr>';
44
    }
45
    $result .= '</table>';
46
  } else {
47
    $result = var_export($value, true);
48
  }
49
50
  return $result;
51
}
52
53
if($detail = sys_get_param_id('detail'))
54
{
55
  $template = SnTemplate::gettemplate('admin/adm_log_main_detail', true);
0 ignored issues
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
  $template = SnTemplate::gettemplate('admin/adm_log_main_detail', /** @scrutinizer ignore-type */ true);
Loading history...
56
57
  $errorInfo = doquery("SELECT * FROM `{{logs}}` WHERE `log_id` = {$detail} LIMIT 1;", true);
0 ignored issues
show
true of type true is incompatible with the type string expected by parameter $table of doquery(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

57
  $errorInfo = doquery("SELECT * FROM `{{logs}}` WHERE `log_id` = {$detail} LIMIT 1;", /** @scrutinizer ignore-type */ true);
Loading history...
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

57
  $errorInfo = /** @scrutinizer ignore-deprecated */ doquery("SELECT * FROM `{{logs}}` WHERE `log_id` = {$detail} LIMIT 1;", true);
Loading history...
58
  $error_dump = json_decode($errorInfo['log_dump'], true);
59
  if(is_array($error_dump))
60
  {
61
    foreach ($error_dump as $key => $value)
62
    {
63
      // Parsing user options to readable state
64
      if($key == 'user' ) {
65
        if(!empty($value['options'])) {
66
          $value['options'] = explode(USER_OPTIONS_SPLIT, $value['options']);
67
        }
68
      }
69
70
      $val = $key == 'query_log' ? $value : admLogRender($value);
71
72
      $template->assign_block_vars('vars', [
73
        'VAR_NAME' => $key,
74
        'VAR_VALUE' => $val,
75
      ]);
76
    }
77
  }
78
79
  // Replacing LF with HTML <br /> tag for better readability
80
  $errorInfo['log_text'] = str_replace("\n", '<br />', $errorInfo['log_text']);
81
82
  $template->assign_vars($errorInfo);
83
}
84
else
85
{
86
  $template = SnTemplate::gettemplate('admin/adm_log_main', true);
87
88
  $i = 0;
89
  $query = doquery("SELECT * FROM `{{logs}}` ORDER BY log_id DESC LIMIT 100;");
0 ignored issues
show
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

89
  $query = /** @scrutinizer ignore-deprecated */ doquery("SELECT * FROM `{{logs}}` ORDER BY log_id DESC LIMIT 100;");
Loading history...
90
  while($u = db_fetch($query))
0 ignored issues
show
Deprecated Code introduced by
The function db_fetch() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

90
  while($u = /** @scrutinizer ignore-deprecated */ db_fetch($query))
Loading history...
91
  {
92
    $i++;
93
    $v = [];
94
    $u['log_text'] = str_replace("\n", "<br />", $u['log_text']);
95
    foreach($u as $key => $value)
96
    {
97
      $v[strtoupper($key)] = $value;
98
    }
99
    $template->assign_block_vars('error', $v);
100
  }
101
  $query = doquery("SELECT COUNT(*) AS LOG_MESSAGES_TOTAL, {$i} AS LOG_MESSAGES_VISIBLE FROM `{{logs}}`;", true);
0 ignored issues
show
Deprecated Code introduced by
The function doquery() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

101
  $query = /** @scrutinizer ignore-deprecated */ doquery("SELECT COUNT(*) AS LOG_MESSAGES_TOTAL, {$i} AS LOG_MESSAGES_VISIBLE FROM `{{logs}}`;", true);
Loading history...
102
103
  $template->assign_vars($query);
104
}
105
106
SnTemplate::display($template, $lang['adm_er_ttle']);
107