File Attributes with ASP in HTML

E

EQNish

Not sure if this is the spot to ask but I need some help with a script I
hijacked and put to my own use in an .ASP page

any ways I am using the FilesystemObjects to get a directory and file
listing and generating a web page of that listing, but I need to filter out
files with the SYSTEM tag, so it wont show files I dont want it to, Below is
my full code for the ASP page, I have Commented where I need to change the
listing structure, if anyone can help me filter these out I would be
greatfull!!!


--- Begin code ---
<%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit
On Error Resume Next

' this section is optional - it just denies anonymous access
If Request.ServerVariables("LOGON_USER")="" Then
Response.Status = "401 Access Denied"
End If

' declare variables
Dim objFSO, objFolder
Dim objCollection, objItem

Dim strPhysicalPath, strTitle, strServerName
Dim strPath, strTemp
Dim strName, strFile, strExt, strAttr
Dim intSizeB, intSizeK, intAttr, dtmDate

' declare constants
Const vbReadOnly = 1
Const vbHidden = 2
Const vbSystem = 4
Const vbVolume = 8
Const vbDirectory = 16
Const vbArchive = 32
Const vbAlias = 64
Const vbCompressed = 128

' don't cache the page
Response.AddHeader "Pragma", "No-Cache"
Response.CacheControl = "Private"

' get the current folder URL path
strTemp = Mid(Request.ServerVariables("URL"),2)
strPath = ""

Do While Instr(strTemp,"/")
strPath = strPath & Left(strTemp,Instr(strTemp,"/"))
strTemp = Mid(strTemp,Instr(strTemp,"/")+1)
Loop

strPath = "/" & strPath

' build the page title
strServerName = UCase(Request.ServerVariables("SERVER_NAME"))
strTitle = "Contents of the " & strPath & " folder"

' create the file system objects
strPhysicalPath = Server.MapPath(strPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
%>

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head>

<body text="#C0C0C0" bgcolor="#000000">

<div align="center">
<table border="0" width="80%" id="table1">
<tr>
<td align="center">Some web page Info here<p align="right"><b><font
size="4">And here</font></b></td>
</tr>
</table>
</div>
<p align="center">
<img border="0" src="Folder.jpg">
</p>

<p align="center"><a href="../">Back</a></p>


<html>
<body>

<div align="center"><center>
<table width="100%" border="0" cellspacing="1" cellpadding="2">

<%
''''''''''''''''''''''''''''''''''''''''
' output the folder list
''''''''''''''''''''''''''''''''''''''''

Set objCollection = objFolder.SubFolders

For Each objItem in objCollection
strName = objItem.Name
strAttr = MakeAttr(objItem.Attributes)
dtmDate = CDate(objItem.DateLastModified)
%>
<% Next %>

<%
''''''''''''''''''''''''''''''''''''''''
' output the file list
''''''''''''''''''''''''''''''''''''''''

Set objCollection = objFolder.Files

For Each objItem in objCollection
strName = objItem.Name
strFile = Server.HTMLEncode(Lcase(strName))

intSizeB = objItem.Size
intSizeK = Int((intSizeB/1024) + .5)
If intSizeK = 0 Then intSizeK = 1

strAttr = MakeAttr(objItem.Attributes)
strName = Ucase(objItem.ShortName)
If Instr(strName,".") Then strExt =
Right(strName,Len(strName)-Instr(strName,".")) Else strExt = ""
dtmDate = CDate(objItem.DateLastModified)
%>
' This is where I am listing the Files in my webpage, but it lists all
files, and I need to block the listing of system Files'
<tr>
<td align="left">A<%=strFile%></a></td>
<td align="right"> </td>
<td align="right">
<p align="left"><%=intSizeK%>K</td>
</tr>
<% Next %>

</table>
</center></div>

</body>
</html>
 
B

Bob Barrows [MVP]

EQNish said:
Not sure if this is the spot to ask but I need some help with a
script I hijacked and put to my own use in an .ASP page
Answered in .scripting.vbscript

This was the most appropriate place to post this, but Alex is doing a
good job with it in .scripting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top