<?php 
require "../Run.php"; 
 
require "zan.inc.php"; 
$css='<style>.wb{border-top:1px solid #ccc;background-color:#fff;text-align:center;width:100%;}
  .wbbottom{
  overflow:hidden;
  background-color:#fff;
  clear:both;
  text-align:right;
  padding:10px;
  } 
  .wbbottom a{
  text-align:center;
  font-size:17px;
  color:#328cc9;

  }
  .wb_left{
  width:50px;
  }
  .wb_right{
  }
  .headinfo{
   margin-top:5px;
  }
  .headinfo time{
  float:right;
  color:#ccc;
  font-size:16px;
  text-align:right;
  }
  .headinfo name{
  float:left;
  color:#222;
  font-size:17px;
  margin-bottom:5px;
  }
  .headinfo name a{
  font-size:17px;
  color:#328cc9;
  }
  .wbcontent{
  clear:both;
  color:#222;
  font-size:16px;
  line-height:22px;
  letter-spacing:1px;
  }
  .wb_z{
  margin-top:5px;
  margin-right:5px;
  margin-bottom:5px;
  padding:5px;
  border:1px solid #efefef;
  background-color:#f8f8f8;
clear:both;  }
  </style>'.$css;
echo head('微博大厅').'<body>';
if($_GET['action'] == 'weibo_add'){
    $time=time();
	$weibo="INSERT INTO weibo(userid,w,weibo,rizhi,wbpic,zhuanzai,time,ower,siteid)VALUES
	('{$_POST["userid"]}','weibo','{$_POST["weibo"]}','NULL','NULL','NO','{$time}','NULL','{$wapid}')";
	$weibo=mysql_query($weibo);
    if($weibo && mysql_affected_rows()>0){
	echo "<div class=\"tip\">";
    echo "发表成功";
	echo "</div>";
	}else{
	echo "发表失败";
	     }
	}
	require "weibo_add.view.php";
	$sql="SELECT id,userid,w,weibo,rizhi,wbpic,zhuanzai,time,zan,zhuan,fen,ower FROM weibo ORDER BY id DESC LIMIT 20";
	/*执行数据查询语句*/  
    $result=mysql_query($sql);      
	if($result && mysql_num_rows($result)>0){
	$i=0;
	while(list($uid,$userid,$w,$weibo,$rizhi,$wbpic,$zhuanzai,$time,$zan,$zhuan,$fen,$yuan)=mysql_fetch_row($result)){
	   $sql="SELECT nc,id,head FROM user WHERE id=
	   '{$userid}'";
	   $reslut=mysql_query($sql);
	  /*数据验证*/
	  if($reslut && mysql_num_rows($reslut)>0){
	  list($unc,$userid,$uhead)=mysql_fetch_row($reslut);};
	  if($w == 'weibo'){
	     if($zhuanzai == 'yes'){
		 /*获取原作者昵称*/
		 $sql="SELECT id,nc FROM user WHERE id=
	     '{$yuan}'";
	  $logininfo=mysql_query($sql);      
	  if($logininfo && mysql_num_rows($logininfo)>0){
	  list($id,$tonc)=mysql_fetch_row($logininfo);}
		    $c='<div class="wb_z"><a href="#"><font color="blue"><b>'.$tonc.'</b></font></a>:'.$weibo.'</div>';
			}else{
			$c=$weibo;
			}
	  echo'<table border="0"  cellpadding="0" cellspacing="0" class="wb" >
	  <tr>
	  <td class="wb_left" valign="top">
	  <img src="'.user('head','id',$userid).'" style="height:40px;width:40px;margin:5px;">
	  </td>
	  <td class="wb_right" valign="top">
	  <div class="headinfo">
	  <name><a href="q">'.$unc.'</a></name>
	 <time>'.date('Y/m/d H:i',$time).'</time>
	  </div>
      <div class="wbcontent">'.$c.'</div>
	  </td></tr>
	  </table>
	   <div class="wbbottom"><a href="?action=zan&id='.$uid.'&page=&sid='.$_GET[sid].'">赞'.$zan.'</a>
	  <a href="?&id='.$uid.'&page=&sid='.$_GET[sid].'">评论'.$zhuan.'</a>
	  <a href="?action=zhuan&id='.$uid.'&page=&sid='.$_GET[sid].'">转载'.$zhuan.'</a>
	  <a href="?action=fen&id='.$uid.'&page=&sid='.$_GET[sid].'">分享'.$fen.'</a></div>
      </div>';
	     }else{
	if($zhuanzai == 'yes'){
	/*获取原作者昵称*/
	$sql="SELECT id,nc FROM user WHERE id='{$yuan}'";
	$logininfo=mysql_query($sql);      
	if($logininfo && mysql_num_rows($logininfo)>0){
	list($id,$tonc)=mysql_fetch_row($logininfo);}
	$c='<a href="#">'.$tonc.'</a>的博客:《<a href="#">'.mb_substr($weibo,0,50,"UTF-8").'</a>》<br/>'.mb_substr($rizhi,0,200,"UTF-8");
	}else{
	 $c='《 <a href="#">'.mb_substr($weibo,0,50,"UTF-8").'</a> 》<br/>'.mb_substr($rizhi,0,200,"UTF-8");
			}
	  echo'<div class="wb">
	  <div class="head">
	  <div class="head_left">
	  <img src="'.$head.'" style="height:30px;width:30px;margin-top:5px;margin-left:0px;">
	  </div>
	  <div class="head_right">
	  <div class="hdtop"><a href="q">'.$unc.'</a></div>
	  <div class="hdtime">发表于:'.$time.'</div>
	  </div>
	  </div>
      <div class="wbcontent">'.$c.'</div>
	  <div class="wbbottom"><a href="?action=zan&id='.$uid.'&page=">赞('.$zan.')</a>
	  <a href="?&id='.$uid.'&page=">评论('.$zhuan.')</a>
	  <a href="?action=zhuan&id='.$uid.'&page=">转载('.$zhuan.')</a>
	  <a href="?action=fen&id='.$uid.'&page=">分享('.$fen.')</a></div>
      </div>';
		 }
	  }
  }

	 ?>
	 </body></html>