<%@language=vbscript codepage=936 %>
<%path="../basedata"%>
<!--#include file="../inc/function.asp"-->
<%call Loginpower%>
<%call legalpower%>
<!--#include file="../conn/conn_data.asp"-->
<!--#include file="../conn/conn_link.asp"-->
<!--#include file="function.asp"-->
<!--#include file="../inc/config.asp"-->
<%
	dim id
	id=request.querystring("id")

	if idboolean(id) then
	id=" where class_id >="& cint(id)
	end if
	'------------------------------------------- 循环读出大类 -------------------------------------------

	dim big_sql,big_rs,big_id,big_opened,big_name
	dim sql,rs,link,rs_link1,rs_link2,songs_end,m_type,m_src,m_bak,M_lrc,M_label
	big_sql="select * from class"& id&" order by class_id"

set big_rs=server.createobject("adodb.recordset")
	big_rs.open big_sql,conn_data,1,1
	if not big_rs.eof and not big_rs.bof then
		'do while not big_rs.eof
			big_id=big_rs("class_id")
			big_opened=big_rs("class_opened")
			big_name=big_rs("class_name")
				'list

				link="<m label="""&big_name&""" opened="""&big_opened&""">"&vbCrLf
				sql="select * from songs where songs_pass=1 and songs_class_id="&big_id&" order by songs_id desc"
			set rs=server.createobject("adodb.recordset")
				rs.open sql,conn_data,1,1
				if rs.eof and rs.bof then
					rs.close
					set rs=nothing
				else
					do while not rs.eof
						rs_link1=""
						rs_link2=""
						rs_link1=conn_link.execute("select url_dl_http,url_id from url where url_id="&rs("songs_url_type1"))
						rs_link2=conn_link.execute("select url_dl_http,url_id from url where url_id="&rs("songs_url_type2"))

						songs_end=""
						music_extension=""
						if instrrev(rs("songs_src"),".") > 0 then music_extension=lcase(mid(rs("songs_src"),instrrev(rs("songs_src"),".")+1,3))
						if rs("songs_type") = "1" and music_extension<>"mp3" then songs_end="#456vv.mp3"
						if rs("songs_type") = "2" and music_extension<>"flv" then songs_end="#456vv.flv"
						if rs("songs_type") = "3" and music_extension<>"wma" then songs_end="#456vv.wma"
						if rs("songs_type") = "4" and music_extension<>"mp4" then songs_end="#456vv.mp4"
						if rs("songs_url_type1")<>0 then
							m_src="src=""dl/?id="&rs_link1(1)&"&url="&rs("songs_src")&songs_end&""""
						else
							m_src="src=""dl/?id=0&url="&rs("songs_src")&""""
						end if

						songs_end=""
						music_extension=""
						if instrrev(rs("songs_bak"),".") > 0 then music_extension=lcase(mid(rs("songs_bak"),instrrev(rs("songs_bak"),".")+1,3))
						if rs("songs_type") = "1" and music_extension<>"mp3" then songs_end="#456vv.mp3"
						if rs("songs_type") = "2" and music_extension<>"flv" then songs_end="#456vv.flv"
						if rs("songs_type") = "3" and music_extension<>"wma" then songs_end="#456vv.wma"
						if rs("songs_type") = "4" and music_extension<>"mp4" then songs_end="#456vv.mp4"
						if rs("songs_url_type1")<>0 then
							if rs("songs_url_type2")<>0  then
								m_bak="bak=""dl/?id="&rs_link2(1)&"&up="&rs_link1(1)&"&url="&rs("songs_bak")&songs_end&""""
							else
								m_bak="bak=""dl/?id=0&up="&rs_link1(1)&"&url="&rs("songs_bak")&songs_end&""""
							end if
						elseif rs("songs_url_type2")<>0  then
							m_bak="bak=""dl/?id="&rs_link2(1)&"&up=0&url="&rs("songs_bak")&songs_end&""""
						else
							m_bak="bak=""dl/?id=0&up=0&url="&rs("songs_bak")&""""
						end if
						if rs("songs_type")<>"0" then
							m_type="type="""&rs("songs_type")&""""
						else
							m_type="type="""""
						end if

						if rs("songs_lrc") <> " " then M_lrc="lrc=""lrc/"&rs("songs_label")&".txt"""
						M_label="label="""&rs("songs_label")&rs("songs_time")&""""

						link=link&"<m "&m_type&" "&m_src&" "&m_bak&" "&M_lrc&" "&M_label&" />"&vbCrLf
						rs.movenext
					loop
				end if

				link=link&"</m>"

				'--------------------- reab mb ---------------------
				dim content_all
				content_all=read_mb("../readXML/list.xml","utf-8")

				content_all=replace(content_all,"$list$",link&"")

				call save_html("../../"&big_id&".xml",content_all,"utf-8")
				'--------------------/ save html ---------------------
				'list
			big_rs.movenext
			big_id=big_rs("class_id")
			if big_rs.eof then big_id=""
		'loop
	end if
	big_rs.close
set big_rs=nothing
	conn_data.close
set conn_data=nothing
	'------------------------------------------- 循环读出大类 -------------------------------------------

if big_id <> "" then
response.write "生成页面中-请勿关闭页面<script language=""javascript"">function ZC(){window.location.href=""?id=" & big_id &""";}setTimeout(""ZC()"",1000);</script>"
else

%>
<script language="javascript">
alert("成功生成");
window.location.href="manager.asp";
</script>
<%end if%>
