Automatische Index.html Erstellung für Ordner (Webspace)
Verfasst: 16.03.2008 20:22
Hi,
Habe festgestellt das mein Webspace bei T-Homepage keine automatische Indexerstellung für Ordner ohne HTML Inhalte durchführt.
Musste somit dieses also selber für jeden Ordner ein "index.html" erstellen.
Das ergebnis siehe hier: http://www.mk-soft.homepage.t-online.de/
Einfach den Basisordner auswählen
FF 
Edit: Ein <BR> entfernt.
Habe festgestellt das mein Webspace bei T-Homepage keine automatische Indexerstellung für Ordner ohne HTML Inhalte durchführt.
Musste somit dieses also selber für jeden Ordner ein "index.html" erstellen.
Das ergebnis siehe hier: http://www.mk-soft.homepage.t-online.de/
Einfach den Basisordner auswählen

Code: Alles auswählen
;-TOP
; Kommentar : Automatische Index.html Erstellung
; Author : mk-soft
; Second Author :
; Datei : CreateHtmlIndex.pb
; Version : 1.01
; Erstellt : 16.03.2008
; Geändert :
;
; Compilermode :
;
; ***************************************************************************************
Structure udtList
Name.s
Size.l
Date.l
EndStructure
; ***************************************************************************************
Global NewList DirList.s()
; ***************************************************************************************
Procedure.l DirectoryListRecursive(ID.l, Directory.s)
Protected Name.s
If ExamineDirectory(ID, Directory, "*.*")
While NextDirectoryEntry(ID)
If DirectoryEntryType(ID) = #PB_DirectoryEntry_Directory
Name = DirectoryEntryName(ID)
If Name <> ".." And Name <> "."
AddElement(DirList())
DirList() = Directory + Name + "\"
DirectoryListRecursive(ID+1, Directory+Name+"\")
EndIf
EndIf
Wend
FinishDirectory(ID)
EndIf
ProcedureReturn CountList(DirList())
EndProcedure
; ***************************************************************************************
Procedure.l DirectoryList(ID.l, Directory.s, List.udtList())
Protected Name.s, Size.l, Datum.l
If ExamineDirectory(ID, Directory, "*.*")
While NextDirectoryEntry(ID)
If DirectoryEntryType(ID) = #PB_DirectoryEntry_Directory
Name = DirectoryEntryName(ID)
If Name <> ".." And Name <> "."
AddElement(List())
List()\Name = Directory + Name
List()\Size = DirectoryEntrySize(ID)
List()\Date = DirectoryEntryDate(ID, #PB_Date_Modified)
EndIf
Else
Name = DirectoryEntryName(ID)
If Name <> "index.html"
AddElement(List())
List()\Name = Directory + Name
List()\Size = DirectoryEntrySize(ID)
List()\Date = DirectoryEntryDate(ID, #PB_Date_Modified)
EndIf
EndIf
Wend
FinishDirectory(ID)
EndIf
ProcedureReturn CountList(DirList())
EndProcedure
; ***************************************************************************************
Procedure CreateIndex(Path.s, BasePath.s)
NewList Index.s()
NewList Entry.udtList()
Protected href.s, base.s, name.s, size.s, datum.s, len.l
Protected file.s
; Kopf
len = Len(BasePath)
base = Mid(path, len, 512)
AddElement(Index())
Index() = "<HTML>"
AddElement(Index())
Index() = "<PRE><H1>Index of " + base + "</H1>"
ReplaceString(Index(), "\", "/", 2)
AddElement(Index())
Index() = "<FONT color='green'><B> « </B></FONT><a href='" + base + "..'>Parent Directory</a>"
ReplaceString(Index(), "'", #DQUOTE$, 2)
ReplaceString(Index(), "\", "/", 2)
; Liste
AddElement(Index())
Index() = "<BR><HR>"
DirectoryList(0, Path, Entry())
ForEach Entry()
AddElement(Index())
base = Mid(Entry()\Name, len, 512)
href = base
name = LSet(GetFilePart(base), 32, " ")
size = RSet(Str(Entry()\Size), 20, " ")
datum = FormatDate("%yyyy.%mm.%dd %hh:%ii:%ss", Entry()\Date)
Index() = "<FONT color='wingdings'><B> ¤ </B></FONT><a href='" + href + "'>" + name + "</a>" + size + " " + datum
ReplaceString(Index(), "'", #DQUOTE$, 2)
ReplaceString(Index(), "\", "/", 2)
Next
; Fuss
AddElement(Index())
Index() = "<BR><HR>"
AddElement(Index())
Index() = "</PRE></HTML>"
file = Path + "index.html"
If CreateFile(0, file)
ForEach Index()
WriteStringN(0, Index())
Next
CloseFile(0)
Else
EndIf
EndProcedure
; ***************************************************************************************
Procedure Main()
Protected Home.s, count.l
Home = PathRequester("Auswahl Homepage Verzeichnis", "")
If Home = ""
ProcedureReturn 0
EndIf
If Right(Home,1) <> "\"
Home + "\"
EndIf
count = DirectoryListRecursive(0, Home)
ForEach DirList()
CreateIndex(Dirlist(), Home)
Next
MessageRequester("Ready.", "Count of Index: " + Str(count))
EndProcedure
; ***************************************************************************************
; ***************************************************************************************
Main()
End

Edit: Ein <BR> entfernt.