Jump to content

Generate file listing for website


CyberSlug
 Share

Recommended Posts

If you want to post a bunch of files to your website and:

1) You want to be lazy

2) The web server does not allow virtual directory listings

Example on a university network where web space is mappeed to a network drive.

; CyberSlug 23 March
; CHANGE THE FOLLOWING PATH TO LOCATION OF FILES...
$webspaceDrive = "W:\Misc"

$searchHandle = FileFindFirstFile($webspaceDrive & "\*.*") 

;backup original index.html file if found
If FileExists($webspaceDrive & "\index.html") Then FileCopy($webspaceDrive & "\index.html", $webspaceDrive & "\index.html.old")

$index = FileOpen($webspaceDrive & "\index.html", 2);overwrite
FileWriteLine($index, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">')
FileWriteLine($index, '<html>')
FileWriteLine($index, '<head>')
FileWriteLine($index, '  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">')
FileWriteLine($index, '  <title>Index of file listing</title>')
FileWriteLine($index, '</head>')
FileWriteLine($index, '<body>')
FileWriteLine($index, '<H1>Here is a listing of files:</H1>')

While 1
    $file = FileFindNextFile($searchHandle) 
    If @error Then ExitLoop
    If $file = "." or $file = ".." or $file = "index.html" or $file = "index.html.old" Then ContinueLoop
    FileWrite($index, '<pre><a href="' & $file & '">' & $file & '<a>')
    $len = StringLen($file) 
    For $width = 1 to 8
        If $len < 8*$width Then FileWrite($index, @TAB)
    Next
        
    FileWrite($index, Round(FileGetSize($webspaceDrive & "\" & $file)/1024,2) & ' KB</pre>')
WEnd

FileWriteLine($index, "<br>")
FileWriteLine($index, "Listing generated " & @Year & "-" & @Mon & "-" & @MDay & "  " & @Hour & ":" & @Min & ":" & @Sec)
FileWriteLine($index, '</body>')
FileWriteLine($index, '</html>')

FileClose($index)

Func _StringRepeat($char, $count)
    Local $output, $i
    For $i = 1 to $count
        $output = $output & $char
    Next
    Return $output
EndFunc
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • 2 months later...

Here is my modified version:

  • Added Displaying "oben.txt" on the top of the page and "unten.txt" on the end of the page if exists.
  • Added Logfile
  • Added Version Information
  • Added Recursive Mode
  • Added Icons for Filetypes
  • Added "Last Modified" category
  • Added MB and GB for size information
  • Name: GenIndex
  • GNU GPL
For new versions see : http://www.jak-software.de/downloads/GenIndex or http://www.jak-software.de/genindex-en.html

or send a mail to : webmaster@jak-software.de or julian.klode@gmail.com

:(

GenIndex121.zip

Edited by jak
Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...