Solved

ASP display directory listing with exclusions for files and folders

Posted on 2009-04-02
7
576 Views
Last Modified: 2012-05-06
Please help, I'm new at VBScript and similarly to asp. I have found and modified a script to display a given directory into an asp page. This script works but has limitations. I would like to exclude hidden files and folders. For example the folder vti_cnf. This script does exclude or include specific extensions, however there are some individual files I'd like to exclude. And one final note, is it possible for date last modified to list it in a short date instead of mm/dd/yyyy hh/mm/ss (3/26/2009 4:00:41 PM)?

<head>
<link rel="stylesheet" media="all" type="text/css" href="css/BasicStyle.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> JCMH Policies and Procedures</title>
<style type="text/css">
 
/*Credits: CSSpplay */
/*URL: http://www.cssplay.co.uk/menus/pro_15 */
.menu {padding:0 0 0 40px; margin:50; list-style:none; height:30px; background:#339999 url(/menu_0.gif);}
.menu li {float:left;}
.menu li a {display:block; float:left; height:30px; line-height:30px; background:url(/menu_0.gif); color:#ddd; text-decoration:none; font-family:arial, verdana, sans-serif; text-align:center; padding:0 0 0 110px; cursor:pointer; font-size:11px;}
.menu li a b {float:left; display:block; background:url(/graphics/menu_0.gif) right top; padding:0 16px 0 10px;}
.menu li.current a {color:#fff; background:url(/menu_2.gif);}
.menu li.current a b {background:url(/menu_2.gif) no-repeat right top;}
.menu li a:hover {color:#fff; background: url(/graphics/menu_1.gif);}
.menu li a:hover b {background:url(/graphics/menu_1.gif) no-repeat right top;}
.menu li.current a:hover {color:#fff; background: url(/graphics/menu_2.gif); cursor:default;}
.menu li.current a:hover b {background:url(/graphics/menu_2.gif) no-repeat right top;}
.menu li a em {display:block; float:left; width:16px; height:30px;}
.menu li a em.home {background:url(/graphics/home2.gif) no-repeat center center;}
.menu li a em.pp {background:url(/graphics/sem_user.gif) no-repeat center center;}
.menu li a em.dept {background:url(/graphics/clock.gif) no-repeat center center;}
.menu li a em.forms {background:url(/graphics/forms.gif) no-repeat center center;}
.menu li a em.schedule {background:url(/graphics/schedule.gif) no-repeat center center;}
.menu li a em.learn {background:url(/graphics/learn.gif) no-repeat center center;}
.menu li a em.mrm {background:url(/graphics/calendar_add.gif) no-repeat center center;}
.menu li a em.pacs {background:url(/graphics/amicas.gif) no-repeat center center;}
 
 
</style>
<title>Policies_and_Procedures/Table_of_Contents</title>
<meta name="Microsoft Border" content="lb, default">
</head>
 
<%@ Language=VBScript %>
<%
 
' ***** Configurable options
' Which file extensions to allow separated by commas ie: "," Set to "" or "all" to allow all extensions
' note: Unless proper permissions are set, files that are not allowed will still be viewable if a user 
' inputs the exact web location of the file. The method used here will only remove the link to the file.
AllowExt = ""
'AllowExt = "doc, pdf"
' DenyExt overrides AllowExt
DenyExt = "gif, asp, jpg, jpeg, htm, ico, txt, ini, html, exe"
 
' Top navigation separator
Const sChevron = ">"     ' "/Policies_and_Procedures/"
 
 
' Always display the navigation path? 
Const bShowPath = True     'False
' Always display the root directory? 
Const bShowRoot = False     'True
 
' Page font tag
Const sFont = "<font face=""Verdana, Arial, Helvetica""  size=""3"" COLOR=""#000088"">"
' Column header font tag
Const sColFont = "<font face=""Verdana, Arial, Helvetica"" size=""3"" COLOR=""#F0F8FF"">"
' Column header color
Const TblHeader = "#5F9F9F" 
 
' Directory grid alternating colors
Const FileRow1 = "#7AC5CD"  
Const FileRow2 = "#E0FFFF"  
Const FolderRow1 = "#B0C4DE"    
Const FolderRow2 = "#CAE1FF"    
 
' Color chart
'#000088    'NavyBlue1			'sFont
'#FFFFFF    'White				'sColFont
'#5F9F9F"   'CadetBlue			'Table Text,TblHeader 
'#7AC5CD"   'CadetBlue3			'FileRow1
'#ADD8E6"   'LightBlue			'FileRow2
'#B0C4DE"   'LightSteelBlue		'FolderRow1
'#CAE1FF"   'LightSteelBlue1	'FolderRow2
'#880088    'Fuchia1			'VLINK
'#C1CDCD    'Azure3				'Table BGRD
'#00009C    'New Midnight Blue	'Link
'F0F0F0	    'Grey94				'Table bgcolor for Navigation Bar
 
 
 
' ***** Begin Script
Dim sError
On Error Resume Next
sDirectory = Trim(sDirectory)
If Right(sDirectory,1) <> "/Policies_and_Procedures/" Then sDirectory = sDirectory & "/Policies_and_Procedures/" 
 
' ***** Get subfolder from passed querystring
sDir = sDirectory & Request.QueryString("dir")
sDir = Trim(sDir)
If Right(sDir,1) <> "/" Then sDir = sDir & "/"
 
' ***** Important! Make sure the subfolder path is in the shared folder. This keeps 
' users from browsing directories outside of the shared. ie: dir=../
' You may want to include some logging code if this happens, here we just
' put the user back into the default directory.
sFolder = Server.MapPath( sDir )
sDirFolder = Server.MapPath( sDirectory )
sSubFolder = Right(sDir,Len(sDir)-Len(sDirectory))
If InStr( sFolder , sDirFolder ) = 0 Then 
sFolder = sDirFolder
sSubFolder = ""
sError = sError & " Path not authorized;"
End If
 
 
' ***** Load the file system and navigate to our shared folder.
Set objFileObject = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileObject.GetFolder( sFolder )
 
' ***** Missing or misspelled folder path.
If IsEmpty( objFolder ) Then 
 
sFolder = sDirFolder
sSubFolder = ""
sDir = sDirectory 
Set objFolder = objFileObject.GetFolder( sFolder )
sError = sError & " Folder not found;"
End If
 
%>
<HTML>
</head>
 
<BODY BGCOLOR="#330056" Text="#000088" LINK="#00009C" VLINK="#880088"><!--msnavigation--><table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%">
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/JCMH%202008-2009%20Organizational%20Goals.doc">
<font color="#FFFFFF">JCMH Organizational Goals</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Standards%20of%20Performance.doc">
<font color="#FFFFFF">JCMH Standards of Performance</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Operating%20Principles.doc">
<font color="#FFFFFF">JCMH Operating Principals</font></a></b></font></p>
<p><b><font color="#000080"><a href="../JCMH%20Directory.htm">
<font color="#FFFFFF">Communication</font></a></font></b></p>
<p><b><font color="#000080"><a href="../departmental%20Pages.htm">
<font color="#FFFFFF">Departmental Pages</font></a></font></b></p>
<p><b><font color="#000080"><a href="../Employee%20Education.htm">
<font color="#FFFFFF">Employee Education</font></a></font></b></p>
<p><font color="#000080"><b><a href="../Emergency%20Operations.htm">
<font color="#FFFFFF">Emergency Operations/ Safety</font></a></b></font></p>
<p><b><font color="#000080"><a href="../External%20Web%20Sites.htm">
<font color="#FFFFFF">External Links</font></a></font></b></p>
<p><font color="#000080"><b><a href="../HR%20and%20Employee%20Benefits.htm">
<font color="#FFFFFF">Employee/ Human Resources</font></a></b></font></p>
<p><font color="#000080"><b><a href="../News%20and%20Notes.htm">
<font color="#FFFFFF">News &amp; Notes</font></a></b></font></p>
<p><font color="#000080"><b><a href="../Patient%20Care_Education.htm">
<font color="#FFFFFF">Patient Care Approved Sites</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Physician%20Services/Physician%20Services%20TOC.doc">
<font color="#FFFFFF">Physician Services</font></a></b></font></p>
<p><b><font color="#000080"><a href="/Policies%20and%20Procedures/index.htm">
<font color="#FFFFFF">Policies &amp; Procedures</font></a></font></b></p>
<p><a href="http://www.okprosperity.com/oklahoma"><font color="#000080">
<img border="0" src="../Graphics/OKProsperitylogo.jpg" width="79" height="66" align="left"></font></a></p>
 
</td><td valign="top" width="24"></td><!--msnavigation--><td valign="top">
 
<TABLE width="90%" Align="Center" BORDER=0 bgcolor="#FFFFFF" height="3px">
<tr><Td ALIGN="CENTER" >
<font face="Verdana, Arial, Helvetica" size="4" COLOR="#BB00BB
<br><B><Center>JCMH Intranet</Center></B></font>
</TR>
</TABLE>
<TABLE width="98%" BORDER=0 bgcolor="#CDCDCD" CELLPADDING=0 CELLSPACING=2>
<% ' ***** Feel free to edit the above table tag
 
' ***** Build path navigation
aNames = Split( sSubFolder , "/")
If bShowPath Then
If UBound( aNames ) > 0 Or bShowRoot Then %>
<TR BGCOLOR="#E6E6FA">
<TD><%= sFont %> </font></TD>
<TD COLSPAN="4"><%= sFont %>
<B>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>"><%= Left(sDirectory,len(sDirectory)-1) %></A></B>
<% End If
 
For count = 0 To UBound( aNames ) -1 
aURL = aURL & aNames(count) & "/"
%> <%= sChevron %> <B><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aURL ) %>"><%= aNames(count) %></A></B><%
Next %></font></TD></TR><% 
End If 
 
For count = 0 To UBound( aNames ) -2
aDirUp = aDirUp & aNames(count) & "/"
Next %>
 
<TR BGCOLOR="<%= TblHeader %>" ALIGN=LEFT>
<TD BGCOLOR="#ffffff"><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aDirUp ) %>"><font face="Wingdings" COLOR="<%= TblHeader %>">
Ç</font></a></TD>
<TD width="60%"><%= sColFont %>  <B>Filename:</B>  </FONT></TD>
<TD WIDTH="15%"><%= sColFont %>  <B>File Type:</B>  </FONT></TD>
<TD WIDTH="25%"><%= sColFont %>  <B>Date Last Modified:</B>  </FONT></TD>
<%
' ***** Iterate through the subfolders in our shared folder.
For Each objFile In objFolder.SubFolders 
 
' ***** Alternate between these two row colors.
If iAlternate = 0 Then 
Response.Write "<TR BGCOLOR=""" & FolderRow1 & """>" 
iAlternate = 1
Else 
Response.Write "<TR BGCOLOR=""" & FolderRow2 & """>"
iAlternate = 0 
End If
 
' ***** Display folder with link to navigate
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
0</font></TD>
<TD><%= sFont %>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( sSubFolder & objFile.Name )%>"><%= objFile.Name %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= objFile.DateLastModified %>  </font></TD>
</TR>
<%
' ***** Next Folder
Next
 
' ***** Iterate through the files in our shared folder / subfolder.
For Each objFile In objFolder.Files
 
sFileName = objFile.name
 
' ***** Only continue if it's a valid extension
If ( IsValidFile (sFileName) ) Then 
 
' ***** Alternate between these two row colors.
' We'll use the same counter variable to continue alternating between 
' the light / dark shade according to the previous folder row color.
If iAlternate = 0 Then 
Response.Write "<TR BGCOLOR=""" & FileRow1 & """>" 
iAlternate = 1
Else 
Response.Write "<TR BGCOLOR=""" & FileRow2 & """>"
iAlternate = 0 
End If
' ***** Display file with link to execute / download.
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
&lt;</font></TD>
<TD><%= sFont %>  <A HREF="<%= sDir %><%= sFileName %>"><%= sFileName %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= objFile.DateLastModified %>  </font></TD>
</TR><%
End If
 
' ***** Next File
Next 
 
' ***** Clean up those nasty memory leaks
Set objFileObject = Nothing
Set objFolder = Nothing
 
' ***** Iterate through and approve extensions
Function IsValidFile(FileName)
If Not AllowExt <> "" Or LCase( AllowExt ) = "all" Then
IsValidFile = True
Else
aAllowExt = Split( AllowExt & "," , ",")
IsValidFile = False
For iCnt = 0 To UBound( aAllowExt ) -1
If Right( FileName , Len( FileName ) - InStrRev( FileName , "." ) ) = Trim(aAllowExt( iCnt )) Then IsValidFile = True
Next
End If
If DenyExt <> "" Then
aDenyExt = Split( DenyExt & "," , ",")
For iCnt = 0 To UBound( aDenyExt ) -1
If Right( FileName , Len( FileName ) - InStrRev( FileName , "." ) ) = Trim(aDenyExt( iCnt )) Then IsValidFile = False
Next
End If
End Function 
 
 
' ***** Did we encounter an Error?
If Err <> 0 Or sError <> "" Then
Response.Write "<TR><TD bgcolor=""#ffffff"" colspan=""5""><font face=""Verdana, Arial, Helvetica"" color=""red"" size=""1"">ERROR: " & sError & Space(1) & "ASP: " & Err.description & ";</font></TD></TR>"
End If
 
 
%>
</TABLE>
<TABLE align="center">
<div align="center" style="width: 1000px; height: 150px">
  <center>
<ul class="menu">
<li><a target=_top href="../"><em class="home"></em><b>Home</b></a></li>
<li><a target=_self href="getdirectory.asp?dir="><em class="pp"></em><b>P & P Directory</b></a></li>
<li><a target=_self href="/departmental%20Pages.htm"><em class="dept"></em><b>Departmental Pages</b></a></li>
</ul>
  
  
  </center>
 
</div>
</TABLE>
<!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
 
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
 
</td></tr><!--msnavigation--></table></BODY></HTML>

Open in new window

0
Comment
Question by:Golfgent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:rejoinder
ID: 24053947
Can you try the attached code.  It will not display hidden folder or files and the date will be formatted in short form.
<head>
<link rel="stylesheet" media="all" type="text/css" href="css/BasicStyle.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> JCMH Policies and Procedures</title>
<style type="text/css">
 
/*Credits: CSSpplay */
/*URL: http://www.cssplay.co.uk/menus/pro_15 */
.menu {padding:0 0 0 40px; margin:50; list-style:none; height:30px; background:#339999 url(/menu_0.gif);}
.menu li {float:left;}
.menu li a {display:block; float:left; height:30px; line-height:30px; background:url(/menu_0.gif); color:#ddd; text-decoration:none; font-family:arial, verdana, sans-serif; text-align:center; padding:0 0 0 110px; cursor:pointer; font-size:11px;}
.menu li a b {float:left; display:block; background:url(/graphics/menu_0.gif) right top; padding:0 16px 0 10px;}
.menu li.current a {color:#fff; background:url(/menu_2.gif);}
.menu li.current a b {background:url(/menu_2.gif) no-repeat right top;}
.menu li a:hover {color:#fff; background: url(/graphics/menu_1.gif);}
.menu li a:hover b {background:url(/graphics/menu_1.gif) no-repeat right top;}
.menu li.current a:hover {color:#fff; background: url(/graphics/menu_2.gif); cursor:default;}
.menu li.current a:hover b {background:url(/graphics/menu_2.gif) no-repeat right top;}
.menu li a em {display:block; float:left; width:16px; height:30px;}
.menu li a em.home {background:url(/graphics/home2.gif) no-repeat center center;}
.menu li a em.pp {background:url(/graphics/sem_user.gif) no-repeat center center;}
.menu li a em.dept {background:url(/graphics/clock.gif) no-repeat center center;}
.menu li a em.forms {background:url(/graphics/forms.gif) no-repeat center center;}
.menu li a em.schedule {background:url(/graphics/schedule.gif) no-repeat center center;}
.menu li a em.learn {background:url(/graphics/learn.gif) no-repeat center center;}
.menu li a em.mrm {background:url(/graphics/calendar_add.gif) no-repeat center center;}
.menu li a em.pacs {background:url(/graphics/amicas.gif) no-repeat center center;}
 
 
</style>
<title>Policies_and_Procedures/Table_of_Contents</title>
<meta name="Microsoft Border" content="lb, default">
</head>
 
<%@ Language=VBScript %>
<%
 
' ***** Configurable options
' Which file extensions to allow separated by commas ie: "," Set to "" or "all" to allow all extensions
' note: Unless proper permissions are set, files that are not allowed will still be viewable if a user 
' inputs the exact web location of the file. The method used here will only remove the link to the file.
AllowExt = ""
'AllowExt = "doc, pdf"
' DenyExt overrides AllowExt
DenyExt = "gif, asp, jpg, jpeg, htm, ico, txt, ini, html, exe"
 
' Top navigation separator
Const sChevron = ">"     ' "/Policies_and_Procedures/"
 
 
' Always display the navigation path? 
Const bShowPath = True     'False
' Always display the root directory? 
Const bShowRoot = False     'True
 
' Page font tag
Const sFont = "<font face=""Verdana, Arial, Helvetica""  size=""3"" COLOR=""#000088"">"
' Column header font tag
Const sColFont = "<font face=""Verdana, Arial, Helvetica"" size=""3"" COLOR=""#F0F8FF"">"
' Column header color
Const TblHeader = "#5F9F9F" 
 
' Directory grid alternating colors
Const FileRow1 = "#7AC5CD"  
Const FileRow2 = "#E0FFFF"  
Const FolderRow1 = "#B0C4DE"    
Const FolderRow2 = "#CAE1FF"    
 
' Color chart
'#000088    'NavyBlue1			'sFont
'#FFFFFF    'White				'sColFont
'#5F9F9F"   'CadetBlue			'Table Text,TblHeader 
'#7AC5CD"   'CadetBlue3			'FileRow1
'#ADD8E6"   'LightBlue			'FileRow2
'#B0C4DE"   'LightSteelBlue		'FolderRow1
'#CAE1FF"   'LightSteelBlue1	'FolderRow2
'#880088    'Fuchia1			'VLINK
'#C1CDCD    'Azure3				'Table BGRD
'#00009C    'New Midnight Blue	'Link
'F0F0F0	    'Grey94				'Table bgcolor for Navigation Bar
 
 
 
' ***** Begin Script
Dim sError
On Error Resume Next
sDirectory = Trim(sDirectory)
If Right(sDirectory,1) <> "/Policies_and_Procedures/" Then sDirectory = sDirectory & "/Policies_and_Procedures/" 
 
' ***** Get subfolder from passed querystring
sDir = sDirectory & Request.QueryString("dir")
sDir = Trim(sDir)
If Right(sDir,1) <> "/" Then sDir = sDir & "/"
 
' ***** Important! Make sure the subfolder path is in the shared folder. This keeps 
' users from browsing directories outside of the shared. ie: dir=../
' You may want to include some logging code if this happens, here we just
' put the user back into the default directory.
sFolder = Server.MapPath( sDir )
sDirFolder = Server.MapPath( sDirectory )
sSubFolder = Right(sDir,Len(sDir)-Len(sDirectory))
If InStr( sFolder , sDirFolder ) = 0 Then 
sFolder = sDirFolder
sSubFolder = ""
sError = sError & " Path not authorized;"
End If
 
 
' ***** Load the file system and navigate to our shared folder.
Set objFileObject = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileObject.GetFolder( sFolder )
 
' ***** Missing or misspelled folder path.
If IsEmpty( objFolder ) Then 
 
sFolder = sDirFolder
sSubFolder = ""
sDir = sDirectory 
Set objFolder = objFileObject.GetFolder( sFolder )
sError = sError & " Folder not found;"
End If
 
%>
<HTML>
</head>
 
<BODY BGCOLOR="#330056" Text="#000088" LINK="#00009C" VLINK="#880088"><!--msnavigation--><table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%">
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/JCMH%202008-2009%20Organizational%20Goals.doc">
<font color="#FFFFFF">JCMH Organizational Goals</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Standards%20of%20Performance.doc">
<font color="#FFFFFF">JCMH Standards of Performance</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Operating%20Principles.doc">
<font color="#FFFFFF">JCMH Operating Principals</font></a></b></font></p>
<p><b><font color="#000080"><a href="../JCMH%20Directory.htm">
<font color="#FFFFFF">Communication</font></a></font></b></p>
<p><b><font color="#000080"><a href="../departmental%20Pages.htm">
<font color="#FFFFFF">Departmental Pages</font></a></font></b></p>
<p><b><font color="#000080"><a href="../Employee%20Education.htm">
<font color="#FFFFFF">Employee Education</font></a></font></b></p>
<p><font color="#000080"><b><a href="../Emergency%20Operations.htm">
<font color="#FFFFFF">Emergency Operations/ Safety</font></a></b></font></p>
<p><b><font color="#000080"><a href="../External%20Web%20Sites.htm">
<font color="#FFFFFF">External Links</font></a></font></b></p>
<p><font color="#000080"><b><a href="../HR%20and%20Employee%20Benefits.htm">
<font color="#FFFFFF">Employee/ Human Resources</font></a></b></font></p>
<p><font color="#000080"><b><a href="../News%20and%20Notes.htm">
<font color="#FFFFFF">News &amp; Notes</font></a></b></font></p>
<p><font color="#000080"><b><a href="../Patient%20Care_Education.htm">
<font color="#FFFFFF">Patient Care Approved Sites</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Physician%20Services/Physician%20Services%20TOC.doc">
<font color="#FFFFFF">Physician Services</font></a></b></font></p>
<p><b><font color="#000080"><a href="/Policies%20and%20Procedures/index.htm">
<font color="#FFFFFF">Policies &amp; Procedures</font></a></font></b></p>
<p><a href="http://www.okprosperity.com/oklahoma"><font color="#000080">
<img border="0" src="../Graphics/OKProsperitylogo.jpg" width="79" height="66" align="left"></font></a></p>
 
</td><td valign="top" width="24"></td><!--msnavigation--><td valign="top">
 
<TABLE width="90%" Align="Center" BORDER=0 bgcolor="#FFFFFF" height="3px">
<tr><Td ALIGN="CENTER" >
<font face="Verdana, Arial, Helvetica" size="4" COLOR="#BB00BB
<br><B><Center>JCMH Intranet</Center></B></font>
</TR>
</TABLE>
<TABLE width="98%" BORDER=0 bgcolor="#CDCDCD" CELLPADDING=0 CELLSPACING=2>
<% ' ***** Feel free to edit the above table tag
 
' ***** Build path navigation
aNames = Split( sSubFolder , "/")
If bShowPath Then
If UBound( aNames ) > 0 Or bShowRoot Then %>
<TR BGCOLOR="#E6E6FA">
<TD><%= sFont %> </font></TD>
<TD COLSPAN="4"><%= sFont %>
<B>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>"><%= Left(sDirectory,len(sDirectory)-1) %></A></B>
<% End If
 
For count = 0 To UBound( aNames ) -1 
aURL = aURL & aNames(count) & "/"
%> <%= sChevron %> <B><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aURL ) %>"><%= aNames(count) %></A></B><%
Next %></font></TD></TR><% 
End If 
 
For count = 0 To UBound( aNames ) -2
aDirUp = aDirUp & aNames(count) & "/"
Next %>
 
<TR BGCOLOR="<%= TblHeader %>" ALIGN=LEFT>
<TD BGCOLOR="#ffffff"><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aDirUp ) %>"><font face="Wingdings" COLOR="<%= TblHeader %>">
Ç</font></a></TD>
<TD width="60%"><%= sColFont %>  <B>Filename:</B>  </FONT></TD>
<TD WIDTH="15%"><%= sColFont %>  <B>File Type:</B>  </FONT></TD>
<TD WIDTH="25%"><%= sColFont %>  <B>Date Last Modified:</B>  </FONT></TD>
<%
' ***** Iterate through the subfolders in our shared folder.
For Each objFile In objFolder.SubFolders 
bHideThisItem = False
If objFile.Attributes AND 2 Then
    bHideThisItem = True
End If
if NOT bHideThisItem then
    ' ***** Alternate between these two row colors.
    If iAlternate = 0 Then 
        Response.Write "<TR BGCOLOR=""" & FolderRow1 & """>" 
        iAlternate = 1
    Else 
        Response.Write "<TR BGCOLOR=""" & FolderRow2 & """>"
        iAlternate = 0 
    End If
 
' ***** Display folder with link to navigate
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
0</font></TD>
<TD><%= sFont %>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( sSubFolder & objFile.Name )%>"><%= objFile.Name %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= FormatDateTime(objFile.DateLastModified,2) %>  </font></TD>
</TR>
<%
end if
' ***** Next Folder
Next
 
' ***** Iterate through the files in our shared folder / subfolder.
For Each objFile In objFolder.Files
  
bHideThisItem = False
If objFile.Attributes AND 2 Then
    bHideThisItem = True
End If
if NOT bHideThisItem then
    sFileName = objFile.name
     
    ' ***** Only continue if it's a valid extension
    If ( IsValidFile (sFileName) ) Then 
         
        ' ***** Alternate between these two row colors.
        ' We'll use the same counter variable to continue alternating between 
        ' the light / dark shade according to the previous folder row color.
        If iAlternate = 0 Then 
            Response.Write "<TR BGCOLOR=""" & FileRow1 & """>" 
            iAlternate = 1
        Else 
            Response.Write "<TR BGCOLOR=""" & FileRow2 & """>"
            iAlternate = 0 
        End If
        ' ***** Display file with link to execute / download.
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
&lt;</font></TD>
<TD><%= sFont %>  <A HREF="<%= sDir %><%= sFileName %>"><%= sFileName %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= FormatDateTime(objFile.DateLastModified,2) %>  </font></TD>
</TR><%
    End If
end if
 
' ***** Next File
Next 
 
' ***** Clean up those nasty memory leaks
Set objFileObject = Nothing
Set objFolder = Nothing
 
' ***** Iterate through and approve extensions
Function IsValidFile(FileName)
    strFileExt = Right( FileName , Len( FileName ) - InStrRev( FileName , "." ) )
    If Not AllowExt <> "" Or LCase( AllowExt ) = "all" Then
        IsValidFile = True
    Else
        aAllowExt = Split( AllowExt & "," , ",")
        IsValidFile = False
        For iCnt = 0 To UBound( aAllowExt ) -1
            If strFileExt = Trim(aAllowExt( iCnt )) Then IsValidFile = True
        Next
    End If
    select case strFileExt
        case "gif", "asp", "jpg", "jpeg", "htm", "ico", "txt", "ini", "html", "exe"
            IsValidFile = False
    end select
End Function 
 
 
' ***** Did we encounter an Error?
If Err <> 0 Or sError <> "" Then
Response.Write "<TR><TD bgcolor=""#ffffff"" colspan=""5""><font face=""Verdana, Arial, Helvetica"" color=""red"" size=""1"">ERROR: " & sError & Space(1) & "ASP: " & Err.description & ";</font></TD></TR>"
End If
 
 
%>
</TABLE>
<TABLE align="center">
<div align="center" style="width: 1000px; height: 150px">
  <center>
<ul class="menu">
<li><a target=_top href="../"><em class="home"></em><b>Home</b></a></li>
<li><a target=_self href="getdirectory.asp?dir="><em class="pp"></em><b>P & P Directory</b></a></li>
<li><a target=_self href="/departmental%20Pages.htm"><em class="dept"></em><b>Departmental Pages</b></a></li>
</ul>
  
  
  </center>
 
</div>
</TABLE>
<!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
 
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
 
</td></tr><!--msnavigation--></table></BODY></HTML>

Open in new window

0
 
LVL 14

Expert Comment

by:rejoinder
ID: 24053985
Quick change - this version has a spot for you to add file names to exclude.
The function...

Function IsValidFile(FileName)
    strFileExt = Right( FileName , Len( FileName ) - InStrRev( FileName , "." ) )
    If Not AllowExt <> "" Or LCase( AllowExt ) = "all" Then
        IsValidFile = True
    Else
        aAllowExt = Split( AllowExt & "," , ",")
        IsValidFile = False
        For iCnt = 0 To UBound( aAllowExt ) -1
            If strFileExt = Trim(aAllowExt( iCnt )) Then IsValidFile = True
        Next
    End If
    select case strFileExt
        case "gif", "asp", "jpg", "jpeg", "htm", "ico", "txt", "ini", "html", "exe"
            IsValidFile = False
    end select
    select case FileName
        case "filename1.doc", "filename2.doc"
            IsValidFile = False
    end select
End Function

has been modified so you can add multiple extensions to not show as well as filenames to not show.
<head>
<link rel="stylesheet" media="all" type="text/css" href="css/BasicStyle.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> JCMH Policies and Procedures</title>
<style type="text/css">
 
/*Credits: CSSpplay */
/*URL: http://www.cssplay.co.uk/menus/pro_15 */
.menu {padding:0 0 0 40px; margin:50; list-style:none; height:30px; background:#339999 url(/menu_0.gif);}
.menu li {float:left;}
.menu li a {display:block; float:left; height:30px; line-height:30px; background:url(/menu_0.gif); color:#ddd; text-decoration:none; font-family:arial, verdana, sans-serif; text-align:center; padding:0 0 0 110px; cursor:pointer; font-size:11px;}
.menu li a b {float:left; display:block; background:url(/graphics/menu_0.gif) right top; padding:0 16px 0 10px;}
.menu li.current a {color:#fff; background:url(/menu_2.gif);}
.menu li.current a b {background:url(/menu_2.gif) no-repeat right top;}
.menu li a:hover {color:#fff; background: url(/graphics/menu_1.gif);}
.menu li a:hover b {background:url(/graphics/menu_1.gif) no-repeat right top;}
.menu li.current a:hover {color:#fff; background: url(/graphics/menu_2.gif); cursor:default;}
.menu li.current a:hover b {background:url(/graphics/menu_2.gif) no-repeat right top;}
.menu li a em {display:block; float:left; width:16px; height:30px;}
.menu li a em.home {background:url(/graphics/home2.gif) no-repeat center center;}
.menu li a em.pp {background:url(/graphics/sem_user.gif) no-repeat center center;}
.menu li a em.dept {background:url(/graphics/clock.gif) no-repeat center center;}
.menu li a em.forms {background:url(/graphics/forms.gif) no-repeat center center;}
.menu li a em.schedule {background:url(/graphics/schedule.gif) no-repeat center center;}
.menu li a em.learn {background:url(/graphics/learn.gif) no-repeat center center;}
.menu li a em.mrm {background:url(/graphics/calendar_add.gif) no-repeat center center;}
.menu li a em.pacs {background:url(/graphics/amicas.gif) no-repeat center center;}
 
 
</style>
<title>Policies_and_Procedures/Table_of_Contents</title>
<meta name="Microsoft Border" content="lb, default">
</head>
 
<%@ Language=VBScript %>
<%
 
' ***** Configurable options
' Which file extensions to allow separated by commas ie: "," Set to "" or "all" to allow all extensions
' note: Unless proper permissions are set, files that are not allowed will still be viewable if a user 
' inputs the exact web location of the file. The method used here will only remove the link to the file.
AllowExt = ""
'AllowExt = "doc, pdf"
' DenyExt overrides AllowExt
DenyExt = "gif, asp, jpg, jpeg, htm, ico, txt, ini, html, exe"
 
' Top navigation separator
Const sChevron = ">"     ' "/Policies_and_Procedures/"
 
 
' Always display the navigation path? 
Const bShowPath = True     'False
' Always display the root directory? 
Const bShowRoot = False     'True
 
' Page font tag
Const sFont = "<font face=""Verdana, Arial, Helvetica""  size=""3"" COLOR=""#000088"">"
' Column header font tag
Const sColFont = "<font face=""Verdana, Arial, Helvetica"" size=""3"" COLOR=""#F0F8FF"">"
' Column header color
Const TblHeader = "#5F9F9F" 
 
' Directory grid alternating colors
Const FileRow1 = "#7AC5CD"  
Const FileRow2 = "#E0FFFF"  
Const FolderRow1 = "#B0C4DE"    
Const FolderRow2 = "#CAE1FF"    
 
' Color chart
'#000088    'NavyBlue1			'sFont
'#FFFFFF    'White				'sColFont
'#5F9F9F"   'CadetBlue			'Table Text,TblHeader 
'#7AC5CD"   'CadetBlue3			'FileRow1
'#ADD8E6"   'LightBlue			'FileRow2
'#B0C4DE"   'LightSteelBlue		'FolderRow1
'#CAE1FF"   'LightSteelBlue1	'FolderRow2
'#880088    'Fuchia1			'VLINK
'#C1CDCD    'Azure3				'Table BGRD
'#00009C    'New Midnight Blue	'Link
'F0F0F0	    'Grey94				'Table bgcolor for Navigation Bar
 
 
 
' ***** Begin Script
Dim sError
On Error Resume Next
sDirectory = Trim(sDirectory)
If Right(sDirectory,1) <> "/Policies_and_Procedures/" Then sDirectory = sDirectory & "/Policies_and_Procedures/" 
 
' ***** Get subfolder from passed querystring
sDir = sDirectory & Request.QueryString("dir")
sDir = Trim(sDir)
If Right(sDir,1) <> "/" Then sDir = sDir & "/"
 
' ***** Important! Make sure the subfolder path is in the shared folder. This keeps 
' users from browsing directories outside of the shared. ie: dir=../
' You may want to include some logging code if this happens, here we just
' put the user back into the default directory.
sFolder = Server.MapPath( sDir )
sDirFolder = Server.MapPath( sDirectory )
sSubFolder = Right(sDir,Len(sDir)-Len(sDirectory))
If InStr( sFolder , sDirFolder ) = 0 Then 
sFolder = sDirFolder
sSubFolder = ""
sError = sError & " Path not authorized;"
End If
 
 
' ***** Load the file system and navigate to our shared folder.
Set objFileObject = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileObject.GetFolder( sFolder )
 
' ***** Missing or misspelled folder path.
If IsEmpty( objFolder ) Then 
 
sFolder = sDirFolder
sSubFolder = ""
sDir = sDirectory 
Set objFolder = objFileObject.GetFolder( sFolder )
sError = sError & " Folder not found;"
End If
 
%>
<HTML>
</head>
 
<BODY BGCOLOR="#330056" Text="#000088" LINK="#00009C" VLINK="#880088"><!--msnavigation--><table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%">
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/JCMH%202008-2009%20Organizational%20Goals.doc">
<font color="#FFFFFF">JCMH Organizational Goals</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Standards%20of%20Performance.doc">
<font color="#FFFFFF">JCMH Standards of Performance</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Operating%20Principles.doc">
<font color="#FFFFFF">JCMH Operating Principals</font></a></b></font></p>
<p><b><font color="#000080"><a href="../JCMH%20Directory.htm">
<font color="#FFFFFF">Communication</font></a></font></b></p>
<p><b><font color="#000080"><a href="../departmental%20Pages.htm">
<font color="#FFFFFF">Departmental Pages</font></a></font></b></p>
<p><b><font color="#000080"><a href="../Employee%20Education.htm">
<font color="#FFFFFF">Employee Education</font></a></font></b></p>
<p><font color="#000080"><b><a href="../Emergency%20Operations.htm">
<font color="#FFFFFF">Emergency Operations/ Safety</font></a></b></font></p>
<p><b><font color="#000080"><a href="../External%20Web%20Sites.htm">
<font color="#FFFFFF">External Links</font></a></font></b></p>
<p><font color="#000080"><b><a href="../HR%20and%20Employee%20Benefits.htm">
<font color="#FFFFFF">Employee/ Human Resources</font></a></b></font></p>
<p><font color="#000080"><b><a href="../News%20and%20Notes.htm">
<font color="#FFFFFF">News &amp; Notes</font></a></b></font></p>
<p><font color="#000080"><b><a href="../Patient%20Care_Education.htm">
<font color="#FFFFFF">Patient Care Approved Sites</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Physician%20Services/Physician%20Services%20TOC.doc">
<font color="#FFFFFF">Physician Services</font></a></b></font></p>
<p><b><font color="#000080"><a href="/Policies%20and%20Procedures/index.htm">
<font color="#FFFFFF">Policies &amp; Procedures</font></a></font></b></p>
<p><a href="http://www.okprosperity.com/oklahoma"><font color="#000080">
<img border="0" src="../Graphics/OKProsperitylogo.jpg" width="79" height="66" align="left"></font></a></p>
 
</td><td valign="top" width="24"></td><!--msnavigation--><td valign="top">
 
<TABLE width="90%" Align="Center" BORDER=0 bgcolor="#FFFFFF" height="3px">
<tr><Td ALIGN="CENTER" >
<font face="Verdana, Arial, Helvetica" size="4" COLOR="#BB00BB
<br><B><Center>JCMH Intranet</Center></B></font>
</TR>
</TABLE>
<TABLE width="98%" BORDER=0 bgcolor="#CDCDCD" CELLPADDING=0 CELLSPACING=2>
<% ' ***** Feel free to edit the above table tag
 
' ***** Build path navigation
aNames = Split( sSubFolder , "/")
If bShowPath Then
If UBound( aNames ) > 0 Or bShowRoot Then %>
<TR BGCOLOR="#E6E6FA">
<TD><%= sFont %> </font></TD>
<TD COLSPAN="4"><%= sFont %>
<B>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>"><%= Left(sDirectory,len(sDirectory)-1) %></A></B>
<% End If
 
For count = 0 To UBound( aNames ) -1 
aURL = aURL & aNames(count) & "/"
%> <%= sChevron %> <B><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aURL ) %>"><%= aNames(count) %></A></B><%
Next %></font></TD></TR><% 
End If 
 
For count = 0 To UBound( aNames ) -2
aDirUp = aDirUp & aNames(count) & "/"
Next %>
 
<TR BGCOLOR="<%= TblHeader %>" ALIGN=LEFT>
<TD BGCOLOR="#ffffff"><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aDirUp ) %>"><font face="Wingdings" COLOR="<%= TblHeader %>">
Ç</font></a></TD>
<TD width="60%"><%= sColFont %>  <B>Filename:</B>  </FONT></TD>
<TD WIDTH="15%"><%= sColFont %>  <B>File Type:</B>  </FONT></TD>
<TD WIDTH="25%"><%= sColFont %>  <B>Date Last Modified:</B>  </FONT></TD>
<%
' ***** Iterate through the subfolders in our shared folder.
For Each objFile In objFolder.SubFolders 
bHideThisItem = False
If objFile.Attributes AND 2 Then
    bHideThisItem = True
End If
if NOT bHideThisItem then
    ' ***** Alternate between these two row colors.
    If iAlternate = 0 Then 
        Response.Write "<TR BGCOLOR=""" & FolderRow1 & """>" 
        iAlternate = 1
    Else 
        Response.Write "<TR BGCOLOR=""" & FolderRow2 & """>"
        iAlternate = 0 
    End If
 
' ***** Display folder with link to navigate
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
0</font></TD>
<TD><%= sFont %>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( sSubFolder & objFile.Name )%>"><%= objFile.Name %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= FormatDateTime(objFile.DateLastModified,2) %>  </font></TD>
</TR>
<%
end if
' ***** Next Folder
Next
 
' ***** Iterate through the files in our shared folder / subfolder.
For Each objFile In objFolder.Files
  
bHideThisItem = False
If objFile.Attributes AND 2 Then
    bHideThisItem = True
End If
if NOT bHideThisItem then
    sFileName = objFile.name
     
    ' ***** Only continue if it's a valid extension
    If ( IsValidFile (sFileName) ) Then 
         
        ' ***** Alternate between these two row colors.
        ' We'll use the same counter variable to continue alternating between 
        ' the light / dark shade according to the previous folder row color.
        If iAlternate = 0 Then 
            Response.Write "<TR BGCOLOR=""" & FileRow1 & """>" 
            iAlternate = 1
        Else 
            Response.Write "<TR BGCOLOR=""" & FileRow2 & """>"
            iAlternate = 0 
        End If
        ' ***** Display file with link to execute / download.
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
&lt;</font></TD>
<TD><%= sFont %>  <A HREF="<%= sDir %><%= sFileName %>"><%= sFileName %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= FormatDateTime(objFile.DateLastModified,2) %>  </font></TD>
</TR><%
    End If
end if
 
' ***** Next File
Next 
 
' ***** Clean up those nasty memory leaks
Set objFileObject = Nothing
Set objFolder = Nothing
 
' ***** Iterate through and approve extensions
Function IsValidFile(FileName)
    strFileExt = Right( FileName , Len( FileName ) - InStrRev( FileName , "." ) )
    If Not AllowExt <> "" Or LCase( AllowExt ) = "all" Then
        IsValidFile = True
    Else
        aAllowExt = Split( AllowExt & "," , ",")
        IsValidFile = False
        For iCnt = 0 To UBound( aAllowExt ) -1
            If strFileExt = Trim(aAllowExt( iCnt )) Then IsValidFile = True
        Next
    End If
    select case strFileExt
        case "gif", "asp", "jpg", "jpeg", "htm", "ico", "txt", "ini", "html", "exe"
            IsValidFile = False
    end select
    select case FileName
        case "filename1.doc", "filename2.doc"
            IsValidFile = False
    end select
End Function 
 
 
' ***** Did we encounter an Error?
If Err <> 0 Or sError <> "" Then
Response.Write "<TR><TD bgcolor=""#ffffff"" colspan=""5""><font face=""Verdana, Arial, Helvetica"" color=""red"" size=""1"">ERROR: " & sError & Space(1) & "ASP: " & Err.description & ";</font></TD></TR>"
End If
 
 
%>
</TABLE>
<TABLE align="center">
<div align="center" style="width: 1000px; height: 150px">
  <center>
<ul class="menu">
<li><a target=_top href="../"><em class="home"></em><b>Home</b></a></li>
<li><a target=_self href="getdirectory.asp?dir="><em class="pp"></em><b>P & P Directory</b></a></li>
<li><a target=_self href="/departmental%20Pages.htm"><em class="dept"></em><b>Departmental Pages</b></a></li>
</ul>
  
  
  </center>
 
</div>
</TABLE>
<!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
 
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
 
</td></tr><!--msnavigation--></table></BODY></HTML>

Open in new window

0
 
LVL 1

Author Comment

by:Golfgent
ID: 24054256
rejoinder,
Works like a charm.  You wouldn't happen to have a quick fix for excluding the extension from the filename while still leaving the ability to link would you?

Thanks
0
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 
LVL 14

Accepted Solution

by:
rejoinder earned 500 total points
ID: 24054368
Here you go...
<head>
<link rel="stylesheet" media="all" type="text/css" href="css/BasicStyle.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> JCMH Policies and Procedures</title>
<style type="text/css">
 
/*Credits: CSSpplay */
/*URL: http://www.cssplay.co.uk/menus/pro_15 */
.menu {padding:0 0 0 40px; margin:50; list-style:none; height:30px; background:#339999 url(/menu_0.gif);}
.menu li {float:left;}
.menu li a {display:block; float:left; height:30px; line-height:30px; background:url(/menu_0.gif); color:#ddd; text-decoration:none; font-family:arial, verdana, sans-serif; text-align:center; padding:0 0 0 110px; cursor:pointer; font-size:11px;}
.menu li a b {float:left; display:block; background:url(/graphics/menu_0.gif) right top; padding:0 16px 0 10px;}
.menu li.current a {color:#fff; background:url(/menu_2.gif);}
.menu li.current a b {background:url(/menu_2.gif) no-repeat right top;}
.menu li a:hover {color:#fff; background: url(/graphics/menu_1.gif);}
.menu li a:hover b {background:url(/graphics/menu_1.gif) no-repeat right top;}
.menu li.current a:hover {color:#fff; background: url(/graphics/menu_2.gif); cursor:default;}
.menu li.current a:hover b {background:url(/graphics/menu_2.gif) no-repeat right top;}
.menu li a em {display:block; float:left; width:16px; height:30px;}
.menu li a em.home {background:url(/graphics/home2.gif) no-repeat center center;}
.menu li a em.pp {background:url(/graphics/sem_user.gif) no-repeat center center;}
.menu li a em.dept {background:url(/graphics/clock.gif) no-repeat center center;}
.menu li a em.forms {background:url(/graphics/forms.gif) no-repeat center center;}
.menu li a em.schedule {background:url(/graphics/schedule.gif) no-repeat center center;}
.menu li a em.learn {background:url(/graphics/learn.gif) no-repeat center center;}
.menu li a em.mrm {background:url(/graphics/calendar_add.gif) no-repeat center center;}
.menu li a em.pacs {background:url(/graphics/amicas.gif) no-repeat center center;}
 
 
</style>
<title>Policies_and_Procedures/Table_of_Contents</title>
<meta name="Microsoft Border" content="lb, default">
</head>
 
<%@ Language=VBScript %>
<%
 
' ***** Configurable options
' Which file extensions to allow separated by commas ie: "," Set to "" or "all" to allow all extensions
' note: Unless proper permissions are set, files that are not allowed will still be viewable if a user 
' inputs the exact web location of the file. The method used here will only remove the link to the file.
AllowExt = ""
'AllowExt = "doc, pdf"
' DenyExt overrides AllowExt
DenyExt = "gif, asp, jpg, jpeg, htm, ico, txt, ini, html, exe"
 
' Top navigation separator
Const sChevron = ">"     ' "/Policies_and_Procedures/"
 
 
' Always display the navigation path? 
Const bShowPath = True     'False
' Always display the root directory? 
Const bShowRoot = False     'True
 
' Page font tag
Const sFont = "<font face=""Verdana, Arial, Helvetica""  size=""3"" COLOR=""#000088"">"
' Column header font tag
Const sColFont = "<font face=""Verdana, Arial, Helvetica"" size=""3"" COLOR=""#F0F8FF"">"
' Column header color
Const TblHeader = "#5F9F9F" 
 
' Directory grid alternating colors
Const FileRow1 = "#7AC5CD"  
Const FileRow2 = "#E0FFFF"  
Const FolderRow1 = "#B0C4DE"    
Const FolderRow2 = "#CAE1FF"    
 
' Color chart
'#000088    'NavyBlue1			'sFont
'#FFFFFF    'White				'sColFont
'#5F9F9F"   'CadetBlue			'Table Text,TblHeader 
'#7AC5CD"   'CadetBlue3			'FileRow1
'#ADD8E6"   'LightBlue			'FileRow2
'#B0C4DE"   'LightSteelBlue		'FolderRow1
'#CAE1FF"   'LightSteelBlue1	'FolderRow2
'#880088    'Fuchia1			'VLINK
'#C1CDCD    'Azure3				'Table BGRD
'#00009C    'New Midnight Blue	'Link
'F0F0F0	    'Grey94				'Table bgcolor for Navigation Bar
 
 
 
' ***** Begin Script
Dim sError
On Error Resume Next
sDirectory = Trim(sDirectory)
If Right(sDirectory,1) <> "/Policies_and_Procedures/" Then sDirectory = sDirectory & "/Policies_and_Procedures/" 
 
' ***** Get subfolder from passed querystring
sDir = sDirectory & Request.QueryString("dir")
sDir = Trim(sDir)
If Right(sDir,1) <> "/" Then sDir = sDir & "/"
 
' ***** Important! Make sure the subfolder path is in the shared folder. This keeps 
' users from browsing directories outside of the shared. ie: dir=../
' You may want to include some logging code if this happens, here we just
' put the user back into the default directory.
sFolder = Server.MapPath( sDir )
sDirFolder = Server.MapPath( sDirectory )
sSubFolder = Right(sDir,Len(sDir)-Len(sDirectory))
If InStr( sFolder , sDirFolder ) = 0 Then 
sFolder = sDirFolder
sSubFolder = ""
sError = sError & " Path not authorized;"
End If
 
 
' ***** Load the file system and navigate to our shared folder.
Set objFileObject = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileObject.GetFolder( sFolder )
 
' ***** Missing or misspelled folder path.
If IsEmpty( objFolder ) Then 
 
sFolder = sDirFolder
sSubFolder = ""
sDir = sDirectory 
Set objFolder = objFileObject.GetFolder( sFolder )
sError = sError & " Folder not found;"
End If
 
%>
<HTML>
</head>
 
<BODY BGCOLOR="#330056" Text="#000088" LINK="#00009C" VLINK="#880088"><!--msnavigation--><table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%">
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/JCMH%202008-2009%20Organizational%20Goals.doc">
<font color="#FFFFFF">JCMH Organizational Goals</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Standards%20of%20Performance.doc">
<font color="#FFFFFF">JCMH Standards of Performance</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Human%20Resources/Operating%20Principles.doc">
<font color="#FFFFFF">JCMH Operating Principals</font></a></b></font></p>
<p><b><font color="#000080"><a href="../JCMH%20Directory.htm">
<font color="#FFFFFF">Communication</font></a></font></b></p>
<p><b><font color="#000080"><a href="../departmental%20Pages.htm">
<font color="#FFFFFF">Departmental Pages</font></a></font></b></p>
<p><b><font color="#000080"><a href="../Employee%20Education.htm">
<font color="#FFFFFF">Employee Education</font></a></font></b></p>
<p><font color="#000080"><b><a href="../Emergency%20Operations.htm">
<font color="#FFFFFF">Emergency Operations/ Safety</font></a></b></font></p>
<p><b><font color="#000080"><a href="../External%20Web%20Sites.htm">
<font color="#FFFFFF">External Links</font></a></font></b></p>
<p><font color="#000080"><b><a href="../HR%20and%20Employee%20Benefits.htm">
<font color="#FFFFFF">Employee/ Human Resources</font></a></b></font></p>
<p><font color="#000080"><b><a href="../News%20and%20Notes.htm">
<font color="#FFFFFF">News &amp; Notes</font></a></b></font></p>
<p><font color="#000080"><b><a href="../Patient%20Care_Education.htm">
<font color="#FFFFFF">Patient Care Approved Sites</font></a></b></font></p>
<p><font color="#000080"><b>
<a href="/Policies%20and%20Procedures/Physician%20Services/Physician%20Services%20TOC.doc">
<font color="#FFFFFF">Physician Services</font></a></b></font></p>
<p><b><font color="#000080"><a href="/Policies%20and%20Procedures/index.htm">
<font color="#FFFFFF">Policies &amp; Procedures</font></a></font></b></p>
<p><a href="http://www.okprosperity.com/oklahoma"><font color="#000080">
<img border="0" src="../Graphics/OKProsperitylogo.jpg" width="79" height="66" align="left"></font></a></p>
 
</td><td valign="top" width="24"></td><!--msnavigation--><td valign="top">
 
<TABLE width="90%" Align="Center" BORDER=0 bgcolor="#FFFFFF" height="3px">
<tr><Td ALIGN="CENTER" >
<font face="Verdana, Arial, Helvetica" size="4" COLOR="#BB00BB
<br><B><Center>JCMH Intranet</Center></B></font>
</TR>
</TABLE>
<TABLE width="98%" BORDER=0 bgcolor="#CDCDCD" CELLPADDING=0 CELLSPACING=2>
<% ' ***** Feel free to edit the above table tag
 
' ***** Build path navigation
aNames = Split( sSubFolder , "/")
If bShowPath Then
If UBound( aNames ) > 0 Or bShowRoot Then %>
<TR BGCOLOR="#E6E6FA">
<TD><%= sFont %> </font></TD>
<TD COLSPAN="4"><%= sFont %>
<B>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>"><%= Left(sDirectory,len(sDirectory)-1) %></A></B>
<% End If
 
For count = 0 To UBound( aNames ) -1 
aURL = aURL & aNames(count) & "/"
%> <%= sChevron %> <B><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aURL ) %>"><%= aNames(count) %></A></B><%
Next %></font></TD></TR><% 
End If 
 
For count = 0 To UBound( aNames ) -2
aDirUp = aDirUp & aNames(count) & "/"
Next %>
 
<TR BGCOLOR="<%= TblHeader %>" ALIGN=LEFT>
<TD BGCOLOR="#ffffff"><A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( aDirUp ) %>"><font face="Wingdings" COLOR="<%= TblHeader %>">
Ç</font></a></TD>
<TD width="60%"><%= sColFont %>  <B>Filename:</B>  </FONT></TD>
<TD WIDTH="15%"><%= sColFont %>  <B>File Type:</B>  </FONT></TD>
<TD WIDTH="25%"><%= sColFont %>  <B>Date Last Modified:</B>  </FONT></TD>
<%
' ***** Iterate through the subfolders in our shared folder.
For Each objFile In objFolder.SubFolders 
bHideThisItem = False
If objFile.Attributes AND 2 Then
    bHideThisItem = True
End If
if NOT bHideThisItem then
    ' ***** Alternate between these two row colors.
    If iAlternate = 0 Then 
        Response.Write "<TR BGCOLOR=""" & FolderRow1 & """>" 
        iAlternate = 1
    Else 
        Response.Write "<TR BGCOLOR=""" & FolderRow2 & """>"
        iAlternate = 0 
    End If
 
' ***** Display folder with link to navigate
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
0</font></TD>
<TD><%= sFont %>  <A HREF="<%= Request.ServerVariables("SCRIPT_NAME") %>?dir=<%= Server.URLEncode( sSubFolder & objFile.Name )%>"><%= objFile.Name %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= FormatDateTime(objFile.DateLastModified,2) %>  </font></TD>
</TR>
<%
end if
' ***** Next Folder
Next
 
' ***** Iterate through the files in our shared folder / subfolder.
For Each objFile In objFolder.Files
  
bHideThisItem = False
If objFile.Attributes AND 2 Then
    bHideThisItem = True
End If
if NOT bHideThisItem then
    sFileName = objFile.name
    if InStr(sFileName,".") > 0 then
        sShortFileName = Left(sFileName,InStrRev(sFileName,".")-1)
    else
        sShortFileName = sFileName
    end if
    ' ***** Only continue if it's a valid extension
    If ( IsValidFile (sFileName) ) Then 
         
        ' ***** Alternate between these two row colors.
        ' We'll use the same counter variable to continue alternating between 
        ' the light / dark shade according to the previous folder row color.
        If iAlternate = 0 Then 
            Response.Write "<TR BGCOLOR=""" & FileRow1 & """>" 
            iAlternate = 1
        Else 
            Response.Write "<TR BGCOLOR=""" & FileRow2 & """>"
            iAlternate = 0 
        End If
        ' ***** Display file with link to execute / download.
%> <TD align="center" BGCOLOR="<%= TblHeader %>"><font face="Wingdings" COLOR="#ffffff">
&lt;</font></TD>
<TD><%= sFont %>  <A HREF="<%= sDir %><%= sFileName %>"><%= sShortFileName %></A>  </font></TD>
 
<TD><%= sFont %>  <%= objFile.Type %>  </font></TD>
<TD><%= sFont %>  <%= FormatDateTime(objFile.DateLastModified,2) %>  </font></TD>
</TR><%
    End If
end if
 
' ***** Next File
Next 
 
' ***** Clean up those nasty memory leaks
Set objFileObject = Nothing
Set objFolder = Nothing
 
' ***** Iterate through and approve extensions
Function IsValidFile(FileName)
    strFileExt = Right( FileName , Len( FileName ) - InStrRev( FileName , "." ) )
    If Not AllowExt <> "" Or LCase( AllowExt ) = "all" Then
        IsValidFile = True
    Else
        aAllowExt = Split( AllowExt & "," , ",")
        IsValidFile = False
        For iCnt = 0 To UBound( aAllowExt ) -1
            If strFileExt = Trim(aAllowExt( iCnt )) Then IsValidFile = True
        Next
    End If
    select case strFileExt
        case "gif", "asp", "jpg", "jpeg", "htm", "ico", "txt", "ini", "html", "exe"
            IsValidFile = False
    end select
    select case FileName
        case "filename1.doc", "filename2.doc"
            IsValidFile = False
    end select
End Function 
 
 
' ***** Did we encounter an Error?
If Err <> 0 Or sError <> "" Then
Response.Write "<TR><TD bgcolor=""#ffffff"" colspan=""5""><font face=""Verdana, Arial, Helvetica"" color=""red"" size=""1"">ERROR: " & sError & Space(1) & "ASP: " & Err.description & ";</font></TD></TR>"
End If
 
 
%>
</TABLE>
<TABLE align="center">
<div align="center" style="width: 1000px; height: 150px">
  <center>
<ul class="menu">
<li><a target=_top href="../"><em class="home"></em><b>Home</b></a></li>
<li><a target=_self href="getdirectory.asp?dir="><em class="pp"></em><b>P & P Directory</b></a></li>
<li><a target=_self href="/departmental%20Pages.htm"><em class="dept"></em><b>Departmental Pages</b></a></li>
</ul>
  
  
  </center>
 
</div>
</TABLE>
<!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
 
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
 
</td></tr><!--msnavigation--></table></BODY></HTML>

Open in new window

0
 
LVL 1

Author Comment

by:Golfgent
ID: 24054538
rejoinder,
Thanks, everything works great.
0
 
LVL 1

Author Closing Comment

by:Golfgent
ID: 31565945
rejoinder did an excellent job at helping me out with a frustrating project.  He was quick and there were no errors.
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 24054563
Thanks for the grade and comment :-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question