コード例 #1
0
function delete_post($post_id, $topic_id, $forum_id)
{
    global $forum_db, $db_type;
    $return = ($hook = get_hook('fn_delete_post_start')) ? eval($hook) : null;
    if ($return != null) {
        return;
    }
    $query = array('SELECT' => 'p.id, p.poster, p.posted', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id=' . $topic_id, 'ORDER BY' => 'p.id DESC', 'LIMIT' => '2');
    ($hook = get_hook('fn_qr_get_topic_lastposts_info')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    list($last_id, , ) = $forum_db->fetch_row($result);
    list($second_last_id, $second_poster, $second_posted) = $forum_db->fetch_row($result);
    // Delete the post
    $query = array('DELETE' => 'posts', 'WHERE' => 'id=' . $post_id);
    ($hook = get_hook('fn_delete_post_qr_delete_post')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    if (!defined('FORUM_SEARCH_IDX_FUNCTIONS_LOADED')) {
        require FORUM_ROOT . 'include/search_idx.php';
    }
    strip_search_index($post_id);
    // Count number of replies in the topic
    $query = array('SELECT' => 'COUNT(p.id)', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id=' . $topic_id);
    ($hook = get_hook('fn_qr_get_topic_reply_count2')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $num_replies = $forum_db->result($result) - 1;
    // Update the topic now that a post has been deleted
    $query = array('UPDATE' => 'topics', 'SET' => 'num_replies=' . $num_replies, 'WHERE' => 'id=' . $topic_id);
    // If we deleted the most recent post, we need to sync up last post data as wel
    if ($last_id == $post_id) {
        $query['SET'] .= ', last_post=' . $second_posted . ', last_post_id=' . $second_last_id . ', last_poster=\'' . $forum_db->escape($second_poster) . '\'';
    }
    ($hook = get_hook('fn_qr_update_topic2')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    sync_forum($forum_id);
    ($hook = get_hook('fn_delete_post_end')) ? eval($hook) : null;
}
コード例 #2
0
ファイル: moderate.php プロジェクト: ZerGabriel/punbb
     while ($row = $forum_db->fetch_row($result)) {
         $post_ids[] = $row[0];
     }
     // Strip the search index provided we're not just deleting redirect topics
     if (!empty($post_ids)) {
         if (!defined('FORUM_SEARCH_IDX_FUNCTIONS_LOADED')) {
             require FORUM_ROOT . 'include/search_idx.php';
         }
         strip_search_index($post_ids);
     }
     // Delete posts
     $query = array('DELETE' => 'posts', 'WHERE' => 'topic_id IN(' . implode(',', $topics) . ')');
     ($hook = get_hook('mr_confirm_delete_topics_qr_delete_topic_posts')) ? eval($hook) : null;
     $forum_db->query_build($query) or error(__FILE__, __LINE__);
     foreach ($forum_ids as $cur_forum_id) {
         sync_forum($cur_forum_id);
     }
     $forum_flash->add_info($multi ? $lang_misc['Delete topics redirect'] : $lang_misc['Delete topic redirect']);
     ($hook = get_hook('mr_confirm_delete_topics_pre_redirect')) ? eval($hook) : null;
     redirect(forum_link($forum_url['forum'], array($fid, sef_friendly($cur_forum['forum_name']))), $multi ? $lang_misc['Delete topics redirect'] : $lang_misc['Delete topic redirect']);
 }
 // Setup form
 $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
 $forum_page['form_action'] = forum_link($forum_url['moderate_forum'], $fid);
 $forum_page['hidden_fields'] = array('csrf_token' => '<input type="hidden" name="csrf_token" value="' . generate_form_token($forum_page['form_action']) . '" />', 'topics' => '<input type="hidden" name="topics" value="' . implode(',', $topics) . '" />');
 // Setup breadcrumbs
 $forum_page['crumbs'] = array(array($forum_config['o_board_title'], forum_link($forum_url['index'])), array($cur_forum['forum_name'], forum_link($forum_url['forum'], array($fid, sef_friendly($cur_forum['forum_name'])))), array($lang_misc['Moderate forum'], forum_link($forum_url['moderate_forum'], $fid)), $multi ? $lang_misc['Delete topics'] : $lang_misc['Delete topic']);
 ($hook = get_hook('mr_delete_topics_pre_header_load')) ? eval($hook) : null;
 define('FORUM_PAGE', 'dialogue');
 require FORUM_ROOT . 'header.php';
 // START SUBST - <!-- forum_main -->
コード例 #3
0
     $prune_days = intval($_POST['prune_days']);
     $prune_date = $prune_days ? time() - $prune_days * 86400 : -1;
     ($hook = get_hook('apr_prune_comply_form_submitted')) ? eval($hook) : null;
     @set_time_limit(0);
     if ($prune_from == 'all') {
         $query = array('SELECT' => 'f.id', 'FROM' => 'forums AS f');
         ($hook = get_hook('apr_prune_comply_qr_get_all_forums')) ? eval($hook) : null;
         $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
         while ($cur_forum = $forum_db->fetch_assoc($result)) {
             prune($cur_forum['id'], $_POST['prune_sticky'], $prune_date);
             sync_forum($cur_forum['id']);
         }
     } else {
         $prune_from = intval($prune_from);
         prune($prune_from, $_POST['prune_sticky'], $prune_date);
         sync_forum($prune_from);
     }
     delete_orphans();
     $forum_flash->add_info($lang_admin_prune['Prune done']);
     ($hook = get_hook('apr_prune_pre_redirect')) ? eval($hook) : null;
     redirect(forum_link($forum_url['admin_prune']), $lang_admin_prune['Prune done']);
 }
 $prune_days = intval($_POST['req_prune_days']);
 if ($prune_days < 0) {
     message($lang_admin_prune['Days to prune message']);
 }
 $prune_date = time() - $prune_days * 86400;
 $prune_from = $_POST['prune_from'];
 if ($prune_from != 'all') {
     $prune_from = intval($prune_from);
     // Fetch the forum name (just for cosmetic reasons)
コード例 #4
0
ファイル: db_update.php プロジェクト: ZerGabriel/punbb
     // Show results page
 // Show results page
 case 'finish':
     // Now we're definitely using UTF-8, so we convert the output properly
     $forum_db->set_names('utf8');
     // We update the version number
     $query = array('UPDATE' => 'config', 'SET' => 'conf_value = \'' . UPDATE_TO . '\'', 'WHERE' => 'conf_name = \'o_cur_version\'');
     $forum_db->query_build($query) or error(__FILE__, __LINE__);
     // And the database revision number
     $query = array('UPDATE' => 'config', 'SET' => 'conf_value = \'' . UPDATE_TO_DB_REVISION . '\'', 'WHERE' => 'conf_name = \'o_database_revision\'');
     $forum_db->query_build($query) or error(__FILE__, __LINE__);
     // This feels like a good time to synchronize the forums
     $query = array('SELECT' => 'id', 'FROM' => 'forums');
     $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
     while ($row = $forum_db->fetch_row($result)) {
         sync_forum($row[0]);
     }
     // We'll empty the search cache table as well (using DELETE FROM since SQLite does not support TRUNCATE TABLE)
     $query = array('DELETE' => 'search_cache');
     $forum_db->query_build($query) or error(__FILE__, __LINE__);
     // Empty the online table too (we did not convert strings there)
     $query = array('DELETE' => 'online');
     $forum_db->query_build($query) or error(__FILE__, __LINE__);
     // Empty the PHP cache
     forum_clear_cache();
     // Drop Base URL row from database config
     if (array_key_exists('o_base_url', $forum_config)) {
         // Generate new config file
         $new_config = "<?php\n\n\$db_type = '{$db_type}';\n\$db_host = '{$db_host}';\n\$db_name = '" . addslashes($db_name) . "';\n\$db_username = '******';\n\$db_password = '******';\n\$db_prefix = '" . addslashes($db_prefix) . "';\n\$p_connect = " . ($p_connect ? 'true' : 'false') . ";\n\n\$base_url = '{$base_url}';\n\n\$cookie_name = '{$cookie_name}';\n\$cookie_domain = '{$cookie_domain}';\n\$cookie_path = '{$cookie_path}';\n\$cookie_secure = {$cookie_secure};\n\ndefine('FORUM', 1);";
         // Attempt to write config.php and display it if writing fails
         $written = false;
コード例 #5
0
<?php 
    $forum_id = $fid;
    $tpl_temp = forum_trim(ob_get_contents());
    $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
    ob_end_clean();
    // END SUBST - <!-- forum_main -->
    require FORUM_ROOT . 'footer.php';
}
if (isset($_POST['move_posts_to'])) {
    $move_to_topic = isset($_POST['move_to_topic']) && !empty($_POST['move_to_topic']) ? $_POST['move_to_topic'] : array();
    if (empty($posts)) {
        message($lang_misc['No posts selected']);
    }
    if (!defined('OM_MOVE_POSTS_FUNCTIONS_LOADED')) {
        require $ext_info['path'] . '/functions.php';
    }
    $om_move_posts_max = om_move_posts_load_cache() + 1;
    om_move_posts_generate_cache($om_move_posts_max);
    // Move the posts
    $query = array('UPDATE' => 'posts', 'SET' => 'topic_id=' . $move_to_topic . ', om_move_posts=' . $om_move_posts_max, 'WHERE' => 'id IN(' . implode(',', $posts) . ')');
    if (isset($_POST['change_time'])) {
        $query['SET'] .= ', posted=' . time();
    }
    ($hook = get_hook('move_post_qr_update_post')) ? eval($hook) : null;
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    sync_topic($tid);
    sync_topic($move_to_topic);
    sync_forum($fid);
    ($hook = get_hook('move_post_end_pre_redirect')) ? eval($hook) : null;
    redirect(forum_link($forum_url['topic'], array($tid, sef_friendly($cur_topic['subject']))), 'Move posts');
}