發新話題

[分享] 【PHP】防止重複發表文章

【PHP】防止重複發表文章

原作者:Detry

PW有時候會發重貼,無論是主題還是回復都是,加分也是。出現這個問題不是程序BUG是程序的不夠完善,因為每個人的網速不同,導致用戶會按多次提交或是什麼的,有時候那個防止功能也沒用。我是用檢查比對是否和上一個帖子發的東西一樣,來判定是否出現重貼,這個功能也能一定程度防止小白複製發廣告。

代碼:(我知道插件區的那個防止發重貼功能的那個帖子寫出來就是悟到新人的,用了那個插件毫數據庫相當大,而且就用那個插件不改的話,就會出現無法編輯帖子的問題。

本人的方法:

1.在數據庫的 pw_members 表中,加入 rtjiancha 字段。
2.打開require目錄,讀取postreply.php文件,修改

require_once(R_P.'require/postupload.php');
if($attachs){
$ifupload=",ifupload='$ifupload'";
} else{
$ifupload='';
}
=====================
中間原來的東西全部刪掉,插入

$atc_content=trim(str_replace('$','$',$atc_content));
$userdbrp = $db->get_one("SELECT rtjiancha FROM pw_members WHERE username='$windid'");
if ($userdbrp['rtjiancha'] != $atc_content) {

$db->update("INSERT INTO pw_posts (fid, tid, aid, author,authorid, icon, postdate,subject,userip,ifsign,ipfrom,ifconvert,ifcheck,content,replaypassname) VALUES ('$fid', '$tid','$attachs','".addslashes($windid)."', '$winddb[uid]', '$atc_iconid', '$timestamp','$atc_title', '$onlineip', '$atc_usesign', '$ipfrom', '$ifconvert','1','$atc_content','$passreadname')");
$db->update("UPDATE pw_threads SET lastpost='$timestamp',lastposter ='".addslashes($windid)."',replies=replies+1 $ifupload ,hits=hits+1 WHERE tid='$tid'");
}
$db->update("UPDATE pw_members SET rtjiancha='$atc_content' WHERE username='$windid'");
}

=====================

bbspostguide();//傳遞原標題!

TOP

發新話題

本站所有圖文均屬網友發表,僅代表作者的觀點與本站無關,如有侵權請通知版主會盡快刪除。