<% Function ShowCode(filename) Set fso = Server.CreateObject("Scripting.FileSystemObject") Set cnrs = fso.OpenTextFile(filename, 1) While Not cnrs.AtEndOfStream rsline = cnrs.ReadLine rsline = server.HTMLEncode(rsline) Response.Write(rsline & "<br>") Wend end Function %> <form action="viewcode.asp" method="post"> 输入文件名<input type="file" name="filename"> <input type="submit" value="查看源程序"> </form> <% file=request.form("filename") response.write (file & "源程序如下<hr>") If trim(file)<> "" then Call ShowCode(file) End If %> |
<% whichfile=server.mappath("test.txt") Set fso = CreateObject("Scripting.FileSystemObject") Set txt = fso.OpenTextFile(whichfile,1) rline = txt.ReadAll rline=replace(Server.HtmlEncode(rline),Chr(13),"<br>") Response.Write rline txt.Close %> |
<% If not request.Form("NextLine")="" then Set fso=Server.CreateObject("Scripting.FileSystemobject") textfile1=Server.MapPath("story.txt") set cnrs=fso.OpenTextFile(textfile1,8) cnrs.WriteLine(Request.Form("NextLine")) cnrs.Close end if %> 故事如下: <% Set fso=Server.CreateObject("Scripting.FileSystemObject") textfile1=Server.MapPath("story.txt") set cnrs=fso.OpenTextFile(textfile1,1) while not cnrs.AtEndOfStream Response.Write " " & cnrs.ReadLine wend cnrs.close %> <hr> <form method="post" action="story.asp"> 请输入这个故事的新行:<input name="NextLine" type="text" size="70"> <input type="submit" value="提交"> </form> |
<% whichfile=server.mappath("site.txt") set fso=createobject("Scripting.FileSystemObject") set thisfile=fso.opentextfile(whichfile) my_string=thisfile.readline a_num = instr(my_string,"A") b_num = instr(my_string,"B") c_num = instr(my_string,"C") d_num = instr(my_string,"D") total_num = len(my_string) a_value = mid(my_string,a_num+1,b_num-a_num-1) b_value = mid(my_string,b_num+1,c_num-b_num-1) c_value = mid(my_string,c_num+1,d_num-c_num-1) d_value = mid(my_string,d_num+1,total_num-d_num) select case request.form("website") case "A": a_value=a_value+1 case "B": b_value=b_value+1 case "C": c_value=c_value+1 case "D": d_value=d_value+1 end select mynew_string="A" & cstr(a_value) & "B" & cstr(b_value) & "C" & cstr(c_value) & "D" & cstr(d_value) set newfile=fso.createtextfile(whichfile) newfile.writeLine(mynew_string) newfile.close set fso=nothing %> 当前投票:<br> cnbruce.com:<%=a_value%><br> blueidea.com:<%=b_value%><br> it356cn.com:<%=c_value%><br> 5d.cn:<%=d_value%><br> <a href="website.html">返回继续</a> |
……