这代码是什么意思?
这代码是什么意思?那里有问题……要
使用这代码服务器要什么条件不???
新手急等,
[quote]case "pass"
conn.execute("update china_data set mark='yes' where adid in("&theid&")")
ServerURL=CStr(Request.ServerVariables("SCRIPT_NAME"))
n=InStrRev(ServerURL,"/") '从右边第一个字符起查找"_"的位置,n为返回值
ServerURL=left(ServerURL, n-1)'显示从左边数第"n-1"个字符前面的字符,
n=InStrRev(ServerURL,"/") '从右边第一个字符起查找"_"的位置,n为返回值
ServerURL=left(ServerURL, n)'显示从左边数第"n"个字符前面的字符,
ServerURL="http://"&Request.ServerVariables("SERVER_NAME")&ServerURL&"show.asp?id="
For i=1 To request("adid").count
id=strint(request("adid")(i))
set http=server.createobject("Ms" & "xml" & "2.XM" & "LHTTP")
Http.open "get",ServerURL&id ,false
Http.send()
if Http.readystate=4 then
AA=Http.responseText
set objfso = Server.CreateObject("Scripting.FileSystemObject")
set htmout = objfso.CreateTextFile(server.mappath("../html/"&id&".htm"))
htmout.write rep1(AA)
htmout.close
set htmout=nothing
set objfso=nothing
End IF
set http=nothing
Next
case "report"
conn.execute("delete from china_report where id in("&theid&")")
end select
conn.close:set conn=nothing
response.redirect request.ServerVariables("HTTP_REFERER")
%>
[/quote]
[[it] 本帖最后由 wyjx 于 2008-6-11 15:25 编辑 [/it]]
'执行更新操作将表china_data中adid为theid变量中存在的数据的mark字段的值更新为yes
conn.execute("update china_data set mark='yes' where adid in("&theid&")")
'返回当前运行脚本的URL绝对路径
ServerURL=CStr(Request.ServerVariables("SCRIPT_NAME"))
'下面的代码在对这个路径字符串进行处理和拼接字符串
n=InStrRev(ServerURL,"/") '从右边第一个字符起查找"_"的位置,n为返回值
ServerURL=left(ServerURL, n-1)'显示从左边数第"n-1"个字符前面的字符,
n=InStrRev(ServerURL,"/") '从右边第一个字符起查找"_"的位置,n为返回值
ServerURL=left(ServerURL, n)'显示从左边数第"n"个字符前面的字符,
ServerURL="http://"&Request.ServerVariables("SERVER_NAME")&ServerURL&"show.asp?id="
'Request.ServerVariables("SERVER_NAME")返回当前服务器的计算机名称
'循环adid元素,该元素很可能是从某个页面的表单提交过来的,而且在表单里,该元素不止一个有很多,因此这里使用循环来处理
For i=1 To request("adid").count
'取得其中的一个元素的值strint不像是系统内置函数,可能是自定义函数,未在楼主提供的代码内发现定义该函数的代码
id=strint(request("adid")(i))
'创建一个远程访问组件对象MSXML2.XMLHTTP一种提供后台远程访问XML或HTML的网页功能的组件
set http=server.createobject("Ms" & "xml" & "2.XM" & "LHTTP")
'开始使用组件get方式访问ServerURL&id所指向的URL地址
Http.open "get",ServerURL&id ,false
Http.send()'发送访问请求
'判断访问是否成功Http.readstate=4表示成功访问远程URL
if Http.readystate=4 then
AA=Http.responseText'获得远程URL的HTML的代码
set objfso = Server.CreateObject("Scripting.FileSystemObject")
'创建FSO文件操作组件对象
'下面的代码将获得的HTML代码写入一个由server.mappath("../html/"&id&".htm")创建的HTML文件,该文件由程序创建。
set htmout = objfso.CreateTextFile(server.mappath("../html/"&id&".htm"))
htmout.write rep1(AA)'写入HTML代码到创建的文件
htmout.close'写入完毕后关闭文件
'将刚才创建的两个组件对象从内存中清除
set htmout=nothing
set objfso=nothing
End IF
set http=nothing'清除刚才创建的http对象
Next
case "report"
'删除表china_report中id为theid变量所包含的值的数据
conn.execute("delete from china_report where id in("&theid&")")
end select
'关闭并清除数据库连接对象
conn.close:set conn=nothing
response.redirect request.ServerVariables("HTTP_REFERER")'跳转到上一页
%> 斑竹就是斑竹,解释这么详细啊
其实这段代码主要弄明白几个主要的就可以了
xmlhttp和fso 使用这段代码一是在服务器上的IIS(Interent信息服务)默认网站要开放写入权限,否则运行是其中一段代码会因为权限不足而错误。
二是服务器上要安装MSXML2.XMLHTTP组件(这个组件微软官方网站或百度搜索都可以找到,很好找的)否则会出现找不到组件的错误。
新问题
我在一个页面掉用这个代码出显无法显示是怎么的? 把错误页面的信息贴上来就这一页。是一个信息提交页
<!--#include file="Conn.asp"--><!--#include file="setup.asp"-->
<!--#include file="inc/function.asp"-->
<%if Request.Cookies("username")="" Then
Response.Write"<script>alert(""请选登陆"");location.href=""User.asp"";</script>"
Response.End
End if
Dim proof,GetCode
proof=Strint(Request("proof"))
GetCode=Strint(Session("GetCode"))
Session("GetCode")=""
If proof<>GetCode Or GetCode=0 Then
Response.Write"<script>alert('验证码错误,请刷新后重填!');history.go(-1)</script>"
Response.End()
End If
Dim dtitle,dcolor,dbgcolor1,dcu,dlei,dispic,dpic,dtext,dstop,dtop,dmoney,sql,Rs
dtitle=HtmlEncode(Request.Form("dtitle"))
dcolor=HtmlEncode(Request.Form("dcolor"))
dcu=HtmlEncode(Request.Form("dcu"))
city_oneid=strint(Request.Form("city_one"))
city_twoid=strint(Request.Form("city_two"))
city_threeid=strint(Request.Form("city_three"))
type_oneid=strint(Request.Form("type_one"))
type_twoid=strint(Request.Form("type_two"))
type_threeid=strint(Request.Form("type_three"))
dispic=HtmlEncode(Request.Form("dispic"))
dpic=HtmlEncode(Request.Form("dpic"))
IF dpic<>"" Then
IF lcase(left(dpic,7))="http://" Or lcase(right(dpic,3))="asp" Or lcase(right(dpic,3))="htm" Then dpic=""
End IF
dtext=HtmlEncode2(Request.Form("dtext"))
dusername=HtmlEncode(Request.Form("dusername1"))
dtel=HtmlEncode(Request.Form("dtel1"))
dcardid=HtmlEncode(Request.Form("dcardid1"))
dstop=dateadd("d",Request.Form("dstop"),date())
dblink
city_one=Conn.Execute("select city from china_city where twoid=0 and id="&city_oneid)(0)
If city_twoid>0 Then city_two=Conn.Execute("select city from china_city where id="&city_oneid&" and threeid=0 and twoid="&city_twoid)(0)
If city_threeid<>0 Then city_three=Conn.Execute("select city from china_city where id="&city_oneid&" and twoid="&city_twoid&" and threeid="&city_threeid)(0)
type_one=Conn.Execute("select name from china_type where twoid=0 and id="&type_oneid)(0)
If type_twoid<>0 Then type_two=Conn.Execute("select name from china_type where id="&type_oneid&" and threeid=0 and twoid="&type_twoid)(0)
If type_threeid<>0 Then type_three=Conn.Execute("select name from china_type where id="&type_oneid&" and twoid="&type_twoid&" and threeid="&type_threeid)(0)
If dtitle="" Or city_oneid="" Or type_oneid="" Or dtext="" Then
Conn.close:Set Conn=Nothing
Response.Write"<script>alert('请认真填写!');history.go(-1)</script>"
Response.End
End If
'使用数组 返回值数组 = Split("字符串","分割符")<br />
'IsArray()判断是否数组的函数,LBound()取数组的下标,UBound()取数组的上标。
unhtmlgl=split(webguolv,"|")
If IsArray(unhtmlgl) Then
for i=0 to UBound(unhtmlgl)
dtitle=replace(dtitle,unhtmlgl(i),"***")
next
End If
unhtmlgl=split(webguolv,"|")
If IsArray(unhtmlgl) Then
for i=0 to UBound(unhtmlgl)
dtext=replace(dtext,unhtmlgl(i),"***")
next
End If
sql="select * from china_data"
Set Rs=Server.createobject("adodb.recordset")
Rs.open sql,Conn,1,3
Rs.addnew
Rs("uid")=Request.Cookies("username")
Rs("title")=dtitle: Rs("color")=dcolor: Rs("cu")=dcu
Rs("city_oneid")=city_oneid:Rs("city_one")=city_one:Rs("city_two")=city_two:Rs("city_twoid")=city_twoid:Rs("city_three")=city_three:Rs("city_threeid")=city_threeid
Rs("type_oneid")=type_oneid:Rs("type_one")=type_one:Rs("type_twoid")=type_twoid:Rs("type_two")=type_two:Rs("type_threeid")=type_threeid:Rs("type_three")=type_three
Rs("ispic")=dispic
If lcase(left(dpic,7))="http://" Then dpic=""
Rs("pic")=dpic:Rs("text")=dtext:Rs("username")=dusername:Rs("tel")=dtel:Rs("cardid")=dcardid:Rs("stop")=dstop:Rs("money")=0
If webinfo="1" Then
Rs("mark")="no" '审核后通过
Else
Rs("mark")="yes" '直接通过
End If
Rs("ip")=getIP
Rs.update
id=Rs("adid")
Rs.close:Set Rs=Nothing
Conn.close:Set Conn=Nothing
If webinfo="1" Then
Response.Write"<script>alert('您的信息已经提交成功,请等待管理员的审核。请牢记本条信息的ID号:"&id&" 以便电话查询和修改信息');location='user.asp'</script>"
Else
''''''''''''''''''生成html开始''''''''''''''''''''''''''
ServerURL=CStr(Request.ServerVariables("SCRIPT_NAME"))
n=InStrRev(ServerURL,"/") '从右边第一个字符起查找"_"的位置,n为返回值
ServerURL=left(ServerURL, n)'显示从左边数第"n"个字符前面的字符,
ServerURL="http://"&Request.ServerVariables("SERVER_NAME")&""&ServerURL&"show.asp?id="&id&""
Set http=Server.createobject("Ms" & "xml" & "2.XM" & "LHTTP")
Http.open "get",ServerURL,false
Http.send()
Dim Temp,TempPath
If Http.readystate=4 Then
TempPath=Server.mappath("html/"&id&".htm")
AA=Http.responseText
Set objfso = Server.CreateObject("Scripting.FileSystemObject")
Set htmout = objfso.CreateTextFile(TempPath)
htmout.Write rep1(AA)
htmout.close:Set htmout=Nothing
IF objfso.FileExists(TempPath) Then
IF objfso.Getfile(TempPath).Size>100 Then
Temp="html/"&id&".htm"
End IF
End IF
Set objfso=Nothing
End IF
Set http=Nothing
IF Temp="" Then Temp="show.asp?id="&id
''''''''''''''''''生成html结束''''''''''''''''''''''''''
Response.Write"<script>alert('恭喜您的信息已经发布成功!现在跳转到您发布的信息页面!');location='"&Temp&"'</script>"
End If %> [quote][bo][un]yms123[/un] 在 2008-6-11 15:54 的发言:[/bo]
case "pass"
'执行更新操作将表china_data中adid为theid变量中存在的数据的mark字段的值更新为yes
conn.execute("update china_data set mark='yes' where adid in("&theid&")")
'返回当前运行脚本 ... [/quote]
版主真是伟大!支持。
页:
[1]
