 <?php
 /*
    文章评论类 用于实现文章评论　
    version：1.0
    author：侯爷的博客
    www.palmcivet.ren
    Date：2016-5-20
    */
    
   
  class comment{
	
	private $linkid;//内容页ID
  private $linktitle;//内容页标题
  private $mouid;//模型ID
  private $nmid;//栏目ID
  private $selectsql;//查询的SQL语句
  private $query;//查询集
  private $table;//当前文件
function __construct($num){
$this->nmid = isset($_GET['lm_nmid']) ? cinput($_GET['lm_nmid']) : '';
$this->linkid = isset($_GET['id']) ? cinput($_GET['id']) : 0;
switch($num){
case 1:
$this->mouid = 1;	
$this->table = "show_article.php?id=".$this->linkid."&lm_nmid=".$this->nmid."";
break;
case 2:
$this->mouid = 2;
$this->table = "show_shop.php?id=".$this->linkid."&lm_nmid=".$this->nmid."";
break;
	}
$this->selectsql = "select * from limao_ping where lm_linkid=$this->linkid and lm_mouid=$this->mouid and lm_yesno=1 order by lm_id desc limit 20";	
$this->query = mysql_query($this->selectsql) or die('查询ID出错');
}


//返回
function viewcomment(){
$tmpall = '';
$tmpto = '';
$i=0;
while($mdata = mysql_fetch_object($this->query)){
$i++;
$tmp1 = '';
$tmp1 .= "<div style='width:98%;height:auto;margin:0px 5px;font-size:14px;line-height:22px;display:block;background:none;'>";
$tmp1 .= "<p>".$i."、&nbsp;<font color='red'>".rinput($mdata->lm_linktitle)."</font>于<font color='red'>".rinput($mdata->lm_date)."</font>评论如下:</p>";
$tmp1 .= "<p>".rinput($mdata->lm_content)."</p>";
$tmp1 .= "</div>";
$tmpto .= $tmp1;
}
$tmpall .= $tmpto;
return $tmpall;
}

function addcomment(){
$temp = '';	
$temp .= "<div style='width:98%;height:auto;margin:15px 0px;font-size:14px;line-height:22px;display:block;background:none;'>";
$temp .=  "<form action='save_com.php' method='post'><input type='hidden' name='lm_linkid' value='".$this->linkid."'>";
$temp .=  "<input type='hidden' name='lm_mouid' value='".$this->mouid."'>";
$temp .=  "<input type='hidden' name='lm_nmid' value='".$this->nmid."'>";	
$temp .=  "<div style='margin:5px 5px;'><input type='text' name='linktitle' value='' style='width:40%;height:25px;border:#666 solid;border-width:thin;background:#eee;' required placeholder='你的名字'></div>";	
$temp .=  "<div style='margin:5px 5px;'><textarea name='content' style='width:90%;height:100px;border:#666 solid;border-width:thin;background:#eee;' required placeholder='留言内容200字符以内'></textarea></div>";
$temp .=  "<div style='margin:20px 5px;'><input type='submit' value='发表评论' style='width:100px;height:30px;background:green;color:#fff;'>&nbsp;评论内容需审核后才会展现</div>";
$temp .=  "<form></div>";	
return $temp;
	}




}
?>

