Jump to content
Sign in to follow this  
CyberSlug

Generate file listing for website

Recommended Posts

CyberSlug

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!

Share this post


Link to post
Share on other sites
jak

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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.