%
dim choose,path,mydb,myset,SQL,fs,mp3
' 獲得用戶提交表單(list.htm)選中的曲目對應(yīng)的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\"
' 設(shè)置文件路徑,把temp目錄的權(quán)限設(shè)為對internet匿名用戶具有read & write 權(quán)限.
Set fs = CreateObject(“Scripting.FileSystemObject")
Set mp3 = fs.CreateTextFile(path+“listen.m3u", True)
' 創(chuàng)建文件對象.
set mydb=server.createobject(“adodb.connection")
' 創(chuàng)建數(shù)據(jù)庫對象.
mydb.open “music"
SQL=“select mp3name,url from "&dbname&“where id in "&choose set myset=tdb.execute(SQL)
do while not myset.eof
' 檢索數(shù)據(jù)庫,獲得曲目信息.
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)
' 更新數(shù)據(jù)庫中的當天點播次數(shù)和總共點播次數(shù).
set myset=nothing
mydb.close
set mydb=nothing
mp3.close
set mp3=nothing
' 清空.
response.redirect(“listen.m3u")
' 將該文件下傳到用戶.
response.end
%>
[1]