satanasov /
phpbbgallery
| 1 | <?php |
||||||
| 2 | /** |
||||||
| 3 | * phpBB Gallery - Core Extension |
||||||
| 4 | * |
||||||
| 5 | * @package phpbbgallery/core |
||||||
| 6 | * @author nickvergessen |
||||||
| 7 | * @author satanasov |
||||||
| 8 | * @author Leinad4Mind |
||||||
| 9 | * @copyright 2007-2012 nickvergessen, 2014- satanasov, 2018- Leinad4Mind |
||||||
| 10 | * @license GPL-2.0-only |
||||||
| 11 | */ |
||||||
| 12 | |||||||
| 13 | namespace phpbbgallery\core\acp; |
||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * @package acp |
||||||
| 17 | */ |
||||||
| 18 | class gallery_logs_module |
||||||
| 19 | { |
||||||
| 20 | var $u_action; |
||||||
| 21 | |||||||
| 22 | function main($id, $mode) |
||||||
|
0 ignored issues
–
show
|
|||||||
| 23 | { |
||||||
| 24 | global $auth, $template, $user, $request; |
||||||
| 25 | global $phpbb_container; |
||||||
| 26 | |||||||
| 27 | $this->language = $phpbb_container->get('language'); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 28 | $this->language->add_lang(['info_acp_gallery_logs'], 'phpbbgallery/core'); |
||||||
| 29 | |||||||
| 30 | $this->tpl_name = 'gallery_logs'; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 31 | add_form_key('acp_logs'); |
||||||
|
0 ignored issues
–
show
The function
add_form_key was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 32 | |||||||
| 33 | $page = $request->variable('page', 0); |
||||||
| 34 | $filter_log = $request->variable('lf', 'all'); |
||||||
| 35 | $sort_days = $request->variable('st', 0); |
||||||
| 36 | $sort_key = $request->variable('sk', 't'); |
||||||
| 37 | $sort_dir = $request->variable('sd', 'd'); |
||||||
| 38 | $deletemark = $request->is_set_post('delmarked'); |
||||||
| 39 | $marked = $request->variable('mark', []); |
||||||
| 40 | |||||||
| 41 | $log = $phpbb_container->get('phpbbgallery.core.log'); |
||||||
| 42 | |||||||
| 43 | $valid_filters = ['all', 'admin', 'moderator', 'system']; |
||||||
| 44 | $valid_sort_keys = ['u', 't', 'i', 'o']; |
||||||
| 45 | $valid_sort_dirs = ['a', 'd']; |
||||||
| 46 | |||||||
| 47 | // Sanitize inputs |
||||||
| 48 | if (!in_array($filter_log, $valid_filters)) |
||||||
| 49 | { |
||||||
| 50 | $filter_log = 'all'; |
||||||
| 51 | } |
||||||
| 52 | if (!in_array($sort_key, $valid_sort_keys)) |
||||||
| 53 | { |
||||||
| 54 | $sort_key = 't'; |
||||||
| 55 | } |
||||||
| 56 | if (!in_array($sort_dir, $valid_sort_dirs)) |
||||||
| 57 | { |
||||||
| 58 | $sort_dir = 'd'; |
||||||
| 59 | } |
||||||
| 60 | |||||||
| 61 | // Delete entries if requested and able |
||||||
| 62 | if ($deletemark && $auth->acl_get('a_clearlogs') && !empty($marked)) |
||||||
| 63 | { |
||||||
| 64 | if (!check_form_key('acp_logs')) |
||||||
|
0 ignored issues
–
show
The function
check_form_key was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 65 | { |
||||||
| 66 | trigger_error($this->language->lang('FORM_INVALID')); |
||||||
| 67 | } |
||||||
| 68 | |||||||
| 69 | if (confirm_box(true)) |
||||||
|
0 ignored issues
–
show
The function
confirm_box was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 70 | { |
||||||
| 71 | $log->delete_logs($marked); |
||||||
| 72 | } |
||||||
| 73 | else |
||||||
| 74 | { |
||||||
| 75 | confirm_box(false, $this->language->lang('CONFIRM_OPERATION'), build_hidden_fields([ |
||||||
|
0 ignored issues
–
show
The function
build_hidden_fields was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 76 | 'page' => $page, |
||||||
| 77 | 'delmarked' => $deletemark, |
||||||
| 78 | 'mark' => $marked, |
||||||
| 79 | 'st' => $sort_days, |
||||||
| 80 | 'sk' => $sort_key, |
||||||
| 81 | 'sd' => $sort_dir, |
||||||
| 82 | 'i' => $id, |
||||||
| 83 | 'mode' => $mode, |
||||||
| 84 | 'action' => $this->u_action, |
||||||
| 85 | ])); |
||||||
| 86 | } |
||||||
| 87 | } |
||||||
| 88 | |||||||
| 89 | switch ($mode) |
||||||
| 90 | { |
||||||
| 91 | case 'main': |
||||||
| 92 | // Template vars based on filter |
||||||
| 93 | $log_titles = [ |
||||||
| 94 | 'all' => ['ACP_GALLERY_LOGS', ''], |
||||||
| 95 | 'admin' => ['ACP_LOG_GALLERY_ADM', 'ACP_LOG_GALLERY_ADM_EXP'], |
||||||
| 96 | 'moderator'=> ['ACP_LOG_GALLERY_MOD', 'ACP_LOG_GALLERY_MOD_EXP'], |
||||||
| 97 | 'system' => ['ACP_LOG_GALLERY_SYSTEM', 'ACP_LOG_GALLERY_SYSTEM_EXP'], |
||||||
| 98 | ]; |
||||||
| 99 | $title = $log_titles[$filter_log][0]; |
||||||
| 100 | |||||||
| 101 | $template->assign_vars([ |
||||||
| 102 | 'L_TITLE' => $this->language->lang($log_titles[$filter_log][0]), |
||||||
| 103 | 'L_EXPLAIN' => $log_titles[$filter_log][1] ? $this->language->lang($log_titles[$filter_log][1]) : '', |
||||||
| 104 | 'S_SELECT_OPTION' => $filter_log, |
||||||
| 105 | ]); |
||||||
| 106 | |||||||
| 107 | // Sorting |
||||||
| 108 | $limit_days = [ |
||||||
| 109 | 0 => $this->language->lang('ALL_ENTRIES'), |
||||||
| 110 | 1 => $this->language->lang('1_DAY'), |
||||||
| 111 | 7 => $this->language->lang('7_DAYS'), |
||||||
| 112 | 14 => $this->language->lang('2_WEEKS'), |
||||||
| 113 | 30 => $this->language->lang('1_MONTH'), |
||||||
| 114 | 90 => $this->language->lang('3_MONTHS'), |
||||||
| 115 | 180 => $this->language->lang('6_MONTHS'), |
||||||
| 116 | 365 => $this->language->lang('1_YEAR'), |
||||||
| 117 | ]; |
||||||
| 118 | $sort_by_text = [ |
||||||
| 119 | 'u' => $this->language->lang('SORT_USER_ID'), |
||||||
| 120 | 't' => $this->language->lang('SORT_DATE'), |
||||||
| 121 | 'i' => $this->language->lang('SORT_IP'), |
||||||
| 122 | 'o' => $this->language->lang('SORT_ACTION'), |
||||||
| 123 | ]; |
||||||
| 124 | |||||||
| 125 | $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; |
||||||
| 126 | gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
||||||
|
0 ignored issues
–
show
The function
gen_sort_selects was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 127 | |||||||
| 128 | $template->assign_vars(array( |
||||||
| 129 | 'S_LIMIT_DAYS' => $s_limit_days, |
||||||
| 130 | 'S_SORT_KEY' => $s_sort_key, |
||||||
| 131 | 'S_SORT_DIR' => $s_sort_dir, |
||||||
| 132 | 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), |
||||||
| 133 | 'U_ACTION' => $this->u_action . "&$u_sort_param&page=$page", |
||||||
| 134 | )); |
||||||
| 135 | $this->page_title = $this->language->lang($title); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 136 | |||||||
| 137 | // Build additional filters |
||||||
| 138 | $additional = []; |
||||||
| 139 | if ($sort_days > 0) |
||||||
| 140 | { |
||||||
| 141 | $additional['sort_days'] = $sort_days; |
||||||
| 142 | } |
||||||
| 143 | if ($sort_key !== 't') |
||||||
| 144 | { |
||||||
| 145 | $additional['sort_key'] = $sort_key; |
||||||
| 146 | } |
||||||
| 147 | if ($sort_dir !== 'd') |
||||||
| 148 | { |
||||||
| 149 | $additional['sort_dir'] = $sort_dir; |
||||||
| 150 | } |
||||||
| 151 | |||||||
| 152 | // Build list |
||||||
| 153 | $log->build_list($filter_log, 0, $page, -1, 0, $additional); |
||||||
| 154 | break; |
||||||
| 155 | |||||||
| 156 | default: |
||||||
| 157 | trigger_error('NO_MODE', E_USER_ERROR); |
||||||
| 158 | break; |
||||||
| 159 | } |
||||||
| 160 | } |
||||||
| 161 | } |
||||||
| 162 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.