1 | <?php |
||||||
2 | /** |
||||||
3 | * |
||||||
4 | * @package phpBB Gallery - ACP CleanUp Extension |
||||||
5 | * @copyright (c) 2012 nickvergessen - http://www.flying-bits.org/ |
||||||
6 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
||||||
7 | * |
||||||
8 | */ |
||||||
9 | |||||||
10 | namespace phpbbgallery\acpcleanup\acp; |
||||||
11 | |||||||
12 | class main_module |
||||||
13 | { |
||||||
14 | var $u_action; |
||||||
15 | |||||||
16 | function main($id, $mode) |
||||||
0 ignored issues
–
show
The parameter
$id is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
17 | { |
||||||
18 | global $auth, $cache, $config, $db, $template, $user, $phpEx, $phpbb_root_path, $phpbb_ext_gallery; |
||||||
19 | |||||||
20 | $user->add_lang_ext('phpbbgallery/core', array('gallery_acp', 'gallery')); |
||||||
21 | //$user->add_lang_ext('phpbbgallery/acpcleanup', 'cleanup'); |
||||||
22 | $this->tpl_name = 'gallery_cleanup'; |
||||||
0 ignored issues
–
show
|
|||||||
23 | add_form_key('acp_gallery'); |
||||||
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
![]() |
|||||||
24 | |||||||
25 | $this->page_title = $user->lang['ACP_GALLERY_CLEANUP']; |
||||||
0 ignored issues
–
show
|
|||||||
26 | $this->cleanup(); |
||||||
27 | } |
||||||
28 | |||||||
29 | function cleanup() |
||||||
0 ignored issues
–
show
|
|||||||
30 | { |
||||||
31 | global $auth, $cache, $db, $template, $user, $phpbb_ext_gallery, $table_prefix, $phpbb_container, $request; |
||||||
32 | |||||||
33 | $delete = (isset($_POST['delete'])) ? true : false; |
||||||
34 | $prune = (isset($_POST['prune'])) ? true : false; |
||||||
35 | $submit = (isset($_POST['submit'])) ? true : false; |
||||||
36 | |||||||
37 | $missing_sources = $request->variable('source', array(0)); |
||||||
38 | $missing_entries = $request->variable('entry', array(''), true); |
||||||
39 | $missing_authors = $request->variable('author', array(0), true); |
||||||
40 | $missing_comments = $request->variable('comment', array(0), true); |
||||||
41 | $missing_personals = $request->variable('personal', array(0), true); |
||||||
42 | $personals_bad = $request->variable('personal_bad', array(0), true); |
||||||
43 | $prune_pattern = $request->variable('prune_pattern', array('' => ''), true); |
||||||
44 | |||||||
45 | $move_to_import = $request->variable('move_to_import', 0); |
||||||
46 | $new_author = $request->variable('new_author', ''); |
||||||
47 | |||||||
48 | $gallery_album = $phpbb_container->get('phpbbgallery.core.album'); |
||||||
49 | $core_cleanup = $phpbb_container->get('phpbbgallery.acpcleanup.cleanup'); |
||||||
50 | $gallery_auth = $phpbb_container->get('phpbbgallery.core.auth'); |
||||||
51 | $gallery_config = $phpbb_container->get('phpbbgallery.core.config'); |
||||||
52 | $gallery_url = $phpbb_container->get('phpbbgallery.core.url'); |
||||||
53 | |||||||
54 | // Lets detect if ACP Import exists (find if directory is with RW access) |
||||||
55 | $acp_import_installed = false; |
||||||
56 | $acp_import_dir = $gallery_url->path('import'); |
||||||
57 | if (file_exists($acp_import_dir) && is_writable($acp_import_dir)) |
||||||
58 | { |
||||||
59 | $acp_import_installed = true; |
||||||
60 | } |
||||||
61 | if ($prune && empty($prune_pattern)) |
||||||
62 | { |
||||||
63 | $prune_pattern['image_album_id'] = implode(',', $request->variable('prune_album_ids', array(0))); |
||||||
64 | if (isset($_POST['prune_username_check'])) |
||||||
65 | { |
||||||
66 | $usernames = $request->variable('prune_usernames', '', true); |
||||||
67 | $usernames = explode("\n", $usernames); |
||||||
68 | $prune_pattern['image_user_id'] = array(); |
||||||
69 | if (!empty($usernames)) |
||||||
70 | { |
||||||
71 | if (!function_exists('user_get_id_name')) |
||||||
72 | { |
||||||
73 | $gallery_url->_include('functions_user', 'phpbb'); |
||||||
74 | } |
||||||
75 | user_get_id_name($user_ids, $usernames); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
76 | $prune_pattern['image_user_id'] = $user_ids; |
||||||
77 | } |
||||||
78 | if (isset($_POST['prune_anonymous'])) |
||||||
79 | { |
||||||
80 | $prune_pattern['image_user_id'][] = ANONYMOUS; |
||||||
0 ignored issues
–
show
|
|||||||
81 | } |
||||||
82 | $prune_pattern['image_user_id'] = implode(',', $prune_pattern['image_user_id']); |
||||||
83 | } |
||||||
84 | if (isset($_POST['prune_time_check'])) |
||||||
85 | { |
||||||
86 | $prune_time = explode('-', $request->variable('prune_time', '')); |
||||||
87 | |||||||
88 | if (sizeof($prune_time) == 3) |
||||||
89 | { |
||||||
90 | $prune_pattern['image_time'] = @gmmktime(0, 0, 0, (int) $prune_time[1], (int) $prune_time[2], (int) $prune_time[0]); |
||||||
91 | } |
||||||
92 | } |
||||||
93 | if (isset($_POST['prune_comments_check'])) |
||||||
94 | { |
||||||
95 | $prune_pattern['image_comments'] = $request->variable('prune_comments', 0); |
||||||
96 | } |
||||||
97 | if (isset($_POST['prune_ratings_check'])) |
||||||
98 | { |
||||||
99 | $prune_pattern['image_rates'] = $request->variable('prune_ratings', 0); |
||||||
100 | } |
||||||
101 | if (isset($_POST['prune_rating_avg_check'])) |
||||||
102 | { |
||||||
103 | $prune_pattern['image_rate_avg'] = (int) ($request->variable('prune_rating_avg', 0.0) * 100); |
||||||
104 | } |
||||||
105 | } |
||||||
106 | |||||||
107 | $s_hidden_fields = build_hidden_fields(array( |
||||||
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
![]() |
|||||||
108 | 'source' => $missing_sources, |
||||||
109 | 'entry' => $missing_entries, |
||||||
110 | 'author' => $missing_authors, |
||||||
111 | 'comment' => $missing_comments, |
||||||
112 | 'personal' => $missing_personals, |
||||||
113 | 'personal_bad' => $personals_bad, |
||||||
114 | 'prune_pattern' => $prune_pattern, |
||||||
115 | 'move_to_import' => $move_to_import, |
||||||
116 | )); |
||||||
117 | |||||||
118 | if ($submit) |
||||||
119 | { |
||||||
120 | $user_id = 1; |
||||||
121 | if ($new_author) |
||||||
122 | { |
||||||
123 | $user_id = 0; |
||||||
124 | if (!function_exists('user_get_id_name')) |
||||||
125 | { |
||||||
126 | $gallery_url->_include('functions_user', 'phpbb'); |
||||||
127 | } |
||||||
128 | user_get_id_name($user_id, $new_author); |
||||||
129 | if (is_array($user_id) && !empty($user_id)) |
||||||
0 ignored issues
–
show
|
|||||||
130 | { |
||||||
131 | $user_id = $user_id[0]; |
||||||
132 | } |
||||||
133 | if (!$user_id) |
||||||
134 | { |
||||||
135 | trigger_error($user->lang('CLEAN_USER_NOT_FOUND', $new_author) . adm_back_link($this->u_action), E_USER_WARNING); |
||||||
0 ignored issues
–
show
The function
adm_back_link 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
![]() |
|||||||
136 | } |
||||||
137 | } |
||||||
138 | if ($missing_authors) |
||||||
139 | { |
||||||
140 | $sql = 'UPDATE ' . $table_prefix . 'gallery_images |
||||||
141 | SET image_user_id = ' . $user_id . ", |
||||||
142 | image_user_colour = '' |
||||||
143 | WHERE " . $db->sql_in_set('image_id', $missing_authors); |
||||||
144 | $db->sql_query($sql); |
||||||
145 | } |
||||||
146 | if ($missing_comments) |
||||||
147 | { |
||||||
148 | $sql = 'UPDATE ' . $table_prefix . 'gallery_comments |
||||||
149 | SET comment_user_id = ' . $user_id . ", |
||||||
150 | comment_user_colour = '' |
||||||
151 | WHERE " . $db->sql_in_set('comment_id', $missing_comments); |
||||||
152 | $db->sql_query($sql); |
||||||
153 | } |
||||||
154 | trigger_error($user->lang['CLEAN_CHANGED'] . adm_back_link($this->u_action)); |
||||||
155 | } |
||||||
156 | |||||||
157 | 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
![]() |
|||||||
158 | { |
||||||
159 | $message = array(); |
||||||
160 | if ($missing_entries) |
||||||
161 | { |
||||||
162 | if ($acp_import_installed && $move_to_import) |
||||||
163 | { |
||||||
164 | foreach ($missing_entries as $entry) |
||||||
165 | { |
||||||
166 | copy($gallery_url->path('upload') . '/' . $entry, $gallery_url->path('import') . '/' . $entry); |
||||||
167 | } |
||||||
168 | } |
||||||
169 | $message[] = $core_cleanup->delete_files($missing_entries); |
||||||
170 | } |
||||||
171 | if ($missing_sources) |
||||||
172 | { |
||||||
173 | $message[] = $core_cleanup->delete_images($missing_sources); |
||||||
174 | } |
||||||
175 | if ($missing_authors) |
||||||
176 | { |
||||||
177 | $message[] = $core_cleanup->delete_author_images($missing_entries); |
||||||
178 | } |
||||||
179 | if ($missing_comments) |
||||||
180 | { |
||||||
181 | $message[] = $core_cleanup->delete_author_comments($missing_comments); |
||||||
182 | } |
||||||
183 | if ($missing_personals || $personals_bad) |
||||||
184 | { |
||||||
185 | $message = array_merge($message, $core_cleanup->delete_pegas($personals_bad, $missing_personals)); |
||||||
186 | |||||||
187 | // Only do this, when we changed something about the albums |
||||||
188 | $cache->destroy('_albums'); |
||||||
189 | $gallery_auth->set_user_permissions('all', ''); |
||||||
190 | } |
||||||
191 | if ($prune_pattern) |
||||||
192 | { |
||||||
193 | $message[] = $core_cleanup->prune($prune_pattern); |
||||||
194 | } |
||||||
195 | |||||||
196 | if (empty($message)) |
||||||
197 | { |
||||||
198 | trigger_error($user->lang['CLEAN_NO_ACTION'] . adm_back_link($this->u_action), E_USER_WARNING); |
||||||
199 | } |
||||||
200 | |||||||
201 | // Make sure the overall image & comment count is correct... |
||||||
202 | $sql = 'SELECT COUNT(image_id) AS num_images, SUM(image_comments) AS num_comments |
||||||
203 | FROM ' . $table_prefix . 'gallery_images |
||||||
204 | WHERE image_status <> ' . (int) \phpbbgallery\core\block::STATUS_UNAPPROVED; |
||||||
205 | $result = $db->sql_query($sql); |
||||||
206 | $row = $db->sql_fetchrow($result); |
||||||
207 | $db->sql_freeresult($result); |
||||||
208 | |||||||
209 | $gallery_config->set('num_images', $row['num_images']); |
||||||
210 | $gallery_config->set('num_comments', (int) $row['num_comments']); |
||||||
211 | |||||||
212 | $cache->destroy('sql', $table_prefix . 'gallery_albums'); |
||||||
213 | $cache->destroy('sql', $table_prefix . 'gallery_comments'); |
||||||
214 | $cache->destroy('sql', $table_prefix . 'gallery_images'); |
||||||
215 | $cache->destroy('sql', $table_prefix . 'gallery_rates'); |
||||||
216 | $cache->destroy('sql', $table_prefix . 'gallery_reports'); |
||||||
217 | $cache->destroy('sql', $table_prefix . 'gallery_watch'); |
||||||
218 | |||||||
219 | $message_string = ''; |
||||||
220 | foreach ($message as $lang_key) |
||||||
221 | { |
||||||
222 | $message_string .= (($message_string) ? '<br />' : '') . $user->lang[$lang_key]; |
||||||
223 | } |
||||||
224 | |||||||
225 | trigger_error($message_string . adm_back_link($this->u_action)); |
||||||
226 | } |
||||||
227 | else if ($delete || $prune || (isset($_POST['cancel']))) |
||||||
228 | { |
||||||
229 | if (isset($_POST['cancel'])) |
||||||
230 | { |
||||||
231 | trigger_error($user->lang['CLEAN_GALLERY_ABORT'] . adm_back_link($this->u_action), E_USER_WARNING); |
||||||
232 | } |
||||||
233 | else |
||||||
234 | { |
||||||
235 | $clean_gallery_confirm = $user->lang['CONFIRM_CLEAN']; |
||||||
236 | if ($missing_sources) |
||||||
237 | { |
||||||
238 | $clean_gallery_confirm = $user->lang['CONFIRM_CLEAN_SOURCES'] . '<br />' . $clean_gallery_confirm; |
||||||
239 | } |
||||||
240 | if ($missing_entries) |
||||||
241 | { |
||||||
242 | $clean_gallery_confirm = $user->lang['CONFIRM_CLEAN_ENTRIES'] . '<br />' . $clean_gallery_confirm; |
||||||
243 | } |
||||||
244 | if ($missing_authors) |
||||||
245 | { |
||||||
246 | $core_cleanup->delete_author_images($missing_authors); |
||||||
247 | $clean_gallery_confirm = $user->lang['CONFIRM_CLEAN_AUTHORS'] . '<br />' . $clean_gallery_confirm; |
||||||
248 | } |
||||||
249 | if ($missing_comments) |
||||||
250 | { |
||||||
251 | $clean_gallery_confirm = $user->lang['CONFIRM_CLEAN_COMMENTS'] . '<br />' . $clean_gallery_confirm; |
||||||
252 | } |
||||||
253 | if ($personals_bad || $missing_personals) |
||||||
254 | { |
||||||
255 | $sql = 'SELECT album_name, album_user_id |
||||||
256 | FROM ' . $table_prefix . 'gallery_albums |
||||||
257 | WHERE ' . $db->sql_in_set('album_user_id', array_merge($missing_personals, $personals_bad)); |
||||||
258 | $result = $db->sql_query($sql); |
||||||
259 | while ($row = $db->sql_fetchrow($result)) |
||||||
260 | { |
||||||
261 | if (in_array($row['album_user_id'], $personals_bad)) |
||||||
262 | { |
||||||
263 | $personals_bad_names[] = $row['album_name']; |
||||||
264 | } |
||||||
265 | else |
||||||
266 | { |
||||||
267 | $missing_personals_names[] = $row['album_name']; |
||||||
268 | } |
||||||
269 | } |
||||||
270 | $db->sql_freeresult($result); |
||||||
271 | } |
||||||
272 | if ($missing_personals) |
||||||
273 | { |
||||||
274 | $clean_gallery_confirm = $user->lang('CONFIRM_CLEAN_PERSONALS', implode(', ', $missing_personals_names)) . '<br />' . $clean_gallery_confirm; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
275 | } |
||||||
276 | if ($personals_bad) |
||||||
277 | { |
||||||
278 | $clean_gallery_confirm = $user->lang('CONFIRM_CLEAN_PERSONALS_BAD', implode(', ', $personals_bad_names)) . '<br />' . $clean_gallery_confirm; |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
279 | } |
||||||
280 | if ($prune && empty($prune_pattern)) |
||||||
281 | { |
||||||
282 | trigger_error($user->lang['CLEAN_PRUNE_NO_PATTERN'] . adm_back_link($this->u_action), E_USER_WARNING); |
||||||
283 | } |
||||||
284 | else if ($prune && $prune_pattern) |
||||||
285 | { |
||||||
286 | $clean_gallery_confirm = $user->lang('CONFIRM_PRUNE', $core_cleanup->lang_prune_pattern($prune_pattern)) . '<br />' . $clean_gallery_confirm; |
||||||
287 | } |
||||||
288 | confirm_box(false, $clean_gallery_confirm, $s_hidden_fields); |
||||||
289 | } |
||||||
290 | } |
||||||
291 | |||||||
292 | $requested_source = array(); |
||||||
293 | $sql_array = array( |
||||||
294 | 'SELECT' => 'i.image_id, i.image_name, i.image_filemissing, i.image_filename, i.image_username, u.user_id', |
||||||
295 | 'FROM' => array($table_prefix . 'gallery_images' => 'i'), |
||||||
296 | |||||||
297 | 'LEFT_JOIN' => array( |
||||||
298 | array( |
||||||
299 | 'FROM' => array(USERS_TABLE => 'u'), |
||||||
0 ignored issues
–
show
|
|||||||
300 | 'ON' => 'u.user_id = i.image_user_id', |
||||||
301 | ), |
||||||
302 | ), |
||||||
303 | ); |
||||||
304 | $sql = $db->sql_build_query('SELECT', $sql_array); |
||||||
305 | $result = $db->sql_query($sql); |
||||||
306 | while ($row = $db->sql_fetchrow($result)) |
||||||
307 | { |
||||||
308 | if ($row['image_filemissing']) |
||||||
309 | { |
||||||
310 | $template->assign_block_vars('sourcerow', array( |
||||||
311 | 'IMAGE_ID' => $row['image_id'], |
||||||
312 | 'IMAGE_NAME' => $row['image_name'], |
||||||
313 | )); |
||||||
314 | } |
||||||
315 | if (!$row['user_id']) |
||||||
316 | { |
||||||
317 | $template->assign_block_vars('authorrow', array( |
||||||
318 | 'IMAGE_ID' => $row['image_id'], |
||||||
319 | 'AUTHOR_NAME' => $row['image_username'], |
||||||
320 | )); |
||||||
321 | } |
||||||
322 | $requested_source[] = $row['image_filename']; |
||||||
323 | } |
||||||
324 | $db->sql_freeresult($result); |
||||||
325 | |||||||
326 | $check_mode = $request->variable('check_mode', ''); |
||||||
327 | if ($check_mode == 'source') |
||||||
328 | { |
||||||
329 | $source_missing = array(); |
||||||
330 | |||||||
331 | // Reset the status: a image might have been viewed without file but the file is back |
||||||
332 | $sql = 'UPDATE ' . $table_prefix . 'gallery_images |
||||||
333 | SET image_filemissing = 0'; |
||||||
334 | $db->sql_query($sql); |
||||||
335 | |||||||
336 | $sql = 'SELECT image_id, image_filename, image_filemissing |
||||||
337 | FROM ' . $table_prefix . 'gallery_images'; |
||||||
338 | $result = $db->sql_query($sql); |
||||||
339 | while ($row = $db->sql_fetchrow($result)) |
||||||
340 | { |
||||||
341 | if (!file_exists($gallery_url->path('upload') . $row['image_filename'])) |
||||||
342 | { |
||||||
343 | $source_missing[] = $row['image_id']; |
||||||
344 | } |
||||||
345 | } |
||||||
346 | $db->sql_freeresult($result); |
||||||
347 | |||||||
348 | if ($source_missing) |
||||||
349 | { |
||||||
350 | $sql = 'UPDATE ' . $table_prefix . "gallery_images |
||||||
351 | SET image_filemissing = 1 |
||||||
352 | WHERE " . $db->sql_in_set('image_id', $source_missing); |
||||||
353 | $db->sql_query($sql); |
||||||
354 | } |
||||||
355 | } |
||||||
356 | |||||||
357 | if ($check_mode == 'entry') |
||||||
358 | { |
||||||
359 | $directory = $gallery_url->path('upload'); |
||||||
360 | $handle = opendir($directory); |
||||||
361 | while ($file = readdir($handle)) |
||||||
362 | { |
||||||
363 | if (!is_dir($directory . $file) && |
||||||
364 | ((substr(strtolower($file), '-5') == '.webp') || (substr(strtolower($file), '-4') == '.png') || (substr(strtolower($file), '-4') == '.gif') || (substr(strtolower($file), '-4') == '.jpg') || (substr(strtolower($file), '-5') == '.jpeg')) && |
||||||
365 | ((substr(strtolower($file), '-8') <> '_wm.webp') && (substr(strtolower($file), '-7') <> '_wm.png') && (substr(strtolower($file), '-7') <> '_wm.gif') && (substr(strtolower($file), '-7') <> '_wm.jpg') && (substr(strtolower($file), '-8') <> '_wm.jpeg')) |
||||||
366 | && !in_array($file, $requested_source) |
||||||
367 | ) |
||||||
368 | { |
||||||
369 | if ((strpos($file, 'image_not_exist') !== false) || (strpos($file, 'not_authorised') !== false) || (strpos($file, 'no_hotlinking') !== false)) |
||||||
370 | { |
||||||
371 | continue; |
||||||
372 | } |
||||||
373 | |||||||
374 | $template->assign_block_vars('entryrow', array( |
||||||
375 | 'FILE_NAME' => utf8_encode($file), |
||||||
376 | )); |
||||||
377 | } |
||||||
378 | } |
||||||
379 | closedir($handle); |
||||||
380 | } |
||||||
381 | |||||||
382 | $sql_array = array( |
||||||
383 | 'SELECT' => 'c.comment_id, c.comment_image_id, c.comment_username, u.user_id', |
||||||
384 | 'FROM' => array($table_prefix . 'gallery_comments' => 'c'), |
||||||
385 | |||||||
386 | 'LEFT_JOIN' => array( |
||||||
387 | array( |
||||||
388 | 'FROM' => array(USERS_TABLE => 'u'), |
||||||
389 | 'ON' => 'u.user_id = c.comment_user_id', |
||||||
390 | ), |
||||||
391 | ), |
||||||
392 | ); |
||||||
393 | $sql = $db->sql_build_query('SELECT', $sql_array); |
||||||
394 | $result = $db->sql_query($sql); |
||||||
395 | while ($row = $db->sql_fetchrow($result)) |
||||||
396 | { |
||||||
397 | if (!$row['user_id']) |
||||||
398 | { |
||||||
399 | $template->assign_block_vars('commentrow', array( |
||||||
400 | 'COMMENT_ID' => $row['comment_id'], |
||||||
401 | 'IMAGE_ID' => $row['comment_image_id'], |
||||||
402 | 'AUTHOR_NAME' => $row['comment_username'], |
||||||
403 | )); |
||||||
404 | } |
||||||
405 | } |
||||||
406 | $db->sql_freeresult($result); |
||||||
407 | |||||||
408 | $sql_array = array( |
||||||
409 | 'SELECT' => 'a.album_id, a.album_user_id, a.album_name, u.user_id, a.album_images_real', |
||||||
410 | 'FROM' => array($table_prefix . 'gallery_albums' => 'a'), |
||||||
411 | |||||||
412 | 'LEFT_JOIN' => array( |
||||||
413 | array( |
||||||
414 | 'FROM' => array(USERS_TABLE => 'u'), |
||||||
415 | 'ON' => 'u.user_id = a.album_user_id', |
||||||
416 | ), |
||||||
417 | ), |
||||||
418 | |||||||
419 | 'WHERE' => 'a.album_user_id <> ' . (int) \phpbbgallery\core\block::PUBLIC_ALBUM . ' AND a.parent_id = 0', |
||||||
420 | ); |
||||||
421 | $sql = $db->sql_build_query('SELECT', $sql_array); |
||||||
422 | $result = $db->sql_query($sql); |
||||||
423 | $personalrow = $personal_bad_row = array(); |
||||||
424 | while ($row = $db->sql_fetchrow($result)) |
||||||
425 | { |
||||||
426 | $album = array( |
||||||
427 | 'user_id' => $row['album_user_id'], |
||||||
428 | 'album_id' => $row['album_id'], |
||||||
429 | 'album_name' => $row['album_name'], |
||||||
430 | 'images' => $row['album_images_real'], |
||||||
431 | ); |
||||||
432 | if (!$row['user_id']) |
||||||
433 | { |
||||||
434 | $personalrow[$row['album_user_id']] = $album; |
||||||
435 | } |
||||||
436 | $personal_bad_row[$row['album_user_id']] = $album; |
||||||
437 | } |
||||||
438 | $db->sql_freeresult($result); |
||||||
439 | |||||||
440 | $sql = 'SELECT ga.album_user_id, ga.album_images_real |
||||||
441 | FROM ' . $table_prefix . 'gallery_albums ga |
||||||
442 | WHERE ga.album_user_id <> ' . (int) \phpbbgallery\core\block::PUBLIC_ALBUM . ' |
||||||
443 | AND ga.parent_id <> 0'; |
||||||
444 | $result = $db->sql_query($sql); |
||||||
445 | while ($row = $db->sql_fetchrow($result)) |
||||||
446 | { |
||||||
447 | if (isset($personalrow[$row['album_user_id']])) |
||||||
448 | { |
||||||
449 | $personalrow[$row['album_user_id']]['images'] = $personalrow[$row['album_user_id']]['images'] + $row['album_images_real']; |
||||||
450 | } |
||||||
451 | $personal_bad_row[$row['album_user_id']]['images'] = $personal_bad_row[$row['album_user_id']]['images'] + $row['album_images_real']; |
||||||
452 | } |
||||||
453 | $db->sql_freeresult($result); |
||||||
454 | |||||||
455 | foreach ($personalrow as $key => $row) |
||||||
456 | { |
||||||
457 | $template->assign_block_vars('personalrow', array( |
||||||
458 | 'USER_ID' => $row['user_id'], |
||||||
459 | 'ALBUM_ID' => $row['album_id'], |
||||||
460 | 'AUTHOR_NAME' => $row['album_name'], |
||||||
461 | )); |
||||||
462 | } |
||||||
463 | foreach ($personal_bad_row as $key => $row) |
||||||
464 | { |
||||||
465 | $template->assign_block_vars('personal_bad_row', array( |
||||||
466 | 'USER_ID' => $row['user_id'], |
||||||
467 | 'ALBUM_ID' => $row['album_id'], |
||||||
468 | 'AUTHOR_NAME' => $row['album_name'], |
||||||
469 | 'IMAGES' => $row['images'], |
||||||
470 | )); |
||||||
471 | } |
||||||
472 | |||||||
473 | $template->assign_vars(array( |
||||||
474 | 'S_GALLERY_MANAGE_RESTS' => true, |
||||||
475 | 'ACP_GALLERY_TITLE' => $user->lang['ACP_GALLERY_CLEANUP'], |
||||||
476 | 'ACP_GALLERY_TITLE_EXPLAIN' => $user->lang['ACP_GALLERY_CLEANUP_EXPLAIN'], |
||||||
477 | 'ACP_IMPORT_INSTALLED' => $acp_import_installed, |
||||||
478 | 'CHECK_SOURCE' => $this->u_action . '&check_mode=source', |
||||||
479 | 'CHECK_ENTRY' => $this->u_action . '&check_mode=entry', |
||||||
480 | |||||||
481 | 'U_FIND_USERNAME' => $gallery_url->append_sid('phpbb', 'memberlist', 'mode=searchuser&form=acp_gallery&field=prune_usernames'), |
||||||
482 | 'S_SELECT_ALBUM' => $gallery_album->get_albumbox(false, '', false, false, false, (int) \phpbbgallery\core\block::PUBLIC_ALBUM, (int) \phpbbgallery\core\block::TYPE_UPLOAD), |
||||||
483 | |||||||
484 | 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, |
||||||
0 ignored issues
–
show
|
|||||||
485 | )); |
||||||
486 | } |
||||||
487 | } |
||||||
488 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.