Zeile 45 | Zeile 45 |
---|
if(!is_array($mybb->input['aids'])) {
|
if(!is_array($mybb->input['aids'])) {
|
$mybb->input['aids'] = array((int)$mybb->input['aid']);
| $mybb->input['aids'] = array($mybb->get_input('aid', MyBB::INPUT_INT));
|
} else {
| } else {
|
Zeile 187 | Zeile 187 |
---|
{ case "pgsql": $query = $db->query("
|
{ case "pgsql": $query = $db->query("
|
SELECT a.*, u.uid AS useruid, u.username, SUM(a.filesize) as totalsize
| SELECT a.uid, u.username, SUM(a.filesize) as totalsize
|
FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
|
FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
|
GROUP BY ".$db->build_fields_string("attachments", "a.").",u.uid,u.username
| GROUP BY a.uid, u.username
|
ORDER BY totalsize DESC LIMIT 5 "); break; default: $query = $db->query("
|
ORDER BY totalsize DESC LIMIT 5 "); break; default: $query = $db->query("
|
SELECT a.*, u.uid AS useruid, u.username, SUM(a.filesize) as totalsize
| SELECT a.uid, u.username, SUM(a.filesize) as totalsize
|
FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid) GROUP BY a.uid
| FROM ".TABLE_PREFIX."attachments a LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid) GROUP BY a.uid
|
Zeile 207 | Zeile 207 |
---|
} while($user = $db->fetch_array($query)) {
|
} while($user = $db->fetch_array($query)) {
|
if(!$user['useruid'])
| if(!$user['uid'])
|
{ $user['username'] = $lang->na; }
|
{ $user['username'] = $lang->na; }
|
$table->construct_cell(build_profile_link($user['username'], $user['useruid'], "_blank"));
| $table->construct_cell(build_profile_link(htmlspecialchars_uni($user['username']), $user['uid'], "_blank"));
|
$table->construct_cell("<a href=\"index.php?module=forum-attachments&results=1&username=".urlencode($user['username'])."\" target=\"_blank\">".get_friendly_size($user['totalsize'])."</a>", array('class' => 'align_center')); $table->construct_row(); }
| $table->construct_cell("<a href=\"index.php?module=forum-attachments&results=1&username=".urlencode($user['username'])."\" target=\"_blank\">".get_friendly_size($user['totalsize'])."</a>", array('class' => 'align_center')); $table->construct_row(); }
|
Zeile 223 | Zeile 223 |
---|
if($mybb->input['action'] == "delete_orphans" && $mybb->request_method == "post") { $plugins->run_hooks("admin_forum_attachments_delete_orphans");
|
if($mybb->input['action'] == "delete_orphans" && $mybb->request_method == "post") { $plugins->run_hooks("admin_forum_attachments_delete_orphans");
|
| $success_count = $error_count = 0;
|
// Deleting specific attachments from uploads directory if(is_array($mybb->input['orphaned_files'])) {
|
// Deleting specific attachments from uploads directory if(is_array($mybb->input['orphaned_files'])) {
|
| /** * @param string $string * * @return string */
|
function clean_filename($string) { return str_replace(array(".."), "", $string);
| function clean_filename($string) { return str_replace(array(".."), "", $string);
|
Zeile 235 | Zeile 242 |
---|
foreach($mybb->input['orphaned_files'] as $file) { if(!@unlink(MYBB_ROOT.$mybb->settings['uploadspath']."/".$file))
|
foreach($mybb->input['orphaned_files'] as $file) { if(!@unlink(MYBB_ROOT.$mybb->settings['uploadspath']."/".$file))
|
{ $error = true;
| { $error_count++; } else { $success_count++;
|
} } }
| } } }
|
Zeile 253 | Zeile 264 |
---|
if(!$attachment['pid']) { remove_attachment(null, $attachment['posthash'], $attachment['aid']);
|
if(!$attachment['pid']) { remove_attachment(null, $attachment['posthash'], $attachment['aid']);
|
}
| }
|
else { remove_attachment($attachment['pid'], null, $attachment['aid']); }
|
else { remove_attachment($attachment['pid'], null, $attachment['aid']); }
|
}
| $success_count++; }
|
}
$plugins->run_hooks("admin_forum_attachments_delete_orphans_commit");
| }
$plugins->run_hooks("admin_forum_attachments_delete_orphans_commit");
|
Zeile 266 | Zeile 278 |
---|
// Log admin action log_admin_action();
|
// Log admin action log_admin_action();
|
if($error == true)
| $message = ''; $status = 'success'; if($error_count > 0)
|
{
|
{
|
flash_message($lang->error_not_all_removed, 'error');
| $status = 'error'; $message = $lang->sprintf($lang->error_count, $error_count);
|
}
|
}
|
else
| if($success_count > 0)
|
{
|
{
|
flash_message($lang->success_orphan_deleted, 'success');
| if($error_count > 0) { $message .= '<br />'.$lang->sprintf($lang->success_count, $success_count); } else { $message = $lang->success_orphan_deleted; }
|
}
|
}
|
admin_redirect("index.php?module=forum-attachments");
| flash_message($message, $status); admin_redirect('index.php?module=forum-attachments');
|
}
if($mybb->input['action'] == "orphans")
| }
if($mybb->input['action'] == "orphans")
|
Zeile 335 | Zeile 359 |
---|
}
$page->output_header($lang->orphan_results);
|
}
$page->output_header($lang->orphan_results);
|
$page->output_nav_tabs($sub_tabs, 'find_orphans');
$form = new Form("index.php?module=forum-attachments&action=delete_orphans", "post");
| $page->output_nav_tabs($sub_tabs, 'find_orphans');
$form = new Form("index.php?module=forum-attachments&action=delete_orphans", "post");
|
$table = new Table; $table->construct_header($form->generate_check_box('checkall', '1', '', array('class' => 'checkall')), array( 'width' => 1)); $table->construct_header($lang->size_attachments, array('colspan' => 2)); $table->construct_header($lang->reason_orphaned, array('width' => '20%', 'class' => 'align_center')); $table->construct_header($lang->date_uploaded, array("class" => "align_center"));
|
$table = new Table; $table->construct_header($form->generate_check_box('checkall', '1', '', array('class' => 'checkall')), array( 'width' => 1)); $table->construct_header($lang->size_attachments, array('colspan' => 2)); $table->construct_header($lang->reason_orphaned, array('width' => '20%', 'class' => 'align_center')); $table->construct_header($lang->date_uploaded, array("class" => "align_center"));
|
|
|
if(is_array($bad_attachments)) { foreach($bad_attachments as $file)
| if(is_array($bad_attachments)) { foreach($bad_attachments as $file)
|
Zeile 372 | Zeile 396 |
---|
$reason = $lang->reason_file_missing; } else if($missing_threads[$attachment['aid']])
|
$reason = $lang->reason_file_missing; } else if($missing_threads[$attachment['aid']])
|
{
| {
|
$reason = $lang->reason_thread_deleted; } else if($incomplete_attachments[$attachment['aid']])
| $reason = $lang->reason_thread_deleted; } else if($incomplete_attachments[$attachment['aid']])
|
Zeile 386 | Zeile 410 |
---|
if($attachment['dateuploaded']) { $table->construct_cell(my_date('relative', $attachment['dateuploaded']), array('class' => 'align_center'));
|
if($attachment['dateuploaded']) { $table->construct_cell(my_date('relative', $attachment['dateuploaded']), array('class' => 'align_center'));
|
}
| }
|
else { $table->construct_cell($lang->unknown, array('class' => 'align_center')); } $table->construct_row();
|
else { $table->construct_cell($lang->unknown, array('class' => 'align_center')); } $table->construct_row();
|
}
| }
|
}
$table->output("{$lang->orphan_attachments_search} - {$results} {$lang->results}");
| }
$table->output("{$lang->orphan_attachments_search} - {$results} {$lang->results}");
|
Zeile 437 | Zeile 461 |
---|
} // Check if the thread/post for this attachment is missing else if(!$attachment['pid'] && $attachment['attachment_pid'])
|
} // Check if the thread/post for this attachment is missing else if(!$attachment['pid'] && $attachment['attachment_pid'])
|
{
| {
|
$missing_threads[$attachment['aid']] = $attachment['aid'];
|
$missing_threads[$attachment['aid']] = $attachment['aid'];
|
}
| }
|
// Check if the attachment was uploaded > 24 hours ago but not assigned to a thread else if(!$attachment['attachment_pid'] && $attachment['dateuploaded'] < TIME_NOW-60*60*24 && $attachment['dateuploaded'] != 0) { $incomplete_attachments[$attachment['aid']] = $attachment['aid'];
|
// Check if the attachment was uploaded > 24 hours ago but not assigned to a thread else if(!$attachment['attachment_pid'] && $attachment['dateuploaded'] < TIME_NOW-60*60*24 && $attachment['dateuploaded'] != 0) { $incomplete_attachments[$attachment['aid']] = $attachment['aid'];
|
} }
| } }
|
// Now send the user to the final page $form = new Form("index.php?module=forum-attachments&action=orphans&step=3", "post", "redirect_form", 0, ""); // Scan complete if($mybb->input['bad_attachments']) { echo $form->generate_hidden_field("bad_attachments", $mybb->input['bad_attachments']);
|
// Now send the user to the final page $form = new Form("index.php?module=forum-attachments&action=orphans&step=3", "post", "redirect_form", 0, ""); // Scan complete if($mybb->input['bad_attachments']) { echo $form->generate_hidden_field("bad_attachments", $mybb->input['bad_attachments']);
|
}
| }
|
if(is_array($missing_attachment_files) && count($missing_attachment_files) > 0) {
|
if(is_array($missing_attachment_files) && count($missing_attachment_files) > 0) {
|
$missing_attachment_files = serialize($missing_attachment_files);
| $missing_attachment_files = my_serialize($missing_attachment_files);
|
echo $form->generate_hidden_field("missing_attachment_files", $missing_attachment_files); } if(is_array($missing_threads) && count($missing_threads) > 0) {
|
echo $form->generate_hidden_field("missing_attachment_files", $missing_attachment_files); } if(is_array($missing_threads) && count($missing_threads) > 0) {
|
$missing_threads = serialize($missing_threads);
| $missing_threads = my_serialize($missing_threads);
|
echo $form->generate_hidden_field("missing_threads", $missing_threads); } if(is_array($incomplete_attachments) && count($incomplete_attachments) > 0) {
|
echo $form->generate_hidden_field("missing_threads", $missing_threads); } if(is_array($incomplete_attachments) && count($incomplete_attachments) > 0) {
|
$incomplete_attachments = serialize($incomplete_attachments);
| $incomplete_attachments = my_serialize($incomplete_attachments);
|
echo $form->generate_hidden_field("incomplete_attachments", $incomplete_attachments); } $form->end();
| echo $form->generate_hidden_field("incomplete_attachments", $incomplete_attachments); } $form->end();
|
Zeile 483 | Zeile 507 |
---|
else { $plugins->run_hooks("admin_forum_attachments_orphans_step1");
|
else { $plugins->run_hooks("admin_forum_attachments_orphans_step1");
|
| /** * @param string $dir */
|
function scan_attachments_directory($dir="") { global $db, $mybb, $bad_attachments, $attachments_to_check;
| function scan_attachments_directory($dir="") { global $db, $mybb, $bad_attachments, $attachments_to_check;
|
Zeile 503 | Zeile 530 |
---|
if($file == "." || $file == ".." || $file == ".svn") { continue;
|
if($file == "." || $file == ".." || $file == ".svn") { continue;
|
}
| }
|
if(is_dir($real_dir.'/'.$file)) {
| if(is_dir($real_dir.'/'.$file)) {
|
Zeile 586 | Zeile 613 |
---|
// Scan complete if(is_array($bad_attachments) && count($bad_attachments) > 0) {
|
// Scan complete if(is_array($bad_attachments) && count($bad_attachments) > 0) {
|
$bad_attachments = serialize($bad_attachments);
| $bad_attachments = my_serialize($bad_attachments);
|
echo $form->generate_hidden_field("bad_attachments", $bad_attachments); } $form->end();
| echo $form->generate_hidden_field("bad_attachments", $bad_attachments); } $form->end();
|
Zeile 668 | Zeile 695 |
---|
}
// LESS THAN or GREATER THAN
|
}
// LESS THAN or GREATER THAN
|
| $direction_fields = array( "dateuploaded" => $mybb->get_input('dateuploaded', MyBB::INPUT_INT), "filesize" => $mybb->get_input('filesize', MyBB::INPUT_INT), "downloads" => $mybb->get_input('downloads', MyBB::INPUT_INT) );
|
if($mybb->input['dateuploaded'] && $mybb->request_method == "post") {
|
if($mybb->input['dateuploaded'] && $mybb->request_method == "post") {
|
$mybb->input['dateuploaded'] = TIME_NOW-$mybb->input['dateuploaded']*60*60*24;
| $direction_fields['dateuploaded'] = TIME_NOW-$direction_fields['dateuploaded']*60*60*24;
|
} if($mybb->input['filesize'] && $mybb->request_method == "post") {
|
} if($mybb->input['filesize'] && $mybb->request_method == "post") {
|
$mybb->input['filesize'] *= 1024;
| $direction_fields['filesize'] *= 1024;
|
}
|
}
|
$direction_fields = array("dateuploaded", "filesize", "downloads"); foreach($direction_fields as $search_field)
| foreach($direction_fields as $field_name => $field_content)
|
{
|
{
|
$direction_field = $search_field."_dir"; if($mybb->input[$search_field] && $mybb->input[$direction_field])
| $direction_field = $field_name."_dir"; if($mybb->input[$field_name] && $mybb->input[$direction_field])
|
{ switch($mybb->input[$direction_field]) {
| { switch($mybb->input[$direction_field]) {
|
Zeile 694 | Zeile 726 |
---|
default: $direction = "="; }
|
default: $direction = "="; }
|
$search_sql .= " AND a.{$search_field}{$direction}'".$db->escape_string($mybb->input[$search_field])."'";
| $search_sql .= " AND a.{$field_name}{$direction}'".$field_content."'";
|
} } if(!$errors)
| } } if(!$errors)
|
Zeile 718 | Zeile 750 |
---|
// Now we fetch the results if there were 100% no errors if(!$errors) {
|
// Now we fetch the results if there were 100% no errors if(!$errors) {
|
$mybb->input['perpage'] = $mybb->get_input('perpage', 1);
| $mybb->input['perpage'] = $mybb->get_input('perpage', MyBB::INPUT_INT);
|
if(!$mybb->input['perpage']) { $mybb->input['perpage'] = 20; }
|
if(!$mybb->input['perpage']) { $mybb->input['perpage'] = 20; }
|
$mybb->input['page'] = $mybb->get_input('page', 1);
| $mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT);
|
if($mybb->input['page']) { $start = ($mybb->input['page'] - 1) * $mybb->input['perpage'];
| if($mybb->input['page']) { $start = ($mybb->input['page'] - 1) * $mybb->input['perpage'];
|
Zeile 835 | Zeile 867 |
---|
$form_container->output_row($lang->name_contains, $lang->name_contains_desc, $form->generate_text_box('filename', $mybb->input['filename'], array('id' => 'filename')), 'filename'); $form_container->output_row($lang->type_contains, "", $form->generate_text_box('mimetype', $mybb->input['mimetype'], array('id' => 'mimetype')), 'mimetype'); $form_container->output_row($lang->forum_is, "", $form->generate_forum_select('forum[]', $mybb->input['forum'], array('multiple' => true, 'size' => 5, 'id' => 'forum')), 'forum');
|
$form_container->output_row($lang->name_contains, $lang->name_contains_desc, $form->generate_text_box('filename', $mybb->input['filename'], array('id' => 'filename')), 'filename'); $form_container->output_row($lang->type_contains, "", $form->generate_text_box('mimetype', $mybb->input['mimetype'], array('id' => 'mimetype')), 'mimetype'); $form_container->output_row($lang->forum_is, "", $form->generate_forum_select('forum[]', $mybb->input['forum'], array('multiple' => true, 'size' => 5, 'id' => 'forum')), 'forum');
|
$form_container->output_row($lang->username_is, "", $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
| $form_container->output_row($lang->username_is, "", $form->generate_text_box('username', htmlspecialchars_uni($mybb->get_input('username')), array('id' => 'username')), 'username');
|
$more_options = array( "less_than" => $lang->more_than,
| $more_options = array( "less_than" => $lang->more_than,
|
Zeile 848 | Zeile 880 |
---|
"less_than" => $lang->less_than );
|
"less_than" => $lang->less_than );
|
$form_container->output_row($lang->date_posted_is, "", $form->generate_select_box('dateuploaded_dir', $more_options, $mybb->input['dateuploaded_dir'], array('id' => 'dateuploaded_dir'))." ".$form->generate_text_box('dateuploaded', $mybb->input['dateuploaded'], array('id' => 'dateuploaded'))." {$lang->days_ago}", 'dateuploaded'); $form_container->output_row($lang->file_size_is, "", $form->generate_select_box('filesize_dir', $greater_options, $mybb->input['filesize_dir'], array('id' => 'filesize_dir'))." ".$form->generate_text_box('filesize', $mybb->input['filesize'], array('id' => 'filesize'))." {$lang->kb}", 'dateuploaded'); $form_container->output_row($lang->download_count_is, "", $form->generate_select_box('downloads_dir', $greater_options, $mybb->input['downloads_dir'], array('id' => 'downloads_dir'))." ".$form->generate_text_box('downloads', $mybb->input['downloads'], array('id' => 'downloads'))."", 'dateuploaded');
| $form_container->output_row($lang->date_posted_is, "", $form->generate_select_box('dateuploaded_dir', $more_options, $mybb->input['dateuploaded_dir'], array('id' => 'dateuploaded_dir'))." ".$form->generate_numeric_field('dateuploaded', $mybb->input['dateuploaded'], array('id' => 'dateuploaded', 'min' => 0))." {$lang->days_ago}", 'dateuploaded'); $form_container->output_row($lang->file_size_is, "", $form->generate_select_box('filesize_dir', $greater_options, $mybb->input['filesize_dir'], array('id' => 'filesize_dir'))." ".$form->generate_numeric_field('filesize', $mybb->input['filesize'], array('id' => 'filesize', 'min' => 0))." {$lang->kb}", 'dateuploaded'); $form_container->output_row($lang->download_count_is, "", $form->generate_select_box('downloads_dir', $greater_options, $mybb->input['downloads_dir'], array('id' => 'downloads_dir'))." ".$form->generate_numeric_field('downloads', $mybb->input['downloads'], array('id' => 'downloads', 'min' => 0))."", 'dateuploaded');
|
$form_container->end();
$form_container = new FormContainer($lang->display_options);
| $form_container->end();
$form_container = new FormContainer($lang->display_options);
|
Zeile 866 | Zeile 898 |
---|
"desc" => $lang->desc ); $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('order', $sort_directions, $mybb->input['order'], array('id' => 'order')), 'sortby');
|
"desc" => $lang->desc ); $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('order', $sort_directions, $mybb->input['order'], array('id' => 'order')), 'sortby');
|
$form_container->output_row($lang->results_per_page, "", $form->generate_text_box('perpage', $mybb->input['perpage'], array('id' => 'perpage')), 'perpage');
| $form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $mybb->input['perpage'], array('id' => 'perpage', 'min' => 1)), 'perpage');
|
$form_container->end();
$buttons[] = $form->generate_submit_button($lang->button_find_attachments);
| $form_container->end();
$buttons[] = $form->generate_submit_button($lang->button_find_attachments);
|
Zeile 876 | Zeile 908 |
---|
$page->output_footer(); }
|
$page->output_footer(); }
|
| /** * @param array $attachment * @param DefaultTable $table * @param bool $use_form */
|
function build_attachment_row($attachment, &$table, $use_form=false) {
|
function build_attachment_row($attachment, &$table, $use_form=false) {
|
global $mybb, $form;
| global $mybb, $form, $lang;
|
$attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
// Here we do a bit of detection, we want to automatically check for removal any missing attachments and any not assigned to a post uploaded > 24hours ago
| $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
// Here we do a bit of detection, we want to automatically check for removal any missing attachments and any not assigned to a post uploaded > 24hours ago
|
Zeile 927 | Zeile 964 |
---|
if($attachment['user_username']) {
|
if($attachment['user_username']) {
|
$attachment['username'] = $attachment['username'];
| $attachment['username'] = $attachment['user_username'];
|
}
|
}
|
$table->construct_cell(build_profile_link($attachment['username'], $attachment['uid'], "_blank"), array("class" => "align_center"));
| $table->construct_cell(build_profile_link(htmlspecialchars_uni($attachment['username']), $attachment['uid'], "_blank"), array("class" => "align_center"));
|
$table->construct_cell("<a href=\"../".get_post_link($attachment['pid'])."\" target=\"_blank\">".htmlspecialchars_uni($attachment['subject'])."</a>", array("class" => "align_center")); $table->construct_cell(my_number_format($attachment['downloads']), array("class" => "align_center")); if($attachment['dateuploaded'] > 0)
| $table->construct_cell("<a href=\"../".get_post_link($attachment['pid'])."\" target=\"_blank\">".htmlspecialchars_uni($attachment['subject'])."</a>", array("class" => "align_center")); $table->construct_cell(my_number_format($attachment['downloads']), array("class" => "align_center")); if($attachment['dateuploaded'] > 0)
|