<?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=music')."';</script>");}
?>
  <div class="user"> 
   <div class="user_center"> 
<?php
include_once('source/space_menu.php');
?>
<?php
if($day) {
	$class=$db->getrow('select * from ' . tname('class') . " where CD_ID='" . $day . "'");
if(cd_zclass=="1"){
	if($class["CD_FatherID"]==0){$fidsql=" and CD_ClassID in (".rtrim($class["CD_ID"].','.$class['CD_TieID'], ',').")";}else{$fidsql=" and CD_ClassID='".$class["CD_ID"]."'";}
	}else{
		$fidsql=" and CD_ClassID='".$class["CD_ID"]."'";
		}
}
if($view=="") {$view='fav';}
if($view=="fav") {
		$djsql="select * from " . tname('fav') . " where cd_type='dj'$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") {
		$djsql="select * from " . tname('down') . " where cd_type='dj'$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 <?php echo $liclass;?> href="<?php echo rewrite_url('space.php?do=music&view=fav');?>" style="font-size: 12px;">收藏的音乐</a> </li> 
        <li class="download"> <a <?php echo $liclass3;?> href="<?php echo rewrite_url('space.php?do=music&view=down');?>" style="font-size: 12px;">下载的音乐</a> </li> 
        <li class="like"> <a href="<?php echo rewrite_url('space.php?do=video&view=fav');?>" style="font-size: 12px;">收藏的视频</a> </li> 
        <li class="download"> <a 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=music&view='.$view.'');?>"<?php if($day=="") {echo ' class="current"';}?>>全部类型</a></li>
<?php
$classsql1="select CD_ID,CD_Name from " . tname('class') . " where CD_FatherID=0 and CD_IsHide=0";
$results=$db->query($classsql1);
if($results) {
		while($class1=$db->fetch_array($results)) {
			if($class["CD_FatherID"]=="0"){$FatherID=$class["CD_ID"];}else{$FatherID=$class["CD_FatherID"];}
				if($class1['CD_ID']==$FatherID){
						echo "<li><a href='" . rewrite_url('space.php?do=music&view=' . $view . '&day='.$class1['CD_ID'].'')."' class=\"current\">" . $class1['CD_Name'] . "</a></li>";
				} else {
						echo "<li><a href='" . rewrite_url('space.php?do=music&view=' . $view . '&day='.$class1['CD_ID'].'')."'>" . $class1['CD_Name'] . "</a></li>";
				}
		}
}
?>
      </div> 
<?php
if($day){
if($class["CD_TieID"]!=999999){
echo'<div class="small_list">';
$classsql2="select CD_ID,CD_Name from " . tname('class') . " where CD_ID in (".$class["CD_TieID"].") and CD_IsHide=0";
$results=$db->query($classsql2);
if($results) {
	while($class2=$db->fetch_array($results)) {
		if($class2['CD_ID']==$day){
			echo "<li><a href='" . rewrite_url('space.php?do=music&view=' . $view . '&day='.$class2['CD_ID'].'')."' class=\"current\">" . $class2['CD_Name'] . "</a></li>";
		}else{
			echo "<li><a href='" . rewrite_url('space.php?do=music&view=' . $view . '&day='.$class2['CD_ID'].'')."'>" . $class2['CD_Name'] . "</a></li>";
		}
	}
}
echo'</div>';
}
}
?> 
      <div id="favoritesList" class="minHeight500"> 
       <div class="private_dance_list"> 
<?php
global $db;
$a=0;
$Arr=getuserpage($djsql, 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;
						$music=$db->getrow("select CD_User,CD_ID from " . tname('dj') . " where CD_ID='" . $row['cd_musicid'] . "'");
						$rowlast=$db->getrow("select cd_id,cd_nicheng from " . tname('user') . " where cd_name='" . $music['CD_User'] . "'");
						echo '<li';
						if($a%2==0) {
								echo ' class="c2"';
						}
						echo '>';
						echo '<div class="song">';
						echo '<span class="cbox"><input id="' . $row['cd_musicid'] . '" type="checkbox" name="did" value="' . $row['cd_musicid'] . '"></span>';
						echo '<div class="aleft">';
						echo '<a href="' . LinkUrl("dj", $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'], $music['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("dj", $row['cd_classid'], 1, 1) . '" target="_blank">' . GetAlias("cctvai_class", "CD_Name", "CD_ID", $row['cd_classid']) . '</a></div>';
						echo '<div class="add"><a class="addition" href="' . LinkUrl("dj", $row['cd_classid'], 1, $row['cd_musicid']) . '" target="p" title="试听"></a></div>';
						echo '<div class="down"><a class="download" href="'.DownLinkUrl(cd_webmlplay,$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="play_button"> 
         <a class="select_all" href="javascript:;" id="selectAll" onclick="dancePlayer.selectAllDance('list', '');">全选</a>	
         <a class="select_play" href="javascript:;" onclick="dancePlayer.playDance('list');">播放</a>
        </div> 
        <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>