1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development How do I change the appearance of an Apache directory?

Discussion in 'Software' started by Lazlow, 12 Nov 2006.

  1. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    As the title says (but I may have worded it wrong), I want to be able to change the appearance of a web directory, for example this.

    Is there a way of calling it within a webpage and applying formatting to it? As that seems to be the most logical way. I could write an index.html page for the directory and manually input all of the links to the files, but I want it to update itself, as and when files are deleted/added. Does this make sense? Any ideas?
     
  2. DougEdey

    DougEdey I pwn all your storage

    Joined:
    5 Jul 2005
    Posts:
    13,933
    Likes Received:
    33
    I have a very basic PHP page which lists all the files in a directory (non recursive) and has small image previews. I can send it to you if you want.

    I'm working on a way to make it 403 but its not working right.
     
  3. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    If you could Doug, I would appreciate it. It'll be to simply display links to .pdf files from a directory. [matt at slickhouse dot com]
     
    Last edited: 12 Nov 2006
  4. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    I'm getting the following PHP error:
    Code:
    Fatal error: Using $this when not in object context in /.../example/index.php on line 10
    with line 10 being
    PHP:
    $this->dir ".";
    Any ideas? I feel like an idiot at times...
     
  5. DougEdey

    DougEdey I pwn all your storage

    Joined:
    5 Jul 2005
    Posts:
    13,933
    Likes Received:
    33
  6. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    That gives me a blank page.
     
  7. simon w

    simon w What's a Dremel?

    Joined:
    3 Nov 2003
    Posts:
    1,302
    Likes Received:
    0
    If only suppressing fatal errors made them go away :D

    @ Lazlow - Search for 'icons' in your httpd.conf/apache.conf. I think directtory contains the icons you see. Not sure about a custom index.html and I don't have an apache install available at the mo to check.
     
  8. Lazlow

    Lazlow I have a dremel.

    Joined:
    8 Aug 2003
    Posts:
    1,464
    Likes Received:
    0
    I ended up with the following:
    PHP:
    <?php
    if ($handle opendir('files/')) {
       while (
    false !== ($file readdir($handle))) {
           if (
    $file != "." && $file != "..") {
                  echo 
    '<span class="links"><p><a href="http://test.slickhouse.com/newsletter/files/'.$file.'">'.substr($dir,strpos($dir,"files/")+1).$file."</a></p></span>";
           }
       }
       
    closedir($handle);
    }
    ?>
    It's messy, but uses the opendir() function and works well for what I needed.
     

Share This Page