Vergleich admin/modules/forum/attachments.php - 1.8.0 - 1.8.36

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 38Zeile 38
}

$plugins->run_hooks("admin_forum_attachments_begin");

}

$plugins->run_hooks("admin_forum_attachments_begin");

 

$uploadspath_abs = mk_path_abs($mybb->settings['uploadspath']);

$default_perpage = 20;
$perpage = $mybb->get_input('perpage', MyBB::INPUT_INT);
if(!$perpage)
{
$perpage = $default_perpage;
}


if($mybb->input['action'] == "delete")
{
$plugins->run_hooks("admin_forum_attachments_delete");


if($mybb->input['action'] == "delete")
{
$plugins->run_hooks("admin_forum_attachments_delete");


if(!is_array($mybb->input['aids']))
{
$mybb->input['aids'] = array((int)$mybb->input['aid']);
}
else
{
$mybb->input['aids'] = array_map("intval", $mybb->input['aids']);
}

if(count($mybb->input['aids']) < 1)









if(isset($mybb->input['aids']))
{
if(!is_array($mybb->input['aids']))
{
$mybb->input['aids'] = array($mybb->get_input('aid', MyBB::INPUT_INT));
}
else
{
$mybb->input['aids'] = array_map("intval", $mybb->input['aids']);
}
}
else
{
$mybb->input['aids'] = array();
}

if(count($mybb->input['aids']) < 1)

	{
flash_message($lang->error_nothing_selected, 'error');
admin_redirect("index.php?module=forum-attachments");

	{
flash_message($lang->error_nothing_selected, 'error');
admin_redirect("index.php?module=forum-attachments");

Zeile 85Zeile 101
		admin_redirect("index.php?module=forum-attachments");
}
else

		admin_redirect("index.php?module=forum-attachments");
}
else

	{

	{

		$aids = array();
foreach($mybb->input['aids'] as $aid)
{

		$aids = array();
foreach($mybb->input['aids'] as $aid)
{

Zeile 129Zeile 145
	$table->construct_row();

$table->output($lang->general_stats);

	$table->construct_row();

$table->output($lang->general_stats);





	// Fetch the most popular attachments

	// Fetch the most popular attachments

	$table = new Table;
$table->construct_header($lang->attachments, array('colspan' => 2));
$table->construct_header($lang->size, array('width' => '10%', 'class' => 'align_center'));
$table->construct_header($lang->posted_by, array('width' => '20%', 'class' => 'align_center'));
$table->construct_header($lang->thread, array('width' => '25%', 'class' => 'align_center'));
$table->construct_header($lang->downloads, array('width' => '10%', 'class' => 'align_center'));
$table->construct_header($lang->date_uploaded, array("class" => "align_center"));

$query = $db->query("
SELECT a.*, p.tid, p.fid, t.subject, p.uid, p.username, u.username AS user_username

	$table = new Table;
$table->construct_header($lang->attachments, array('colspan' => 2));
$table->construct_header($lang->size, array('width' => '10%', 'class' => 'align_center'));
$table->construct_header($lang->posted_by, array('width' => '20%', 'class' => 'align_center'));
$table->construct_header($lang->thread, array('width' => '25%', 'class' => 'align_center'));
$table->construct_header($lang->downloads, array('width' => '10%', 'class' => 'align_center'));
$table->construct_header($lang->date_uploaded, array("class" => "align_center"));

$query = $db->query("
SELECT a.*, p.tid, p.fid, t.subject, p.uid, p.username, u.username AS user_username

		FROM ".TABLE_PREFIX."attachments a
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
ORDER BY a.downloads DESC

		FROM ".TABLE_PREFIX."attachments a
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
ORDER BY a.downloads DESC

		LIMIT 5
");
while($attachment = $db->fetch_array($query))
{
build_attachment_row($attachment, $table);
}

		LIMIT 5
");
while($attachment = $db->fetch_array($query))
{
build_attachment_row($attachment, $table);
}

	$table->output($lang->popular_attachments);

// Fetch the largest attachments

	$table->output($lang->popular_attachments);

// Fetch the largest attachments

Zeile 161Zeile 177
	$table->construct_header($lang->posted_by, array('width' => '20%', 'class' => 'align_center'));
$table->construct_header($lang->thread, array('width' => '25%', 'class' => 'align_center'));
$table->construct_header($lang->downloads, array('width' => '10%', 'class' => 'align_center'));

	$table->construct_header($lang->posted_by, array('width' => '20%', 'class' => 'align_center'));
$table->construct_header($lang->thread, array('width' => '25%', 'class' => 'align_center'));
$table->construct_header($lang->downloads, array('width' => '10%', 'class' => 'align_center'));

	$table->construct_header($lang->date_uploaded, array("class" => "align_center"));


	$table->construct_header($lang->date_uploaded, array("class" => "align_center"));


	$query = $db->query("
SELECT a.*, p.tid, p.fid, t.subject, p.uid, p.username, u.username AS user_username
FROM ".TABLE_PREFIX."attachments a

	$query = $db->query("
SELECT a.*, p.tid, p.fid, t.subject, p.uid, p.username, u.username AS user_username
FROM ".TABLE_PREFIX."attachments a

Zeile 173Zeile 189
		LIMIT 5
");
while($attachment = $db->fetch_array($query))

		LIMIT 5
");
while($attachment = $db->fetch_array($query))

	{

	{

		build_attachment_row($attachment, $table);
}
$table->output($lang->largest_attachments);

		build_attachment_row($attachment, $table);
}
$table->output($lang->largest_attachments);

Zeile 184Zeile 200
	$table->construct_header($lang->total_size, array('width' => '20%', 'class' => 'align_center'));

switch($db->type)

	$table->construct_header($lang->total_size, array('width' => '20%', 'class' => 'align_center'));

switch($db->type)

	{

	{

		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 207Zeile 223
	}
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&amp;results=1&amp;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&amp;results=1&amp;username=".urlencode($user['username'])."\" target=\"_blank\">".get_friendly_size($user['totalsize'])."</a>", array('class' => 'align_center'));
$table->construct_row();
}

Zeile 221Zeile 237
}

if($mybb->input['action'] == "delete_orphans" && $mybb->request_method == "post")

}

if($mybb->input['action'] == "delete_orphans" && $mybb->request_method == "post")

{

{

	$plugins->run_hooks("admin_forum_attachments_delete_orphans");

	$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']))

	{
function clean_filename($string)
{
return str_replace(array(".."), "", $string);
}
$mybb->input['orphaned_files'] = array_map("clean_filename", $mybb->input['orphaned_files']);
foreach($mybb->input['orphaned_files'] as $file)
{
if(!@unlink(MYBB_ROOT.$mybb->settings['uploadspath']."/".$file))
{
$error = true;
}










	{
foreach($mybb->input['orphaned_files'] as $file)
{
$file = str_replace('..', '', $file);
$path = $uploadspath_abs."/".$file;
$real_path = realpath($path);

if($real_path === false || strpos(str_replace('\\', '/', $real_path), str_replace('\\', '/', realpath(MYBB_ROOT)).'/') !== 0 || $real_path == realpath(MYBB_ROOT.'install/lock'))
{
$error_count++;
continue;
}

if(!@unlink($uploadspath_abs."/".$file))
{
$error_count++;
}
else
{
$success_count++;
}

		}
}


		}
}


Zeile 258Zeile 285
			{
remove_attachment($attachment['pid'], null, $attachment['aid']);
}

			{
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");





	// Log admin action
log_admin_action();


	// Log admin action
log_admin_action();


	if($error == true)
{
flash_message($lang->error_not_all_removed, 'error');
}
else

	$message = '';
$status = 'success';
if($error_count > 0)



	{

	{

		flash_message($lang->success_orphan_deleted, 'success');


		$status = 'error';
$message = $lang->sprintf($lang->error_count, $error_count);

	}

	}

	admin_redirect("index.php?module=forum-attachments");















if($success_count > 0)
{
if($error_count > 0)
{
$message .= '<br />'.$lang->sprintf($lang->success_count, $success_count);
}
else
{
$message = $lang->success_orphan_deleted;
}
}
flash_message($message, $status);
admin_redirect('index.php?module=forum-attachments');

}

if($mybb->input['action'] == "orphans")

}

if($mybb->input['action'] == "orphans")

Zeile 288Zeile 328
	// - Files uploaded > 24h ago not attached to a real post

// This process is quite intensive so we split it up in to 2 steps, one which scans the file system and the other which scans the database.

	// - Files uploaded > 24h ago not attached to a real post

// This process is quite intensive so we split it up in to 2 steps, one which scans the file system and the other which scans the database.

 

$mybb->input['step'] = $mybb->get_input('step', MyBB::INPUT_INT);


// Finished second step, show results
if($mybb->input['step'] == 3)


// Finished second step, show results
if($mybb->input['step'] == 3)

Zeile 296Zeile 338

$reults = 0;
// Incoming attachments which exist as files but not in database


$reults = 0;
// Incoming attachments which exist as files but not in database

		if($mybb->input['bad_attachments'])
{

		if(!empty($mybb->input['bad_attachments']))
{

			$bad_attachments = my_unserialize($mybb->input['bad_attachments']);
$results = count($bad_attachments);

			$bad_attachments = my_unserialize($mybb->input['bad_attachments']);
$results = count($bad_attachments);

		}


		}


		$aids = array();

		$aids = array();

		if($mybb->input['missing_attachment_files'])
{

		if(!empty($mybb->input['missing_attachment_files']))
{

			$missing_attachment_files = my_unserialize($mybb->input['missing_attachment_files']);
$aids = array_merge($aids, $missing_attachment_files);

			$missing_attachment_files = my_unserialize($mybb->input['missing_attachment_files']);
$aids = array_merge($aids, $missing_attachment_files);

		}

if($mybb->input['missing_threads'])
{

		}

if(!empty($mybb->input['missing_threads']))
{

			$missing_threads = my_unserialize($mybb->input['missing_threads']);
$aids = array_merge($aids, $missing_threads);

			$missing_threads = my_unserialize($mybb->input['missing_threads']);
$aids = array_merge($aids, $missing_threads);

		}

		}





		if($mybb->input['incomplete_attachments'])

		if(!empty($mybb->input['incomplete_attachments']))

		{
$incomplete_attachments = my_unserialize($mybb->input['incomplete_attachments']);
$aids = array_merge($aids, $incomplete_attachments);
}

foreach($aids as $key => $aid)

		{
$incomplete_attachments = my_unserialize($mybb->input['incomplete_attachments']);
$aids = array_merge($aids, $incomplete_attachments);
}

foreach($aids as $key => $aid)

		{

		{

			$aids[$key] = (int)$aid;

			$aids[$key] = (int)$aid;

		}

$results += count($aids);

		}

$results = count($aids);


if($results == 0)
{
flash_message($lang->success_no_orphans, 'success');
admin_redirect("index.php?module=forum-attachments");


if($results == 0)
{
flash_message($lang->success_no_orphans, 'success');
admin_redirect("index.php?module=forum-attachments");

		}


		}


		$page->output_header($lang->orphan_results);
$page->output_nav_tabs($sub_tabs, 'find_orphans');

		$page->output_header($lang->orphan_results);
$page->output_nav_tabs($sub_tabs, 'find_orphans');





		$form = new Form("index.php?module=forum-attachments&amp;action=delete_orphans", "post");

$table = new Table;

		$form = new Form("index.php?module=forum-attachments&amp;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($form->generate_check_box('allbox', '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->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)
{

				$file_path = MYBB_ROOT.$mybb->settings['uploadspath']."/".$file;
$filesize = get_friendly_size(filesize($file_path));
$table->construct_cell($form->generate_check_box('orphaned_files[]', $file, '', array('checked' => true)));
$table->construct_cell(get_attachment_icon(get_extension($attachment['filename'])), array('width' => 1));
$table->construct_cell("<span class=\"float_right\">{$filesize}</span>{$file}");
$table->construct_cell($lang->reason_not_in_table, array('class' => 'align_center'));
$table->construct_cell(my_date('relative', filemtime($file_path)), array('class' => 'align_center'));
$table->construct_row();






				$file_path = $uploadspath_abs."/".$file;

if(file_exists($file_path))
{
$filename = htmlspecialchars_uni($file);
$filesize = get_friendly_size(filesize($file_path));
$table->construct_cell($form->generate_check_box('orphaned_files[]', $file, '', array('checked' => true)));
$table->construct_cell(get_attachment_icon(get_extension($attachment['filename'])), array('width' => 1));
$table->construct_cell("<span class=\"float_right\">{$filesize}</span>{$filename}");
$table->construct_cell($lang->reason_not_in_table, array('class' => 'align_center'));
$table->construct_cell(my_date('relative', filemtime($file_path)), array('class' => 'align_center'));
$table->construct_row();
}

			}
}


			}
}


Zeile 370Zeile 417
				if($missing_attachment_files[$attachment['aid']])
{
$reason = $lang->reason_file_missing;

				if($missing_attachment_files[$attachment['aid']])
{
$reason = $lang->reason_file_missing;

				}

				}

				else if($missing_threads[$attachment['aid']])
{
$reason = $lang->reason_thread_deleted;

				else if($missing_threads[$attachment['aid']])
{
$reason = $lang->reason_thread_deleted;

Zeile 381Zeile 428
				}
$table->construct_cell($form->generate_check_box('orphaned_attachments[]', $attachment['aid'], '', array('checked' => true)));
$table->construct_cell(get_attachment_icon(get_extension($attachment['filename'])), array('width' => 1));

				}
$table->construct_cell($form->generate_check_box('orphaned_attachments[]', $attachment['aid'], '', array('checked' => true)));
$table->construct_cell(get_attachment_icon(get_extension($attachment['filename'])), array('width' => 1));

				$table->construct_cell("<span class=\"float_right\">".get_friendly_size($attachment['filesize'])."</span>{$attachment['filename']}", array('class' => $cell_class));

				$table->construct_cell("<span class=\"float_right\">".get_friendly_size($attachment['filesize'])."</span>{$attachment['filename']}");

				$table->construct_cell($reason, array('class' => 'align_center'));
if($attachment['dateuploaded'])
{

				$table->construct_cell($reason, array('class' => 'align_center'));
if($attachment['dateuploaded'])
{

Zeile 402Zeile 449
		$form->end();
$page->output_footer();
}

		$form->end();
$page->output_footer();
}





	// Running second step - scan the database
else if($mybb->input['step'] == 2)
{
$plugins->run_hooks("admin_forum_attachments_orphans_step2");

	// Running second step - scan the database
else if($mybb->input['step'] == 2)
{
$plugins->run_hooks("admin_forum_attachments_orphans_step2");





		$page->output_header("{$lang->orphan_attachments_search} - {$lang->step2}");

		$page->output_header("{$lang->orphan_attachments_search} - {$lang->step2}");





		$page->output_nav_tabs($sub_tabs, 'find_orphans');
echo "<h3>{$lang->step2of2}</h3>";
echo "<p class=\"align_center\">{$lang->step2of2_line1}</p>";

		$page->output_nav_tabs($sub_tabs, 'find_orphans');
echo "<h3>{$lang->step2of2}</h3>";
echo "<p class=\"align_center\">{$lang->step2of2_line1}</p>";

		echo "<p class=\"align_center\">{$lang->step_line2}</p>";
echo "<p class=\"align_center\"><img src=\"styles/{$page->style}/images/spinner_big.gif\" alt=\"{$lang->scanning}\" id=\"spinner\" /></p>";

$page->output_footer(false);
flush();


		echo "<p class=\"align_center\">{$lang->step_line2}</p>";
echo "<p class=\"align_center\"><img src=\"styles/{$page->style}/images/spinner_big.gif\" alt=\"{$lang->scanning}\" id=\"spinner\" /></p>";

$page->output_footer(false);
flush();


		$missing_attachment_files = array();
$missing_threads = array();
$incomplete_attachments = array();

		$missing_attachment_files = array();
$missing_threads = array();
$incomplete_attachments = array();

Zeile 431Zeile 478
		while($attachment = $db->fetch_array($query))
{
// Check if the attachment exists in the file system

		while($attachment = $db->fetch_array($query))
{
// Check if the attachment exists in the file system

			if(!file_exists(MYBB_ROOT.$mybb->settings['uploadspath']."/{$attachment['attachname']}"))

			if(!file_exists($uploadspath_abs."/{$attachment['attachname']}"))

			{
$missing_attachment_files[$attachment['aid']] = $attachment['aid'];
}

			{
$missing_attachment_files[$attachment['aid']] = $attachment['aid'];
}

Zeile 450Zeile 497
		// Now send the user to the final page
$form = new Form("index.php?module=forum-attachments&amp;action=orphans&amp;step=3", "post", "redirect_form", 0, "");
// Scan complete

		// Now send the user to the final page
$form = new Form("index.php?module=forum-attachments&amp;action=orphans&amp;step=3", "post", "redirect_form", 0, "");
// Scan complete

		if($mybb->input['bad_attachments'])

		if($mybb->get_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)
{

		{
echo $form->generate_hidden_field("bad_attachments", $mybb->input['bad_attachments']);
}
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 "<script type=\"text/javascript\">$(function() {
window.setTimeout(
function() {

			echo $form->generate_hidden_field("incomplete_attachments", $incomplete_attachments);
}
$form->end();
echo "<script type=\"text/javascript\">$(function() {
window.setTimeout(
function() {

						$(\"#redirect_form\").submit();

						$(\"#redirect_form\").trigger('submit');

					}, 100
);
});</script>";

					}, 100
);
});</script>";

Zeile 484Zeile 531
	{
$plugins->run_hooks("admin_forum_attachments_orphans_step1");


	{
$plugins->run_hooks("admin_forum_attachments_orphans_step1");


 
		/**
* @param string $dir
*/

		function scan_attachments_directory($dir="")
{

		function scan_attachments_directory($dir="")
{

			global $db, $mybb, $bad_attachments, $attachments_to_check;

			global $db, $mybb, $bad_attachments, $attachments_to_check, $uploadspath_abs;





			$real_dir = MYBB_ROOT.$mybb->settings['uploadspath'];

			$real_dir = $uploadspath_abs;

			$false_dir = "";
if($dir)
{

			$false_dir = "";
if($dir)
{

Zeile 541Zeile 591
				}
closedir($dh);
// Any reamining to check?

				}
closedir($dh);
// Any reamining to check?

				if(count($attachments_to_check) > 0)

				if(!empty($attachments_to_check))

				{
$attachments_to_check = array_map(array($db, "escape_string"), $attachments_to_check);
$attachment_names = "'".implode("','", $attachments_to_check)."'";

				{
$attachments_to_check = array_map(array($db, "escape_string"), $attachments_to_check);
$attachment_names = "'".implode("','", $attachments_to_check)."'";

Zeile 586Zeile 636
		// 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 "<script type=\"text/javascript\">$(function() {
window.setTimeout(
function() {

			echo $form->generate_hidden_field("bad_attachments", $bad_attachments);
}
$form->end();
echo "<script type=\"text/javascript\">$(function() {
window.setTimeout(
function() {

						$(\"#redirect_form\").submit();

						$(\"#redirect_form\").trigger('submit');

					}, 100
);
});</script>";

					}, 100
);
});</script>";

Zeile 604Zeile 654
if(!$mybb->input['action'])
{
$plugins->run_hooks("admin_forum_attachments_start");

if(!$mybb->input['action'])
{
$plugins->run_hooks("admin_forum_attachments_start");


if($mybb->request_method == "post" || $mybb->input['results'] == 1)


if($mybb->request_method == "post" || $mybb->get_input('results', MyBB::INPUT_INT) == 1)

	{
$search_sql = '1=1';

	{
$search_sql = '1=1';

 

$plugins->run_hooks("admin_forum_attachments_commit_start");


// Build the search SQL for users



// Build the search SQL for users


Zeile 615Zeile 667
		$user_like_fields = array("filename", "filetype");
foreach($user_like_fields as $search_field)
{

		$user_like_fields = array("filename", "filetype");
foreach($user_like_fields as $search_field)
{

			if($mybb->input[$search_field])

			if($mybb->get_input($search_field))

			{
$search_sql .= " AND a.{$search_field} LIKE '%".$db->escape_string_like($mybb->input[$search_field])."%'";
}
}

$errors = array();

			{
$search_sql .= " AND a.{$search_field} LIKE '%".$db->escape_string_like($mybb->input[$search_field])."%'";
}
}

$errors = array();

 

// Normal users only
if($mybb->get_input('user_types', MyBB::INPUT_INT) == 1)
{
$user_types = 1;
}
// Guests only
elseif($mybb->get_input('user_types', MyBB::INPUT_INT) == -1)
{
$user_types = -1;
$search_sql .= " AND a.uid='0'";
}
// Users & Guests
else
{
$user_types = 0;
}


// Username matching
if($mybb->input['username'])


// Username matching
if($mybb->input['username'])

Zeile 630Zeile 699

if(!$user['uid'])
{


if(!$user['uid'])
{

				$errors[] = $lang->error_invalid_username;










				if($user_types == 1)
{
$errors[] = $lang->error_invalid_username;
}
else
{
// Don't error if we are searching for guests or users & guests
$search_sql .= " AND p.username LIKE '%".$db->escape_string_like($mybb->input['username'])."%'";
}


			}
else
{

			}
else
{

Zeile 641Zeile 719
		$forum_cache = cache_forums();

// Searching for attachments in a specific forum, we need to fetch all child forums too

		$forum_cache = cache_forums();

// Searching for attachments in a specific forum, we need to fetch all child forums too

		if($mybb->input['forum'])

		if(!empty($mybb->input['forum']))

		{
if(!is_array($mybb->input['forum']))
{

		{
if(!is_array($mybb->input['forum']))
{

Zeile 652Zeile 730
			foreach($mybb->input['forum'] as $fid)
{
if(!$forum_cache[$fid])

			foreach($mybb->input['forum'] as $fid)
{
if(!$forum_cache[$fid])

				{

				{

					$errors[] = $lang->error_invalid_forums;
break;
}

					$errors[] = $lang->error_invalid_forums;
break;
}

Zeile 668Zeile 746
		}

// LESS THAN or GREATER THAN

		}

// LESS THAN or GREATER THAN

		if($mybb->input['dateuploaded'] && $mybb->request_method == "post")







		$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(!empty($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(!empty($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(!empty($mybb->input[$field_name]) && !empty($mybb->input[$direction_field]))

			{
switch($mybb->input[$direction_field])
{

			{
switch($mybb->input[$direction_field])
{

Zeile 694Zeile 777
					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 702Zeile 785
			// Lets fetch out how many results we have
$query = $db->query("
SELECT COUNT(a.aid) AS num_results

			// Lets fetch out how many results we have
$query = $db->query("
SELECT COUNT(a.aid) AS num_results

				FROM ".TABLE_PREFIX."attachments a
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
WHERE {$search_sql}

				FROM ".TABLE_PREFIX."attachments a
LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid)
WHERE {$search_sql}

			");
$num_results = $db->fetch_field($query, "num_results");


			");
$num_results = $db->fetch_field($query, "num_results");


Zeile 718Zeile 801
		// 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);
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'])
{

			if($mybb->input['page'])
{

				$start = ($mybb->input['page'] - 1) * $mybb->input['perpage'];

				$start = ($mybb->input['page'] - 1) * $perpage;

			}
else
{

			}
else
{

Zeile 742Zeile 819
					break;
case "downloads":
$sort_field = "a.downloads";

					break;
case "downloads":
$sort_field = "a.downloads";

					break;

					break;

				case "dateuploaded":
$sort_field = "a.dateuploaded";

				case "dateuploaded":
$sort_field = "a.dateuploaded";

					break;

					break;

				case "username":
$sort_field = "u.username";
break;
default:
$sort_field = "a.filename";
$mybb->input['sortby'] = "filename";

				case "username":
$sort_field = "u.username";
break;
default:
$sort_field = "a.filename";
$mybb->input['sortby'] = "filename";

			}


			}


			if($mybb->input['order'] != "desc")
{
$mybb->input['order'] = "asc";
}

			if($mybb->input['order'] != "desc")
{
$mybb->input['order'] = "asc";
}

 

$plugins->run_hooks("admin_forum_attachments_commit");


$page->add_breadcrumb_item($lang->results);
$page->output_header($lang->index_find_attachments);


$page->add_breadcrumb_item($lang->results);
$page->output_header($lang->index_find_attachments);

Zeile 767Zeile 846
			$form = new Form("index.php?module=forum-attachments&amp;action=delete", "post");

$table = new Table;

			$form = new Form("index.php?module=forum-attachments&amp;action=delete", "post");

$table = new Table;

			$table->construct_header($form->generate_check_box('checkall', '1', '', array('class' => 'checkall')), array( 'width' => 1));

			$table->construct_header($form->generate_check_box('allbox', '1', '', array('class' => 'checkall')), array( 'width' => 1));

			$table->construct_header($lang->attachments, array('colspan' => 2));
$table->construct_header($lang->size, array('width' => '10%', 'class' => 'align_center'));
$table->construct_header($lang->posted_by, array('width' => '20%', 'class' => 'align_center'));

			$table->construct_header($lang->attachments, array('colspan' => 2));
$table->construct_header($lang->size, array('width' => '10%', 'class' => 'align_center'));
$table->construct_header($lang->posted_by, array('width' => '20%', 'class' => 'align_center'));

Zeile 784Zeile 863
				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
WHERE {$search_sql}
ORDER BY {$sort_field} {$mybb->input['order']}

				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=a.uid)
WHERE {$search_sql}
ORDER BY {$sort_field} {$mybb->input['order']}

				LIMIT {$start}, {$mybb->input['perpage']}

				LIMIT {$start}, {$perpage}

			");
while($attachment = $db->fetch_array($query))
{

			");
while($attachment = $db->fetch_array($query))
{

Zeile 792Zeile 871
			}

// Need to draw pagination for this result set

			}

// Need to draw pagination for this result set

			if($num_results > $mybb->input['perpage'])


			$pagination = '';
if($num_results > $perpage)

			{
$pagination_url = "index.php?module=forum-attachments&amp;results=1";

			{
$pagination_url = "index.php?module=forum-attachments&amp;results=1";

				$pagination_vars = array('perpage', 'sortby', 'order', 'filename', 'mimetype', 'username', 'fid', 'downloads', 'downloads_dir', 'dateuploaded', 'dateuploaded_dir', 'filesize', 'filesize_dir');

				$pagination_vars = array('perpage', 'sortby', 'order', 'filename', 'mimetype', 'username', 'downloads', 'downloads_dir', 'dateuploaded', 'dateuploaded_dir', 'filesize', 'filesize_dir');

				foreach($pagination_vars as $var)
{
if($mybb->input[$var])

				foreach($pagination_vars as $var)
{
if($mybb->input[$var])

Zeile 803Zeile 883
						$pagination_url .= "&{$var}=".urlencode($mybb->input[$var]);
}
}

						$pagination_url .= "&{$var}=".urlencode($mybb->input[$var]);
}
}

				$pagination = draw_admin_pagination($mybb->input['page'], $mybb->input['perpage'], $num_results, $pagination_url);








				if(!empty($mybb->input['forum']) && is_array($mybb->input['forum']))
{
foreach($mybb->input['forum'] as $fid)
{
$pagination_url .= "&forum[]=".(int)$fid;
}
}
$pagination = draw_admin_pagination($mybb->input['page'], $perpage, $num_results, $pagination_url);

			}

echo $pagination;

			}

echo $pagination;

Zeile 832Zeile 919
	$form = new Form("index.php?module=forum-attachments", "post");

$form_container = new FormContainer($lang->find_where);

	$form = new Form("index.php?module=forum-attachments", "post");

$form_container = new FormContainer($lang->find_where);

	$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->name_contains, $lang->name_contains_desc, $form->generate_text_box('filename', $mybb->get_input('filename'), array('id' => 'filename')), 'filename');
$form_container->output_row($lang->type_contains, "", $form->generate_text_box('mimetype', $mybb->get_input('mimetype'), array('id' => 'mimetype')), 'mimetype');
$form_container->output_row($lang->forum_is, "", $form->generate_forum_select('forum[]', $mybb->get_input('forum', MyBB::INPUT_INT), array('multiple' => true, 'size' => 5, 'id' => 'forum')), 'forum');
$form_container->output_row($lang->username_is, "", $form->generate_text_box('username', htmlspecialchars_uni($mybb->get_input('username')), array('id' => 'username')), 'username');
$form_container->output_row($lang->poster_is, "", $form->generate_select_box('user_types', array('0' => $lang->poster_is_either, '1' => $lang->poster_is_user, '-1' => $lang->poster_is_guest), $mybb->get_input('user_types', MyBB::INPUT_INT), array('id' => 'guests')), 'user_types');


$more_options = array(
"less_than" => $lang->more_than,


$more_options = array(
"less_than" => $lang->more_than,

Zeile 848Zeile 936
		"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->get_input('dateuploaded_dir'), array('id' => 'dateuploaded_dir'))." ".$form->generate_numeric_field('dateuploaded', $mybb->get_input('dateuploaded', MyBB::INPUT_INT), 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->get_input('filesize_dir'), array('id' => 'filesize_dir'))." ".$form->generate_numeric_field('filesize', $mybb->get_input('filesize', MyBB::INPUT_INT), 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->get_input('downloads_dir'), array('id' => 'downloads_dir'))." ".$form->generate_numeric_field('downloads', $mybb->get_input('downloads', MyBB::INPUT_INT), 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 865Zeile 953
		"asc" => $lang->asc,
"desc" => $lang->desc
);

		"asc" => $lang->asc,
"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->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->get_input('sortby'), array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('order', $sort_directions, $mybb->get_input('order'), array('id' => 'order')), 'sortby');
$form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $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 876Zeile 964
	$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
// Check if the attachment exists in the file system
$checked = false;
$title = $cell_class = '';

	$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
// Check if the attachment exists in the file system
$checked = false;
$title = $cell_class = '';

	if(!file_exists(MYBB_ROOT.$mybb->settings['uploadspath']."/{$attachment['attachname']}"))

	if(!file_exists(mk_path_abs($mybb->settings['uploadspath'])."/{$attachment['attachname']}"))

	{
$cell_class = "bad_attachment";
$title = $lang->error_not_found;

	{
$cell_class = "bad_attachment";
$title = $lang->error_not_found;

Zeile 927Zeile 1020

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)