[6] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * Copyright (C) 2008-2011 FluxBB |
---|
| 5 | * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
---|
| 6 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | // Make sure no one attempts to run this script "directly" |
---|
| 10 | if (!defined('PUN')) |
---|
| 11 | exit; |
---|
| 12 | |
---|
| 13 | // Make sure we have a usable language pack for admin. |
---|
| 14 | if (file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/admin_common.php')) |
---|
| 15 | $admin_language = $pun_user['language']; |
---|
| 16 | else if (file_exists(PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/admin_common.php')) |
---|
| 17 | $admin_language = $pun_config['o_default_lang']; |
---|
| 18 | else |
---|
| 19 | $admin_language = 'English'; |
---|
| 20 | |
---|
| 21 | // Attempt to load the admin_common language file |
---|
| 22 | require PUN_ROOT.'lang/'.$admin_language.'/admin_common.php'; |
---|
| 23 | |
---|
| 24 | // |
---|
| 25 | // Display the admin navigation menu |
---|
| 26 | // |
---|
| 27 | function generate_admin_menu($page = '') |
---|
| 28 | { |
---|
| 29 | global $pun_config, $pun_user, $lang_admin_common; |
---|
| 30 | |
---|
| 31 | $is_admin = $pun_user['g_id'] == PUN_ADMIN ? true : false; |
---|
| 32 | |
---|
| 33 | ?> |
---|
| 34 | <div id="adminconsole" class="block2col"> |
---|
| 35 | <div id="adminmenu" class="blockmenu"> |
---|
| 36 | <h2><span><?php echo $lang_admin_common['Moderator menu'] ?></span></h2> |
---|
| 37 | <div class="box"> |
---|
| 38 | <div class="inbox"> |
---|
| 39 | <ul> |
---|
| 40 | <li<?php if ($page == 'index') echo ' class="isactive"'; ?>><a href="admin_index.php"><?php echo $lang_admin_common['Index'] ?></a></li> |
---|
| 41 | <li<?php if ($page == 'users') echo ' class="isactive"'; ?>><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
---|
| 42 | <?php if ($is_admin || $pun_user['g_mod_ban_users'] == '1'): ?> <li<?php if ($page == 'bans') echo ' class="isactive"'; ?>><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li> |
---|
| 43 | <?php endif; if ($is_admin || $pun_config['o_report_method'] == '0' || $pun_config['o_report_method'] == '2'): ?> <li<?php if ($page == 'reports') echo ' class="isactive"'; ?>><a href="admin_reports.php"><?php echo $lang_admin_common['Reports'] ?></a></li> |
---|
| 44 | <?php endif; ?> </ul> |
---|
| 45 | </div> |
---|
| 46 | </div> |
---|
| 47 | <?php |
---|
| 48 | |
---|
| 49 | if ($is_admin) |
---|
| 50 | { |
---|
| 51 | |
---|
| 52 | ?> |
---|
| 53 | <h2 class="block2"><span><?php echo $lang_admin_common['Admin menu'] ?></span></h2> |
---|
| 54 | <div class="box"> |
---|
| 55 | <div class="inbox"> |
---|
| 56 | <ul> |
---|
| 57 | <li<?php if ($page == 'options') echo ' class="isactive"'; ?>><a href="admin_options.php"><?php echo $lang_admin_common['Options'] ?></a></li> |
---|
| 58 | <li<?php if ($page == 'permissions') echo ' class="isactive"'; ?>><a href="admin_permissions.php"><?php echo $lang_admin_common['Permissions'] ?></a></li> |
---|
| 59 | <li<?php if ($page == 'categories') echo ' class="isactive"'; ?>><a href="admin_categories.php"><?php echo $lang_admin_common['Categories'] ?></a></li> |
---|
| 60 | <li<?php if ($page == 'forums') echo ' class="isactive"'; ?>><a href="admin_forums.php"><?php echo $lang_admin_common['Forums'] ?></a></li> |
---|
| 61 | <li<?php if ($page == 'groups') echo ' class="isactive"'; ?>><a href="admin_groups.php"><?php echo $lang_admin_common['User groups'] ?></a></li> |
---|
| 62 | <li<?php if ($page == 'censoring') echo ' class="isactive"'; ?>><a href="admin_censoring.php"><?php echo $lang_admin_common['Censoring'] ?></a></li> |
---|
| 63 | <li<?php if ($page == 'ranks') echo ' class="isactive"'; ?>><a href="admin_ranks.php"><?php echo $lang_admin_common['Ranks'] ?></a></li> |
---|
| 64 | <li<?php if ($page == 'maintenance') echo ' class="isactive"'; ?>><a href="admin_maintenance.php"><?php echo $lang_admin_common['Maintenance'] ?></a></li> |
---|
| 65 | </ul> |
---|
| 66 | </div> |
---|
| 67 | </div> |
---|
| 68 | <?php |
---|
| 69 | |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | // See if there are any plugins |
---|
| 73 | $plugins = forum_list_plugins($is_admin); |
---|
| 74 | |
---|
| 75 | // Did we find any plugins? |
---|
| 76 | if (!empty($plugins)) |
---|
| 77 | { |
---|
| 78 | |
---|
| 79 | ?> |
---|
| 80 | <h2 class="block2"><span><?php echo $lang_admin_common['Plugins menu'] ?></span></h2> |
---|
| 81 | <div class="box"> |
---|
| 82 | <div class="inbox"> |
---|
| 83 | <ul> |
---|
| 84 | <?php |
---|
| 85 | |
---|
| 86 | foreach ($plugins as $plugin_name => $plugin) |
---|
| 87 | echo "\t\t\t\t\t".'<li'.(($page == $plugin_name) ? ' class="isactive"' : '').'><a href="admin_loader.php?plugin='.$plugin_name.'">'.str_replace('_', ' ', $plugin).'</a></li>'."\n"; |
---|
| 88 | |
---|
| 89 | ?> |
---|
| 90 | </ul> |
---|
| 91 | </div> |
---|
| 92 | </div> |
---|
| 93 | <?php |
---|
| 94 | |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | ?> |
---|
| 98 | </div> |
---|
| 99 | |
---|
| 100 | <?php |
---|
| 101 | |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | // |
---|
| 106 | // Delete topics from $forum_id that are "older than" $prune_date (if $prune_sticky is 1, sticky topics will also be deleted) |
---|
| 107 | // |
---|
| 108 | function prune($forum_id, $prune_sticky, $prune_date) |
---|
| 109 | { |
---|
| 110 | global $db; |
---|
| 111 | |
---|
| 112 | $extra_sql = ($prune_date != -1) ? ' AND last_post<'.$prune_date : ''; |
---|
| 113 | |
---|
| 114 | if (!$prune_sticky) |
---|
| 115 | $extra_sql .= ' AND sticky=\'0\''; |
---|
| 116 | |
---|
| 117 | // Fetch topics to prune |
---|
| 118 | $result = $db->query('SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.$extra_sql, true) or error('Unable to fetch topics', __FILE__, __LINE__, $db->error()); |
---|
| 119 | |
---|
| 120 | $topic_ids = ''; |
---|
| 121 | while ($row = $db->fetch_row($result)) |
---|
| 122 | $topic_ids .= (($topic_ids != '') ? ',' : '').$row[0]; |
---|
| 123 | |
---|
| 124 | if ($topic_ids != '') |
---|
| 125 | { |
---|
| 126 | // Fetch posts to prune |
---|
| 127 | $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topic_ids.')', true) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); |
---|
| 128 | |
---|
| 129 | $post_ids = ''; |
---|
| 130 | while ($row = $db->fetch_row($result)) |
---|
| 131 | $post_ids .= (($post_ids != '') ? ',' : '').$row[0]; |
---|
| 132 | |
---|
| 133 | if ($post_ids != '') |
---|
| 134 | { |
---|
| 135 | // Delete topics |
---|
| 136 | $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topic_ids.')') or error('Unable to prune topics', __FILE__, __LINE__, $db->error()); |
---|
| 137 | // Delete subscriptions |
---|
| 138 | $db->query('DELETE FROM '.$db->prefix.'topic_subscriptions WHERE topic_id IN('.$topic_ids.')') or error('Unable to prune subscriptions', __FILE__, __LINE__, $db->error()); |
---|
| 139 | // Delete posts |
---|
| 140 | $db->query('DELETE FROM '.$db->prefix.'posts WHERE id IN('.$post_ids.')') or error('Unable to prune posts', __FILE__, __LINE__, $db->error()); |
---|
| 141 | |
---|
| 142 | // We removed a bunch of posts, so now we have to update the search index |
---|
| 143 | require_once PUN_ROOT.'include/search_idx.php'; |
---|
| 144 | strip_search_index($post_ids); |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | } |
---|