<?php 
error_reporting(0);
if(!$userlogined==true){exit("<script type=\"text/javascript\">location.href='".cd_webpath."user/login.php?login_referer=".cd_webpath."user/".rewrite_url('space.php?do=miniblog')."';</script>");}
?>
  <div class="user"> 
   <div class="user_center"> 
<?php include_once('source/space_menu.php');?> 
<?php
if($view==""){$class='class="on"';}
if($view=="following"){$class1='class="on"';}
?>
    <div class="user_main"> 
     <div class="uMain_content"> 
      <div class="main_nav"> 
       <ul> 
        <li class="me_microblog"> <a <?php echo $class ?> href="<?php echo rewrite_url('space.php?do=miniblog');?>">我的说说</a> </li> 
        <li class="friend_microblog"> <a <?php echo $class1 ?> href="<?php echo rewrite_url('space.php?do=miniblog&view=following');?>">好友们在说</a> </li> 
       </ul> 
       <div class="action"> <a href="<?php echo rewrite_url('space.php?do=miniblog');?>">发表说说</a> </div> 
      </div> 
      <div class="main"> 
       <div id="tooltip" class="refresh"> 
       </div> 
      </div> 
      <div class="minHeight500"> 
       <div class="miniblogBox"> 
        <form> 
         <div class="note"> 
          <div id="note" contenteditable="true" class="miniblogInput" name="note"></div> 
         </div> 
         <div class="action"> 
          <div id="emot_note" class="emot" to="note"></div> 
          <div class="button"> 
           <span class="button-main"> <span> <button id="send">发表</button> </span> </span> 
          </div> 
          <div id="miniblogMessage" class="miniblogMessage"></div> 
         </div> 
        </form> 
       </div> 
       <div class="miniblogList" id="miniblogList"> 
<?php if($view==""){ ?>
        <ul> 
<?php
global $db;
$a=0;
$sql="select * from " . tname('blog') . " where cd_uid='" . $CcTvAi_com_userid . "' order by cd_addtime desc";
$Arr=getuserpage($sql, 20); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num) {
		while($row=$db->fetch_array($result)) {
				$a=$a+1;
				$cd_content=preg_replace("/\[em:(\d+)]/is", "<img src=\"" . cd_webpath . "user/static/images/emot/e\\1.gif\" class=\"face\">", $row['cd_content']);
				//$cd_content = preg_replace("/\<br.*?\>/is", ' ', $cd_content);
				echo '<li>';
				echo '<div class="time"><em>' . date('Y', $row['cd_addtime']) . '</em>' . date('m', $row['cd_addtime']) . '/' . date('d', $row['cd_addtime']) . '</div>';
				echo '<div class="content">';
				echo '<div class="text"><a href="javascript:;">您说</a><span>：' . $cd_content . '</span></div>';
				echo '<div class="info">';
				echo '<span class="action"><a href="' . cd_webpath .cd_webmlsinger. '/index.php?ac=miniblog&id=' . $row['cd_uid'] . '&day=' . $row['cd_id'] . '" target="_blank">评论[' . $row['cd_commentnum'] . ']</a></span>';
				echo '<span class="update_time">发表于:' . datetime(date('Y-m-d H:i:s', $row['cd_addtime'])) . '</span>';
				echo '<span id="' . $row['cd_id'] . '" class="del" bid="' . $row['cd_id'] . '" title="删除" uid="' . $row['cd_uid'] . '"></span>';
				echo '</div>';
				echo '</div>';
				echo '</li>';
		}
} else {
		echo '<div class="nothing">还没有发表说说。</div>';
}
?>
        </ul> 
<?php if($num>0){?><div class="page"><div class="pages"><?php echo $Arr[0]; ?><input type="text" maxlength="5" onkeydown="function c(event,val){e = event ? event :(window.event ? window.event : null);if(e.keyCode==13){val = parseInt(val);val=isNaN(val)||(val<=0)?1:val;window.location.href='<?php echo cd_webpath?>user/space.php?do=miniblog&pages='+val+'';return false;}else{return true;}};if(!c(event,this.value))return false;" title="输入页码，按回车快速跳转"/></div></div><?php } ?>
<?php }elseif($view=="following"){ ?>
        <ul> 
<?php
global $db;
$a=0;
$sql="select a.cd_content,a.cd_uid,a.cd_uname,b.cd_nicheng,b.cd_checkmusic,b.cd_checkmm,b.cd_grade,b.cd_viprank,a.cd_id,a.cd_commentnum,a.cd_addtime from " . tname('blog') . " as a," . tname('user') . " as b where a.cd_uid = b.cd_id and cd_uid in(" . GetFolloWing($CcTvAi_com_userid, 0) . ") order by cd_addtime desc";
$Arr=getuserpage($sql, 20); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num) {
		while($row=$db->fetch_array($result)) {
				$a=$a+1;
				$cd_content=preg_replace("/\[em:(\d+)]/is", "<img src=\"" . cd_webpath . "user/static/images/emot/e\\1.gif\" class=\"face\">", $row['cd_content']);
				echo '<li>';
				echo '<div class="avatar"><a href="' . linkweburl($row['cd_uid'], $row['cd_uname']) . '" target="_blank"><img class="avatar-42" src="' . linkuserphoto($row['cd_uid'], 48) . '"/></a></div>';
				echo '<div class="content">';
				echo '<div class="text"><a href="' . linkweburl($row['cd_uid'], $row['cd_uname']) . '" target="_blank">' . $row['cd_nicheng'] . '</a>' . CheckCertify($row['cd_checkmusic'], $row['cd_checkmm'], $row['cd_grade'], $row['cd_viprank']) . '<span>：' . $cd_content . '</span></div>';
				echo '<div class="info">';
				echo '<span class="action"><a href="' . cd_webpath .cd_webmlsinger. '/index.php?ac=miniblog&id=' . $row['cd_uid'] . '&day=' . $row['cd_id'] . '" target="_blank">评论[' . $row['cd_commentnum'] . ']</a></span>';
				echo '<span class="update_time">发表于:' . datetime(date('Y-m-d H:i:s', $row['cd_addtime'])) . '</span>';
				echo '<span id="' . $row['cd_id'] . '" class="del" bid="' . $row['cd_id'] . '" title="删除" uid="' . $row['cd_uid'] . '"></span>';
				echo '</div>';
				echo '</div>';
				echo '</li>';
		}
} else {
		echo '<div class="nothing">还没有发表说说。</div>';
}
?>
        </ul> 
<?php if($num>0){?><div class="page"><div class="pages"><?php echo $Arr[0]; ?><input type="text" maxlength="5" onkeydown="function c(event,val){e = event ? event :(window.event ? window.event : null);if(e.keyCode==13){val = parseInt(val);val=isNaN(val)||(val<=0)?1:val;window.location.href='<?php echo cd_webpath?>user/space.php?do=miniblog&pages='+val+'';return false;}else{return true;}};if(!c(event,this.value))return false;" title="输入页码，按回车快速跳转"/></div></div><?php } ?>
<?php }?>
       </div> 
      </div> 
     </div> 
    </div> 
   </div> 
  </div> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/jquery/jquery.min.js"></script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/core.js"></script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/card.js"></script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/dialog.js"></script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/jquery/jquery.plugins.js"></script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/common.js"></script> 
  <script type="text/javascript">listenMsg.start();nav.init();nav.userMenu();</script> 
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/miniblog.js"></script> 
  <script type="text/javascript">
nav.helpNoticeInit();
miniblogLib.miniblogDelInit("#miniblogList"); 
miniblogLib.miniblogAddInit();
  </script> 
<?php include_once('source/space_footer.php');?>
  </body>
</html>