<?php
$bt ="一线印象 小清新简洁日记本儿 Beta";
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'];
$name=$uin["name"];
$tel=$uin["phone"];
if($tel==Null){
$xie="+<a href='/m/user/smsbd.php'>绑定手机»</a><br/>+<a href='/m/diary/add.php'>写下第一篇日记»</a> ";
}else{
$xie="+<a href='add.php'>写下第一篇日记»</a>";
}


if($id==1){
$admin="<a href='/m/adm.php'>后台</a>";
}else{
$admin=" ";
}
if(!$uin){
header("Location:../login.php");
exit;//跳转到登录页面
}
echo <<<htm
<div class="hui"><div class="zuo">日记　<a href="/m/one">ONE</a>　<a href="/m/timepill">胶囊</a></div><div class="you"><a href="add.php">写日记</a> | <a href="diary.php">流年</a></div></div>
htm;
$qm=$uin["qm"];
if(stripos($uin["tx"],"http")!==false){
$tx=$uin["tx"];
}else{
$tx="/m/img.php?t=http://".$_SERVER['SERVER_NAME'].$uin["tx"];
}

/*
$URL_="http://{$_SERVER['HTTP_HOST']}/image/tx/";
$f=str_replace($URL_,"",$tx);
*/
echo '<div id="main"><div><span class="zuo"><a href="/m/user/tx.php"><img src="'.$tx.'" alt="头像" height="50" width="50" /></a></span><span class="you">　<font color="red"><b>'.$name.'</b></font>';
/*
<a href="/m/qq"><img src="/m/css/qq.png" alt="绑定QQ" /></a>
<a href="/m/timepill"><img src="/m/css/pill.png" alt="时间胶囊" height="10" width="25" /></a>
*/
echo '<br/>　<a href="/m/user/att.php">我关注的人</a> </span></div><br>”'.$qm.'” '.$admin.'</div>';

$max=mysql_num_rows(mysql_query("SELECT * FROM diary WHERE diarywriteid='$id'"));
$p=ceil($max/5);
if(!$page or $page>$p){
$page=1;
}
$low=5*($page-1);//开始查询的条数
$pagesize=1;//每页查询的条数
$rs=mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' ORDER BY diarytime DESC LIMIT {$low},{$pagesize}");//列出用户最新的一个日记

while($uinfo=mysql_fetch_array($rs)){
$ytime=ytime($uinfo['diarytime']);
$htime=htime($uinfo['diarytime']); 
$wtime=wtime($uinfo[diarytime]);
$zzs=$uinfo["diaryzz"];
if($zzs==2){
$tb="<img src='/m/css/suo.png' alt='私密日记' /><br/>";
}else{
$tb="";
}
echo '<div id="main"><div class="youlist"><div class="listyou">'.$ytime.' '.$wtime.'</div></div><br/><div class="time">'.$htime.' '.$tb.'</div>'.$uinfo["diarytxt"].'</div>';
}
$rss=mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' ORDER BY diarytime DESC LIMIT {$low},{$pagesize}");
$ui=mysql_fetch_array($rss);
$today=date("d M Y",$ui["diarytime"]);
$jt=strtotime($today);
$q=1;//开始查询的条数
$z=500;//每页查询的条数
$rws=mysql_query("SELECT * FROM diary WHERE diarywriteid='$id' and diarytime>'$jt' ORDER BY diarytime DESC LIMIT {$q},{$z}");


while($uinf=mysql_fetch_array($rws)){
$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>';
}
if($max){echo' <br/> <div id="main"> <div class="you"> <div class="time"> -- '.$name.'　　</div></div></div><br/>';
}

/*广告

echo"<br/><div id='main'><a href='http://fileserver.iuoooo.com/Jinher.JAP.BaseApp.FileServer.UI/FileManage/GetFile?fileURL=29E54E46-3E17-4CA4-8F03-DB71FB8F9660/APK/cbca59a3-8d25-4e41-ade4-c96638428f28.apk'><font color='red'>*</font>文艺聚合-变文艺还有福利 [安卓/8.8MB]</a></div>";

*/

if($max){
echo '<br/><div class="hui"> <div class="zuo">共'.$max.'篇日记/'.diaryday($id).'天回忆</div><div class="you"> <font color="red">+</font><a href="all.php">日记本»</a></div></div>';
}else{
echo "<div id='main'><div class='youlist'> </div><br/><font color=red>还没有开始写日记</font><br/><br/>现在是 ".date('H点i分s秒')."<br/><br/>生活中有很多值得我们去记录的东西<br/>最难得的是静下心来写日记的心情。<br/><br/>".$xie."</div><br/><br/>";
}

?>

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