This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.asp
1296 lines (1153 loc) · 41 KB
/
Default.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%>
<%Response.Buffer = True%>
<%Response.Expires = -1442%>
<%Response.AddHeader "Pragma", "no-cache" %>
<%Response.AddHeader "Cache-Control", "no-cache"%>
<%
'###########################################################################
' blokada na extranet
If Request.ServerVariables("remote_addr") = "149.156.89.220" Or Request.ServerVariables("remote_addr") = "89.77.88.189" Then
' nothing - give user access
Else
echo "<html><head><meta charset='utf-8' /><title>$REPO</title><style>body{background-color: red;} h1{font-size: 36px;}</style></head><body><h1><center>$REPO<br />jest dostępne tylko dla stduentów UJ przez extranet<br />-<br />zaloguj się na <a href='https://extranet.uj.edu.pl/,DanaInfo=$REPO'>https://extranet.uj.edu.pl/</a><br />za pomocą konta USOSweb,<br />cofnij się na tą stronę i kliknij jeszcze raz w link.</center></h1></body></html>"
Response.End
End If
'###########################################################################
'#
'# Version History
'#
'# 1.0
'# 2004/09/26: Original build
'#
'# 1.1
'# 2004/10/25: Added "View Source" ability for ASP files.
'#
'# 1.2
'# 2004/11/13: - Added rudimentary syntax highlighting for ASP Source View,
'# which can be VERY slow with large files, but it seems well
'# worth the cost to me. Also, file must use CR+LF for line breaks
'# for syntax highlighting to work properly.
'# - Fixed "parent directory" link when viewing source.
'#
'# 1.3
'# 2005/01/12: - Added choices for which files to be able to view source of.
'#
'# 1.4
'# 2005/05/02: - Toggled alternate background colors for highlighted list.
'# which makes it easier to find which "view source" link you
'# want to choose.
'#
'# 1.5
'# 2005/05/13: - Added ability to exclude files / folders from view.
'#
'# 1.5.1
'# 2006/03/01: - Pound symbol in folders resulted in non-downloadable files.
'#
'# 1.5.2
'# 2007/04/27: - The script breaks if it is in the root directory of the website. Who knew!
'#
'# 1.5.3
'# 2008/09/19: - Added option to turn off folder sizes - makes things much quicker for large collections of files.
'#
'# 1.5.4
'# 2008-11-24: - Fixed script so that it now asks for NT credentials (instead of crashing) when it doesn't have permission to access files.
'#
'# 1.6.0
'# 2009-03-08: - Added "default document" list. When the EDB runs in to one of the listed documents, it will redirect to it, instead of listing the contents of the containing directory. I would have liked to have pulled the default document property right from IIS itself, but IIS doesn't even allow anonymous users read-only access to the metabase.
'#
'# 1.6.1
'# 2009-04-20: - Happy Four Twenty! Fixed a bug with redirection... Redirecting over "#" symbols in file names turned out badly. Had to redirect by manually specifying location header, as opposed to using Response.Redirect. (Thanks Craig!)
'#
'# 1.6.2
'# 2009-12-08: - Fixed case sensitivity issue for arrPathsToExclude
'#
'#
'##########
'Const Version = "1.6.2 (2009/12/08)"
Const Version = "1.9.9 (2015/05/10)"
'###########################################################################
'#
'# Script Config
'#
'##########
Const bAllowViewSource = True
' Boolean. Are anonymous users allowed to see
' the source code of ASP pages in this directory
' and its subdirectories?
Dim arrSourceViewFilenameExtensions
arrSourceViewFilenameExtensions = Array(".asp",".vbs",".txt",".cpp",".c",".h",".java",".scm",".pl")
' Which file types do you want to be able to view
' the source of?
'Const LocateLink = "/locate/default.asp?Catalog=Files"
Const LocateLink = ""
' String. If you have Dale's LOCATE or some
' other file search utility available, put the link
' to it here, and it will display itself near the top right
' hand side of the page. Otherwise, leave this as a zero-length string.
Const bShowHiddenFiles = False
' Boolean. Show files with the "hidden" attribute?
' You probably dont want this on.
Const bShowSystemFiles = False
' Boolean. Show files with the "system" attribute?
' You probably dont want this on.
Const bShowShortcutFiles = False
' Boolean. Show files that are links /aliases / or
' shortcuts to other files? Note that IIS does not
' follow links and shortcuts. It is more prone to
' just let the browser download a ".lnk" file, which
' isnt all that useful.
Const bSyntaxHighlightingOnByDefault = False
' Boolean. Only applies to source viewing. => currently not styled properly
Const bLineNumberingOnByDefault = True
' Boolean. Only applies to source viewing.
Const bShowFolderSizes = False
' Boolean - If the script is dog slow, it's because it's collecting
' folder sizes. Set this to false to speed things up.
dim arrPathsToExclude
' ArrPathsToExclude can be either filenames or folder names.
' They must include leading slashes, and are relative to the current directory.
' Becasue this file cannot browse above its own directory, the leading
' slash indicates the root of this directory. This directory is effectively
' the root directory.
arrPathsToExclude = Array( _
"/incoming" _
, "/notpublic" _
, "/_search.asp" _
)
Dim arrDefaultDocumentList
' If EDB runs in to one of these files, it will redirect to it instead of
' listing the directory that it's in.
arrDefaultDocumentList = Array ( _
"default.aspx" _
, "default.html" _
, "default.htm" _
, "index.aspx" _
, "index.asp" _
, "index.html" _
, "index.htm" _
, "home.aspx" _
, "home.asp" _
, "home.html" _
, "home.htm" _
)
'###########################################################################
'#
'# Declare Global Constants and Variables
'#
'##########
Const VbEnum = 100
Const ColumnOrdinal_LastModified = 0
Const ColumnOrdinal_Size = 1
Const ColumnOrdinal_Filename = 2
Const ColumnOrdinal_CanViewSource = 3
Const ColumnOrdinal_StepSize = 4
Const FileAttribute_Hidden = 2
Const FileAttribute_System = 4
Const FileAttribute_Alias = 64
Const ShowHidden = False
Const ShowSystem = False
Const ShowAlias = False 'links or shortcuts to other files
Dim oFso, oFiles, oFolders, oFolder, path, thing
Dim PageTitle
Dim FolderSpec, FileSpec
Dim i
Dim arrfiles, arrFolders
Dim Sort
Dim DefaultVPath
Dim DefaultPhysPath
Dim ParentDirectoryLink
Dim DefaultSort
Dim bViewSource, bRequestedSourceFileFound
Dim gVisibleFilesCount
Dim gVisibleFoldersCount
gVisibleFilesCount = 0
gVisibleFoldersCount = 0
'###########################################################################
'#
'# Runtime
'#
'##########
Call ScriptInit
Call DumpHtmlBody
Call ScriptTerminate
'End of Script.
'###########################################################################
'#
'# Primary Functions
'#
'##########
'___________________________________________________________________
Sub DumpHtmlBody
echo "<html>"
echo "<head>"
echo "<META http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"">"
echo "<title>" & PageTitle & "</title>"
echo "<link rel='stylesheet' type='text/css' href='/theme.css' />"
echo "<style type=""text/css"">"
echo ""
echo "<!--"
echo ".h1 {"
echo " font-family: ""Times New Roman"", Times, serif;"
echo " font-size: 24pt;"
echo " font-weight: bold;"
echo " color: #000000;"
echo " }"
echo ".td, td, th { "
echo " font-family: ""Courier New"", Courier, mono; "
echo " font-size: 10pt; "
echo " white-space: nowrap; "
echo " vertical-align: top;"
echo "}"
echo ".lm {"
echo " text-align: right; "
echo " padding-left: 4px; "
echo " padding-right: 4px;"
echo "}"
echo ".sz {"
echo " text-align: right; "
echo " padding-left: 4px; "
echo " padding-right: 4px;"
echo "}"
echo ".fn {"
echo " text-align: left; "
echo " padding-left: 4px; "
echo " padding-right: 4px;"
echo "}"
echo ".InsideASP {"
echo " color: #000000; "
' echo " background-color: #ffffee; "
' echo " width: 100%;"
echo "}"
echo ".OutsideASP {"
echo " color: #9999cc; "
echo " background-color: #ffffff;"
echo "}"
echo ".AspComment {"
echo " font-style: italic; "
echo " color: #008080; "
echo " background-color: #ffffff;"
echo "}"
echo ".AspTransition {"
echo " color: #000000; "
echo " background-color: #ffffcc;"
echo "}"
echo ".InsideQuote {"
echo " color: #808080; "
echo "}"
echo ".LineNumber {"
echo " color: #666666; "
echo "}"
echo "-->"
echo ""
echo "</style>"
echo "</head>"
echo "<body>"
echo "<table width=""100%"" border=""0"">"
echo "<tr valign=""top"">"
echo "<td width=""84%"" class=""h1"">" & PageTitle & "<br />nie ma czegoś? znajdź i wyślij na [email protected] to dodamy</td>"
echo "<td width=""16%"" align=""right""> </td>"
echo "</tr>"
echo "</table>"
echo "<hr>"
echo "<table "
echo " width=""100%"" "
echo " border=""0"" "
echo " cellpadding=""0"" "
echo " cellspacing=""0"""
echo ">"
echo "<tr>"
echo "<td colspan=""3""><a href=""" & ParentDirectoryLink & """>[Katalog nadrzędny]</a></td>"
echo "<td align=""right""> "
If Len(locateLink) > 0 Then echo "<a href=""" & LocateLink & """>[Search Filenames]</a>"
echo "</td>"
echo "</tr>"
echo "<tr>"
echo "<td colspan=""4""> </td>"
echo "</tr>"
echo "</table>"
echo "<table "
echo " width=""100%"" "
echo " border=""0"" "
echo " cellpadding=""0"" "
echo " cellspacing=""0"""
echo ">"
echo ""
If bViewSource And bAllowViewSource Then
echo "<tr colspan=""4""><td>"
Call DumpSource(oFso, FolderSpec & "\" & FileSpec)
echo "</td></tr>"
Else
echo ""
echo " <tr bgcolor=""#222"">"
echo " <th width=""20%"" colspan=""2"">"
echo "<a href=""" & PathInfo() & "?sort=" & ColumnOrdinal_LastModified & "&FolderSpec=" & server.urlencode(FolderSpec) & """>Data modyfikacji</a>"
echo "</th>"
echo " <th width=""10%"">"
echo "<aa href=""" & PathInfo() & "?sort=" & ColumnOrdinal_Size & "&FolderSpec=" & server.urlencode(FolderSpec) & """>Rozmiar</aa>"
echo "</th>"
echo " <th width=""70%"" colspan=""2"">"
echo "<a href=""" & PathInfo() & "?sort=" & ColumnOrdinal_Filename & "&FolderSpec=" & server.urlencode(FolderSpec) & """>Nazwa</a>"
echo "</th>"
echo " </tr>"
if gVisibleFoldersCount > 0 Then
echo " <tr>"
echo " <th colspan=""5"" align=""left"" bgcolor=""#222"">Katalogi</th>"
echo " </tr>"
echo " "
bgcolor_now = bgcolor_dark
Call DumpFoldersList(arrFolders, 0, ubound(arrFolders,1), sort)
echo ""
echo " <tr>"
echo " <td colspan=""5""> </td>"
echo " </tr>"
End If
if gVisibleFilesCount > 0 Then
echo " <tr>"
echo " <th colspan=""5"" align=""left"" bgcolor=""#222"">Pliki</th>"
echo " </tr>"
echo " "
bgcolor_now = bgcolor_dark
Call DumpFilesList(FolderSpec, ArrFiles, 0, ubound(arrFiles,1), sort)
End If
End If
echo ""
echo "</table>"
echo "<br>"
echo "<hr>"
' echo "<p align=""right"" class=""td"">Dale's <a href=""http://www.daleanderson.ca/edb/"">Enhanced Directory Browser and ASP Source Viewer</a>, v" & Version & "</p>"
echo "<br>"
echo "</body>"
echo "</html>"
End Sub
'___________________________________________________________________
Sub ScriptInit
FileSpec = Request("FileSpec")
bRequestedSourceFileFound = False
Set oFso = createobject("scripting.filesystemobject")
DefaultVPath = oFso.GetParentFolderName(PathInfo())
If Len(DefaultVPath) = 0 Then ' This means that the script is in the root folder of the website. It's not recommended to do this, btw.
DefaultVPath = "/"
End If
DefaultPhysPath = Server.MapPath(DefaultVPath)
DefaultSort = ColumnOrdinal_Filename
Sort = Request.Querystring("sort")
bViewSource = Typecast(Len(request("ViewSource")),VbBoolean,False)
PageTitle = request.servervariables("SERVER_NAME")
Dim j
If Sort = "0" Then
Sort = ColumnOrdinal_LastModified
ElseIf Sort = "1" Then
Sort = ColumnOrdinal_Size
Else
sort = DefaultSort
End If
'Validate the FolderSpec request
'{
FolderSpec = Trim(Request("FolderSpec"))
FolderSpec = Replace(FolderSpec, "\", "/")
FolderSpec = Replace(FolderSpec, "//", "/")
If Len(FolderSpec) = 0 Then FolderSpec = DefaultVPath
If Len(FolderSpec) > 255 Then FolderSpec = DefaultVPath
If Left(FolderSpec, Len(DefaultVPath)) <> DefaultVPath Then FolderSpec = DefaultVPath
If bFilenameHasIllegalChars(FolderSpec, True) Then FolderSpec = DefaultVPath
If InStr(FolderSpec, "..") > 0 Then FolderSpec = DefaultVPath
If Not (InStr(FolderSpec, "/") > 0) Then FolderSpec = DefaultVPath 'FolderSpec must start with a leading slash
if InArray(Replace(FolderSpec, DefaultVPath, "", 1, 1, vbTextCompare), arrPathsToExclude) Then FolderSpec = DefaultVPath
'}
path = mappath(FolderSpec)
Dim ErrorCheck
On Error Resume Next
Set oFolder = oFso.getFolder(path)
ErrorCheck = err.number
On Error GoTo 0
If ErrorCheck <> 0 Then
FolderSpec = DefaultVPath
path = Server.MapPath(DefaultVPath)
Set oFolder = oFso.getFolder(path)
End If
If bViewSource Then
ParentDirectoryLink = PathInfo() & "?FolderSpec=" & server.urlencode((FolderSpec)) & "&sort=" & sort
Else
If (FolderSpec = DefaultVPath) Then
ParentDirectoryLink = "../"
Else
ParentDirectoryLink = PathInfo() & "?FolderSpec=" & server.urlencode(oFso.GetParentFolderName(FolderSpec)) & "&sort=" & sort
End If
End If
Set oFolders = oFolder.subfolders
Set oFiles = oFolder.Files
On Error Resume Next
Dim sRedirectURL
For Each thing In oFiles
If LCase(FolderSpec & "/" & thing.Name) = "//default.asp" Then Exit For End If
'if requested file is script itself do not redirect to it
'Look for a default document in this folder. If found, display it.
If InArray(thing.Name, arrDefaultDocumentList) Then
If LCase(FolderSpec & "/" & thing.Name) <> LCase(Pathinfo()) Then
sRedirectURL = FolderSpec & "/" & thing.Name
'sRedirectURL = Replace(sRedirectURL, "#", "%23")
'br sRedirectURL
sRedirectURL = Replace(sRedirectURL, "/", "FFFOOORRWWWARDDDSSLLLLAAASHH")
sRedirectURL = Replace(sRedirectURL, ".", "DDDDDDDDDDDDOOOOOOOOOOTTTTTTT")
sRedirectURL = Server.UrlEncode(sRedirectURL)
sRedirectURL = Replace(sRedirectURL, "+", "%20")
sRedirectURL = replace(sRedirectURL, "FFFOOORRWWWARDDDSSLLLLAAASHH", "/")
sRedirectURL = Replace(sRedirectURL, "DDDDDDDDDDDDOOOOOOOOOOTTTTTTT", ".")
'Response.Redirect sRedirectURL
Response.Status = "302 Object Moved"
Response.AddHeader "Location", sRedirectUrl
'br sRedirectURL
Response.End
End If
End If
'Just counting files.
If bShowFile(Thing) Then
gVisibleFilesCount = gVisibleFilesCount + 1
End if
Next
ReDim arrFiles(gVisibleFilesCount - 1, ColumnOrdinal_StepSize - 1)
if lcase(err.description) = "permission denied" And Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Authorization Required"
Response.End
End If
on error goto 0
For Each Thing in oFolders
If bShowFile(Thing) Then
gVisibleFoldersCount = gVisibleFoldersCount + 1
End If
Next
ReDim arrFolders(gVisibleFoldersCount - 1, ColumnOrdinal_StepSize - 1)
If err.number <> 0 Then
If Len(Request.ServerVariables("LOGON_USER")) = 0 Then
Response.Status = "401 Authorization Required"
Response.End
End If
End If
i = 0
For Each thing In oFiles
If bShowFile(Thing) Then
On Error Resume Next
ArrFiles(i,ColumnOrdinal_LastModified) = thing.datelastmodified
ArrFiles(i,ColumnOrdinal_Size) = thing.size
ArrFiles(i,ColumnOrdinal_Filename) = thing.name
ArrFiles(i,ColumnOrdinal_CanViewSource) = False 'set default
For j = 0 To UBound(arrSourceViewFilenameExtensions)
If LCase(ext(thing.name)) = LCase(arrSourceViewFilenameExtensions(j)) Then
ArrFiles(i,ColumnOrdinal_CanViewSource) = True
End If
Next
If bViewSource Then
If LCase(thing.path) = LCase(Server.MapPath(FolderSpec) & "\" & FileSpec) Then
bRequestedSourceFileFound = True
End If
End If
On Error GoTo 0
i = i + 1
End If
Next
If Not bRequestedSourceFileFound Then bViewSource = False
i = 0
For each thing in oFolders
If bShowFile(Thing) Then
On Error Resume Next
ArrFolders(i,ColumnOrdinal_LastModified) = thing.datelastmodified
If bShowFolderSizes Then
ArrFolders(i,ColumnOrdinal_Size) = thing.size
Else
ArrFolders(i,ColumnOrdinal_Size) = Null
End If
ArrFolders(i,ColumnOrdinal_Filename) = thing.name
On Error GoTo 0
i = i + 1
End If
Next
If Sort <> DefaultSort Then
If ubound(arrFiles,1) > 0 Then Call QuickSort(arrFiles, 0, ubound(arrFiles,1), cint(sort))
If ubound(arrFolders,1) > 0 Then Call QuickSort(arrFolders, 0, ubound(arrFolders,1), cint(sort))
End if
PageTitle = PageTitle & " - " & FolderSpec
If bViewSource Then PageTitle = PageTitle & "/" & FileSpec & " (Source)"
On Error GoTo 0
End Sub
'___________________________________________________________________
Sub ScriptTerminate
On Error Resume Next
Set oFiles = nothing
Set oFolders = nothing
Set oFolder = nothing
Set oFso = Nothing
On Error GoTo 0
End Sub
'###########################################################################
'#
'# Secondary Functions
'#
'##########
'___________________________________________________________________
Sub DumpFilesList(FolderSpec, ArrFiles, lo, hi, mark)
'==-----------------------------------------==
'== Print out an array from the lo bound ==
'== to the hi bound. Highlight the column ==
'== whose number matches parm mark ==
'==-----------------------------------------==
Dim Row,Column
Dim Filename
Dim v
For Row = lo to hi
Filename = FolderSpec & "/" & ArrFiles(Row, ColumnOrdinal_Filename)
If LCase(Filename) <> LCase(PathInfo()) Then
echo "<tr>"
For Column = 0 to Ubound(ArrFiles,2)
v = ArrFiles(Row,Column)
If Column = mark then
echo "<td bgcolor=""" & BgColor() & """ class=""" & ColumnClass(Column) & """>"
Else
echo "<td class=""" & ColumnClass(Column) & """>"
End If
If VarType(v) <> 0 Then
if Column = ColumnOrdinal_Filename then
echo "<a href=""" & Replace(FolderSpec, "#", "%23") & "/" & FilenameAsUrl(v) & """>" & v & "</a>"
If ArrFiles(Row,ColumnOrdinal_CanViewSource) And bAllowViewSource Then
If Column = mark then
echo "</td><td bgcolor=""" & BgColor_Now & """ class=""sz""><a href=""" & PathInfo & "?ViewSource=1&FolderSpec=" & Server.UrlEncode(FolderSpec) & "&FileSpec=" & Server.UrlEncode(v) & """>(pokaż źródło)</a>"
Else
echo "</td><td class=""sz""><a href=""" & PathInfo & "?ViewSource=1&FolderSpec=" & Server.UrlEncode(FolderSpec) & "&FileSpec=" & Server.UrlEncode(v) & """>(pokaż źródło)</a>"
End If
' echo "</td><td>
Else
If Column = mark then
echo "</td><td bgcolor=""" & BgColor_Now & """ class=""sz""> "
Else
echo "</td><td class=""sz""> "
End If
End If
ElseIf Column = ColumnOrdinal_Size Then
echo FormatNumber(v, 0)
ElseIf Column = ColumnOrdinal_LastModified Then
echo FormatDateTime(DateValue(v), VbShortDate) & "</td><td class=""" & ColumnClass(Column) & """>" & FormatDateTime(TimeValue(v), VbShortTime)
ElseIf column = ColumnOrdinal_CanViewSource Then
'do nothing
Else
echo v
End If
End If
response.write "</td>"
Next
echo "</tr>"
End If
Next
End Sub 'PrintArray
Const BgColor_Dark = "#222"
Const BgColor_Light = "#333"
Dim BgColor_Now
Function BgColor()
If BgColor_Now = BgColor_Light Then
BgColor_Now = BgColor_Dark
Else
BgColor_Now = BgColor_Light
End If
BgColor = BgColor_Now
End Function
'___________________________________________________________________
Sub DumpFoldersList(ByVal ArrFolders,lo,hi,mark)
'==-----------------------------------------==
'== Print out an array from the lo bound ==
'== to the hi bound. Highlight the column ==
'== whose number matches parm mark ==
'==-----------------------------------------==
Dim Row, Column
Dim Data
For Row = lo to hi
echo "<tr>"
For Column = 0 to Ubound(ArrFolders,2)
Data = ArrFolders(Row, Column)
If Column = mark then
echo "<td bgcolor=""" & BgColor() & """ class=""" & ColumnClass(Column) & """>"
Else
echo "<td class=""" & ColumnClass(Column) & """>"
End If
If Column = ColumnOrdinal_Filename Then
if vartype(data) = 0 then
response.write " "
else
echo "<a href=""" & PathInfo() & "?FolderSpec=" & Server.UrlEncode(FolderSpec & "/" & Data) & "&sort=" & sort & """>" & Data & "</a>"
end if
If Column = mark then
echo "</td><td bgcolor=""" & BgColor_Now & """ class=""sz""> "
Else
echo "</td><td class=""sz""> "
End If
ElseIf Column = ColumnOrdinal_Size Then
if vartype(data) = 0 then
response.write " "
Elseif IsNull(data) then
response.write "<span style=""color:#cccccc;""><--></span>"
else
Echo FormatNumber(Data, 0)
end if
ElseIf Column = ColumnOrdinal_LastModified Then
if vartype(data) = 0 then
echo " </td><td class=""" & ColumnClass(Column) & """> "
else
echo FormatDateTime(DateValue(Data), VbShortDate)
echo "</td><td class=""" & ColumnClass(Column) & """>"
echo FormatDateTime(TimeValue(Data), VbShortTime)
end if
Else
if vartype(data) = 0 then
response.write " "
else
Response.Write Data
end if
End If
response.write "</td>"
Next
echo "</tr>"
Next
End Sub
'___________________________________________________________________
Sub DumpSource(ByRef fso, ByVal VPath)
Dim tso, buffer, i
Dim NewBuffer
Dim CursorPos
Dim Needle
Dim c, cPrefix, cPostfix
Dim LN
Dim bWaitingForMoreChars
Dim bInsideASP
Dim bCommentOn
Dim bInsideQuote
Dim cLast
LN = 1
Set tso = fso.opentextfile(server.mappath(VPath))
Set NewBuffer = CreateObject("ADODB.Stream")
NewBuffer.Type = 2 'String
NewBuffer.Open
echo "<pre>"
If bShowLineNumbers Then
response.write " <a href=""" & PathInfo() & "?ln=0&hls=" & Abs(CInt(bShowSyntaxHighlighting)) & "&ViewSource=1&FolderSpec=" & Server.UrlEncode(FolderSpec) & "&FileSpec=" & Server.UrlEncode(FileSpec) & """>Wyłącz numerowanie linii</a>"
Else
response.write " <a href=""" & PathInfo() & "?ln=1&hls=" & Abs(CInt(bShowSyntaxHighlighting)) & "&ViewSource=1&FolderSpec=" & Server.UrlEncode(FolderSpec) & "&FileSpec=" & Server.UrlEncode(FileSpec) & """>Włącz numerowanie linii</a>"
End If
If bShowSyntaxHighlighting Then
response.write " <a href=""" & PathInfo() & "?hls=0&ln=" & Abs(CInt(bShowLineNumbers)) & "&ViewSource=1&FolderSpec=" & Server.UrlEncode(FolderSpec) & "&FileSpec=" & Server.UrlEncode(FileSpec) & """>Wyłącz podświetlanie składni</a>"
Else
response.write " <a href=""" & PathInfo() & "?hls=1&ln=" & Abs(CInt(bShowLineNumbers)) & "&ViewSource=1&FolderSpec=" & Server.UrlEncode(FolderSpec) & "&FileSpec=" & Server.UrlEncode(FileSpec) & """>Włącz podświetlanie składni</a>"
End If
echo ""
If bShowSyntaxHighlighting Then
echo ""
bInsideASP = False
bWaitingForMoreChars = False
bCommentOn = False
bInsideQuote = False
Buffer = Tso.ReadAll
Response.Write "<span class=""OutsideASP"">"
For i = 1 To Len(Buffer)
cPrefix = ""
cPostfix = ""
c = Mid(Buffer, i, 1)
If bInsideAsp Then
Select Case C
Case ">"
If Not bInsideQuote Then
If bWaitingForMoreChars Then
bInsideAsp = False
cPrefix = "</span><span class=""AspTransition"">"
cPostfix = "</span><span class=""OutsideASP"">"
End If
End If
bWaitingForMoreChars = False
Case VbCr
If Not bInsideQuote Then
If bCommentOn Then
bCommentOn = False
cPostfix = "</span><span class=""InsideASP"">"
End If
End If
bWaitingForMoreChars = False
Case "%" 'stop right here, wait to see if next char is a greater than symbol.
If Not bInsideQuote Then
bWaitingForMoreChars = True
End If
Case "'"
If Not bInsideQuote Then
bCommentOn = True
cPrefix = "</span><span class=""AspComment"">"
End If
bWaitingForMoreChars = False
Case Chr(34)
If Not bCommentOn Then
If bInsideQuote Then
bInsideQuote = False
cPostfix = "</span><span class=""InsideASP"">"
Else
bInsideQuote = True
cPrefix = "</span><span class=""InsideQuote"">"
End If
End If
bWaitingForMoreChars = False
Case Else
bWaitingForMoreChars = False
End Select
Else
If bWaitingForMoreChars Then
If c = "%" Then
bInsideAsp = True
cPrefix = "</span><span class=""AspTransition"">"
cPostFix = "</span><span class=""InsideASP"">"
End If
bWaitingForMoreChars = False
Else
If c = "<" Then 'stop right here, wait to see if next char is a percent symbol.
bWaitingForMoreChars = True
Else
bWaitingForMoreChars = False
End If
End If
End If
If bShowLineNumbers Then
If c = VbLf Then
LN = LN + 1
End If
If i = 1 Then
response.write "<span class=""LineNumber"">" & LN & "</span>" & VbTab
Else
If c = VbLf Then
cpostfix = cpostfix & "<span class=""LineNumber"">" & LN & "</span>" & VbTab
End If
End If
End If
If bWaitingForMoreChars Then
cLast = cLast & C
Else
Response.Write cPrefix & server.htmlencode(cLast & C) & cPostfix
cLast = ""
End If
Next
Else
Do While Not tso.atendofstream
i = i + 1
response.write vbnewline
If bShowLineNumbers Then response.write "<span class=""LineNumber"">" & i & "</span>" & VbTab
response.write server.htmlencode(tso.readline)
Loop
End If
tso.close
Set tso = Nothing
NewBuffer.Position = 0
Response.Write NewBuffer.ReadText
NewBuffer.Close
Set NewBuffer = Nothing
echo "</pre>"
End Sub
'###########################################################################
'#
'# Tertiary Functions and Utilities
'#
'##########
'___________________________________________________________________
Function FilenameAsUrl(s)
FilenameAsUrl = Replace(Server.UrlEncode(oFso.GetBaseName(s)),"+","%20") & Ext(s)
End Function
'___________________________________________________________________
'EXT RETURNS THE dot IN THE FILENAME
function ext(byval fname)
If InStr(fname, ".") > 0 Then
ext = lcase(mid(fname,inStrRev(fname,".")))
Else
ext = ""
End If
end function
'___________________________________________________________________
Function ColumnClass(i)
Select Case i
case ColumnOrdinal_LastModified
ColumnClass = "lm"
case ColumnOrdinal_Size
ColumnClass = "sz"
case ColumnOrdinal_Filename
ColumnClass = "fn"
End Select
End Function
'___________________________________________________________________
Function P()
p = Request.ServerVariables("PATH_INFO")
End Function
'___________________________________________________________________
'Replacement for Server.MapPath
Function MapPath(ByVal path)
Dim i
Dim arrBadChars
Dim arrDidReplace
Dim arrGoodChars
arrBadChars = Array(";" ,"," ,"'" ,"]")
arrDidReplace = Array(False ,False ,False ,False)
arrGoodChars = Array("%3B" ,"%2C" ,"%27" ,"%5D")
For i = 0 To UBound(arrBadChars)
If InStr(path, arrBadChars(i)) > 0 Then
path = Replace(path, arrBadChars(i), arrGoodChars(i))
arrDidReplace(i) = True
End If
Next
Path = Server.MapPath(path)
For i = 0 To UBound(arrBadChars)
If arrDidReplace(i) Then
Path = Replace(path, arrGoodChars(i), arrBadChars(i))
End If
Next
MapPath = Path
End Function
' ________________________________________
Function TypeCast(ByVal What, ByVal WhatType, ByVal DefaultValue)
Dim result, i
if vartype(What) = WhatType Then
result = What ' no problem! lets split and get back to work.
else
' not specifically that type.
' Ok, lets try and convert it.
on error resume next
select case WhatType
case vbInteger
result = CInt(what)
case vbLong
result = CLng(what)
case vbSingle
result = CSng(what)
case vbDouble
result = CDbl(what)
case vbCurrency
result = CCur(what)
case vbDate
result = CDate(what)
case vbString
result = CStr(what)
case vbBoolean
result = CBool(what)
case vbByte
result = CByte(what)
case VbEnum '### NOTE!! IMPORTANT!! VbEnum is NOT a built-in vb value:
' This is something that I made up myself-
' you MUST declare VbEnum as a global CONST
' for this to work!!!! (i use 100 - its far enough away
' from any other VbXXX constants that its not likely to
' interfereany time soon)
'to use this option, pass an ARRAY of possible enum values
' in the "DefaultValue" argument.
' If "what" does not match any of the values of the array,
' then TypeCast() will return the first value in the array.
'echo "; what=" & what & " " & typename(what)
for i = 0 to ubound(DefaultValue)
if what = DefaultValue(i) then
result = what
exit for
else
result = defaultValue(0)
end if
next
end select
if err.number <> 0 then
Result = DefaultValue 'sorry pal. you trying to fake us out. no soup for you.
end if
on error goto 0
End If
TypeCast = result
End Function
'__________________________________________________________
'__________________________________________________________
Function pathinfo()
pathinfo = Request.ServerVariables("PATH_INFO")
End Function
'************************************************************************
' Just an error-free wrapper. Especially handy in the case of html-encoding values
' directly from an SQL recordset, because "Server.HtmlEncode" chokes on nulls.
'___________________________________________________________________
Function HtmlEncode(s)
HtmlEncode = Server.HtmlEncode(Typecast(s,VbString,""))
End Function
'____________________________________________________________________
Function echo(s)
Response.write vbnewline & s
End Function
'______________________________________________________________________________
Function bDeveloperMode
Dim Result
Result = False
If request.servervariables("REMOTE_ADDR") = "89.167.32.149" _
or request.servervariables("REMOTE_ADDR") = "64.251.68.238" _
or request.servervariables("REMOTE_ADDR") = "64.251.68.232" _
Then
Result = True
End If
bDeveloperMode = Result
End Function
'___________________________________________________________________
Sub Debug(s)
DebugL "Debug", s
End Sub
'___________________________________________________________________
Sub DebugL(label, value)