public function getBbsHistory()
{
if(I('time')){
if (I('time')==date('Ymd')){
if( $_SESSION['userinfo']['user_id'] ){
$gotime = mktime(0, 0, 0, date('m'), date('d'), date('Y'))+25200;
if($gotime>time()){
$gotime = mktime(0, 0, 0, date('m'), date('d')-1, date('Y'))+25200;
}
$endtime = $gotime+86400;
}else{
$ajax['state'] = 1;
$ajax['data'] = '<p>登陆后才可以查看当天信息</p>';
$this->ajaxReturn($ajax,'JSON');
}
}else{
$gotime = strtotime(I('time'))+25200;
$endtime = $gotime+86400;
}
}else{
$gotime = mktime(0, 0, 0, date('m'), date('d')-1, date('Y'))+25200;
$endtime = $gotime+86400;
}
$dataGood = D('QuestionRelation')->relation(true)->where("zbs_id=4 and good = 1 and addtime>=$gotime and addtime<=$endtime and type<>5 and ( type<>2 or (type=2 and pid<>0) ) and tui=1")->order('addtime desc')->select();
$dataNull = D('QuestionRelation')->relation(true)->where("zbs_id=4 and good = 1 and addtime>=$gotime and addtime<=$endtime and type<>5 and ( type<>2 or (type=2 and pid<>0) ) and tui=1")->order('addtime desc')->select();
if($dataGood){
$data = array_merge($dataGood,$dataNull);
}else{
$data = $dataNull;
}
$str = '';
foreach ($data as $value) {
if($value['num']>0){
$more = '<i></i>';
}else{
$more = '';
}
if(strlen($value['uname'])==11){
$value['uname'] = substr($value['uname'],0,3).'*'.substr($value['uname'],-4);
}
$str .= '<div class="bbs_lists">
<h3>
<li class="face"><img data="'.$value['user_id'].'" ps="bbs" src="'.getTouxiang($value['face']).'" /></li>
<li class="nt"><b>'.$value['uname'].':</b>'.date('m-d H:i:s',$value['addtime']);
$str .= '</li>';
if($value['good']==1){
$str .= '<li class="top">置顶</li>';
}
$str .= '</h3>
<div class="con">';
if($value['type']==2 and $value['pid']<>0){
$zdata = D('QuestionRelation')->relation(true)->where("ques_id = ".$value['pid'])->find();
$str .= '<fieldset><legend>回复 '.$zdata['uname'].' 的提问:</legend><div class="fcon">'.stripslashes($zdata['content']).'</div></fieldset>';
}
$str .= stripslashes($value['content']).'</div><div class="Huifu" id="'.$value['ques_id'].'"><a>回复(<s>'.$value['num'].'</s>)</a>'.$more.'</div></div>';
}
$ajax['data'] = $str;
$ajax['state'] = 1;
$this->ajaxReturn($ajax,'JSON');
}
最佳答案
