<%
dim choose,path,mydb,myset,SQL,fs,mp3
' 獲得用戶提交表單(list.htm)選中的曲目對應的id號,並將其賦給字串變量choose.
choose=“("
for i=3 to request.form.count
choose=choose+request.form(i)+“,"
next
choose=left(choose,len(choose)-1)+“)"
if choose=“()" then
response.redirect(“list.htm")
response.end
' 判斷choose變量,如果不包含id號,說明list.htm中沒有選中任何歌曲,終止程序.
end if
path=“E:\inetpub\wwwroot\temp\"
' 設置文件路徑,把temp目錄的權限設為對internet匿名用戶具有read & write 權限.
Set fs = CreateObject(“Scripting.FileSystemObject")
Set mp3 = fs.CreateTextFile(path+“listen.m3u", True)
' 創建文件對象.
set mydb=server.createobject(“adodb.connection")
' 創建數據庫對象.
mydb.open “music"
SQL=“select mp3name,url from "&dbname&“where id in "&choose set myset=tdb.execute(SQL)
do while not myset.eof
' 檢索數據庫,獲得曲目信息.
mp3.Write(“http://"+myset(“url")+chr(10))
myset.movenext
' 生成點播曲目文件列表.
loop
SQL=“update music set click=click+1,
this=this+1 where id in "&choose
mydb.execute(SQL)
' 更新數據庫中的當天點播次數和總共點播次數.
set myset=nothing
mydb.close
set mydb=nothing
mp3.close
set mp3=nothing
' 清空.
response.redirect(“listen.m3u")
' 將該文件下傳到用戶.
response.end
%>
[1]