<?php
	session_start();
	include "conn/conn.php";
	$u=$_SERVER['HTTP_HOST'];
	$url="http://"."$u";
if($_POST[Submits3]=="添加到播放列表"){
if($_POST[checkboxs]==""){
echo "<script>alert('您没有选择要添加的音乐！'); history.back();</script>";
}else{
session_register("music_list1");
foreach($_POST[checkboxs] as $key=>$value){  //以book数组做循环，输出键和值

	if($_SESSION["music_list1"]==""){
		$_SESSION["music_list1"]=$value."@";
	}else{
    	$array=explode("@",$_SESSION["music_list1"]);
		if(in_array($value,$array)){
	   		echo "<script>alert('播放列表中已经存在此音乐！');history.back();</script>";
	   		exit;
		}

}
   $_SESSION["music_list1"].=$value."@";
}
echo "<script>window.location.href='music_list1.php';</script>";
}
}else{

if($_POST[checkboxs]==""){
echo "<script>alert('您没有选择要播放的音乐！'); history.back();</script>";
}else{
$date=date("His");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style></head>
<script type="text/javascript" src="js/delete_m3u.js"></script>
<body onUnload="channel_check('<?php echo "upfiles/video/".$date.".m3u"; ?>')">
<table width="1004" height="720" border="0" cellpadding="0" cellspacing="0" background="images/111.jpg">
  <tr>
    <td>&nbsp;</td>
    <td height="241" align="center" valign="bottom">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="271">&nbsp;</td>
    <td width="440" height="357" align="center" valign="top">
<center>
<?php

if (!$fopen = fopen ("upfiles/video/$date.m3u","w")){        //使用添加模式打开文件,文件指针指在表尾
	echo "打开.m3u文件失败！" ;   
    exit ; 
	}
foreach($_POST[checkboxs] as $key=>$value){  //以book数组做循环，输出键和值
	$l_sqlstr = "select * from tb_internet_video where tb_internet_id='$value' and tb_music_user='".$_SESSION[names]."' order by tb_internet_id";
	$l_rst = $conn->execute($l_sqlstr);
    if ( !fwrite ($fopen,"".$l_rst->fields[3].""
		)){               
    	print "写入内容失败！" ;
        exit ; 
	}
	if(!fwrite ($fopen,"\n\r")){               
		print "写入内容失败！" ;
    exit ; 
}
}
?>
<embed src="upfiles/video/<?php echo $date;?>.m3u" loop="<?php if($_POST[Submits]=="连续播放"){echo "false";}elseif($_POST[Submits2]=="循环播放"){echo "true";}?>" align="middle" ShowStatusBar=true></embed>
</center>


</td>
    <td width="280">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td height="122">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

</body>
</html>
<?php }}?>