Page 1 of 1

Directory List in Xampp home page

PostPosted: 14. December 2010 17:41
by Caique
Hi all,

I wrote this code to make my life more simple. I modify start.php file that is placed in "your instalation dir"\htdocs\xampp\start.php. This code put in the xampp homepage a list of your projects that are located in htdocs folder.

Download the images that i am using at my host: http://www.ecanti.com.br/files/

Enjoy!

bofore "</body></html>":

Code: Select all
<?php
echo "<br>";
echo "<h1>My Projects:</h1>";
      
$folder = "E:/xampp/htdocs";// path of htdocs

//Directory list
if(!$open = @opendir($folder))
   die('O diretório não é valido!');

while(($namearq = readdir($open)) !== false) {

   if($namearq == "." or $namearq == "..") continue;
   
   $dir = "E:/xampp/htdocs/".$namearq;
   
   if(is_dir($dir)){
      $list_dir .= "<img src=\"http://www.ecanti.com.br/files/folder.png\" width=\"18\" height=\"15\" alt=\"\"><a href=\"/$namearq\" target=\"top\">$namearq<br></a>\n";
   } else {
      $list_file .= "<img src=\"http://www.ecanti.com.br/files/file.png\" width=\"18\" height=\"16\" alt=\"\"><a href=\"$namearq\" target=\"top\">$namearq<br></a>\n";
   }
}
echo $list_dir;
echo $list_file;

?>

Re: Directory List in Xampp home page

PostPosted: 15. December 2010 19:31
by jzigbe
:D
Thanks! I was looking for this!

Re: Directory List in Xampp home page

PostPosted: 28. August 2013 13:30
by chocolateman
Hi

This looks brilliant. I have just moved from using Wampserver to Xampp and not having your projects listed is a bit of a pain.

I'm using Xampp v1.8.3 and unfortunately, this does not work correctly. I don't suppose that anybody has managed to modify it to work with my version? If so, I would love to find out how you did it or if anybody had any similar ideas.

To be specific, it does work but there seems to be some sort of issue:
Notice: Undefined variable: list_file in C:\xampp\htdocs\xampp\start.php on line 47
Notice: Undefined variable: list_dir in C:\xampp\htdocs\xampp\start.php on line 45

Many thanks. :D

Re: Directory List in Xampp home page

PostPosted: 28. August 2013 14:12
by Altrea
Hi,

that should get rid of the messages.

Code: Select all
<?php
echo "<br>";
echo "<h1>My Projects:</h1>";
     
$folder = "E:/xampp/htdocs";// path of htdocs

//Directory list
if(!$open = @opendir($folder))
   die('O diretório não é valido!');

$list_dir = '';
$list_file = '';

while(($namearq = readdir($open)) !== false) {

   if($namearq == "." or $namearq == "..") continue;
   
   $dir = "E:/xampp/htdocs/".$namearq;
   
   if(is_dir($dir)){
      $list_dir .= "<img src=\"http://www.ecanti.com.br/files/folder.png\" width=\"18\" height=\"15\" alt=\"\"><a href=\"/$namearq\" target=\"top\">$namearq<br></a>\n";
   } else {
      $list_file .= "<img src=\"http://www.ecanti.com.br/files/file.png\" width=\"18\" height=\"16\" alt=\"\"><a href=\"$namearq\" target=\"top\">$namearq<br></a>\n";
   }
}
echo $list_dir;
echo $list_file;

?>


but there are for sure cleaner methods to list a directory with php.

best wishes,
Altrea