日期:2010-08-23  浏览次数:20840 次

<% @Language="JavaScript" %>
<%

/*
 *--------------- decode.asp -----------------
 * 功能:遍历某个目录下的所有文件,对加密过的.asp文件
 *      进行解密,并写入源文件中.
 * 实例:单个文件解密
 * Response.Write(DncodeFile(Server.MapPath("conn.asp")));
 * 实例:目录下所有文件解密.
 * DncodeFolderFiles(Server.MapPath("xml"))
 * author:wanghr100(灰豆宝宝.net)
 * update:2004-5-17 11:31
 *--------------- decode.asp -----------------
 */

function DncodeFile(sFilePath)
{
/*
 *--------------- DncodeFile(sFilePath) -----------------
 * DncodeFile(sFilePath)
 * 功能:打开文件sFilePath,Encode解密,重写该文件.
 * 参数:sFilePath,字符串,文件的路径.
 * 返回:sFilePath,文件的路径.
 * 实例:Response.Write(DncodeFile(Server.MapPath("conn.asp")));
 * author:wanghr100(灰豆宝宝.net)
 * update:2004-5-17 0:58
 *--------------- DncodeFile(sFilePath) -----------------
 */
    var ForReading = 1, ForWriting =2, ForAppending =8;
    var fso = Server.CreateObject("Scripting.FileSystemObject");
    var f = fso.OpenTextFile(sFilePath,ForReading,true);
    sFileText = f.ReadAll();
    f.Close();
    sDncodeText = strdec(sFileText)
    var f = fso.OpenTextFile(sFilePath,ForWriting,true);
    f.Write(sDncodeText);
    f.Close();
    //return sDncodeText;
    return sFilePath;
}

function GetFilesPath(sFolderPath)
{
/*
 *--------------- GetFilesPath(sFolderPath) -----------------
 * GetFilesPath(sFolderPath)
 * 功能:遍历sFolderPath目录下的所有文件.返回数组.存储文件路径.
 * 参数:sFolderPath,字符串,目录绝对路径.
 * 实例:Response.Write(GetFilesPath(Server.MapPath("xml")))
 * update:2004-5-12 8:33
 * author:wanghr100(灰豆宝宝.net)
 *--------------- GetFilesPath(sFolderPath) -----------------
 */
    var sFilePath = new Array();
    var fso = Server.CreateObject("Scripting.FileSystemObject");
    var oFolder = fso.GetFolder(sFolderPath);
    var oSubFolders = oFolder.SubFolders;
    var oFiles = oFolder.Files;
    icount = oFiles.Count;

    var enmFiles = new Enumerator(oFiles);
    for(;!enmFiles.atEnd();enmFiles.moveNext())
    {
        sFilePath[sFilePath.length] = enmFiles.item().Path
    }

    var enmFolders = new Enumerator(oSubFolders);
    for(;!enmFolders.atEnd();enmFolders.moveNext())
    {
        /* Old 数组成了多维. */
        //sFilePath[sFilePath.length]=GetFilesPath(enmFolders.item().Path);
        /* Add 2004-5-17 11:09 只为一维数组 */
        sFilePath=sFilePath.concat(GetFilesPath(enmFolders.item().Path));
    }

    return sFilePath;

}

function GetFileType(sFileName)
{
/*
 *--------------- GetFileType(sFileName) -----------------
 * GetFileType(sFileName)
 * 功能:通过后缀,取得sFileName的文件类型.
 * 参数:sFileName,字符串,文件名.
 * 实例:Response.Write(GetFileType("decode.asp"))
 * update:2004-5-13 8:33
 * author:wanghr100(灰豆宝宝.net)
 *--------------- GetFileType(sFileName) -----------------
 */
    sFileName = String(sFileName);
    return sFileName.split(".")[sFileName.split(".").length-1];
}

/* Start 解密实现:李辉煌 Start*/
functio