|
14 | 14 |
|
15 | 15 | class main_module |
16 | 16 | { |
17 | | - var $u_action; |
| 17 | + public string $u_action; |
18 | 18 |
|
19 | | - function main($id, $mode) |
| 19 | + public function main(string $id, string $mode): void |
20 | 20 | { |
21 | | - global $auth, $cache, $config, $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_ext_gallery; |
| 21 | + global $auth, $cache, $config, $db, $template, $request, $user, $phpEx, $phpbb_root_path, $phpbb_ext_gallery; |
22 | 22 |
|
23 | 23 | $user->add_lang_ext('phpbbgallery/core', array('gallery_acp', 'gallery')); |
24 | | - //$user->add_lang_ext('phpbbgallery/acpcleanup', 'cleanup'); |
25 | 24 | $this->tpl_name = 'gallery_cleanup'; |
| 25 | + |
26 | 26 | add_form_key('acp_gallery'); |
27 | 27 |
|
| 28 | + $submit = $request->is_set_post('submit'); |
| 29 | + |
| 30 | + if ($submit && !check_form_key('acp_gallery')) |
| 31 | + { |
| 32 | + trigger_error($user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); |
| 33 | + } |
| 34 | + |
28 | 35 | $this->page_title = $user->lang['ACP_GALLERY_CLEANUP']; |
29 | | - $this->cleanup(); |
| 36 | + $this->cleanup($submit); |
30 | 37 | } |
31 | 38 |
|
32 | | - function cleanup() |
| 39 | + /** |
| 40 | + * Cleanup gallery files and database entries |
| 41 | + * |
| 42 | + * @param array $missing_entries Files to clean |
| 43 | + * @param bool $move_to_import Whether to move files to import dir |
| 44 | + * @return array Messages about cleanup results |
| 45 | + * @throws \RuntimeException On file operation errors |
| 46 | + */ |
| 47 | + public function cleanup(bool $submit = false): void |
33 | 48 | { |
34 | 49 | global $auth, $cache, $db, $template, $user, $phpbb_ext_gallery, $table_prefix, $phpbb_container, $request; |
35 | 50 |
|
36 | | - $delete = (isset($_POST['delete'])) ? true : false; |
37 | | - $prune = (isset($_POST['prune'])) ? true : false; |
38 | | - $submit = (isset($_POST['submit'])) ? true : false; |
| 51 | + $delete = $request->is_set_post('delete'); |
| 52 | + $prune = $request->is_set_post('prune'); |
39 | 53 |
|
40 | 54 | $missing_sources = $request->variable('source', array(0)); |
41 | 55 | $missing_entries = $request->variable('entry', array(''), true); |
|
0 commit comments