comment.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. define('IN_SMT',true);
  3. define('IN_MYMPS',true);
  4. require_once dirname(__FILE__)."/include/global.php";
  5. require_once dirname(__FILE__)."/data/config.php";
  6. require_once MYMPS_DATA."/config.db.php";
  7. require_once MYMPS_INC."/db.class.php";
  8. require_once MYMPS_INC."/member.class.php";
  9. $iflogin = $member_log -> chk_in();
  10. $action = isset($action) ? trim($action) : '';
  11. $part = isset($part) ? trim($part) : '';
  12. $id = isset($id) ? intval($id) : '';
  13. $inajax = isset($inajax) ? intval($inajax) : '';
  14. if(empty($id)) exit('Access Denied!');
  15. if(!in_array($part,array('information','news','store'))) write_msg('您提交的评论所属模块不能为空!');
  16. $dotphpurlarray = array('information'=>'information.php','news'=>'news.php','coupon'=>'coupon.php','group'=>'group.php');
  17. $commentsettings = get_commentsettings();
  18. /*如果关闭了信息评论*/
  19. if(!$commentsettings[$part]){
  20. exit(html2js('<div class="closed">系统管理员已关闭该模块评论功能</div>'));
  21. $commentsettings = $part = $db = $db_mymps = $id = NULL;
  22. }
  23. if($action == 'insert'){
  24. $_COOKIE['comment'.$part.$id] == 1 && write_msg('您的语速太快了,请休息一下再发表评论...');
  25. if(!$iflogin && !$randcode = mymps_chk_randcode($checkcode)){
  26. write_msg('验证码输入错误,请返回重新输入');
  27. exit;
  28. }
  29. empty($content) && write_msg("提交失败!评论内容不能为空!");
  30. strlen($content)>255 && write_msg("请不要填写超过127个汉字!");
  31. if(!$iflogin){
  32. switch($commentsettings[$part]){
  33. case 1:
  34. $userid = '';
  35. break;
  36. case 2:
  37. $loginuser = $loginuser ? mhtmlspecialchars($loginuser) : '';
  38. $loginpwd = $loginpwd ? mhtmlspecialchars($loginpwd) : '';
  39. if(empty($loginuser)) write_msg('请填写你的用户帐号!');
  40. if(empty($loginpwd)) write_msg('请填写你的用户密码!');
  41. $loginpwd = md5($loginpwd);
  42. if(!$res = $db -> getOne("SELECT id FROM `{$db_mymps}member` WHERE userid = '$loginuser' AND userpwd = '$loginpwd'")){
  43. unset($res);
  44. write_msg('你的帐号或密码输入错误,或不存在该用户!');
  45. } else {
  46. $userid = $loginuser;
  47. $member_log -> in($loginuser,$loginpwd,'','noredirect');
  48. }
  49. break;
  50. }
  51. } else {
  52. $userid = $s_uid;
  53. }
  54. $result = verify_badwords_filter($mymps_global['cfg_if_comment_verify'],'',$content);
  55. $content = textarea_post_change($result['content']);
  56. $comment_level = $result['level'];
  57. $db->query("INSERT INTO `{$db_mymps}comment` (typeid,content,pubtime,ip,comment_level,userid,type)VALUES('$id','$content','$timestamp','".GetIP()."','$comment_level','".$userid."','$part')");
  58. setcookie('comment'.$part.$id,1,$timestamp+30,'/');
  59. if($comment_level == 1){
  60. write_msg("",$dotphpurlarray[$part]."?id=".$id.'#comment_write');
  61. }else{
  62. define('IN_AJAX',true);
  63. write_msg("您提交的留言可能含有违禁词语,审核通过后显示!",$dotphpurlarray[$part]."?id=".$id);
  64. }
  65. unset($loginuser,$loginpwd,$comment_level,$id);
  66. }
  67. $res = $db->getAll("SELECT content,userid,pubtime,ip FROM `{$db_mymps}comment` WHERE typeid = '$id' AND comment_level = '1' AND type = '$part' ORDER BY pubtime ASC LIMIT 0,10");
  68. foreach($res as $k => $row){
  69. $arr['content'] = $row['content'];
  70. $arr['pubtime'] = get_format_time($row['pubtime']);
  71. $arr['userid'] = $row['userid'];
  72. $arr['ip'] = $row['ip'];
  73. $comment_all[] = $arr;
  74. }
  75. $ajax_content ='
  76. <div class="box specialpostcontainer">';
  77. if(is_array($comment_all)){
  78. $i = 0;
  79. foreach($comment_all as $key => $val){
  80. $i++;
  81. $ajax_content.='
  82. <div class="specialpost">
  83. <div class="postinfo">
  84. <h2>';
  85. $ajax_content.= $val['userid'] ? '<a class="dropmenu" style="font-weight: normal;" href="'.Rewrite("space",array("user"=>$val["userid"])).'" target="_blank" >'.$val["userid"].'</a>' : '<a class="dropmenu" style="font-weight: normal;">'.part_ip($val['ip']).'</a>';
  86. $ajax_content.='
  87. '.$val["pubtime"].' </h2>
  88. <strong>'.$i.'<sup>楼</sup></strong>
  89. </div>
  90. <div class="postmessage">
  91. <div class="t_msgfont">'.$val["content"].'
  92. </div>
  93. </div>
  94. </div>';
  95. }
  96. } else {
  97. $ajax_content.='
  98. <div class="specialpost">
  99. <div class="postinfo">
  100. <h2>还没有人发表评论哦 ^_^</h2>
  101. <strong></strong>
  102. </div>
  103. </div>';
  104. }
  105. $ajax_content.='
  106. <div id="postleave">
  107. <a name="comment_write"></a>
  108. <form action="'.$mymps_global["SiteUrl"].'/comment.php?part='.$part.'&amp;action=insert" method="post" id="CommentForm" name="CommentForm" onsubmit="return CommentCheckForm();">
  109. <input name="id" value="'.$id.'" type="hidden">
  110. <dl><dt>评论内容:</dt><dd><textarea name="content" class="commenttextarea"></textarea></dd></dl>
  111. ';
  112. if($iflogin){
  113. $ajax_content .= '<div class=clearfix></div><dl><dt>&nbsp;</dt><dd><div style="margin-top:5px">'.$s_uid.' &nbsp;<a href="'.$mymps_global[SiteUrl].'/'.$mymps_global[cfg_member_logfile].'?part=out&url='.urlencode($mymps_global["SiteUrl"].'/'.$dotphpurlarray[$part].'?id='.$id).'">退出</a></div></dd></dl>';
  114. } else {
  115. /*如果会员登录状态评论 */
  116. if($commentsettings[$part] == 2){
  117. $ajax_content .= '
  118. <div class="clearfix"></div>
  119. <dl>
  120. <dt>登录帐号:</dt>
  121. <dd>
  122. <input name="loginuser" class="commenttxt" style="width:100px;">
  123. &nbsp;&nbsp;&nbsp;&nbsp;
  124. 密码:<input name="loginpwd" type="password" class="commenttxt" style="width:100px;">&nbsp;&nbsp;&nbsp;&nbsp;<a href="'.$mymps_global[SiteUrl].'/'.$mymps_global[cfg_member_logfile].'?mod=register" target="_blank">注册帐号 &raquo;</a>
  125. </dd>
  126. </dl>
  127. ';
  128. }
  129. $ajax_content .='<div class="clearfix"></div>';
  130. $ajax_content .= '<dl><dt>验 证 码:</dt><dd><input name="checkcode" class="commenttxt" type="text" style="width:74px"/></dd></dl>';
  131. $ajax_content .='<div class="clearfix"></div>';
  132. $ajax_content .= '<dl><dt>&nbsp;</dt><dd><img src="'.$mymps_global["SiteUrl"].'/'.$mymps_global[cfg_authcodefile].'" alt="看不清,请点击刷新" class="authcode" align="absmiddle" onClick="this.src=this.src+\'?\'"/></dd></dl>';
  133. }
  134. $ajax_content .= '
  135. <div class="clearfix"></div>
  136. <dl><dt>&nbsp;</dt><dd><input type="submit" class="commentsubmit" value="提交评论" style="line-height:18px" name="mymps"></dd></dl>
  137. </form>
  138. </div>
  139. </div>
  140. ';
  141. echo html2js($ajax_content);
  142. is_object($db) && $db -> Close();
  143. unset($ajax_concotent,$iflogin,$mymps_global,$member_log,$comment_all,$rows_num,$param,$page,$userid,$content,$inajax,$id,$part,$action,$userid,$s_uid,$db,$timestamp,$dotphpurlarray,$commentsettings);
  144. ?>