DedeCMS 仅限会员发表评论的修改方法

只有会员才可以发表评论。 实现原理:判断是否登录,是,则加载评论框和按钮等,否,则提示只有注册或登录后才可以发表评论。
 
下面列出需要修改的文件的代码: 
 
1、文章模板article_article.htm (以下代码插入你模板的合适位置):
 
Copy to zuola.net Codes引用的内容:[www.zuola.net]
<div class="box"> 
<h2><a name="comment">评论内容</a></h2> 
<p> </p> 
<div class="content"> 
<form action="{dede:field name='phpurl'/}/feedback.php" method="post" name="feedback"> 
<input type="hidden" name="action" value="send" /> 
<input type="hidden" name="comtype" value="comments"> 
<input type="hidden" name="aid" value="{dede:field name="id"/}" /> 
<input type="hidden" name="isconfirm" value="yes" /> 
<p> 
<script language='javascript' type='text/javascript' src="{dede:field name='phpurl'/}/feedback_js.php?aid={dede:field name='id'/}"></script> 
<br></p> 
<p><label for="txaArticle"></label></p> 
<div class="dcmp-userinfo" id="_ajax_feedback"> 
请您<b><a target="_blank" href="{dede:global.cfg_memberurl/}/index_do.php?fmdo=user&dopost=regnew"><font size="4" color="#008000">注册</font></a></b>或者<b><a target="_blank" href="{dede:global.cfg_memberurl/}/login.php"><font size="4" color="#008000">登录</font></a></b>后发表评论! 忘记密码了?点击<b><a target="_blank" href="{dede:global.cfg_memberurl/}/resetpassword.php"><font color="#008000" size="4">这里</font></a></b>找回密码! 
</div> 
<script language="javascript" type="text/javascript">CheckLogin();</script> 
</p><br> 
</form> 
</div></div>
2、member目录下的ajax_feedback.php (全部内容):
 
Copy to zuola.net Codes引用的内容:[www.zuola.net]
<?php 
require_once(dirname(__FILE__)."/config.php"); 
AjaxHead(); 
if($myurl == '') 
exit(''); 
$uid = $cfg_ml->M_LoginID; 
$face = $cfg_ml->fields['face'] == '' ? $GLOBALS['cfg_memberurl'].'/images/nopic.gif' : $cfg_ml->fields['face']; 
?> 
<p> 
<div class="dcmp-mood"> 
<strong>评价:</strong> 
<ul> 
<li><input type="radio" name="feedbacktype" checked="1" value="feedback" id="dcmp-stand-neu" /><label for="dcmp-stand-neu"><img src="/templets/images/cmt-neu.gif" />中立</label> 
<li><input type="radio" name="feedbacktype" value="good" id="dcmp-stand-good" /><label for="dcmp-stand-good"><img src="/templets/images/cmt-good.gif" />好评</label> 
<li><input type="radio" name="feedbacktype" value="bad" id="dcmp-stand-bad" /><label for="dcmp-stand-bad"><img src="/templets/images/cmt-bad.gif" />差评</label> 
</ul> 
</div> 
</p> 
<div class="dcmp-mood"> 
<strong>表情:</strong> 
<ul> 
<li><input type="radio" name='face' value='6' checked="1" /><img src="/templets/images/mood/ico-mood-6.gif" /></li> 
<li><input type="radio" name='face' value='4'/><img src="/templets/images/mood/ico-mood-4.gif" /></li> 
<li><input type="radio" name='face' value='3'/><img src="/templets/images/mood/ico-mood-3.gif" /></li> 
<li><input type="radio" name='face' value='5'/><img src="/templets/images/mood/ico-mood-5.gif" /></li> 
<li><input type="radio" name='face' value='2'/><img src="/templets/images/mood/ico-mood-2.gif" /></li> 
<li><input type="radio" name='face' value='1'/><img src="/templets/images/mood/ico-mood-1.gif" /></li> 
<li><input type="radio" name='face' value='7'/><img src="/templets/images/mood/ico-mood-7.gif" /></li> 
</ul> 
</div> 
<p><textarea cols="60" name="msg" rows="5" class="ipt-txt" style="width:600px; height:100px;" ></textarea></p> 
以用户名 <?php echo $cfg_ml->M_UserName; ?> 发表评论,请控制在200字以内。系统会自动记录你的IP地址,请勿发布非法信息! 
<p>验证码:<input name="validate" type="text" id="validate" size="10" style="height:15px;width:50px;margin-right:6px;" class="nb" /> 
<img src='<?php echo $cfg_cmsurl;?>/include/vdimgck.php' width='50' height='20' /> 
<input type="submit" id="submit" value="提交评论" class="button" /> 
<?php if($cfg_feedback_ck=='Y') { ?> 
</p> 
<?php } ?>
3、templets目录下plus里的feedback_templet_js.htm (全部内容):
 
Copy to zuola.net Codes引用的内容:[www.zuola.net]
{dede:config pagesize='5'/} 
{dede:datalist} 
<?php 
if($fields['userid']!='') $spaceurl = $cfg_basehost.'/member/index.php?uid='.$fields['userid']; 
else $spaceurl = "#"; 
if($fields['username']=='匿名') $spaceurl = "#"; 
$fields['bgimg'] = 'cmt-neu.gif'; 
$fields['ftypetitle'] = '该用户表示中立'; 
if($fields['ftype']=='bad') { 
$fields['bgimg'] = 'cmt-bad.gif'; 
$fields['ftypetitle'] = '该用户表示差评'; 
else if($fields['ftype']=='good') { 
$fields['bgimg'] = 'cmt-good.gif'; 
$fields['ftypetitle'] = '该用户表示好评'; 
?> 
document.write("<div class='decmt-box'>"); 
document.write("<div class='decmt-title'>"); 
document.write("<span class='moodico'><img src='{dede:global.cfg_templeturl/}/images/mood/ico-mood-<?php if($fields['face']>0) echo $fields['face'];?>.gif'/></span>"); 
document.write("<span class='username'><a href='<?php echo $spaceurl;?>'>{dede:field.username/}</a></span>"); 
document.write("<span class='date'>{dede:field.dtime function=GetDateMk(@me)/}</span>"); 
document.write("<span>评论<img src='{dede:global.cfg_templeturl/}/images/{dede:field.bgimg/}' alt='{dede:field.ftypetitle/}' /></span>"); 
document.write("</div>"); 
document.write("<div class='decmt-act'>"); 
document.write("</div>"); 
document.write("<div class='decmt-content'>{dede:field.msg function='jstrim(@me,500)'/}"); 
document.write(" "); 
document.write("<span id='goodfb{dede:field.id/}'><a href=#goodfb{dede:field.id/} onclick=postBadGood('goodfb',{dede:field.id/})>支持</a>[{dede:field.good/}]</span>"); 
document.write("<span id='badfb{dede:field.id/}'><a href=#badfb{dede:field.id/} onclick=postBadGood('badfb',{dede:field.id/})>反对</a>[{dede:field.bad/}]</span>"); 
document.write("</div>"); 
document.write("</div>"); 
{/dede:datalist}