softwrite.asp
来自「多用户管理分权限发布、管理软件信息; 自由选择系统默认为静态HTML或动态A」· ASP 代码 · 共 422 行
ASP
422 行
<!--#include file="CONNsky.ASP"-->
<%
dim CacheName
CacheName = Replace(Replace(Replace(Replace(LCase(Server.MapPath("index.asp")),"index.asp",""),":",""),"\",""),"admin","")
if session(CacheName & "AdminName")="" then
Response.redirect "login.asp"
Response.End
else
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>批量自动生成本地数据库</title>
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<%
''=================================================
''设置区,可以设置生成后下载地址的名称,和是否覆盖已经有的记录
SoftUrlName_1="下载地址1"
SoftOverWrite="yes" 'yes覆盖,no不覆盖,注意大小写
''设置结束
''=====================================================
'url=Request("url")
url="soft"
id=Request("id")
on error resume next
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr (CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
Url = "http://www.skycn.com/"&url&"/"&id&".html"
set oSend=createobject("Microsoft.XMLHTTP")
SourceCode = oSend.open ("GET",url,false)
oSend.send()
if err.number<>0 then
Response.write err.description
Response.End()
end if
SourceCode = bytes2BSTR(oSend.responseBody)
if instr(SourceCode,"建议您检查输入文字有无错误")=0 then
'为了取软件分类,先取SourceCode1=SourceCode
SourceCode1=SourceCode
'response.write SourceCode
'response.end
SkySoftId=id
'response.write SkySoftId
betw=instr(SourceCode," <td vAlign=top width=540>")-instr(SourceCode,"* </b>为了达到最快的下载速度")
first=instr(SourceCode," <td vAlign=top width=540>")
SourceCode = Mid(SourceCode,first,abs(betw))
SourceCode =replace(SourceCode,"http://count.skycn.com/1softdownload.php?id="&Id&"&url=","")
tt1=split(SourceCode,"<hr")
end if
'取软件的类别
betw1=instr(SourceCode1,"您的位置:")-instr(SourceCode1,"</td><td align=right><script language=javascript src=../js/text_ad2.js></script>")
first1=instr(SourceCode1,"您的位置:")
SourceCode1 = Mid(SourceCode1,first1,abs(betw1))
SourceCode1 =replace(SourceCode1,"您的位置:","")
SourceCode1 = Mid(SourceCode1,240,50)
betw1=instr(SourceCode1,"e='")-instr(SourceCode1,"'>")
first1=instr(SourceCode1,"e='")
SourceCode1 = Mid(SourceCode1,first1,abs(betw1))
SourceCode1 =replace(SourceCode1,"e='软件分类 - ","")
dim SoftClass_1,SoftClass_2 '主类别,二级类别
SoftClass_1 = Mid(SourceCode1,1,4)
SoftClass_2 = Mid(SourceCode1,7)
'取软件的类别结束
%>
<!---<textarea name="textarea" cols="100" rows=20><%'response.write SourceCode%></textarea><BR>---!-->
<%
'取软件各种信息
'SourceCode_0是页面取得的总数据
''SourceCode_1是截取需要内容所需的开始位置的代码'
''SourceCode_1是截取需要内容所需的结束位置的代?
''SourceCode_1是截取需要内容所需的代码中多余的内容
Function GetSourceCode(SourceCode_0,SourceCode_1,SourceCode_2,SourceCode_3)
between=instr(SourceCode_0,SourceCode_1)-instr(SourceCode_0,SourceCode_2)
first=instr(SourceCode_0,SourceCode_1)
GetSourceCode = Mid(SourceCode_0,first,abs(between))
GetSourceCode =replace(GetSourceCode,SourceCode_3,"")
end function
dim SoftName,SoftSize,SoftLan,SoftType,SoftOS,SoftTime,SoftMail,SoftBrief,SoftType_1,SoftType_2,Softdj '软件名称,软件大小,软件语言,软件性质,应用平台,加入时间,联系人,软件介绍,类别,授权,推荐等级
SoftName=GetSourceCode(SourceCode,"<b><font color='#004FC6' size='3'>","</font></b></td></tr>","<b><font color='#004FC6' size='3'>")
SoftSize=GetSourceCode(SourceCode,"<b>软件大小:</b>","<br><b>软件语言:</b>","<b>软件大小:</b>")
SoftSize=replace(SoftSize," KB","")
SoftLan=GetSourceCode(SourceCode,"<br><b>软件语言:</b>","<br><b>软件类别:</b>","<br><b>软件语言:</b>")
SoftType=GetSourceCode(SourceCode,"<br><b>软件类别:</b>","<br><b>应用平台:</b>","<br><b>软件类别:</b>")
SoftType =replace(SoftType," /"&SoftClass_2,"")
SoftType_1=Mid(SoftType,13,4)
if SoftType_1="汉化补丁" then
SoftType_1="汉化补丁"
end if
SoftType_2=Mid(SoftType,20,3)
SoftOS=GetSourceCode(SourceCode,"<br><b>应用平台:</b>","<br><b>界面预览:</b>","<br><b>应用平台:</b>")
SoftTime=GetSourceCode(SourceCode,"<br><b>加入时间:</b>","<br><b>下载次数:</b>","<br><b>加入时间:</b>")
SoftTime=replace(SoftTime," ","")
SoftMail=GetSourceCode(SourceCode,"title='与他联系'>","</A></td><td width=285 align='center'><script","title='与他联系'>")
SoftDeveloper=GetSourceCode(SourceCode,"<b>开 发 商:</b>","<br><br><b>软件介绍","<b>开 发 商:</b>")
SoftDeveloper=GetSourceCode(SoftDeveloper,"target=_blank>http://","</A>","target=_blank>")
SoftDeveloper =replace(SoftDeveloper,"<A href='' target=_blank></A>","")
SoftBrief=GetSourceCode(SourceCode,"_ad4.js></script><br>","<script language=javascript src=../js/text_ad5.js></script></td></tr></table></td></tr></table>","_ad4.js></script><br>")
Softdj=GetSourceCode(SourceCode,"<b>推荐等级:</b>","<b>在线注册:</b>","<b>推荐等级:</b>")
Softdj=GetSourceCode(Softdj,"star",".gif","star")
dim SoftUrl_1,SoftUrl_2,SoftUrl_3,SoftUrl_4,SoftUrl_5,SoftUrl_6,SoftUrl_7,SoftUrl_8,SoftUrl_9,SoftUrl_10,SoftUrl_11,SoftUrl_12,SoftUrl_13,SoftUrl_14,SoftUrl_15,SoftUrl_16,SoftUrl_17
SoftUrl_1=GetSourceCode(SourceCode,"border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=http://zztl-","' target=_blank>河南铁通下载</A>","border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=")
SoftUrl_2=GetSourceCode(SourceCode,"border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=http://hn-","' target=_blank>河南南阳下载</A>","border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=")
SoftUrl_3=GetSourceCode(SourceCode,"border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=http://yz-","' target=_blank>扬州热线下载</A>","border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=")
SoftUrl_4=GetSourceCode(SourceCode,"border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=http://on165-","' target=_blank>重庆联通下载</A>","border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=")
SoftUrl_5=GetSourceCode(SourceCode,"border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=http://cbbn-","' target=_blank>淄博网通下载</A>","border=0><A href='http://count.skycn.com/softdownload.php?id="&id&"&url=")
'response.write "<BR>==============================================================<BR>"
response.write "SoftClass_1 ="&SoftClass_1&"<BR>"
response.write "SoftClass_2 ="&SoftClass_2&"<BR>"
response.write "SoftName ="&SoftName&"<BR>"
response.write "SoftSize ="&SoftSize&"<BR>"
response.write "SoftLan ="&SoftLan&"<BR>"
response.write "SoftType ="&SoftType&"<BR>"
response.write "SoftType_1 ="&SoftType_1&"<BR>"
response.write "SoftType_2 ="&SoftType_2&"<BR>"
response.write "SoftOS ="&SoftOS&"<BR>"
response.write "SoftTime ="&SoftTime&"<BR>"
response.write "SoftMail ="&SoftMail&"<BR>"
response.write "SoftDeveloper ="&SoftDeveloper&"<BR>"
response.write "SoftBrief ="&SoftBrief&"<BR>"
response.write "SoftUrl_1 ="&SoftUrl_1&"<BR>"
response.write "SoftUrl_2 ="&SoftUrl_2&"<BR>"
response.write "SoftUrl_3 ="&SoftUrl_3&"<BR>"
response.write "SoftUrl_4 ="&SoftUrl_4&"<BR>"
response.write "SoftUrl_5 ="&SoftUrl_5&"<BR>"
response.write "SoftId ="&id&"<BR>"
%>
<%
if SoftUrl_1<>"" then
SoftUrl=SoftUrl_1
elseif SoftUrl_2<>"" then
SoftUrl=SoftUrl_2
elseif SoftUrl_3<>"" then
SoftUrl=SoftUrl_3
elseif SoftUrl_4<>"" then
SoftUrl=SoftUrl_4
elseif SoftUrl_5<>"" then
SoftUrl=SoftUrl_6
end if
website= request.servervariables("server_name")
start=instrrev(SoftUrl,"/")
over=len(SoftUrl)
SoftUrlName=mid(SoftUrl,start+1,over-start)
'=================================
'开始处理数据,加入数据库
'验证取得的数据中必需的项目是否为空,为空则跳
if SoftName<>"" and SoftSize<>"" and SoftLan<>"" and SoftType<>"" and SoftUrlName<>"" then
'处理软件的一级类别,如数据库中没有该类别,则增加
set rs=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_SoftSort Where Depth=0 and SortName='"&trim(SoftClass_1)&"'"
Rs.Open Sql,Conn,1,3
If Rs.Eof And Rs.Bof Then
Rs.AddNew
set rsid=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_SoftSort where sortid"
Rsid.Open Sql,Conn,1,3
If not(Rsid.Eof And Rsid.Bof) Then
tid=rsid.recordcount
rs("sortid")=tid + 1
else
rs("sortid")=1
end if
Rsid.Close
rs("SortName")=trim(SoftClass_1)
rs("Readme")=trim(SoftClass_1)
rs("Depth")=0
set rs1=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_SoftSort Where Depth=0"
Rs1.Open Sql,Conn,1,3
If not(Rs1.Eof And Rs1.Bof) Then
tid1=rs1.recordcount
rs("Rootid")=tid1 + 1
else
rs("Rootid")=1
end if
Rs1.Close
Set Rs1 = Nothing
rs("Orders")=0
rs("Parentid")=0
rs("StrParent")=0
rs("Child")=0
Rs.Update
Rs.Close
Set Rs = Nothing
End If
Set rsc = Conn.Execute("select * from NC_SoftSort where Depth=0 and SortName='"&trim(SoftClass_1)&"'")
RootID=rsc("Rootid")
Child1=rsc("Child")
rsc.close
set rsc=nothing
'处理软件的二级类别,如数据库中没有该类别,则增加
set rst=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_SoftSort Where Depth=1 and RootID="&RootID&" and SortName='"&trim(SoftClass_2)&"'"
Rst.Open Sql,Conn,1,3
If Rst.Eof And Rst.Bof Then
Rst.AddNew
set rsid=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_SoftSort"
Rsid.Open Sql,Conn,1,3
If not(Rsid.Eof And Rsid.Bof) Then
tidd=rsid.recordcount
rst("sortid")=tidd + 1
else
rst("sortid")=1
end if
Rsid.Close
rst("SortName")=trim(SoftClass_2)
rst("Readme")=trim(SoftClass_2)
rst("Depth")=1
rst("RootID")=RootID
set rst1=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_SoftSort Where Depth=1"
Rst1.Open Sql,Conn,1,3
If not(Rst1.Eof And Rst1.Bof) Then
tid2=rst1.recordcount
rst("Orders")=tid2 + 1
else
rst("Orders")=1
end if
Rst1.Close
Set Rst1 = Nothing
rst("ParentID")=RootID
rst("StrParent")=RootID
rst("Child")=0
Rst.Update
Rst.Close
Set Rst = Nothing
set rst=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_SoftSort Where Depth=0 and SortName='"&trim(SoftClass_1)&"'"
Rst.Open Sql,Conn,1,3
rst("Child")=Child1 + 1
Rst.Update
Rst.Close
Set Rst = Nothing
End If
'取类别的ID号
Set rsc = Conn.Execute("select * from NC_SoftSort where Depth=1 and RootID="&RootID&" and SortName='"&trim(SoftClass_2)&"'")
FRootid=rsc("Rootid")
Fsortid=rsc("sortid")
rsc.close
set rsc=nothing
'===================================================
'可以开始写入软件记录
'验证该条记录是否已经存在数据库中
set rs=server.CreateObject("ADODB.RecordSet")
rs.open "select * from NC_Softinfo where skycnid="&id,conn,1,1
if not rs.eof then
SoftOverWriteID=rs("softid")
'response.write "<BR>============<Br>"
'response.write SoftOverWriteID
'是否覆盖
if SoftOverWrite="yes" then
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from NC_Softinfo where skycnid="&id
rs.open sql,conn,1,3
'rs("skycn_id")=SkySoftId
rs("sortid")=Fsortid
rs("RootId")=RootId
rs("SoftName")=DelNbsp(SoftName)
rs("SoftVer")=""
rs("SortName")=trim(SoftClass_2)
rs("Content")=SoftBrief
rs("Language")=DelNbsp(SoftLan)
rs("SoftType")=DelNbsp(SoftType_1)
rs("RunSystem")=DelNbsp(SoftOS)
rs("impower")=DelNbsp(SoftType_2)
rs("SoftSize")=DelNbsp(SoftSize)
rs("Grades")=Softdj
rs("Contact")=DelNbsp(SoftMail)
rs("Homepage")=DelNbsp(SoftDeveloper)
rs("username")="tianlan"
rs("SoftTime")=now()
rs("HitsTime")=now()
rs.update
rs.close
'写入
if SoftOverWriteID<>"" then
filename1=FileNameAdd(SoftOverWriteID,1,SoftUrlName_1,SoftUrlName,Fsortid,1)
end if
msg="完成,已存在该软件,您选择覆盖该软件"
call EndSoftWrite()
elseif SoftOverWrite="no" then
rs.close
msg="已存在该软件,您选择不覆盖该软件"
call EndSoftWrite()
end if
else
'如该条记录不存在数据库中则开始加入数据库中
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from NC_Softinfo where (softid is null)"
rs.open sql,conn,1,3
rs.addnew
set rsid=server.CreateObject("ADODB.RecordSet")
Sql="Select * From NC_Softinfo"
Rsid.Open Sql,Conn,1,3
If not(Rsid.Eof And Rsid.Bof) Then
tid=rsid.recordcount
rs("softid")=tid + 1
else
rs("softid")=1
end if
Rsid.Close
Set Rsid = Nothing
rs("skycnid")=Id
rs("sortid")=Fsortid
rs("RootId")=RootId
rs("SoftName")=DelNbsp(SoftName)
rs("SoftVer")=""
rs("Content")=SoftBrief
rs("SortName")=trim(SoftClass_2)
rs("Language")=DelNbsp(SoftLan)
rs("SoftType")=DelNbsp(SoftType_1)
rs("RunSystem")=DelNbsp(SoftOS)
rs("impower")=DelNbsp(SoftType_2)
rs("SoftSize")=DelNbsp(SoftSize)
rs("Grades")=Softdj
rs("Contact")=DelNbsp(SoftMail)
rs("Homepage")=DelNbsp(SoftDeveloper)
rs("username")="tianlan"
rs("SoftTime")=SoftTime
rs("HitsTime")=SoftTime
rs.update
rs.close
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from NC_Softinfo order by Softid desc"
rs.open sql,conn,1,1
if not rs.eof then
newid=rs("Softid")
end if
rs.close
if newid<>"" then
filename1=FileNameAdd(newid,1,SoftUrlName_1,SoftUrlName,Fsortid,0)
end if
msg="完成"
call EndSoftWrite()
end if
else
msg="不合格"
call EndSoftWrite()
end if
function DelNbsp(SourceCode)
DelNbsp =replace(SourceCode," ","")
end function
function FileNameAdd(newid,i,filename1,filename2,tid,fg)
set rs=server.CreateObject("ADODB.RecordSet")
if fg=1 then
sql="select * from NC_SoftSite where SoftID="&newid
rs.open sql,conn,1,3
rs("sortid")=tid
rs("SiteName")=filename1
rs("DownSite")=filename2
else
sql="select * from NC_SoftSite where (id is null)"
rs.open sql,conn,1,3
rs.addnew
rs("sortid")=tid
rs("SoftId")=newid
rs("serverid")=i
rs("SiteName")=filename1
rs("DownSite")=filename2
end if
rs.update
rs.close
end function
sub EndSoftWrite()
response.write "<BR><font color=#ff0000><b>"&msg&"</b></font><br>"
end sub
%>
</body></html>
<%end if%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?