Several useful functions in ASP

zhaozj2021-02-16  47

/ * Written by Jaron, 2003-6-8 * // * Original: Jiangdu Information Network Forum http://www.jiangdu.net/bbs * // * Reprint Please indicate the source and keep this copyright information * // * Welcome to SiteManager website management system http://sitemanager.cnzone.net * /

function DeleteFile (Filename) 'to delete the file if Filename <> "" then Set fso = server.CreateObject ( "Scripting.FileSystemObject") if fso.FileExists (Filename) then fso.DeleteFile Filename end if set fso = nothing end ifend functionfunction CreateDIR (Byval localPath) 'Establish a program of the directory, if there is a multi-level directory, the first-level level creation

ON Error ResMe next

LocalPath = Replace (localpath, "/", "/")

Set fileObject = server.createObject ("scripting.filesystemObject")

Patharr = split (localpath, "/")

PATH_LEVEL = Ubound (Patharr)

For i = 0 to Path_level

IF i = 0 THEN PATHTMP = Patharr (0) & "/" Else Pathtmp = Pathtmp & Patharr (i) & "/"

CPath = Left (pathtmp, len (pathtmp) -1)

If not fileObject.folderexists (cpath) THEN fileObject.createfolder cpath

NEXT

SET fileObject = Nothing

IF Err.Number <> 0 THEN

CreateDir = false

Err.clear

Else

CreateDir = TRUE

END IF

END FUNCTION

Function generaterandomfilename (byval szfilename) 'According to the original file name NOW) if Day (now) <10 dam c_day = "0" & ​​day (now) else c_day = day (now) if Hour (now) <10 TEN C_HOUR = "0" & ​​HOUR (NOW) else c_Hour = HOUR ( NOW) IF minute (now) <10 THEN C_MINUTE = "0" & ​​minute (now) else c_minute = minute (now) if Second (now) <10 TEN C_SECOND = "0" & ​​Second (now) else c_second = Minute ( now) fileExt_a = split (szFilename, ".") fileExt = lcase (fileExt_a (ubound (fileExt_a))) GenerateRandomFileName = year (now) & c_month & c_day & c_hour & c_minute & c_second & "_" & ranNum & "." & fileExtend functionfunction jaron_replacer (strContent, start_string, end_string, replace_string) 'CMS replacement function: Source string, front part, rear section, replacement character' Returns the replaced string Jaron_replace = Replace (strContent, INSTR (Strcontent, Start_String), INSTR (Strcontent, End_String) LEN (End_String) -1), Replace_String) End Function

function replaceplus (strContent, start_string, end_string, replace_string) 'document, will all start, all the characters between the end of the deletion on error resume nextMARKCOUNTS = ubound (split (strContent, start_string)) PRESTRING = strContentfor i = 0 to MARKCOUNTSSTARTMARK = instr (1, PRESTRING, start_string, 1) if STARTMARK = 0 then exit forCOMPMARK = instr (1, PRESTRING, end_string, 1) len (end_string) verString = mid (PRESTRING, STARTMARK, COMPMARK - STARTMARK) PRESTRING = replace (PRESTRING, Verstring, replace_string) NextReplacePlus = preStringif Err.Number <> 0 Then Err.clerend Function

If you don't know how many Flash inside, you want to remove them all. It can be used with this. StrContent = ReplacePlus (strcontent, "", "")

This command can remove all .... of the HTML code all deleted.

转载请注明原文地址:https://www.9cbs.com/read-27149.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.041, SQL: 9