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 FilesystemObjec ts 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="VB SCRIPT"%>
<%
Option Explicit
On Error Resume Next
' this section is optional - it just denies anonymous access
If Request.ServerV ariables("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.AddHea der "Pragma", "No-Cache"
Response.CacheC ontrol = "Private"
' get the current folder URL path
strTemp = Mid(Request.Ser verVariables("U RL"),2)
strPath = ""
Do While Instr(strTemp,"/")
strPath = strPath & Left(strTemp,In str(strTemp,"/"))
strTemp = Mid(strTemp,Ins tr(strTemp,"/")+1)
Loop
strPath = "/" & strPath
' build the page title
strServerName = UCase(Request.S erverVariables( "SERVER_NAM E"))
strTitle = "Contents of the " & strPath & " folder"
' create the file system objects
strPhysicalPath = Server.MapPath( strPath)
Set objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set objFolder = objFSO.GetFolde r(strPhysicalPa th)
%>
<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="#00000 0">
<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.SubFo lders
For Each objItem in objCollection
strName = objItem.Name
strAttr = MakeAttr(objIte m.Attributes)
dtmDate = CDate(objItem.D ateLastModified )
%>
<% Next %>
<%
''''''''''''''' ''''''''''''''' ''''''''''
' output the file list
''''''''''''''' ''''''''''''''' ''''''''''
Set objCollection = objFolder.Files
For Each objItem in objCollection
strName = objItem.Name
strFile = Server.HTMLEnco de(Lcase(strNam e))
intSizeB = objItem.Size
intSizeK = Int((intSizeB/1024) + .5)
If intSizeK = 0 Then intSizeK = 1
strAttr = MakeAttr(objIte m.Attributes)
strName = Ucase(objItem.S hortName)
If Instr(strName," .") Then strExt =
Right(strName,L en(strName)-Instr(strName," .")) Else strExt = ""
dtmDate = CDate(objItem.D ateLastModified )
%>
' 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>
hijacked and put to my own use in an .ASP page
any ways I am using the FilesystemObjec ts 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="VB SCRIPT"%>
<%
Option Explicit
On Error Resume Next
' this section is optional - it just denies anonymous access
If Request.ServerV ariables("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.AddHea der "Pragma", "No-Cache"
Response.CacheC ontrol = "Private"
' get the current folder URL path
strTemp = Mid(Request.Ser verVariables("U RL"),2)
strPath = ""
Do While Instr(strTemp,"/")
strPath = strPath & Left(strTemp,In str(strTemp,"/"))
strTemp = Mid(strTemp,Ins tr(strTemp,"/")+1)
Loop
strPath = "/" & strPath
' build the page title
strServerName = UCase(Request.S erverVariables( "SERVER_NAM E"))
strTitle = "Contents of the " & strPath & " folder"
' create the file system objects
strPhysicalPath = Server.MapPath( strPath)
Set objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
Set objFolder = objFSO.GetFolde r(strPhysicalPa th)
%>
<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="#00000 0">
<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.SubFo lders
For Each objItem in objCollection
strName = objItem.Name
strAttr = MakeAttr(objIte m.Attributes)
dtmDate = CDate(objItem.D ateLastModified )
%>
<% Next %>
<%
''''''''''''''' ''''''''''''''' ''''''''''
' output the file list
''''''''''''''' ''''''''''''''' ''''''''''
Set objCollection = objFolder.Files
For Each objItem in objCollection
strName = objItem.Name
strFile = Server.HTMLEnco de(Lcase(strNam e))
intSizeB = objItem.Size
intSizeK = Int((intSizeB/1024) + .5)
If intSizeK = 0 Then intSizeK = 1
strAttr = MakeAttr(objIte m.Attributes)
strName = Ucase(objItem.S hortName)
If Instr(strName," .") Then strExt =
Right(strName,L en(strName)-Instr(strName," .")) Else strExt = ""
dtmDate = CDate(objItem.D ateLastModified )
%>
' 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>
Comment