高分求一段能完成如下功能的asp代码。(200分)

  • 主题发起人 sunjinhua
  • 开始时间
S

sunjinhua

Unregistered / Unconfirmed
GUEST, unregistred user!
没用过ASP,所以不知怎么用ASP来完成。
用户这样调用:
www.xxx.com/test.asp?ip=xxx.xxx.xxx.xxx,bgndatetime=2001-06-12 18:20:30,enddateTime=2001-06-12 18:20:40
然后服务器中的test.asp能把参数内容记录下来到一个文本文件中。变成如下的形式。
xxx.xxx.xxx.xxx,2001-06-12 18:20:30,2001-06-12 18:20:40
当用户再用同样的参数调用并且enddatetime变化时,如
www.xxx.com/test.asp?ip=xxx.xxx.xxx.xxx,bgndatetime=2001-06-12 18:20:30,enddateTime=2001-06-12 18:22:40
那么这条记录应变为:
xxx.xxx.xxx.xxx,2001-06-12 18:20:30,2001-06-12 18:22:40
如果ip及bgndateTime变化了,则追加记录到文件中。

不知说没说清,请asp高手相助,老板逼的太紧,先看asp来不急了:(
 

栋栋

Unregistered / Unconfirmed
GUEST, unregistred user!
www.xxx.com/test.asp?ip=xxx.xxx.xxx.xxx,bgndatetime=2001-06-12 18:20:30,enddateTime=2001-06-12 18:22:40
---------------------------------------^ 为何不用 &
呢?
如果用 &
就方便多了
如果一定要用 , 那么就用 Split 函数分割两次就行了
第一次分割 , 第二次分割 = 就可以了
就可以到 xxx.xxx.xxx.xxx,2001-06-12 18:20:30,2001-06-12 18:22:40这三个东西了
然后写入文本文件就可以了
至于如何修改那条记录吗,可以用 Instr 来检查,当然要重写一个临时文件,然后再写入
不过好像有点问题,比如说同时又多个用户访问的话,可能会出问题
 
H

honestman

Unregistered / Unconfirmed
GUEST, unregistred user!
通常是用&的吧???
用数据库好象比较方便啊!
 
B

bnulaw

Unregistered / Unconfirmed
GUEST, unregistred user!
试试这段代码,没调试
<%
dim content,myrray(),i,j,bol
content="ip=" + trim(Request.QueryString("ip"))
dim fso,myfile
set fso=server.createobject("scripting.filesystemobject")
set myfile=fso.openTextFile("e:/test.txt",1,true)
i=0
do
while not myfile.atendofstream
i=i+1
redim myrray(i)
myrray(i-1)=trim(myfile.readline)
Response.Write(myrray(i-1))
loop

for j=0 to i-1
if left(myrray(j),18)=left(content,18) then
myrray(j)=content
bol=true
end if
next

if bol<>true then
redim myrray(i+1)
myrray(i)=content
end if

myfile.close
set myfile=fso.createTextFile("e:/test.txt",true)

for j=0 to i
myfile.writeline(myrray(j))
next
myfile.close
set myfile=nothing
set fso=nothing
%>
 
B

bnulaw

Unregistered / Unconfirmed
GUEST, unregistred user!
漏了重要的preserve ,下面这段代码已经测试过,没有问题
<%
dim content,myrray(),i,j,bol
content="ip=" + trim(Request.QueryString("ip"))
dim fso,myfile
set fso=server.createobject("scripting.filesystemobject")
set myfile=fso.openTextFile("e:/test.txt",1,true)
i=0
do
while not myfile.atendofstream
i=i+1
redim preserve myrray(i)
myrray(i-1)=trim(myfile.readline)

loop

for j=0 to i-1
if left(myrray(j),18)=left(content,18) then
myrray(j)=content
bol=true

end if
next

if bol<>true then
redim preserve myrray(i+1)
myrray(i)=content
end if

myfile.close
set myfile=fso.createTextFile("e:/test.txt",true)

for j=0 to i
if trim(myrray(j))<>"" then
myfile.writeline(myrray(j))
end if
next
myfile.close
set myfile=nothing
set fso=nothing
%>
 
M

madaha

Unregistered / Unconfirmed
GUEST, unregistred user!
用ACCESS数据库
 
R

runner1981

Unregistered / Unconfirmed
GUEST, unregistred user!
你们有没有用过application("endtime")
它可以用
application.lock
.....
application.unlook
来控制只有一个用户写进文本,还有就是建议用&amp;来区分不同的变量
 

悲酥清风

Unregistered / Unconfirmed
GUEST, unregistred user!
如果用&来连接的话,只需几行代码就可以解决问题了。
 
S

sunjinhua

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢各位。
 
S

sunjinhua

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
908
SUNSTONE的Delphi笔记
S
S
回复
0
查看
931
SUNSTONE的Delphi笔记
S
S
回复
0
查看
755
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
顶部