Custom functions used in asp to process file uploads and deletions
<%
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
'All custom VBS Functions
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
Function DeleteFile (Filename) 'deletes an object
If Filename <> "" then
Set fso = server. CreateObject ("Scripting. FileSystemObject ")
If fso. FileExists (Filename) then
Fso. DeleteFile Filename
End if
Set fso = nothing
End if
End function
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
Function CreateDIR (byval LocalPath) 'creates a directory program. If there is a multi-level directory, it is created at the first level.
On error resume 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 SaveRandFileName (byval szFilename) 'generates a new random file name based on the original file name
Randomize
'Rannum = int (90000 * rnd) + 10000
'If month (now) <10 then c_month = "0" & month (now) else c_month = month (now)
'If day (now) <10 then c_day = "0" & day (now) else c_day = day (now)
'If hour (now) <10 then 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 then c_second = "0" & second (now) else c_second = minute (now)
FileExt_a = split (szFilename ,".")
FileExt = lcase (fileExt_a (ubound (fileExt_a )))
SaveRandFileName = replace (now, ":", ""), "-", ""), "", "") & int (10 * rnd) &". "& fileExt
'Generaterandomfilename = year (now) & c_month & c_day & c_hour & c_minute & c_second & "_" & ranNum & "." & fileExt
End function
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
Function jaron_replacer (strContent, start_string, end_string, replace_string)
'Cms replacement function: Source string, prefix, suffix, and character to be replaced
'Return the replaced string
Jaron_replacer = replace (strContent, mid (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)
'In the document, all characters between start and end are deleted
On error resume next
MARKCOUNTS = ubound (split (strContent, start_string ))
PRESTRING = strContent
For I = 0 to MARKCOUNTS
STARTMARK = instr (1, PRESTRING, start_string, 1)
If STARTMARK = 0 then exit
COMPMARK = instr (1, PRESTRING, end_string, 1) + len (end_string)
VerString = mid (PRESTRING, STARTMARK, COMPMARK-STARTMARK)
PRESTRING = replace (PRESTRING, VerString, replace_string)
Next
Replaceplus = PRESTRING
If err. number <> 0 then err. Clear
End function
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
%>