function post_create($arr, $fid) { global $conf, $time; $pid = post__create($arr); if (!$pid) { return $pid; } $tid = $arr['tid']; $uid = $arr['uid']; // 回帖 if ($tid > 0) { thread__update($tid, array('posts+' => 1, 'lastpid' => $pid, 'lastuid' => $uid, 'last_date' => $time)); $uid and user__update($uid, array('posts+' => 1)); runtime_set('posts+', 1); runtime_set('todayposts+', 1); forum__update($fid, array('todayposts+' => 1)); // 最新回复 thread_lastpid_create($tid, $pid); thread_tids_cache_delete_by_order($fid, 'lastpid'); } post_list_cache_delete($tid); // 更新板块信息。 thread_lastpid_cache_delete(); forum_list_cache_delete(); // 更新附件 $attachlist = attach_find_just_upload($uid); if ($attachlist) { foreach ($attachlist as $attach) { attach__update($attach['aid'], array('tid' => $tid, 'pid' => $pid)); } list($images, $files) = attach_images_files($attachlist); post__update($pid, array('images' => $images, 'files' => $files)); } return $pid; }
function thread_lastpid_gc() { if (thread_lastpid_count() > 100) { $threadlist = thread_lastpid_find(); thread_lastpid_truncate(); thread_lastpid_cache_delete(); foreach ($threadlist as $v) { thread_lastpid__create($v['tid'], $v['lastpid']); } } }
function thread_lastpid_truncate() { db_exec("TRUNCATE `bbs_thread_lastpid`"); thread_lastpid_cache_delete(); }
function thread_delete($tid) { global $conf; $thread = thread__read($tid); if (empty($thread)) { return TRUE; } $fid = $thread['fid']; $uid = $thread['uid']; $r = thread__delete($tid); if ($r === FALSE) { return FALSE; } // 删除所有回帖,同时更新 posts 统计数 $n = post_delete_by_tid($tid); // 删除我的主题 $uid and mythread_delete($uid, $tid); // 删除附件 // 更新统计 forum__update($fid, array('threads-' => 1)); user__update($uid, array('threads-' => 1)); // 删除 SEO URL thread_url_delete($tid); // 全站统计 runtime_set('threads-', 1); // 清除相关缓存 thread_tids_cache_delete($fid); forum_list_cache_delete(); // 最新和置顶也清理 thread_new_delete($tid); thread_top_delete($tid); thread_lastpid_delete($tid); thread_new_cache_delete(); thread_top_cache_delete(); thread_lastpid_cache_delete(); return $r; }