Home  >  Article  >  CMS Tutorial  >  How does DEDECMS prohibit visitors from posting comments?

How does DEDECMS prohibit visitors from posting comments?

藏色散人
藏色散人Original
2019-12-07 10:39:542015browse

How does DEDECMS prohibit visitors from posting comments?

DEDECMS How to ban visitors from posting comments?

1. Click on the background system settings → Basic system parameters → Add a new variable

The variable name is: cfg_feedback_guest The variable value is 1 Type Boolean

Recommended learning :梦Weavercms

2. Modify the feedback.php file under the plus folder

Modify the code as follows: Replace lines 276---313 with:

The code is as follows:

//检查游客是否可以发表评论 
if($cfg_feedback_guest=='N') 
{ 
//检查用户登录 
if(empty($notuser)) 
{ 
$notuser=0; 
} 
//匿名发表评论 
if($notuser==1) 
{ 
$username = $cfg_ml->M_ID > 0 ? '匿名' : '游客'; 
} 
else if($cfg_ml->M_ID > 0) 
{ 
$username = $cfg_ml->M_UserName; 
} 
else 
{ 
if($username!='' && $pwd!='') 
{ 
$rs = $cfg_ml->CheckUser($username,$pwd); 
if($rs==1) 
{ 
$dsql->ExecuteNoneQuery("Update `dede_member` set logintime='".time()."',loginip='".GetIP()."' where mid='{$cfg_ml->M_ID}'; "); 
} 
else 
{ 
ResetVdValue(); 
ShowMsg('管理员设置了游客不允许发表评论,请先登入或注册!','-1'); 
exit(); 
} 
} 
else 
{ 
ResetVdValue(); 
ShowMsg('管理员设置了游客不允许发表评论,请先登入或注册!','-1'); 
exit(); 
} 
} 
} 
else 
{ 
//检查用户登录 
if(empty($notuser)) 
{ 
$notuser=0; 
} 
//匿名发表评论 
if($notuser==1) 
{ 
$username = $cfg_ml->M_ID > 0 ? '匿名' : '游客'; 
} 
//已登录的用户 
else if($cfg_ml->M_ID > 0) 
{ 
$username = $cfg_ml->M_UserName; 
} 
//用户身份验证 
else 
{ 
if($username!='' && $pwd!='') 
{ 
$rs = $cfg_ml->CheckUser($username,$pwd); 
if($rs==1) 
{ 
$dsql->ExecuteNoneQuery("Update `dede_member` set logintime='".time()."',loginip='".GetIP()."' where mid='{$cfg_ml->M_ID}'; "); 
} 
else 
{ 
$username = '游客'; 
} 
} 
else 
{ 
$username = '游客'; 
} 
} 
}

The above is the detailed content of How does DEDECMS prohibit visitors from posting comments?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn