<?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=video')."';</script>");}
?>
  <div class="user"> 
   <div class="user_center"> 
<?php
include_once('source/space_menu.php');
?>
<?php
if($day) {
	$videoclass=$db->getrow('select * from ' . tname('videoclass') . " where CD_ID='" . $day . "'");
if(cd_zclass=="1"){
	if($videoclass["CD_FatherID"]==0){$fidsql=" and CD_ClassID in (".rtrim($videoclass["CD_ID"].','.$videoclass['CD_TieID'], ',').")";}else{$fidsql=" and CD_ClassID='".$videoclass["CD_ID"]."'";}
	}else{
		$fidsql=" and CD_ClassID='".$videoclass["CD_ID"]."'";
		}
}
if($view=="") {$view='fav';}
if($view=="fav") {
		$videosql="select * from " . tname('fav') . " where cd_type='video'$fidsql and cd_uid='" . $CcTvAi_com_userid . "' order by cd_addtime desc";
		$liclass="class='on'";
		$js='<script type="text/javascript">listenMsg.start();nav.init();nav.userMenu();danceLib.favoritesDelInit();</script>';
} elseif($view=="down") {
		$videosql="select * from " . tname('down') . " where cd_type='video'$fidsql and cd_uid='" . $CcTvAi_com_userid . "' order by cd_addtime desc";
		$liclass3="class='on'";
		$js='<script type="text/javascript">listenMsg.start();nav.init();nav.userMenu();danceLib.downDelInit();</script>';
}
?>
    <div class="user_main"> 
     <div class="uMain_content"> 
      <div class="main_nav"> 
       <ul> 
        <li class="like"> <a href="<?php echo rewrite_url('space.php?do=music&view=fav');?>" style="font-size: 12px;">收藏的音乐</a> </li> 
        <li class="download"> <a href="<?php echo rewrite_url('space.php?do=music&view=down');?>" style="font-size: 12px;">下载的音乐</a> </li> 
        <li class="like"> <a <?php echo $liclass;?> href="<?php echo rewrite_url('space.php?do=video&view=fav');?>" style="font-size: 12px;">收藏的视频</a> </li> 
        <li class="download"> <a <?php echo $liclass3;?> href="<?php echo rewrite_url('space.php?do=video&view=down');?>" style="font-size: 12px;">下载的视频</a> </li> 
       </ul> 
      </div> 
      <div class="big_list"> 
         <li><a href="<?php echo rewrite_url('space.php?do=video&view='.$view.'');?>"<?php if($day=="") {echo ' class="current"';}?>>全部类型</a></li>
<?php
$videoclasssql1="select CD_ID,CD_Name from " . tname('videoclass') . " where CD_FatherID=0 and CD_IsHide=0";
$results=$db->query($videoclasssql1);
if($results) {
		while($videoclass1=$db->fetch_array($results)) {
			if($videoclass["CD_FatherID"]=="0"){$FatherID=$videoclass["CD_ID"];}else{$FatherID=$videoclass["CD_FatherID"];}
				if($videoclass1['CD_ID']==$FatherID){
						echo "<li><a href='" . rewrite_url('space.php?do=video&view=' . $view . '&day='.$videoclass1['CD_ID'].'')."' class=\"current\">" . $videoclass1['CD_Name'] . "</a></li>";
				} else {
						echo "<li><a href='" . rewrite_url('space.php?do=video&view=' . $view . '&day='.$videoclass1['CD_ID'].'')."'>" . $videoclass1['CD_Name'] . "</a></li>";
				}
		}
}
?>
      </div> 
<?php
if($day){
if($videoclass["CD_TieID"]!=999999){
echo'<div class="small_list">';
$videoclasssql2="select CD_ID,CD_Name from " . tname('videoclass') . " where CD_ID in (".$videoclass["CD_TieID"].") and CD_IsHide=0";
$results=$db->query($videoclasssql2);
if($results) {
	while($videoclass2=$db->fetch_array($results)) {
		if($videoclass2['CD_ID']==$day){
			echo "<li><a href='" . rewrite_url('space.php?do=video&view=' . $view . '&day='.$videoclass2['CD_ID'].'')."' class=\"current\">" . $videoclass2['CD_Name'] . "</a></li>";
		}else{
			echo "<li><a href='" . rewrite_url('space.php?do=video&view=' . $view . '&day='.$videoclass2['CD_ID'].'')."'>" . $videoclass2['CD_Name'] . "</a></li>";
		}
	}
}
echo'</div>';
}
}
?>
      <div id="favoritesList" class="minHeight500"> 
       <div class="private_dance_list"> 
<?php
global $db;
$a=0;
$Arr=getuserpage($videosql, 20); //sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0) {
		echo '<div class="nothing">没有您的数据！</div>';
} else {
		if($result) {
				echo '<ul id="list">';
				echo '<li class="title">';
				echo '<div class="song">视频/分享人</div>';
				echo '<div class="time">添加时间</div>';
				echo '<div class="file">类别</div>';
				echo '<div class="add">观看</div>';
				echo '<div class="down">下载</div>';
				echo '<div class="deleting">删除</div>';
				echo '</li>';
				while($row=$db->fetch_array($result)) {
						$a=$a+1;
						$video=$db->getrow("select CD_User,CD_ID from " . tname('video') . " where CD_ID='" . $row['cd_musicid'] . "'");
						$rowlast=$db->getrow("select cd_id,cd_nicheng from " . tname('user') . " where cd_name='" . $video['CD_User'] . "'");
						echo '<li';
						if($a%2==0) {
								echo ' class="c2"';
						}
						echo '>';
						echo '<div class="song">';
						echo '<div class="aleft">';
						echo '<a href="' . LinkUrl("video", $row['cd_classid'], 1, $row['cd_musicid']) . '" target="p" class="mname">' . $a . '.&nbsp;&nbsp;' . $row["cd_musicname"] . '</a>';
						echo ' - ';
						echo '<a href="' . linkweburl($rowlast['cd_id'], $video['CD_User']) . '" class="nickname" title="' . $rowlast['cd_nicheng'] . '" target="_blank" uid="' . $row['cd_uid'] . '">' . $rowlast['cd_nicheng'] . '</a>';
						echo '</div>';
						echo '</div>';
						echo '<div class="time">' . datetime(date('Y-m-d H:i:s', $row['cd_addtime'])) . '</div>';
						echo '<div class="file"><a href="' . LinkClassUrl("video", $row['cd_classid'], 1, 1) . '" target="_blank">' . GetAlias("cctvai_videoclass", "CD_Name", "CD_ID", $row['cd_classid']) . '</a></div>';
						echo '<div class="vadd"><a class="addition" href="' . LinkUrl("video", $row['cd_classid'], 1, $row['cd_musicid']) . '" target="p" title="观看"></a></div>';
						echo '<div class="down"><a class="download" href="'.DownLinkUrl(cd_webmlvideo,$row['cd_musicid']).'" title="下载视频" target="down" ></a></div>';
						echo '<div class="action">';
						echo '<a class="del" did="' . $row['cd_id'] . '" title="删除歌曲" href="javascript:;"></a>';
						echo '</div>';
						echo '</li>';
				}
				echo '</ul>';
		}
}
?> 
       </div> 
<?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=<?php echo $ac;?>&view=<?php echo $view?>&day=<?php echo $day?>&pages='+val+'';return false;}else{return true;}};if(!c(event,this.value))return false;" title="输入页码，按回车快速跳转"/>
        </div> 
       </div> 
<?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" src="<?php echo cd_webpath?>user/static/space/js/dance.js"></script>
<?php echo $js?>
<?php include_once('source/space_footer.php');?> 
  </body>
</html>