Free Web Hosting PHP/mySQL
GlobalWeb.com.ru Forum Index GlobalWeb.com.ru
Free Web Hosting :: Commercial Web Hosting :: PHP/mySQL :: CGI/Perl
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The script use to check server-side files

 
Post new topic   Reply to topic    GlobalWeb.com.ru Forum Index -> ASP
Author Message
dottedlife



Joined: 05 Mar 2004
Posts: 106

PostPosted: Sat Mar 13, 2004 5:04 am    Post subject: The script use to check server-side files Reply with quote

This script can use to check the server-side files(notes:u must make some pic for show the type of file: unknown file, folder, *.html, *.log, go to previous folder, *.gif, *.txt)
==========================
DIR.asp
Code:

<% @ LANGUAGE="VBSCRIPT" %>

<%
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path
MODE = Request.QueryString("MODE")
if sPP & "" = "" then sPP = GetPP
if sUP & "" = "" then sUP = GetUP

result = DIR(sPP,sUP)      



Function DIR(byval sPP,byval sUP)

   if right(sPP,1) <> "\" then sPP = sPP & "\"
   if right(sUP,1) <> "/" then sUP = sUP & "/"
      
   Response.Write "<Font size=4><b>Index of " & sPP & "</b></font><br><hr>"      

   
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(sPP)     
   Set fc = f.Files 
   Set ff = f.SubFolders


   Response.Write "<table cellpadding=2 cellspacing=2 border=0>"
   if MODE = "DRIVES" then
      Set dc = fso.Drives
      For Each d in dc
         Response.Write "<tr><td width=15 valign=middle>&nbsp;</td>"
         Response.Write "<td valign=middle><a href=dir.asp?PP=" & d.DriveLetter & ":\>" & d.DriveLetter & ":\</a>  " & d.DriveType & "<br></td></tr>"
      Next
      set dc = nothing
   else
      ' Set Parent folder
      if right(sPP,2) = ":\" then
         Response.Write "<a href=" & chr(34) & "dir.asp?MODE=DRIVES" & chr(34) & "><b>DRIVE LIST</b></a><br><br>"
      else
         Response.Write "<tr><td width=15 valign=middle><img src=pardir.bmp></td>"
         Response.Write "<td valign=middle><a href=" & chr(34) & "dir.asp?PP=" & f.ParentFolder & "&UP=" & ParDir(sUP,"/") & chr(34) & "><b>PARENT DIRECTORY</b></a><br><br></td></tr>"
      end if      


      For Each f in ff
         Response.Write "<tr><td width=15 valign=middle><img src=folder.bmp></td>"
         Response.Write "<td valign=middle><a href=" & chr(34) & "dir.asp?PP=" & sPP & f.name & "&UP=" & sUP & f.name & chr(34) & ">" & f.name & "\</a></td></tr>"
      Next    
      For Each f in fc
         Response.Write "<tr><td width=15 valign=middle><img src=" & Image(f.name) & "></td>"
         Response.Write "<td valign=middle><a href=" & chr(34) & "cat.asp?file=" & sPP & f.name & chr(34) & ">" & f.name & "</a><br></td></tr>" 'only works in current domain.
         'Response.Write "<td valign=middle>" & f.name & "</td></tr>" 'only works in current domain.
      Next 
   end if
   Set ff = nothing
   Set fso = nothing
   Set f = nothing
   Set fc = nothing   
End Function

Function ParDir(byval s,byval Slash)
ParDir = ""
if s & "" = "" then Exit Function
s = left(s,len(s)-1)
   do while true
      c = right(s,1)
      if c = ":" then exit do
      if c <> Slash then
         if len(s) <= 0 then exit do
         s = left(s,len(s)-1)
      else
         exit do
      end if            
   loop
   ParDir = s
end function

Function Image(byval sName)
Dim sType: sType = GetType(sName)
   Image = ""
   Select Case sType
      case ".htm"
          Image = Image & "html.bmp"
      case ".html"
         Image = Image & "html.bmp"
      case ".bak"
          Image = Image & "log.bmp"
      case ".BAK"
         Image = Image & "log.bmp"
      case ".gif"
      case ".GIF"
         Image = Image & "pic.bmp"
      case ".jpg"
      case ".JPG"
         Image = Image & "pic.bmp"
      case ".jpeg"
      case ".JPEG"
         Image = Image & "pic.bmp"
      case ".bmp"
          Image = Image & "pic.bmp"   
      case ".BMP"
         Image = Image & "pic.bmp"   
      case ".txt"
          Image = Image & "txt.bmp"
      case else
         Image = Image & "dontknow.bmp"
   end select   
End Function

Function GetPP 'Physical Path
dim s
s = Request.ServerVariables("path_translated")
 Do while true
   if instr(s,"\") then
      if right(s,1) = "\" then exit do
      s = left(s,len(s)-1)      
   else
      exit do
   end if
 loop
GetPP = s
End function

Function GetUP() 'URL Path
dim s
s = Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("script_name")
 Do while true
   if instr(s,"/") then
      if right(s,1) = "/" then exit do
      s = left(s,len(s)-1)      
   else
      exit do
   end if
 loop
GetUP = "http://" & s
End function

Function GetType(byval s) 'Get file type
 Do while true
   if instr(s,".") then
      if left(s,1) = "." then exit do
      s = right(s,len(s)-1)      
   else
      GetType = ""
      exit do
   end if
 loop
GetType = s
End function
%>

CAT.asp
Code:

<%
Response.ContentType="text/plain"
file=Request.QueryString("file")
If file="" Then
Response.Write "Please Input File Name:http://xxxx/cat.asp?file=c:\autoexec.bat"
Else
set fsFilesys=CreateObject("Scripting.FileSystemObject")
set tsCoffee=fsFilesys.OpenTextFile(file)
Response.Write tsCoffee.Readall
tsCoffee.Close
set fsFilesys=Nothing
set tsCoffee=Nothing
End If
%>



_________________
Dottedlife
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    GlobalWeb.com.ru Forum Index -> ASP All times are GMT
Page 1 of 1

 


Free Web Hosting, Commercial Web Hosting, PHP/mySQL Copyright © 2009
Free Scripts Directory | Free Software Downloads | Newsgroups Directory | Optel.net | Mirroraty | Cruised.net | Hardware Keylogger