<?php
$bt ="日记本";
include("../conn.php");
include("../head.php");
include_once("../function.php");
$sid = sqlstr($_COOKIE['dl']);
$uin=mysql_fetch_array(mysql_query("select * from user where sid='$sid'"));
$id=$uin['id'];
$wwname=$uin["name"];
if(!$uin){
header("Location:../login.php");
exit;//跳转到登录页面
}
$page= $_GET['page'];


echo <<<htm
<div class="hui"><div class="zuo"><a href="/m/diary/">日记</a>　<a href="/m/one">ONE</a></div><div class="you">日记本 | <a href="add.php">写日记</a></div></div>
htm;
echo '<div id="main"><div class="listyou">你的痕迹，似水流年，消逝不见<br/>'.$wwname.',你总共记录了'.diaryday($id).'天回忆。</div>
<form action="time.php" method="POST">
<p> <input type="text"  class="loginput" name="time" maxlength="20" value="'.date("Y-m-d").'"/>　<input class="libbtn" type="submit" value="翻到这天" /></p></form></div>';
$max=mysql_num_rows(mysql_query("SELECT * FROM diary WHERE diarywriteid='$id'"));
$p=ceil($max/10);
if(!$page or $page>$p){
$page=1;
}
$low=10*($page-1);//开始查询的条数
$pagesize=10;//每页查询的条数
$rs=mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' ORDER BY diarytime DESC LIMIT {$low},{$pagesize}");//列出最新公开的日记


while($uinfo=mysql_fetch_array($rs)){
$time=ytime($uinfo['diarytime'])." ".wtime($uinfo['diarytime']); 
$zzs=$uinfo["diaryzz"];
if($zzs==2){
$tb="<img src='/m/css/suo.png' alt='私密日记' /><font color='red'>私密日记</font><br/>";
}else{
$tb="";
}

$timess=$uinfo["diarytime"];
$htime=htime($timess);
$today=date("d M Y",$timess);
$jt=strtotime($today);
$mt=$jt+86400;
$rws=mysql_fetch_array(mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' and diarytime>'$jt' and diarytime<'$mt' ORDER BY diarytime DESC LIMIT {$low},{$pagesize}"));
$timem=$rws["4"];

if($timess>$jt and $timess<$timem){

echo '<div id="main"><div class="time">'.$htime .'</div>'.$tb.$uinfo["diarytxt"].'</div>';
}else{
echo '<div id="main"><div class="youlist"><div class="time">'.$time.'</div></div><div class="time">'.$htime.'</div>'.$tb.$uinfo["diarytxt"].'</div>';
}

}

echo '<br/><div class="hui"><center>';
if($max){
if($page>1){
$pag=$page-1;
echo '<center><a href="all.php?page='.$pag.'">«更近的</a>　';
} if($page<$p){
$page=$page+1;
echo  '　<a href="all.php?page='.$page.'">更远的»</a>';
}
$pa=$page-1;
echo '</center><div class="zuo">共'.$p.'页/第'.$pa.'页/'.$max.'篇日记</div><div class="you"><a href="#C1">顶部</a></div></div>';
}else{
echo '你还没有发布日记哦<br/>';
}

?>

<?php include("../footer.php"); ?>