Seite 1 von 1

Automatische Index.html Erstellung für Ordner (Webspace)

Verfasst: 16.03.2008 20:22
von mk-soft
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 :allright:

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> &laquo </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> &curren   </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
FF :wink:

Edit: Ein <BR> entfernt.

Re: Automatische Index.html Erstellung für Ordner (Webspace)

Verfasst: 16.03.2008 22:18
von PMTheQuick
mk-soft hat geschrieben:blablabla laber laber laber schwafel schwafel schwafel blablabla
Hm nicht schlecht. Nur für mich unnützlich, ich habe sowieso schon Directory Listing, und dass habe ich auch SELBER EXTRA deaktiviert, aus Sicherheitsgründen :D Und sonst: PHP wär fast noch ne bessere Lösung ;)

Gruss
PMTheQuick ^^

Re: Automatische Index.html Erstellung für Ordner (Webspace)

Verfasst: 16.03.2008 22:57
von mk-soft
PMTheQuick hat geschrieben:
mk-soft hat geschrieben:blablabla laber laber laber schwafel schwafel schwafel blablabla
Hm nicht schlecht. Nur für mich unnützlich, ich habe sowieso schon Directory Listing, und dass habe ich auch SELBER EXTRA deaktiviert, aus Sicherheitsgründen :D Und sonst: PHP wär fast noch ne bessere Lösung ;)

Gruss
PMTheQuick ^^
Erst mal richtig lesen bevor man mit irgendwelchen aussagen mit Sicherheit und PHP anfäng

Die Standard Homepage für nothing unterstützt das alles nicht.

Verfasst: 17.03.2008 00:39
von hardfalcon
Auch wenns halb OT is: Hast du schonmal versucht, DirectoryListing über die .htaccess explizit zu aktivieren?