예제 #1
0
     }
     $t_tid = post_create_thread($t_fid, $uid, $t_threadtitle, "N", $t_sticky, $t_closed);
     $t_rpid = 0;
 } else {
     $t_tid = isset($_POST['t_tid']) && is_numeric($_POST['t_tid']) ? $_POST['t_tid'] : 0;
     $t_rpid = isset($_POST['t_rpid']) && is_numeric($_POST['t_rpid']) ? $_POST['t_rpid'] : 0;
     if (isset($thread_data['CLOSED']) && $thread_data['CLOSED'] > 0 && !session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) {
         html_draw_error(gettext("This thread is closed, you cannot post in it!"));
     }
     if (session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) {
         $t_closed = isset($_POST['t_closed']) && $_POST['t_closed'] == 'Y' ? true : false;
         $t_sticky = isset($_POST['t_sticky']) && $_POST['t_sticky'] == 'Y' ? 'Y' : 'N';
         if (isset($t_closed) && $t_closed == "Y") {
             thread_set_closed($t_tid, true);
         } else {
             thread_set_closed($t_tid, false);
         }
         if (isset($t_sticky) && $t_sticky == "Y") {
             thread_set_sticky($t_tid, true);
         } else {
             thread_set_sticky($t_tid, false);
         }
     }
 }
 if ($t_tid > 0) {
     if ($allow_sig == true && strlen(trim($t_sig)) > 0) {
         $t_content .= "<div class=\"sig\">{$t_sig}</div>";
     }
     $new_pid = post_create($t_fid, $t_tid, $t_rpid, $uid, $t_to_uid, $t_content);
     if ($new_pid > -1) {
         $user_rel = user_get_relationship($t_to_uid, $uid);
예제 #2
0
function thread_split($tid, $spid, $split_type, &$error_str)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($tid)) {
        return false;
    }
    if (!is_numeric($spid)) {
        return false;
    }
    if (!in_array($split_type, array(THREAD_SPLIT_REPLIES, THREAD_SPLIT_FOLLOWING))) {
        return false;
    }
    if (!($table_prefix = get_table_prefix())) {
        return thread_split_error(THREAD_SPLIT_FORUM_ERROR, $error_str);
    }
    if (!($thread_data = thread_get($tid))) {
        return thread_split_error(THREAD_SPLIT_THREAD_ERROR, $error_str);
    }
    if (!($forum_fid = get_forum_fid())) {
        return thread_split_error(THREAD_SPLIT_THREAD_ERROR, $error_str);
    }
    if (!is_numeric($spid) || $spid < 2 || $spid > $thread_data['LENGTH']) {
        return thread_split_error(THREAD_SPLIT_INVALID_ARGS, $error_str);
    }
    if (!is_numeric($split_type)) {
        return thread_split_error(THREAD_SPLIT_INVALID_ARGS, $error_str);
    }
    thread_set_closed($tid, true);
    $pid_array = array();
    switch ($split_type) {
        case THREAD_SPLIT_REPLIES:
            $pid_array = thread_split_get_replies($tid, $spid, $pid_array);
            break;
        case THREAD_SPLIT_FOLLOWING:
            $pid_array = thread_split_get_following($tid, $spid, $pid_array);
            break;
    }
    if (!is_array($pid_array) || sizeof($pid_array) < 1) {
        thread_split_error(THREAD_SPLIT_POST_ERROR, $error_str);
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        return false;
    }
    if (!($new_tid = post_create_thread($thread_data['FID'], $thread_data['BY_UID'], $thread_data['TITLE'], 'N', 'N', true))) {
        thread_split_error(THREAD_SPLIT_CREATE_ERROR, $error_str);
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        return false;
    }
    if (!($thread_new = thread_get($new_tid, true, true))) {
        thread_split_error(THREAD_SPLIT_CREATE_ERROR, $error_str);
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        return false;
    }
    $pid_list = implode(',', $pid_array);
    $sql = "INSERT INTO `{$table_prefix}POST` (TID, REPLY_TO_PID, ";
    $sql .= "FROM_UID, TO_UID, VIEWED, CREATED, STATUS, APPROVED, APPROVED_BY, ";
    $sql .= "EDITED, EDITED_BY, IPADDRESS, MOVED_TID, MOVED_PID) ";
    $sql .= "SELECT '{$new_tid}', REPLY_TO_PID, FROM_UID, TO_UID, NULL, NOW(), ";
    $sql .= "STATUS, APPROVED, APPROVED_BY, EDITED, EDITED_BY, IPADDRESS, TID, ";
    $sql .= "PID FROM `{$table_prefix}POST` WHERE TID = {$tid} ";
    $sql .= "AND PID IN ({$pid_list}) ORDER BY CREATED";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_split_error(THREAD_SPLIT_QUERY_ERROR, $error_str);
    }
    // Copy the post contents to the new thread
    $sql = "INSERT INTO `{$table_prefix}POST_CONTENT` (TID, PID, CONTENT) ";
    $sql .= "SELECT POST.TID, POST.PID, POST_CONTENT.CONTENT FROM `{$table_prefix}POST` POST ";
    $sql .= "LEFT JOIN `{$table_prefix}POST_CONTENT` POST_CONTENT ";
    $sql .= "ON (POST_CONTENT.TID = POST.MOVED_TID AND POST_CONTENT.PID = MOVED_PID) ";
    $sql .= "WHERE POST.TID = '{$new_tid}'";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_split_error(THREAD_SPLIT_QUERY_ERROR, $error_str);
    }
    // Insert the new Sphinx Search IDs.
    $sql = "INSERT INTO `{$table_prefix}POST_SEARCH_ID` (TID, PID) ";
    $sql .= "SELECT {$new_tid}, POST.PID FROM `{$table_prefix}POST` POST ";
    $sql .= "WHERE POST.TID = '{$new_tid}'";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_merge_error(THREAD_MERGE_QUERY_ERROR, $error_str);
    }
    // Update the REPLY_TO_PIDs in the new thread
    $sql = "INSERT INTO `{$table_prefix}POST` (TID, PID, REPLY_TO_PID) ";
    $sql .= "SELECT TARGET_POST.TID, TARGET_POST.PID, SOURCE_POST.PID ";
    $sql .= "FROM `{$table_prefix}POST` TARGET_POST ";
    $sql .= "INNER JOIN `{$table_prefix}POST` SOURCE_POST ";
    $sql .= "ON (SOURCE_POST.MOVED_TID = TARGET_POST.MOVED_TID ";
    $sql .= "AND TARGET_POST.REPLY_TO_PID = SOURCE_POST.MOVED_PID) ";
    $sql .= "WHERE TARGET_POST.TID = '{$new_tid}' AND TARGET_POST.PID > 1 ";
    $sql .= "ON DUPLICATE KEY UPDATE REPLY_TO_PID = VALUES(REPLY_TO_PID) ";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str);
    }
    // Remove the first post in the thread's REPLY_TO_PID
    $sql = "UPDATE `{$table_prefix}POST` POST SET REPLY_TO_PID = NULL ";
    $sql .= "WHERE POST.TID = '{$new_tid}' AND POST.PID = 1";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str);
    }
    // Update the old thread's post MOVED_TID and MOVED_PID
    $sql = "INSERT INTO `{$table_prefix}POST` (TID, PID, MOVED_TID, MOVED_PID) ";
    $sql .= "SELECT {$tid}, MOVED_PID, {$new_tid}, PID FROM `{$table_prefix}POST` POST ";
    $sql .= "WHERE POST.TID = {$new_tid} ON DUPLICATE KEY UPDATE MOVED_TID = VALUES(MOVED_TID), ";
    $sql .= "MOVED_PID = VALUES(MOVED_PID)";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str);
    }
    // Link the attachments to the new thread.
    $sql = "INSERT INTO POST_ATTACHMENT_IDS (FID, TID, PID, AID) ";
    $sql .= "SELECT {$forum_fid}, TARGET_POST.TID, TARGET_POST.PID, ";
    $sql .= "SOURCE_POST_ATTACHMENT_IDS.AID ";
    $sql .= "FROM `{$table_prefix}POST` TARGET_POST ";
    $sql .= "INNER JOIN `{$table_prefix}POST` SOURCE_POST ";
    $sql .= "ON (SOURCE_POST.MOVED_TID = TARGET_POST.MOVED_TID ";
    $sql .= "AND TARGET_POST.REPLY_TO_PID = SOURCE_POST.MOVED_PID) ";
    $sql .= "INNER JOIN POST_ATTACHMENT_IDS SOURCE_POST_ATTACHMENT_IDS ";
    $sql .= "ON (SOURCE_POST_ATTACHMENT_IDS.TID = SOURCE_POST.TID ";
    $sql .= "AND SOURCE_POST_ATTACHMENT_IDS.PID = SOURCE_POST.PID) ";
    $sql .= "WHERE TARGET_POST.TID = '{$new_tid}'";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str);
    }
    // Now we unset the MOVED_TID and MOVED_PIDs for the new thread
    // so the posts appear in the new thread.
    $sql = "UPDATE `{$table_prefix}POST` SET MOVED_TID = NULL, ";
    $sql .= "MOVED_PID = NULL WHERE TID = '{$new_tid}'";
    if (!$db->query($sql)) {
        // Unlock the original thread if it wasn't originally locked.
        thread_set_closed($tid, $thread_data['CLOSED'] > 0);
        // Return error message.
        return thread_merge_error(THREAD_SPLIT_QUERY_ERROR, $error_str);
    }
    thread_set_split($tid, $new_tid);
    thread_set_length($new_tid, sizeof($pid_array));
    thread_set_closed($tid, $thread_data['CLOSED'] > 0);
    thread_set_closed($new_tid, $thread_data['CLOSED'] > 0);
    return array($tid, $spid, $new_tid, $thread_new['TITLE']);
}
예제 #3
0
                 post_add_edit_text($tid, 1);
                 if (session::check_perm(USER_PERM_FOLDER_MODERATE, $fid)) {
                     admin_add_log_entry(MOVED_THREAD, array($tid, $thread_data['TITLE'], $old_folder_title, $new_folder_title));
                 }
             } else {
                 $error_msg_array[] = gettext("Failed to move thread to specified folder");
                 $valid = false;
             }
         }
     }
 }
 if (session::check_perm(USER_PERM_FOLDER_MODERATE, $fid)) {
     if (isset($_POST['closed']) && is_numeric($_POST['closed'])) {
         $t_closed = in_array($_POST['closed'], range(0, 1)) ? $_POST['closed'] : $thread_data['CLOSED'];
         if ($t_closed != $thread_data['CLOSED']) {
             if (thread_set_closed($tid, $t_closed > 0)) {
                 post_add_edit_text($tid, 1);
                 admin_add_log_entry($t_closed > 0 ? CLOSED_THREAD : OPENED_THREAD, array($tid, $thread_data['TITLE']));
             } else {
                 $error_msg_array[] = gettext("Failed to update thread closed status");
                 $valid = false;
             }
         }
     }
     if (isset($_POST['admin_lock']) && is_numeric($_POST['admin_lock'])) {
         $t_admin_lock = in_array($_POST['admin_lock'], range(0, 1)) ? $_POST['admin_lock'] : $thread_data['ADMIN_LOCK'];
         if ($t_admin_lock != $thread_data['ADMIN_LOCK']) {
             if (thread_admin_lock($tid, $t_admin_lock > 0)) {
                 post_add_edit_text($tid, 1);
                 admin_add_log_entry($t_admin_lock > 0 ? LOCKED_THREAD : UNLOCKED_THREAD, array($tid, $thread_data['TITLE']));
             } else {