<?php
include_once("inc/config.php");
include_once("inc/publicfun.php");
include_once("inc/ftbbsdbclass.php");
include_once("inc/pageclass.php");
include_once("inc/ftcode.php");
include_once("conn.php");
include_once("checkuser.php");

$userlogin=checkuserlogin();
$userid=intval($_GET["userid"]);
$id=intval($_GET["id"]);
$blogtypeid=intval($_GET["blogtypeid"]);
$ck_name=get_cookie('username');
//$clubuser_id=get_cookie('clubuser_id');
include_once("memberinfo.php");

$query = "SELECT * FROM {$tablepre}ftbbsmb";
$ftbbsmb=makecache('ftbbsmb.html',$query,$expire);
$bbsname=$ftbbsmb[11];
$copyright=$ftbbsmb[14];
$getcodeoff=$ftbbsmb[30];
$htmlsign=$ftbbsmb[37];
$pagesize=$ftbbsmb[5];

if ($_POST["act"]=="y"){
   $id=intval($_POST["id"]);
   $userip=GetUserIP();
   $netname = ftbbs_request($ck_name);
   if ($userlogin=="N"){
   ftbbs_msg("请先登录才能评论",$_SERVER["HTTP_REFERER"]);
   exit;
   }
   $userid=$_POST["userid"];
   $blogid=$_POST["blogtypeid"];
   $plnl = ftbbs_request(trim($_POST["remenu"]));
   $plnl=ubb($plnl);
   $plnl=eregi_replace("<script>","< script >",$plnl);
   $plnl=eregi_replace("<iframe","< iframe",$plnl);
   if (clearnulllen($_POST["remenu"])<=0){
   ftbbs_msg("内容不能为空","myblog.php?id=".$id."&userid=".$userid."&blogtypeid=".$blogid);
   exit;
   }
   If ($getcodeoff==1&&$_SESSION["code"]!=$codestr){
     echo "<script language='javascript'>alert('验证码错误!');history.go(-1);</script>";
     exit;
   }
   $str="insert into {$tablepre}ftblog_pl(netname,plcontent,blogid,userid,userip,pltype,pldate) values('".$netname."','".$plnl."','".$id."','".$userid."','".$userip."',0,'".$getnow."')";
   mysql_query($str);
   $str="update {$tablepre}ftblog set blogplnum=blogplnum+1 where id=".$id;
   mysql_query($str);
   //header("Location:myblog.php?id=".$id."&userid=".$userid."&blogtypeid=".$blogid."");
}
?>
<html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8>">
<title><?=$username?></title>
<link rel="stylesheet" type="text/css" href="<?=$cssfile?>">
<link rel="stylesheet" type="text/css" href="blogcss/blogpage.css">
</head>
<body>
<center>
<?
include_once("usernav.php");
include_once("bokerhead.php");
?>
    <div class="stage"> 
      <div class="stagepad"> 
        <div style="width:100%"> 
          <table width="100%" border="0" cellspacing="0" cellpadding="0" class="modth">
            <tr> 
              <td class="modtl" width="7">&nbsp;</td>
              <td class="modtc" nowrap><div class="modhead"><span class="modtit"></span></div></td>
              <td class="modtc" nowrap align="right"></td>
              <td class="modtr" width="7">&nbsp;</td>
            </tr>
          </table>
          <div id="m_blog" class="modbox"> 
<?
$sql="select {$tablepre}ftblog.id,{$tablepre}ftblog.blogtitle,{$tablepre}ftblog.blogtypeid,{$tablepre}ftblog.xinqin,{$tablepre}ftblog_type.blogtype,{$tablepre}ftblog.blogcontent,{$tablepre}ftblog.writedate,{$tablepre}ftblog.blogplnum,{$tablepre}ftblog.plqs,{$tablepre}ftblog.hits from {$tablepre}ftblog,{$tablepre}ftblog_type where {$tablepre}ftblog.blogtypeid={$tablepre}ftblog_type.id and {$tablepre}ftblog.sign=0 and {$tablepre}ftblog.blogqs=0 and {$tablepre}ftblog.id=".$id." order by {$tablepre}ftblog.id desc";
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);
$plqs=$myrow["plqs"]
?>
            <div class="tit"><?=$myrow["blogtitle"]?></div>
            <div class="date"><?=$myrow["writedate"]?> &nbsp;&nbsp;<? if ($myrow["xinqin"]!=""){?>心情:&nbsp;<?=$myrow["xinqin"]?><? }?></div>
            <?=$myrow["blogcontent"]?> 
            <div class="opt"> <a href="boker.php?userid=<?=$userid?>&blogtypeid=<?=$myrow["blogtypeid"]?>"><?=$myrow["blogtype"]?></a> 
              | (<?=$myrow["hits"]?>) </div>
            <div class="line">&nbsp;</div>
<?
if ($plqs==0){
?>
            <div id="in_comment"> <a name="comment"></a> 
<?
$sql="select * from {$tablepre}ftblog_pl where blogid=".$id." and plqs=0 and pltype=0 order by id desc";
$rs=mysql_query($sql);
$row = mysql_fetch_array($rs);
$num = mysql_num_rows($rs);

$p = new ft_page;
$p->pvar="page"; 
$p->setvar(array("userid" => $userid)); 
$p->set($pagesize,$num,$psize); 
$rsx=mysql_query($sql." limit ".$p->limit());
if ($num!=0){
?>
              <div class="tit"></div>
<?
while ($row = mysql_fetch_array($rsx)){
$i++;
?>
              <div class="user"> <strong><?=$i?></strong>&nbsp;&nbsp;&nbsp;&nbsp;<?=$row["netname"]?>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;<?=$row["pldate"]?> 
              </div>
              <div class="desc"><?=$row["plcontent"]?></div>
              <div class="line">&nbsp;</div>
<?
}
?>
              <div class="desc">
<?
$p->output(0);
mysql_free_result($rs);
mysql_free_result($rsx);
$db->close(); 
?>
			  </div>
<?
}
else{
 echo "<div class=\"desc\"></div>";
}
?>
            </div>
            <div id="in_send"> 
                <div class="tit"></div>
                <table width="620" border="0" cellspacing="5" cellpadding="0">
              <form name="form1" action="" method="post" onsubmit="return CheckF(this)">
                <input name="id" type="hidden" id="id" value="<?=$id?>">
                <input name="userid" type="hidden" id="userid" value="<?=$userid?>">
				<input name="blogtypeid" type="hidden" id="blogtypeid" value="<?=$blogtypeid?>">
                  <tr> 
                    <td class="f14">姓　名：</td>
                    <td>
<?
if ($ck_name!=""){
echo $ck_name;
}else{
echo "你还没有登录!";
}
?>
					</td>
                  </tr>
                  <tr> 
                    <td height=300 class="f14">内　容：</td>
                    <td>
<TEXTAREA type="hidden" rows=1 cols=1 name="remenu" style="position:absolute;left:0;visibility:hidden;"></textarea>
<script type="text/javascript" src="fteditor/blogeditor.js"></script> 
<script type="text/javascript">
var editor = new FtEditor("editor");
editor.hiddenName = "remenu";
editor.editorType = "simple";
editor.editorWidth = "500px";
editor.editorHeight = "250px";
editor.show();
</script>
				    </td>
                  </tr>
				  <? if ($getcodeoff==1){?>
                  <tr id="vercode"> 
                    <td valign="top" class="f14"></td>
                    <td valign="top"><input name=codestr id=codestr type=text size=10 maxlength=4> 
                      <img src="getyzm.php" alt="看不清楚请点击刷新验证码" class="simg" style="cursor : pointer;" onclick="this.src='getyzm.php';" align="absmiddle">
                    </td>
                  </tr>
				  <? }?>
                  <tr> 
                    <td valign="top"class="f14">&nbsp;</td>
                    <td valign="top" class="f14"><input name="submit1" type="submit" value="发表评论" class="button"> 
                      <input name="act" type="hidden" id="act" value="y"></td>
                  </tr>
				  </form>
                </table>
            </div>
            <br>
          </div>
<?
}
?>
          <table width="100%" border="0" cellspacing="0" cellpadding="0" height="8">
            <tr> 
              <td class="modbl" width="7">&nbsp;</td>
              <td class="modbc">&nbsp;</td>
              <td class="modbr" width="7">&nbsp;</td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </div>

<br><center>
<?
include_once("tail.php");
?>
  </center>
</center>
<script src="homehits.php?id=<?=$id?>&userid=<?=$userid?>&ty=myblog"></script>
</body></html>