} } // reorder reorder_tree(); // add topics count and various informations get_user_tree($user->data); $mode = ''; } // resync if ($mode == 'resync') { $tkeys = array(); $tkeys = get_auth_keys($fid, true); for ($i = 0; $i < sizeof($tkeys['id']); $i++) { $wid = $tkeys['id'][$i]; if (substr($wid, 0, 1) == POST_FORUM_URL) { $class_mcp->sync('forum', intval(substr($wid, 1))); } } // reorder reorder_tree(); // end message $message = $lang['Forums_updated'] . $return_msg; message_die(GENERAL_MESSAGE, $message); exit; } // handle edit if ($mode == 'edit' || $mode == 'create' || $mode == 'delete') { $CH_this = isset($tree['keys'][$fid]) ? $fid : ''; $idx = isset($tree['keys'][$fid]) ? $tree['keys'][$fid] : ''; $item = array(); // Get values from memory
function auto_prune($forum_id = 0) { global $db, $lang, $class_mcp; $sql = "SELECT *\n\t\tFROM " . PRUNE_TABLE . "\n\t\tWHERE forum_id = {$forum_id}"; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { if ($row['prune_freq'] && $row['prune_days']) { $prune_date = time() - $row['prune_days'] * 86400; $next_prune = time() + $row['prune_freq'] * 86400; if (!class_exists('class_mcp')) { include IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT; } if (empty($class_mcp)) { $class_mcp = new class_mcp(); } prune($forum_id, $prune_date); $class_mcp->sync('forum', $forum_id); $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\tSET prune_next = {$next_prune}\n\t\t\t\tWHERE forum_id = {$forum_id}"; $db->sql_query($sql); } } return; }
$row_id = intval($forum_topic_data['topic_replies']) % intval($config['posts_per_page']); if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + sizeof($postrow) < $forum_topic_data['topic_replies']) { $resync = true; } } elseif (sizeof($postrow) < $config['posts_per_page']) { $resync = true; } if ($resync) { if (!class_exists('class_mcp')) include(IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT); if (empty($class_mcp)) $class_mcp = new class_mcp(); $class_mcp->sync('topic', $topic_id); $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $total_replies = $row['total']; } // Mighty Gorgon - Multiple Ranks - BEGIN $ranks_array = $cache->obtain_ranks(false); // Mighty Gorgon - Multiple Ranks - END $topic_title = censor_text($topic_title); // Was a highlight request part of the URI? $highlight_match = '';
} // Check for submit to be equal to Prune. If so then proceed with the pruning. if (isset($_POST['doprune'])) { $prunedays = request_post_var('prunedays', 0); // Convert days to seconds for timestamp functions... $prunedate = time() - $prunedays * 86400; $template->set_filenames(array('body' => ADM_TPL . 'forum_prune_result_body.tpl')); if (!class_exists('class_mcp')) { include IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT; } if (empty($class_mcp)) { $class_mcp = new class_mcp(); } for ($i = 0; $i < sizeof($forum_rows); $i++) { $p_result = prune($forum_rows[$i]['forum_id'], $prunedate); $class_mcp->sync('forum', $forum_rows[$i]['forum_id']); $row_class = !($i % 2) ? $theme['td_class1'] : $theme['td_class2']; $template->assign_block_vars('prune_results', array('ROW_CLASS' => $row_class, 'FORUM_NAME' => get_object_lang(POST_FORUM_URL . $forum_rows[$i]['forum_id'], 'name'), 'FORUM_TOPICS' => $p_result['topics'], 'FORUM_POSTS' => $p_result['posts'])); } $template->assign_vars(array('L_FORUM_PRUNE' => $lang['Forum_Prune'], 'L_FORUM' => $lang['Forum'], 'L_TOPICS_PRUNED' => $lang['Topics_pruned'], 'L_POSTS_PRUNED' => $lang['Posts_pruned'], 'L_PRUNE_RESULT' => $lang['Prune_success'])); } else { // If they haven't selected a forum for pruning yet then display a select box to use for pruning. if (empty($_POST[POST_FORUM_URL])) { // Output a selection table if no forum id has been specified. $template->set_filenames(array('body' => ADM_TPL . 'forum_prune_select_body.tpl')); $select_list = ip_make_forum_select(POST_FORUM_URL, false, '', true); $template->assign_vars(array('L_FORUM_PRUNE' => $lang['Forum_Prune'], 'L_SELECT_FORUM' => $lang['Select_a_Forum'], 'L_LOOK_UP' => $lang['Look_up_Forum'], 'S_FORUMPRUNE_ACTION' => append_sid('admin_forum_prune.' . PHP_EXT), 'S_FORUMS_SELECT' => $select_list)); } else { // Output the form to retrieve Prune information. $template->set_filenames(array('body' => ADM_TPL . 'forum_prune_body.tpl')); $forum_name = $fid == 'Root' ? $lang['All_Forums'] : get_object_lang($fid, 'name');
function delete_item($old, $new = '', $topic_dest = '') { global $db; // no changes if ($old == $new) { return; } // old type and id $old_type = substr($old, 0, 1); $old_id = intval(substr($old, 1)); // new type and id $new_type = substr($new, 0, 1); $new_id = intval(substr($new, 1)); if ($new_id == 0 || !in_array($new_type, array(POST_FORUM_URL, POST_CAT_URL))) { $new_type = POST_CAT_URL; $new_id = 0; } // topic dest $dst_type = substr($topic_dest, 0, 1); $dst_id = intval(substr($topic_dest, 1)); if ($dst_id == 0 || $dst_type != POST_FORUM_URL) { $topic_dest = ''; } // re-attach all the content to the new id if (!empty($new)) { $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\t\tSET main_type = '{$new_type}', parent_id = {$new_id}\n\t\t\t\t\tWHERE main_type = '{$old_type}' AND parent_id = {$old_id}"; $db->sql_query($sql); } // topics move if (!empty($topic_dest) && $dst_type == POST_FORUM_URL) { if ($dst_type == POST_FORUM_URL && $old_type == POST_FORUM_URL) { // topics $sql = "UPDATE " . TOPICS_TABLE . " SET forum_id = {$dst_id} WHERE forum_id = {$old_id}"; $db->sql_query($sql); // posts $sql = "UPDATE " . POSTS_TABLE . " SET forum_id = {$dst_id} WHERE forum_id = {$old_id}"; $db->sql_query($sql); if (!class_exists('class_mcp')) { include IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT; } if (empty($class_mcp)) { $class_mcp = new class_mcp(); } $class_mcp->sync('forum', $dst_id); } } // all what is attached to a forum if ($old_type == POST_FORUM_URL) { // read current moderators for the old forum $sql = "SELECT ug.user_id FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug\n\t\t\t\t\tWHERE a.forum_id = {$old_id}\n\t\t\t\t\t\tAND a.auth_mod = 1\n\t\t\t\t\t\tAND ug.group_id = a.group_id"; $result = $db->sql_query($sql); $user_ids = array(); while ($row = $db->sql_fetchrow($result)) { $user_ids[] = $row['user_id']; } $db->sql_freeresult($result); // remove moderator status for those ones if (!empty($user_ids)) { $old_moderators = implode(', ', $user_ids); // check which ones remain moderators $sql = "SELECT ug.user_id FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug\n\t\t\t\t\t\tWHERE a.forum_id <> {$old_id}\n\t\t\t\t\t\t\tAND a.auth_mod = 1\n\t\t\t\t\t\t\tAND ug.group_id = a.group_id\n\t\t\t\t\t\t\tAND ug.user_id IN ({$old_moderators})"; $result = $db->sql_query($sql); $user_ids = array(); while ($row = $db->sql_fetchrow($result)) { $user_ids[] = $row['user_id']; } $new_moderators = empty($user_ids) ? '' : implode(', ', $user_ids); // update users status $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\tSET user_level = " . USER . "\n\t\t\t\t\t\tWHERE user_id IN ({$old_moderators})\n\t\t\t\t\t\t\tAND user_level NOT IN (" . JUNIOR_ADMIN . ", " . ADMIN . ")"; $db->sql_query($sql); if (!empty($new_moderators)) { $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\t\tSET user_level = " . MOD . "\n\t\t\t\t\t\t\tWHERE user_id IN ({$new_moderators})\n\t\t\t\t\t\t\t\tAND user_level NOT IN (" . JUNIOR_ADMIN . ", " . ADMIN . ")"; $db->sql_query($sql); } } // remove auth for the old forum $sql = "DELETE FROM " . AUTH_ACCESS_TABLE . " WHERE forum_id = {$old_id}"; $db->sql_query($sql); // prune table $sql = "DELETE FROM " . PRUNE_TABLE . " WHERE forum_id = {$old_id}"; $db->sql_query($sql); // polls $sql = "SELECT t.topic_id FROM " . TOPICS_TABLE . " t\n\t\t\t\t\tWHERE t.forum_id = {$old_id}"; $result = $db->sql_query($sql); $topic_ids = array(); while ($row = $db->sql_fetchrow($result)) { $topic_ids[] = $row['topic_id']; } if (!empty($topic_ids)) { if (!class_exists('class_mcp')) { include IP_ROOT_PATH . 'includes/class_mcp.' . PHP_EXT; } if (empty($class_mcp)) { $class_mcp = new class_mcp(); } $class_mcp->topic_poll_delete($topic_ids); } // topics prune($old_id, 0, true); // Delete everything from forum } // delete the old one $sql = "DELETE FROM " . FORUMS_TABLE . " WHERE forum_id = {$old_id}"; $db->sql_query($sql); }