<?php
include_once("../function.php");
$date=sqlstr($_POST["time"]);
$sj=explode('-', $date); 
$bt=$sj[0]."年".$sj[1]."月".$sj[2]."日";
include("../conn.php");
include("../head.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;//跳转到登录页面
}
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> | <a href="all.php">全部</a></div></div>
htm;
echo '<div id="main"><div class="listyou">你的痕迹，似水流年，消逝不见<br/>这是你'.$sj[0].'年'.$sj[1].'月'.$sj[2].'日的日记</div>
<form action="time.php" method="POST">
<p> <input type="text"  class="loginput" name="time" maxlength="20" value="'.$date.'"/>　<input class="libbtn" type="submit" value="查看日记" /></p></form></div>';

if($date==Null){
header("Location:all.php");
exit;//跳转到日记页面
}
$today=mktime(0,0,0,$sj[1],$sj[2],$sj[0]);
$tomorrow=$today+86400;

$max=mysql_num_rows(mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' and diarytime>'$today' and diarytime<'$tomorrow' ORDER BY diarytime DESC"));

if($max){
$rws=mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' and diarytime>'$today' and diarytime<'$tomorrow' ORDER BY diarytime DESC LIMIT 0,1");

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


$q=1;//开始查询的条数
$z=1000;//每页查询的条数
$rs=mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' and diarytime>'$today' and diarytime<'$tomorrow' ORDER BY diarytime DESC LIMIT {$q},{$z}");


while($uinf=mysql_fetch_array($rs)){
$times=htime($uinf['diarytime']); 
$zzs=$uinf["diaryzz"];
if($zzs==2){
$tb="<img src='/m/css/suo.png' alt='私密日记' /><br/>";
}else{
$tb="";
}
echo '<div id="main"><div class="time">'.$times.' '.$tb.'</div>'.$uinf["diarytxt"].'<br/></div>';
}
echo '<div id="main"><div class="you"><div class="time">- '.$wwname.'　　</div></div></div>';
}else{
echo ' <div id="main"> <div class="youlist"><div class="time">'.$sj[0].'年'.$sj[1].'月'.$sj[2].'日 </div></div> <br/> <div class="listyou"> 看来这天没发生什么事呢<br/>你这天没有写日记</div><br/><br/><div class="you"><div class="time">- 一线印象　　</div></div></div> ';
}
echo '<br/><div class="hui"> <div class="zuo">查看回忆</div><div class="you"> <font color="red"></font><a href="index.php">首页»</a> </div></div>';

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

