|
17 | 17 |
|
18 | 18 | use phpMyFAQ\Administration\AdminLog; |
19 | 19 | use phpMyFAQ\Component\Alert; |
| 20 | +use phpMyFAQ\Configuration; |
20 | 21 | use phpMyFAQ\Date; |
21 | 22 | use phpMyFAQ\Enums\PermissionType; |
22 | 23 | use phpMyFAQ\Filter; |
23 | 24 | use phpMyFAQ\Pagination; |
24 | 25 | use phpMyFAQ\Session\Token; |
25 | 26 | use phpMyFAQ\Strings; |
26 | 27 | use phpMyFAQ\Translation; |
| 28 | +use phpMyFAQ\User\CurrentUser; |
27 | 29 |
|
28 | 30 | if (!defined('IS_VALID_PHPMYFAQ')) { |
29 | 31 | http_response_code(400); |
30 | 32 | exit(); |
31 | 33 | } |
32 | 34 |
|
| 35 | +$faqConfig = Configuration::getConfigurationInstance(); |
| 36 | +$user = CurrentUser::getCurrentUser($faqConfig); |
| 37 | + |
33 | 38 | $logging = new AdminLog($faqConfig); |
34 | 39 | $csrfToken = Filter::filterInput(INPUT_GET, 'csrf', FILTER_SANITIZE_SPECIAL_CHARS); |
35 | 40 |
|
|
44 | 49 | 'adminlog' === $action |
45 | 50 | ) { |
46 | 51 | $date = new Date($faqConfig); |
47 | | - $perpage = 15; |
| 52 | + $perPage = 15; |
48 | 53 | $pages = Filter::filterInput(INPUT_GET, 'pages', FILTER_VALIDATE_INT); |
49 | 54 | $page = Filter::filterInput(INPUT_GET, 'page', FILTER_VALIDATE_INT, 1); |
50 | 55 |
|
51 | 56 | if (is_null($pages)) { |
52 | | - $pages = round(($logging->getNumberOfEntries() + ($perpage / 3)) / $perpage, 0); |
| 57 | + $pages = round(($logging->getNumberOfEntries() + ($perPage / 3)) / $perPage, 0); |
53 | 58 | } |
54 | 59 |
|
55 | | - $start = ($page - 1) * $perpage; |
56 | | - $lastPage = $start + $perpage; |
| 60 | + $start = ($page - 1) * $perPage; |
| 61 | + $lastPage = $start + $perPage; |
57 | 62 |
|
58 | 63 | $baseUrl = sprintf( |
59 | 64 | '%sadmin/?action=adminlog&page=%d', |
|
65 | 70 | $options = [ |
66 | 71 | 'baseUrl' => $baseUrl, |
67 | 72 | 'total' => $logging->getNumberOfEntries(), |
68 | | - 'perPage' => $perpage, |
| 73 | + 'perPage' => $perPage, |
69 | 74 | 'pageParamName' => 'page', |
70 | 75 | ]; |
71 | 76 | $pagination = new Pagination($options); |
72 | 77 |
|
73 | 78 | $loggingData = $logging->getAll(); |
74 | 79 | ?> |
75 | 80 |
|
76 | | - <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> |
| 81 | + <div |
| 82 | + class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> |
77 | 83 | <h1 class="h2"> |
78 | 84 | <i aria-hidden="true" class="bi bi-list-ol"></i> <?= Translation::get('ad_menu_adminlog') ?> |
79 | 85 | </h1> |
|
105 | 111 | <?php |
106 | 112 | $counter = $displayedCounter = 0; |
107 | 113 |
|
108 | | - foreach ($loggingData as $loggingId => $loggingValue) { |
109 | | - if ($displayedCounter >= $perpage) { |
| 114 | + foreach ($loggingData as $value) { |
| 115 | + if ($displayedCounter >= $perPage) { |
110 | 116 | ++$displayedCounter; |
111 | 117 | continue; |
112 | 118 | } |
|
117 | 123 | } |
118 | 124 | ++$displayedCounter; |
119 | 125 |
|
120 | | - $user->getUserById($loggingValue['usr'], true); |
| 126 | + $user->getUserById($value->getUserId(), true); |
121 | 127 | ?> |
122 | 128 | <tr> |
123 | | - <td><?= $loggingId ?></td> |
124 | | - <td><?= $date->format(date('Y-m-d H:i', $loggingValue['time'])) ?></td> |
| 129 | + <td><?= $value->getId() ?></td> |
| 130 | + <td><?= $date->format(date('Y-m-d H:i', $value->getTime())) ?></td> |
125 | 131 | <td><?= Strings::htmlentities($user->getLogin()) ?></td> |
126 | | - <td><?= $loggingValue['ip'] ?></td> |
| 132 | + <td><?= $value->getIp() ?></td> |
127 | 133 | <td><small><?php |
128 | | - $text = Strings::htmlentities($loggingValue['text']); |
| 134 | + $text = Strings::htmlentities($value->getText()); |
129 | 135 | $text = str_replace('Loginerror', Translation::get('ad_log_lger'), $text); |
130 | 136 | $text = str_replace('Session expired', Translation::get('ad_log_sess'), $text); |
131 | 137 | $text = str_replace('Useredit', Translation::get('ad_log_edit'), $text); |
|
0 commit comments