本帖最后由 jameson512 于 2015-10-13 21:50 编辑
我来做一次雷锋,代码可用但没做优化
如果你用的是3.2版本的,打开 /source/module/forum/forum_forumdisplay.php 找到163--175行如下代码
- if($_G['forum']['password']) {
- if($_GET['action'] == 'pwverify') {
- if($_GET['pw'] != $_G['forum']['password']) {
- showmessage('forum_passwd_incorrect', NULL);
- } else {
- dsetcookie('fidpw'.$_G['fid'], $_GET['pw']);
- showmessage('forum_passwd_correct', "forum.php?mod=forumdisplay&fid=$_G[fid]");
- }
- } elseif($_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) {
- include template('forum/forumdisplay_passwd');
- exit();
- }
- }
复制代码
将全部上述代码替换成
- if($_G['forum']['password']) {
- if($_GET['action'] == 'pwverify') {
- if($_GET['pw'] != $_G['forum']['password']) {
- showmessage('forum_passwd_incorrect', NULL);
- } else {
- dsetcookie('fidpw'.$_G['fid'], $_GET['pw']);
- if(intval($_G['cookie']['ziban'])>1){
- showmessage('forum_passwd_correct', "forum.php?mod=forumdisplay&fid=".$_G['cookie']['ziban'].'&yanzheng=yes');
- dsetcookie('ziban',null);
- exit;
- }else{
- showmessage('forum_passwd_correct', "forum.php?mod=forumdisplay&fid=".$_G['fid']);
- }
- }
- } elseif($_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) {
- include template('forum/forumdisplay_passwd');
- exit();
- }
- }else{
- if(!isset($_G['gp_yanzheng']) || ($_G['gp_yanzheng'] != 'yes') || !$_G['cookie']['ziban']){
- /*查询上级论坛的fid*/
- $parent_fid = DB::fetch_all("SELECT fup FROM `".DB::table('forum_forum')."` WHERE fid='".$_G['fid']."'");
- /*如果上级论坛fid>0,则再判断上级论坛是否是加密访问*/
- if(is_array($parent_fid) && ($parent_fid[0]['fup']>0)){
- $parent_pw = DB::fetch_all("SELECT password FROM `".DB::table('forum_forumfield')."` WHERE fid='".$parent_fid[0]['fup']."'");
- if(is_array($parent_pw) && !empty($parent_pw[0]['password'])){
- /*如果设置了密码访问,则再判断是否已经在上级论坛输入过密码,如果没有输入过,则要求输入密码*/
- if(!$_G['cookie']['fidpw'.$_G[$parent_fid[0]['fup']]] || ($_G['cookie']['fidpw'.$_G[$parent_fid[0]['fup']]] != $parent_pw[0]['password'])){
- dsetcookie('ziban',$_G['fid']);
- showmessage('需要密码',"forum.php?mod=forumdisplay&fid=".$parent_fid[0]['fup']);
- }
- }
- }
- }
- }
复制代码
实测可用,有优化的空间,楼主自己看哈
|