function guest_agree_delete($sid, $pid, $touid, $tid) { $pid = intval($pid); $sid = addslashes($sid); $r = db_exec("DELETE FROM `bbs_guest_agree` WHERE sid='{$sid}' AND pid='{$pid}'"); if ($r !== FALSE) { user_update($touid, array('agrees-' => 1)); post_update($pid, array('agrees-' => 1)); $tid and thread_update($tid, array('agrees-' => 1)); // 改变用户组 user_update_group($touid); return TRUE; // 0 } else { return FALSE; } }
function myagree_delete($uid, $pid, $isfirst) { $agree = myagree_read($pid, $uid); if (empty($agree)) { return 0; } $fromuid = $agree['uid']; $touid = $agree['touid']; $tid = $agree['tid']; $r = db_exec("DELETE FROM `bbs_myagree` WHERE uid='{$uid}' AND pid='{$pid}' LIMIT 1"); db_exec("DELETE FROM `bbs_post_agree` WHERE pid='{$pid}' AND uid='{$uid}' LIMIT 1"); if ($r !== FALSE) { user_update($fromuid, array('myagrees-' => 1)); user_update($touid, array('agrees-' => 1)); post_update($pid, array('agrees-' => 1)); $isfirst and thread_update($tid, array('agrees-' => 1)); // 改变用户组 user_update_group($touid); return $r; // 0 } else { return FALSE; } }
} if ($seo_url != $thread['seo_url'] && $conf['seo_url_rewrite'] && $group['allowcustomurl']) { $seo_url = preg_replace('#[\\W]#', '-', $seo_url); // 只允许英文和 - $seo_url and thread_read_by_seo_url($seo_url) and message(4, '自定义的 URL 已经存在,请修改。'); // 这里可能有并发问题,seo_url 并非 UNIQUE KEY strlen($seo_url) > 128 and message(3, '自定义 URL 太长'); $arr['seo_url'] = $seo_url; } if ($subject != $thread['subject']) { mb_strlen($subject, 'UTF-8') > 80 and message(1, '标题最长80个字符'); $arr['subject'] = $subject; } $arr and thread_update($tid, $arr) === FALSE and message(-1, '更新主题失败'); } $r = post_update($pid, array('message' => $message)); $r === FALSE and message(-1, '更新帖子失败'); message(0, array('pid' => $pid, 'subject' => $subject, 'message' => $message)); } } elseif ($action == 'delete') { $pid = param(2, 0); if ($method != 'POST') { message(-1, '方法不对'); } $post = post_read($pid); empty($post) and message(-1, '帖子不存在:' . $pid); $tid = $post['tid']; $thread = thread_read($tid); empty($thread) and message(-1, '主题不存在:' . $tid); $fid = $thread['fid']; $forum = forum_read($fid);
if (attachments_get_count($aid) > 0 && !session::check_perm(USER_PERM_POST_ATTACHMENTS | USER_PERM_POST_READ, $t_fid)) { $error_msg_array[] = gettext("You cannot post attachments in this folder. Remove attachments to continue."); $valid = false; } if ((forum_get_setting('allow_post_editing', 'N') || $uid != $edit_message['FROM_UID'] && !(perm_get_user_permissions($edit_message['FROM_UID']) & USER_PERM_PILLORIED) || session::check_perm(USER_PERM_PILLORIED, 0) || $post_edit_time > 0 && time() - $edit_message['CREATED'] >= $post_edit_time * HOUR_IN_SECONDS) && !session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) { html_draw_error(gettext("You are not permitted to edit this message."), 'discussion.php', 'get', array('back' => gettext("Back")), array('msg' => $msg)); } if (forum_get_setting('require_post_approval', 'Y') && isset($edit_message['APPROVED']) && $edit_message['APPROVED'] == 0 && !session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid)) { html_draw_error(gettext("You are not permitted to edit this message."), 'discussion.php', 'get', array('back' => gettext("Back")), array('msg' => $msg)); } if ($valid) { $t_content_new = $t_content; if ($allow_sig == true && isset($t_sig)) { $t_content_new .= "<div class=\"sig\">{$t_sig}</div>"; } if (post_update($t_fid, $tid, $pid, $t_content_new)) { post_add_edit_text($tid, $pid); post_save_attachment_id($tid, $pid, $aid); if (session::check_perm(USER_PERM_FOLDER_MODERATE, $t_fid) && $edit_message['FROM_UID'] != $uid) { admin_add_log_entry(EDIT_POST, array($t_fid, $tid, $pid)); } header_redirect("discussion.php?webtag={$webtag}&msg={$msg}&edit_success={$msg}"); exit; } else { $error_msg_array[] = gettext("Error updating post"); } } } else { if (isset($_POST['emots_toggle']) || isset($_POST['sig_toggle'])) { if (isset($_POST['emots_toggle'])) { $page_prefs = (double) $page_prefs ^ POST_EMOTICONS_DISPLAY;
$valid = false; } if (sizeof($attachments) > 0 && !attachments_check_post_space($_SESSION['UID'], $attachments)) { $max_post_attachment_space = forum_get_setting('attachments_max_post_space', 'is_numeric', 1048576); $error_msg_array[] = gettext(sprintf("You have too many files attached to this post. Maximum attachment space per post is %s", format_file_size($max_post_attachment_space))); $valid = false; } if ((forum_get_setting('allow_post_editing', 'N') || $_SESSION['UID'] != $edit_message['FROM_UID'] && !(perm_get_user_permissions($edit_message['FROM_UID']) & USER_PERM_PILLORIED) || session::check_perm(USER_PERM_PILLORIED, 0) || $post_edit_time > 0 && time() - $edit_message['CREATED'] >= $post_edit_time * HOUR_IN_SECONDS) && !session::check_perm(USER_PERM_FOLDER_MODERATE, $fid)) { light_html_draw_error(gettext("You are not permitted to edit this message."), 'lmessages.php', 'get', array('back' => gettext("Back")), array('msg' => $return_msg)); } if ($valid) { $content_new = $content; if ($allow_sig == true && isset($sig)) { $content_new .= "<div class=\"sig\">{$sig}</div>"; } if (post_update($fid, $tid, $pid, $content_new)) { post_add_edit_text($tid, $pid); post_remove_attachments($tid, $pid); if (perm_check_folder_permissions($fid, USER_PERM_POST_APPROVAL, $edit_message['FROM_UID']) && !perm_is_moderator($edit_message['FROM_UID'], $fid)) { admin_send_post_approval_notification($fid); } if (sizeof($attachments) > 0 && ($attachments_array = attachments_get($edit_message['FROM_UID'], $attachments))) { foreach ($attachments_array as $attachment) { post_add_attachment($tid, $pid, $attachment['aid']); } } if (session::check_perm(USER_PERM_FOLDER_MODERATE, $fid) && $edit_message['FROM_UID'] != $_SESSION['UID']) { admin_add_log_entry(EDIT_POST, array($fid, $tid, $pid)); } header_redirect("lmessages.php?webtag={$webtag}&msg={$return_msg}&edit_success={$msg}"); exit;
function blog_posts_update() { $post_id = params('id'); if (post_update($post_id, $_POST['post'])) { redirect_to('posts', $post_id); # redirects to this freshly just updated post } else { halt(SERVER_ERROR, "An error occured while trying to update post " . $post_id); # raises error / renders an error page } }