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

$userid=intval(get_cookie('clubuser_id'));
$id=intval($_GET["id"]);
include_once("memberinfo.php");
$query = "SELECT * FROM {$tablepre}ftbbsmb";
$ftbbsmb=makecache('ftbbsmb.html',$query,$expire);
$url=$ftbbsmb[10];
$upfiletype=$ftbbsmb[12];
$upfilesize=$ftbbsmb[13];
$getcodeoff=$ftbbsmb[30];
$htm_ext=$ftbbsmb[32];

if ($_POST["act"]=="y"){
   $userip=GetUserIP();
   $id=intval($_POST["id"]);
   $codestr=trim($_POST["codestr"]);
   $blogtitle = ftbbs_request(trim($_POST["blogtitle"]));
   $blogqs=intval(trim($_POST["blogqs"]));
   $plqs=intval(trim($_POST["plqs"]));
   $blogtypeid=intval(trim($_POST["blogtypeid"]));
   $xinqin=trim($_POST["DiaryHeart"]);
   $writedate=trim($_POST["writedate"]);
   $remenu=trim($_POST["remenu"]);
   $blogtag=ftbbs_request(trim($_POST["blogtag"]));
   $bbstag=trim($_POST["bbstag"]);
   
    //阻止关键字
    $sql_arrest="select * from {$tablepre}bbs_arrest where Kind='Keyword' order by id asc";
    $qsrs=mysql_query($sql_arrest);
    $qsrow = mysql_fetch_array($qsrs);
    $numrows = mysql_num_rows($qsrs);
    if ($numrows!=0){
       do {
          $content=$qsrow["Content"];
	      $blogtitle = str_replace($content,'*****',$blogtitle);
	      $remenu = str_replace($content,'*****',$remenu);		
        }
       while ($qsrow = mysql_fetch_array($qsrs)); 
     }
   
   if ($blogtypeid==""){
	  echo "<SCRIPT language=JavaScript>alert('你没有选择日志类型！');history.go(-1);</script>";       
      exit;
   }
   
   If (get_cookie('payuser')==3){
      ftbbs_msg("你的用户名被管理员封锁,请联系管理员！","blogcenter_add.php");
      exit;
    }
   if ($_SESSION["LastPostTime"]==""){
      $_SESSION["LastPostTime"]=$now;
    }
   else{
      if (datediff("MINUTE",$_SESSION["LastPostTime"],$now)<=$lxft && $lxft!=0){
	  ftbbs_msg("连续发帖间隔时间不能少于".$lxft."秒!","blogcenter_add.php");
	  exit;
	  }
      else{
      $_SESSION["LastPostTime"]=$now;
      }
    }
    session_destroy();
   if ($getcodeoff==1&&$_SESSION["code"]!=$codestr){
       ftbbs_msg("验证码错误!","blogcenter_add.php");
       exit;
    }
 
   
   $remenu=ubb($remenu);
   $remenu=nojs($remenu);
   $str="update {$tablepre}ftblog set blogtitle='".$blogtitle."',blogcontent='".$remenu."',blogtypeid=".$blogtypeid.",blogqs=".$blogqs.",writedate='".$writedate."',xinqin='".$xinqin."',userip='".$userip."',blogtag='".$blogtag."',userid=".$userid.",plqs=".$plqs." where id=".$id;
   mysql_query($str);
   echo "<script language='javascript'>window.location.href='blogcenter.php';</script>";
   //header("Location:blogcenter.php");
}
?>
<html><head><meta http-equiv=Content-Type content="text/html; charset=utf-8>">
</head>
<body>
<center>
<title><?=$username?></title>
<link rel="stylesheet" type="text/css" href="<?=$cssfile?>">
<?
include_once("usernav.php");
include_once("bokerhead.php");
$sql="select * from {$tablepre}ftblog where id=".$id;
$rs=mysql_query($sql);
$row = mysql_fetch_array($rs);
$blogtypeid=$row["blogtypeid"];
?>
<div class="stage">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="layout">
<tr>
<td valign="top" class="c2t3">
<div id="mod_profile" class="mod" rel="drag">
<?
include_once("usercalog.php");
?>
</div>
</td>
<td valign="top" class="c2t1">
<div id="mod_bloglist" class="mod" rel="drag"> 
              <table width="95%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td height="50">
<div align="center"><strong>编辑日志</strong></div></td>
                </tr>
              </table>
              <table width="95%" border="0" cellspacing="0" cellpadding="0">
                <form name="form1" method="post" action="" onsubmit="return CheckBlogForm(this)">
                  <tr> 
                    <td width="16%" height="27"> 
                      <div align="right">标题：</div></td>
                    <td width="86%"> 
                      <input name="blogtitle" type="text" id="blogtitle" value="<?=$row["blogtitle"]?>" size="40">
                      <select name="blogqs" id="blogqs">
                        <option value="0" <? if ($row["blogqs"]==0){?>selected<? }?>>是</option>
                        <option value="1" <? if ($row["blogqs"]==1){?>selected<? }?>>否</option>
                      </select></td>
                  </tr>
                  <tr> 
                    <td height="28"> 
                      <div align="right">分类：</div></td>
                    <td> 
                      <select name="blogtypeid" id="blogtypeid">
<?
$sql="select * from {$tablepre}ftblog_type where userid=".$userid." and blogphoto=0 order by id desc";
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
do{
?>
                        <option value="<?=$myrow["id"]?>" <? if ($myrow["id"]==$blogtypeid){?>selected<? }?>><?=$myrow["blogtype"]?></option>
<?
}
while ($myrow = mysql_fetch_array($rs));
?>
                      </select>
                       
                      <select name="select" id="postheart" Onchange="setHeart();">
                        <option value="" <? if ($row["xinqin"]==""){?>selected<? }?>>无</option>
                        <option value="一般" <? if ($row["xinqin"]=="一般"){?>selected<? }?>>一般</option>
                        <option value="开心" <? if ($row["xinqin"]=="开心"){?>selected<? }?>>开心</option>
                        <option value="伤心" <? if ($row["xinqin"]=="伤心"){?>selected<? }?>>伤心</option>
                        <option value="郁闷" <? if ($row["xinqin"]=="郁闷"){?>selected<? }?>>郁闷</option>
                        <option value="茫然" <? if ($row["xinqin"]=="茫然"){?>selected<? }?>>茫然</option>
                        <option value="说不清" <? if ($row["xinqin"]=="说不清"){?>selected<? }?>>说不清</option>
                        <option value="selfHeart">自填心情</option>
                      </select> &nbsp; <input name="DiaryHeart" id="myheart" style="display:none;" size="14" maxlength="10"> 
<script language="JavaScript">
function setHeart()
{
if(document.getElementById("postheart").value == "selfHeart")
{
document.getElementById("myheart").style.display = "";
document.getElementById("myheart").style.color = "#c0c0c0";
document.getElementById("myheart").value = "请输入自填心情";
}
else
{
document.getElementById("myheart").style.display = "none";
document.getElementById("myheart").value = document.getElementById("postheart").value;
}
}
function isNum(theNum)
{
if (theNum =="")
return false;
for(var i=0;i<theNum.length;i++){
oneNum=theNum.substring(i,i+1);
if (oneNum<"0" || oneNum>"9")
return false;
}
return true;
}
</script> </td>
                  </tr>
                  <tr> 
                    <td height="28"> 
                      <div align="right">时间：</div></td>
                    <td> 
                      <input name="writedate" type="text" id="writedate" value="<?=$row["writedate"]?>" size="26"></td>
                  </tr>
                  <tr> 
                    <td height=300></td>
                    <td> 
<TEXTAREA type="hidden" rows=1 cols=1 name="remenu" style="position:absolute;left:0;visibility:hidden;"><?=$row["blogcontent"]?></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 = "100%";
editor.editorHeight = "250px";
editor.show();
</script>
                    </td>
                  </tr>
                  <tr> 
                    <td height="28"> 
                      <div align="right">标签：</div></td>
                    <td> 
                      <input name="blogtag" type="text" id="blogtag" value="<?=$row["blogtag"]?>" size="28">
                      多个标签用"|"线分开.</td>
                  </tr>
                  <tr> 
                    <td height="28"> 
                      <div align="right">评论：</div></td>
                    <td> 
                      <input name="plqs" type="radio" value="0" <? if ($row["plqs"]==0){?>checked<? }?>>允许
                      <input type="radio" name="plqs" value="1" <? if ($row["plqs"]==1){?>checked<? }?>>禁止
                      </td>
                  </tr>
                  <? if ($getcodeoff==1){?>
                  <TR class="maintbtr1"> 
                    <TD width="16%" height="28"> 
                      <div align="center"> &nbsp;</div></TD>
                    <TD width="84%"> 
                      <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 height="35"> 
                      <div align="right"></div></td>
                    <td> 
                      <input type="submit" name="submit1" value="提交" class="button"> 
                      <input name="act" type="hidden" id="act" value="y"> <INPUT type="hidden" name="id" value="<?=$id?>"> 
                    </td>
                  </tr>
                </form>
              </table>
              <br>
            </div>
</td>
</tr></table>
</div>
</div>
<br><center>
<?
include_once("tail.php");
?>
  </center>
</center>
</body>
</html>