function post_delete($pid) { global $conf; $post = post_read_cache($pid); if (empty($post)) { return TRUE; } // 已经不存在了。 $tid = $post['tid']; $uid = $post['uid']; $thread = thread_read_cache($tid); $fid = $thread['fid']; $r = post__delete($pid); if ($r === FALSE) { return FALSE; } !$post['isfirst'] and thread__update($tid, array('posts-' => 1)); !$post['isfirst'] and $uid and user__update($uid, array('posts-' => 1)); !$post['isfirst'] and runtime_set('posts-', 1); // 清理赞同 $uid and myagree_delete($uid, $pid, $post['isfirst']); // 清理缓存 $post['isfirst'] and post_list_cache_delete($tid); $post['images'] || $post['files'] and attach_delete_by_pid($pid); return $r; }
function thread_check_lastpid($tid, $lastpid) { // 查找最新的 pid $thread = thread_read_cache($tid); if (empty($thread)) { return; } if ($thread['lastpid'] == $lastpid) { $arr = db_find_one("SELECT pid FROM bbs_post WHERE tid='{$tid}' ORDER BY pid DESC LIMIT 1"); if (empty($arr)) { return; } $lastpid = $arr['pid']; db_exec("UPDATE bbs_thread SET lastpid='{$lastpid}' WHERE tid='{$tid}'"); // 如果在最新主题当中,应该清理掉。 //thread_lastpid_truncate(); } }