PageRenderTime 33ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 15ms app.codeStats 0ms

/upload/admin/admin_forum_prune.php

http://torrentpier2.googlecode.com/
PHP | 68 lines | 54 code | 12 blank | 2 comment | 7 complexity | 776a4aeb1b6ec781c17dfe25206b887a MD5 | raw file
 1<?php
 2
 3// ACP Header - START
 4if (!empty($setmodules))
 5{
 6	$module['Forums']['Prune'] = basename(__FILE__);
 7	return;
 8}
 9require('./pagestart.php');
10// ACP Header - END
11
12$all_forums = -1;
13
14$pruned_total = 0;
15$prune_performed = false;
16
17function return_msg_prune ($status_msg)
18{
19	return $status_msg;
20}
21
22if (isset($_REQUEST['submit']))
23{
24	if (!$var =& $_REQUEST['f'] OR !$f_selected = get_id_ary($var))
25	{
26		message_die(GENERAL_MESSAGE, return_msg_prune('Forum not selected'));
27	}
28	if (!$var =& $_REQUEST['prunedays'] OR !$prunedays = abs(intval($var)))
29	{
30		message_die(GENERAL_MESSAGE, return_msg_prune($lang['NOT_DAYS']));
31	}
32
33	$prunetime = TIMENOW - 86400*$prunedays;
34	$forum_csv = in_array($all_forums, $f_selected) ? $all_forums : join(',', $f_selected);
35
36	$where_sql = ($forum_csv != $all_forums) ? "WHERE forum_id IN($forum_csv)" : '';
37
38	$sql = "SELECT forum_id, forum_name FROM ". BB_FORUMS ." $where_sql";
39
40	foreach (DB()->fetch_rowset($sql) as $i => $row)
41	{
42		$pruned_topics = topic_delete('prune', $row['forum_id'], $prunetime, !empty($_POST['prune_all_topic_types']));
43		$pruned_total += $pruned_topics;
44		$prune_performed = true;
45
46		$template->assign_block_vars('pruned', array(
47			'ROW_CLASS'     => !($i % 2) ? 'row1' : 'row2',
48			'FORUM_NAME'    => htmlCHR($row['forum_name']),
49			'PRUNED_TOPICS' => $pruned_topics,
50		));
51	}
52	if (!$prune_performed)
53	{
54		message_die(GENERAL_MESSAGE, return_msg_prune($lang['NONE_SELECTED']));
55	}
56	if (!$pruned_total)
57	{
58		message_die(GENERAL_MESSAGE, return_msg_prune($lang['NO_SEARCH_MATCH']));
59	}
60}
61
62$template->assign_vars(array(
63	'PRUNED_TOTAL'   => $pruned_total,
64	'S_PRUNE_ACTION' => basename(__FILE__),
65	'SEL_FORUM'      => get_forum_select('admin', 'f[]', null, 65, 16, '', $all_forums),
66));
67
68print_page('admin_forum_prune.tpl', 'admin');