<?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();
$blogid=intval($_GET["id"]);
$userid=intval($_GET["userid"]);
$photo_name=ftbbs_request($_GET["photo_name"]);
$ck_name=get_cookie('username');

if ($blogid==""){
   $searchstr="";
} 
else{
   $searchstr="and blogid=".$blogid;
}
include_once("memberinfo.php");

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

if ($_POST["act"]=="y"){

   $id=intval($_POST["id"]);
   $userip=GetUserIP();
   $netname = ftbbs_request($ck_name);
   if ($userlogin=="N"){
   ftbbs_msg("请先登录才能评论",$_SERVER["HTTP_REFERER"]);
   exit;
   }
   if (clearnulllen($_POST["remenu"])<=0){
   ftbbs_msg("内容不能为空",$_SERVER["HTTP_REFERER"]);
   exit;
   }
   $userid=intval($_POST["userid"]);
   $blogid=intval($_POST["id"]);
   $plnl = ftbbs_request(trim($_POST["remenu"]));
   $plnl=ubb($plnl);
   $plnl=eregi_replace("<script>","< script >",$plnl);
   $plnl=eregi_replace("<iframe","< iframe",$plnl);

   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."','".$blogid."','".$userid."','".$userip."',1,'".$getnow."')";
   mysql_query($str);
   $str="update {$tablepre}ftbbs_upload set photo_pl_num=photo_pl_num+1 where id=".$id;
   mysql_query($str);
   //header("Location:mypic.php?id=".$id."&userid=".$userid."&photo_name=".$photo_name);
}

$p = new ft_page;
$sql="SELECT * FROM {$tablepre}ftbbs_upload WHERE (bbs_blog_type=1 or bbs_blog_type=2) and clubuser_id=".$userid." and photo_name='".$photo_name."' order by indate desc";
$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);

$p->pvar="page"; 
$p->setvar(array("userid" => $userid,"id" => $blogid,"photo_name" => $photo_name));
$p->set(1,$numrows,$psize); 
$rsx=mysql_query($sql." limit ".$p->limit());
?>
<html><head><meta http-equiv=content-type content="text/html; charset=utf-8>">
</head>
<script language=javascript src="js/resizeImages.js"></script>
<body>
<center>
<title><?=$username?>的个人相册</title>
<link rel="stylesheet" type="text/css" href="<?=$cssfile?>">
<link rel="stylesheet" type="text/css" href="blogcss/blogpage.css">
<?
include_once("usernav.php");
include_once("photohead.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"><a href="myphoto.php?userid=<?=$userid?>" class="modtit">相册列表</a> 
                  &gt;&gt; <a href="disphoto.php?id=<?=$blogid?>&userid=<?=$userid?>&photo_name=<?=$photo_name?>" class="modtit"><?=$photo_name?></a></div></td>
<td class="modtc" nowrap align="right"></td>
<td class="modtr" width="7">&nbsp;</td>
</tr></table>
<div id="m_albumlist" class="modbox">

<div class="phbox">
  <div align="center">
<?
if ($numrows!=0){
  while ($myrow = mysql_fetch_array($rsx)) {
    $i++;
    if ($myrow["file_type"]==1){
       $photourl=$myrow["upload_pic"];
	}
    else{
       $photourl=$myrow["upload_pic"];
    }
?>
              </div>
              <div align="center" class="phinfo">
			  <? if ($myrow["pic_note"]!=""){
			      echo "描述：".$myrow["pic_note"];
			  }?>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;大小：<?=$myrow["upload_size"]?> K&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;上传时间：<?=$myrow["indate"]?></div>
              <div align="center" class="phimg"><img src="<?=$photourl?>" border="0" resize="1"></div>
<?
  }
}
?>
<div align="center" class="phimg">
<?
$p->output(0);
?>
</div>
            <div class="line">&nbsp;</div>
<div id="in_comment"> <a name="comment"></a> 
<?
$sql="select * from {$tablepre}ftblog_pl where pltype=1 and plqs=0 ".$searchstr." 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,"id" => $blogid)); 
$p->set($pagesize,$num,$psize); 
$rsb=mysql_query($sql." limit ".$p->limit());
if ($num!=0){
?>
              <div class="tit">网友评论：</div>
<?
while ($row = mysql_fetch_array($rsb)){
$i++;
?>
              <div class="user"> <strong><?=$i?></strong>&nbsp;&nbsp;&nbsp;&nbsp;<?=$row["netname"]?>&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;<?=$row["pldate"]?> 
              </div>
              <div class="user"><?=$row["plcontent"]?></div>
              <div class="line">&nbsp;</div>
<?
}
?>
              
            <div class="user"><a href="mypic.php?id=<?=$blogid?>&userid=<?=$userid?>&photo_name=<?=$photo_name?>&page=2">更多评论...</a> 
              <?
//$p->output(0);
mysql_free_result($rs);
mysql_free_result($rsb);
$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="<?=$blogid?>">
                <input name="userid" type="hidden" id="userid" value="<?=$userid?>">
                  <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>

<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>
</body>
</html>