在线汇率查询php代码:asp修改文件

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 09:31:42
不懂者请别忽悠我...
我现在在网站下有config.asp文件.内容如下
<%
Const SiteName="华英机械网"
Const SiteTitle="华英机械|下料机|裁断机|模切机|全胶鞋设备|制鞋流水线设备"
%>
我如何在 updata.asp文件里修改 SiteName和 SiteTitle呢?
我的意思是在后台里改,不是在文件里改..

在后台 update.asp里的
<form action="">
<input type=text value=<%=sitename%>>
<input type=submit value=修改>
</form>
修改

正则表达的哪位,我看的不是太懂.详细点好吗??
update.asp应该怎么写?
写完整点.我可以追加分.如果在这里写麻烦的话,可以留个QQ给我..我现在在线等呢.

三楼的,你写的我看不懂,不知道怎么用?呵呵.你的意思是放在config.asp里了吧?

<!--#include file="config.asp"-->
<%
if request("edite")="修改" then
dim fso,filepath,fso_txt,msg
set fso=Server.CreateObject("SCRIPTING.FILESYSTEMOBJECT")
filepath=server.mappath("config.asp")
'filepath1=server.mappath("config.asp")
If fso.FileExists(filepath) Then
set fso_txt=fso.OpenTextFile(filepath,1)
msg=fso_txt.ReadAll
'Response.Write(msg&"*^*")
Set regEx = New RegExp
patrn = SiteName
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
set matches=regEx.execute(msg)
for each match in matches
msg=Replace(msg,match.value,request("sitename"))
next
set fso_txt=nothing
if fso.fileexists(filepath) then
fso.deletefile(filepath)
end if
if not fso.fileexists(filepath) then
fso.createtextfile(filepath)
set txt=fso.opentextfile(filepath,8)
'msg=chr(60)&"%"&msg&"%"&chr(62)
Txt.Write(msg)
end if
set txt=nothing
Response.Write("修改成功!")
else
Response.Write("有没有搞错!")
end if
set fso=nothing
'Response.Write(msg)
else
%>
<form action="">
<input name="sitename" type=text id="sitename" value="<%= SiteName %>">
<input name="edite" type=submit id="edite" value="修改">
</form>
<% End If %>

<%
if Request.Form("SiteName")<>Empty then
Application("SiteName")=Request.Form("SiteName")
else
Application("SiteName")="华英机械网"
end if
if Request.Form("SiteTitle")<>Empty then
Application("SiteTitle")=Request.Form("SiteName")
else
Application("SiteTitle")="华英机械|下料机|裁断机|模切机|全胶鞋设备|制鞋流水线设备"
end if
Const SiteName=Application("SiteName")
Const SiteTitle=Application("SiteTitle")%>
-----------
<form action="">
<input type=text name=SiteName value=<%=Application("SiteName")%>> <br>
<input type=text name=SiteTitle value=<%=Application("SiteTitle")%>>
<input type=submit value=修改>
</form>

把 Const 去掉,这表示变量是只读的
然后在update.asp文件里直接赋值就行了:
<%
SiteName = "网网网"
'......
%>

使用正则来修改吧
<%
Dim regEx, Match, Matches,patrn
'首先使用FileSystemObject读取文件的内容:
str = "Const SiteName=""华英机械网"""
Set regEx = New RegExp
patrn = "华英机械网"
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
s=regEx.Replace(str,"找VCD电影")

response.write s
%>

ASP是动态网页文件,如果要修改,只能在后台改,
也可以<title>华英机械|下料机|裁断机|模切机|全胶鞋设备|制鞋流水线设备</title>