Her er et ASP-script der skal kun bruge en Winamp-playlist:
<%@ Language=VBScript %>
<%
dim sort(2000), file1(2000), tid(2000)
Dim fs, a, b, s, tael, s1, file
Set fs = CreateObject(\"Scripting.FileSystemObject\")
Set a = fs.getfile(\"D:\\programmer\\winamp\\winamp.m3u\")
set b = a.OpenAsTextStream(1,0)
%>
<%
if request(\"download\") = \"\" then
%>
<html><head><Title>Winamp Playlist loader</title></head>
<body onload=\"window.status = \'M R. F U N N Y S W I N A M P P L A Y L I S T W E B I N T E R F A C E\'\">
<%
end if
if lcase(request(\"type\")) = \"file\" then
\'b.skipline
do while b.AtEndOfStream <> true
s = b.readline
if Left(s,1) <> \"#\" then
tael = tael + 1
sort(tael) = s \'mid(s,instr(s,\",\")+1)
end if
loop
sortsub(Tael)
elseif lcase(request(\"type\")) = \"full\" then
b.skipline
do while b.AtEndOfStream <> true
s = b.readline
response.write s + \"<BR>\"
loop
elseif lcase(request(\"type\")) = \"title\" then
b.skipline
do while b.AtEndOfStream <> true
s = b.readline
if left(s,1) = \"#\" then
tael = tael + 1
sort(tael) = mid(s,instr(s,\",\")+1)
tid(tael) = mid(s,9,instr(s,\",\")-9)
convtid(tael)
file1(tael) = b.readline
end if
loop
sortsub(tael)
elseif request(\"type\") = \"findfile\" then
b.skipline
do while b.AtEndOfStream <> true
s = b.readline
if left(s,1) <> \"#\" then
if instr(lcase(s),lcase(request(\"find\"))) <> 0 then
tael = tael + 1
sort(tael) = mid(s,instr(s,\",\")+1)
end if
end if
loop
sortsub(tael)
elseif request(\"type\") = \"findtitle\" then
b.skipline
do while b.AtEndOfStream <> true
s = b.readline
s1 = mid(s,9)
if left(s,1) = \"#\" then
if instr(lcase(s1),lcase(request(\"find\"))) <> 0 then
tael = tael + 1
sort(tael) = mid(s1,instr(s1,\",\")+1)
tid(tael) = mid(s,9,instr(s,\",\")-9)
convtid(tael)
file1(tael) = b.readline
end if
end if
loop
sortsub(tael)
elseif request(\"download\") <> \"\" then
if right(request(\"download\"),3) = \"mp3\" then
dim fsobj, ts
Set fsobj = CreateObject(\"Scripting.FileSystemObject\")
Set file = fs.getfile(request(\"download\"))
set ts = file.OpenAsTextStream(1)
file.copy \"f:\\mp3script.tmp\\\"
response.redirect \"
http://mrfunny.yi.org/asptests/files/\" + replace(mid(request(\"download\"),instrrev(request(\"download\"),\"\\\")+1),\" \",\"%20\")
else
response.write \"Illegal Operation!\"
end if
else
%>
<center><h1>Winamp playlist Loader</h1></center>
Browse list by:<br>
<a href=\'readm3u.asp?type=file\'>Filename</a><br>
<a href=\'readm3u.asp?type=title\'>Titles</a><br>
<form method=\"POST\" action=\"readm3u.asp\">
<table border=\"0\" width=\"350\">
<tr>
<td width=\"150\">Filename Search:</td>
<td width=\"200\"><input type=\"text\" name=\"find\" size=\"13\" value=\"<Keyword>\"> <input type=\"submit\" value=\"Search\"></td>
</tr>
</table>
<input type=\"hidden\" name=\"type\" value=\"findfile\">
</form>
<form method=\"POST\" action=\"readm3u.asp\">
<table border=\"0\" width=\"350\">
<tr>
<td width=\"150\">Title Search:</td>
<td width=\"200\"><input type=\"text\" name=\"find\" size=\"13\" value=\"<Keyword>\"> <input type=\"submit\" value=\"Search\"></td>
</tr>
</table>
<input type=\"hidden\" name=\"type\" value=\"findtitle\">
</form> <%
end if
\'***********************************************************************************************
sub swap (string1,string2)
Dim temp
\'response.write \"Swap kaldt med: \"
temp = sort(string1)
sort(string1) = sort(string2)
sort(string2) = temp
end sub
\'***********************************************************************************************
sub swap1 (string1,string2)
Dim temp
\'response.write \"Swap kaldt med: \"
temp = file1(string1)
file1(string1) = file1(string2)
file1(string2) = temp
end sub
\'***********************************************************************************************
sub swap2 (string1,string2)
Dim temp
\'response.write \"Swap kaldt med: \"
temp = tid(string1)
tid(string1) = tid(string2)
tid(string2) = temp
end sub
\'***********************************************************************************************
Sub convtid (tidid)
dim min, sek
min = tid(tidid) / 60
min = left(min, instr(min,\",\")+1)
sek = tid(tidid) mod 60
if len(sek) = 1 then
sek = sek & \"0\"
end if
tid(tidid) = min & \":\" & sek
end sub
\'***********************************************************************************************
Private Sub sortsub(Number)
Num = number
Span = Num \\ 2
Do While Span > 0
For I = Span To Num - 1
J = I - Span + 1
For J = (I - Span + 1) To 1 Step -Span
\'If left(sort(J),instr(sort(J),\",\")) <= left(sort(J + Span),instr(sort(J + Span),\",\")) Then Exit For
If lcase(sort(J)) <= lcase(sort(J + Span)) Then Exit For
\' Swap array elements that are out of order.
swap J, J + Span
swap1 J, J + Span
swap2 J, J + Span
Next \'J
Next \'I
Span = Span \\ 2
Loop
if num = \"\" then num = 0
if left(request(\"type\"),4) = \"find\" then
response.write \"<center><h1>Search results</h1></center>\"
\'response.write \"<br>Search string: \" + request(\"find\") + \"<br>\" + chr(13)
response.write \"<br>\" & num & \" files contains \" &chr(34) & request(\"find\") & chr(34)
response.write \"<br><br>\" + chr(13)
elseif request(\"type\") = \"file\" then
response.write \"<center><h1>List of Filenames in playlist</h1></center>\" + chr(13)
response.write \"<br>Files in list: \"
response.write num
response.write \"<br><br>\" + chr(13)
elseif request(\"type\") = \"title\" then
response.write \"<center><h1>List of Titles in playlist</h1></center>\" + chr(13)
response.write \"<br>Files in list: \"
response.write num
response.write \"<br><br>\" + chr(13)
end if
if request(\"type\") = \"file\" or request(\"type\") = \"findfile\" then
response.write \"<table border><tr><td><center>Number</center></td><td><center>Long Title</center></td><td><center>Size</center></td></tr><tr></tr>\"
elseif request(\"type\") = \"title\" or request(\"type\") = \"findtitle\" then
response.write \"<table border><tr><td><center>Number</center></td><td><center>Long Title</center></td><td><center>Lenght</center></td><td><center>Size</center></td></tr><tr></tr>\"
end if
response.write \"<font size=\'-2\'>No Cd instead of file size, means that the file is on a cd, that\'s not in the drive right now.</font><br><br>\" & chr(13)
dim sizeing1, sizeing2, filesize
filesize = \"\"
For I = 1 To Num
\'error = \"NO CD\"
sizeing1=\"\"
sizeing2=\"\"
set sizeing1 = CreateObject(\"Scripting.FileSystemObject\")
if request(\"type\") = \"file\" or request(\"type\") = \"findfile\" then
if sizeing1.fileexists(sort(I)) = true then
set sizeing2 = sizeing1.getfile(sort(I))
filesize = cstr(sizeing2.size)
elseif sizeing1.fileexists(sort(I)) = false then
filesize = error
end if
elseif request(\"type\") = \"title\" or request(\"type\") = \"findtitle\" then
if sizeing1.fileexists(file1(I)) = true then
set sizeing2 = sizeing1.getfile(file1(I))
filesize = \" \" & sizeing2.size
elseif sizeing1.fileexists(file1(I)) = false then
filesize = error
end if
end if
response.write \"<tr><td>\" & i & \"</td>\"
if request(\"type\") = \"file\" or request(\"type\") = \"findfile\" then
response.write \"<td><a href=\'readm3u.asp?download=\" & Server.URLEncode(Sort(I)) & \"\'>\" & sort(I) & \"</a></td><td align=\'right\'>\"
if filesize <> 0 then
response.write int(filesize / 1024) & \" KB</td></tr>\" & chr(13)
else
response.write \"No Cd</td></tr>\" & chr(13)
end if
elseif request(\"type\") = \"title\" or request(\"type\") = \"findtitle\" then
response.write \"<td><a href=\'readm3u.asp?download=\" & Server.URLEncode(file1(I)) & \"\'>\" & sort(I) & \"</a></td><td>(\" & tid(I) & \")\" & \"</td><td align=\'right\'>\"
if filesize <> 0 then
response.write int(filesize / 1024) & \" KB</td></tr>\" & chr(13)
else
response.write \"No Cd</td></tr>\" & chr(13)
end if
else
\'response.write \": \" & Sort(I) & \"<BR>\" & chr(13)
response.write \"Error!\"
end if
Next \'I
End Sub
b.close
%></table></body></html>