📄 getmp3_function.asp
字号:
<!-- #include file="mp3_config.asp" -->
<%
dim mp3fso,xmlfile,xmlstr,configstr,configfile
dim mp3rs,mp3sql,mp3title,mp3postdate,mp3author,mp3_havenew
dim mp3url,mp3_i,mp3_j,mp3_info,totalmp32,mp3list
mp3_havenew=0
%>
<%
sub batchmp3(contentstr1,mp3title,mp3postdate,mp3author,bbsid)
call addmp3(getmp3(contentstr1),mp3title,mp3postdate,mp3author,bbsid)
call writeconfig()
call writexml()
end sub
sub batchmodmp3(contentstr1,mp3title,mp3postdate,mp3author,bbsid)
call modmp3(getmp3(contentstr1),mp3title,mp3postdate,mp3author,bbsid)
call writeconfig()
call writexml()
end sub
sub batchdelmp3(contentstr1,mp3title,mp3postdate,mp3author,bbsid)
call delmp3(getmp3(contentstr1),mp3title,mp3postdate,mp3author,bbsid)
call writeconfig()
call writexml()
end sub
sub scanbbs()
totalmp3=""
call opendb()
mp3sql="select id,topic,name,addtime,content from m3_bbs where valid=1 order by istop desc,addtime asc"
set mp3rs=server.CreateObject("adodb.recordset")
mp3rs.open mp3sql,conn,1,1
do while not mp3rs.eof
mp3list=getmp3(mp3rs("content"))
if mp3list<>"" then
call addmp3(mp3list,mp3rs("topic"),datevalue(mp3rs("addtime")),mp3rs("name"),mp3rs("id"))
end if
mp3rs.movenext
loop
mp3rs.close
set mp3rs=nothing
call closedb()
call writeconfig()
call writexml()
end sub
sub writeconfig()
if mp3_havenew=0 then exit sub
configstr="<"&"%"&vbcrlf
configstr=configstr&"dim lastupdate,totalmp3"&vbcrlf
configstr=configstr&"lastupdate="""&now()&""""&vbcrlf
configstr=configstr&"totalmp3="""&totalmp3&""""&vbcrlf
configstr=configstr&"%"&">"
set mp3fso=Server.CreateObject("Scripting.FileSystemObject")
set configfile=mp3fso.CreateTextFile(server.mappath("mp3_config.asp"),True)
configfile.write(configstr)
configfile.close
set configfile=nothing
set mp3fso=nothing
end sub
sub writexml()
if mp3_havenew=0 then exit sub
mp3_j=1
xmlstr="<?xml version=""1.0"" encoding=""gb2312""?>"&vbcrlf
xmlstr=xmlstr&"<Matrix3OnlineMP3>"&vbcrlf
if not isnull(totalmp3) then
totalmp32=totalmp3
totalmp32=split(totalmp32,"Θ")
for mp3_i=0 to ubound(totalmp32)
mp3_info=totalmp32(mp3_i)
if trim(mp3_info)<>"" then
mp3_info=split(mp3_info,"Ω")
if ubound(mp3_info)=4 then
xmlstr=xmlstr&" <mp3file mp3index="""&mp3_j&""" mp3url ="""&mp3_info(0)&""" mp3name = """&mp3_info(1)&""" postdate ="""&mp3_info(2)&""" postauthor="""&mp3_info(3)&""" bbsid="""&mp3_info(4)&"""/>"&vbcrlf
mp3_j=mp3_j+1
end if
end if
next
end if
xmlstr=xmlstr&"</Matrix3OnlineMP3>"
set mp3fso=Server.CreateObject("Scripting.FileSystemObject")
set xmlfile=mp3fso.CreateTextFile(server.mappath("music.xml"),True)
xmlfile.write(xmlstr)
xmlfile.close
set xmlfile=nothing
set mp3fso=nothing
end sub
sub addmp3(mp3str1,mp3title1,mp3postdate1,mp3author1,mp3bbsid)
if isnull(mp3str1) or mp3str1="" then exit sub
mp3str1=split(mp3str1,"Ω")
for mp3_i=0 to ubound(mp3str1)
mp3url=mp3str1(mp3_i)
if trim(mp3url)<>"" and instr(totalmp3,mp3url)=0 then
mp3_info=mp3url&"Ω"&mp3title1&"Ω"&mp3postdate1&"Ω"&mp3author1&"Ω"&mp3bbsid
if totalmp3="" then
totalmp3=mp3_info
else
totalmp3=mp3_info&"Θ"&totalmp3
end if
mp3_havenew=1
end if
next
end sub
sub modmp3(mp3str1,mp3title1,mp3postdate1,mp3author1,mp3bbsid)
if isnull(mp3str1) or mp3str1="" then exit sub
dim oldmp3info
mp3str1=split(mp3str1,"Ω")
for mp3_i=0 to ubound(mp3str1)
mp3url=mp3str1(mp3_i)
if trim(mp3url)<>"" and instr(totalmp3,mp3url)>0 then
oldmp3info=mid(totalmp3,instr(totalmp3,mp3url)+1)
if instr(oldmp3info,"Θ")>0 then oldmp3info=left(oldmp3info,instr(oldmp3info,"Θ")-2)
mp3_info=mp3url&"Ω"&mp3title1&"Ω"&mp3postdate1&"Ω"&mp3author1&"Ω"&mp3bbsid
totalmp3=replace(totalmp3,oldmp3info,mp3_info)
mp3_havenew=1
end if
next
end sub
sub delmp3(mp3str1,mp3title1,mp3postdate1,mp3author1,mp3bbsid)
if isnull(mp3str1) or mp3str1="" then exit sub
dim oldmp3info
mp3str1=split(mp3str1,"Ω")
for mp3_i=0 to ubound(mp3str1)
mp3url=mp3str1(mp3_i)
mp3_info=mp3url&"Ω"&mp3title1&"Ω"&mp3postdate1&"Ω"&mp3author1&"Ω"&mp3bbsid
if trim(mp3url)<>"" and instr(totalmp3,mp3_info)>0 then
totalmp3=replace(replace(totalmp3,mp3_info,""),"ΘΘ","Θ")
mp3_havenew=1
end if
next
end sub
function getmp3(contentstr)
getmp3 = ""
if isnull(contentstr) then exit function
if instr(contentstr,".mp3")=0 then exit function
dim re,Matches,Match,reContent
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="\]((http|https|ftp)://)?([^\[]*)(.mp3)\[\/"
Set Matches =re.Execute(contentstr)
For Each Match in Matches
reContent=replace(replace(Match.value,"[/",""),"]","")
if getmp3="" then
getmp3=reContent
else
getmp3=getmp3&"Ω"&reContent
end if
Next
set re=nothing
set Matches=nothing
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -