Page 1 of 1

Filelist

Posted: Wed Aug 27, 2008 10:39 am
by CIMO
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Code: Select all

<?
$cartella="prova/";
 
chdir("./$cartella");
 
if(!($dp = opendir("./")))
    die("Non riesco a esplorare il contenuto");
 
while($file = readdir($dp))
{
    if(is_file($file))
        $lista[] = $file;
}
if(!($dp = opendir("./")))
    die("Non riesco a esplorare il contenuto");
while($file = readdir($dp))
{
    if(!is_file($file))
    $lista[] = $file;
}
/*if(!($dp = opendir("./")))
    die("Non riesco a esplorare il contenuto");
while($file = readdir($dp))
{
    if(!is_file($file))
    $lista[] = $file;
}
*/
sort($lista);
?>
<table border="1">
    <tr>
        <td>
            <?
            echo "Tipo file: ";
            ?>
        </td>
        <td>
            <?
            echo "Dimensione file KB: ";
            ?>
        </td>
        <td>
            <?
            echo "Nome: ";
            ?>
        </td>
        <td>
            <?
            echo "Data: ";
            ?>
        </td>
    </tr>
    <tr>
        <td>
            <?
            foreach($lista as $index => $nome)
            {
                echo "<div align=center>".filetype($nome)."</div>";
            }
            ?>
        </td>
        <td>
            <?
            foreach($lista as $index => $nome)
            {
                echo "<div align=center>".filesize($nome)."</div>";
            }
            ?>
        </td>
        <td>
            <?
            foreach($lista as $index => $nome)
            {
            ?>
                <a href="<? echo $cartella; echo $nome; ?>"><? echo $nome; ?></a><br>
            <?
            }
            ?>
        </td>
        <td>
            <?
            foreach($lista as $index => $nome)
            {
                echo date("F d Y H:i:s.", filectime($nome))."<br>";
            }
            ?>
        </td>
    </tr>
</table>
Hi to everyone, this is the code i use to do my file list and i wish to visualize the table that i created instead of the basic one of the server. I wish to preserve my graphics, ho can i do? I have installed xampp on my pc and test the script in local. When i try to enter to lista.php the graphic visualized is the mine. Instead, if i create a new folder and enter in it, the visualization was the default that the server use, and not the one i created. This is my problem, if anyone can help i appreciate a lot^^Thanks to all


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Filelist

Posted: Wed Aug 27, 2008 11:58 am
by pickle
I think I understand, but let me explain it to see if I do understand.

Usually, when someone views a directory on your webserver, they are shown the default page that is just a list of files (assuming there is no index.html or index.php, or other default file available). You made a new file (lista.php) that you want to be shown instead.

The two ways you can do that (that I know of - there may be more) are:
  1. Rename your file "lista.php" to "index.php" and copy it into every directory you want it used in.
  2. Do some .htaccess file magic. I think there's a way you can set up your .htaccess file so that it automatically uses a file you specify to do a file list.

Re: Filelist

Posted: Thu Aug 28, 2008 4:27 am
by CIMO
thanks for everything. Can you explain how can i set the .htaccess so that automatically use my file to do the file list instead of putting "index.php" into every directory please?