Directory List in Xampp home page

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Directory List in Xampp home page

Postby Caique » 14. December 2010 17:41

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;

?>
Caique
 
Posts: 1
Joined: 14. December 2010 17:27

Re: Directory List in Xampp home page

Postby jzigbe » 15. December 2010 19:31

:D
Thanks! I was looking for this!
jzigbe
 
Posts: 2
Joined: 15. December 2010 19:15

Re: Directory List in Xampp home page

Postby chocolateman » 28. August 2013 13:30

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
chocolateman
 
Posts: 1
Joined: 28. August 2013 13:16
XAMPP Version: 5.5.19
Operating System: Windows 7 64bit

Re: Directory List in Xampp home page

Postby Altrea » 28. August 2013 14:12

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
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6946
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 66 guests