aaronbdavis
07-02-2006, 10:02 AM
I am modifying my WAMP installation in order to use my home PC as a development machine. Normally, the index.php file provided by WAMP will look at all the subdirectories of the doc root and list them under the heading "Your Projects." I use most of the those sub-directories for general purpose development, not for a particular site. Therefore I created another sub-directory called sites, and modified index.php to list all of its
sub-directories under the heading "Sites." The code provided uses the is_dir function so that it only shows directories, not files. However, for some reason, this does not work for my projects folder. I thought it might be because the folder was named /sites/thebaseballwanderer.local (thinking that it might think local was the extension) but when I changed the name, it still did not work. Now, when I comments out the check if the file is a directory, the script works fine, but I am curious why it didn't work like it should.
FYI:
Here is my file structure:
C:/wamp/www
bin
pear
...
sites
thebaseballwanderer.local
...
Here is the relevent section of the original script provided by WAMP
<h1><?php echo $langues[$langue]['txt_projet']; ?></h1>
<div class="content">
<?php
// Affichage de la liste des dossiers non énumérés plus haut ( = projets ).
$list_ignore = array ('.','..','exemples','phpmyadmin','sqlitemanager', 'sites');
$handle=opendir(".");
$msg = $langues[$langue]['txt_no_projet'];
while ($file = readdir($handle)) {
if (is_dir($file) && !in_array($file,$list_ignore)) {
$msg = '';
echo '<a class="ditem" href="'.$file.'"><img src="dossier.gif" alt="image dossier" /> '.$file.'</a>';
}
}
closedir($handle);
echo $msg;
?>
</div>
Here is my modified version<h1>Sites</h1>
<div class="content">
<?php
$handle = opendir("sites");
while ($file = readdir($handle)) {
if (/*is_dir($file) && */!in_array($file, array('.','..'))) {
echo '<a class="ditem" href="http://'.preg_replace('/.com|.net|.org/','.local',$file).'"><img src="dossier.gif" alt="image dossier" /> '.$file.'</a>';
}
}
?>
</div>
sub-directories under the heading "Sites." The code provided uses the is_dir function so that it only shows directories, not files. However, for some reason, this does not work for my projects folder. I thought it might be because the folder was named /sites/thebaseballwanderer.local (thinking that it might think local was the extension) but when I changed the name, it still did not work. Now, when I comments out the check if the file is a directory, the script works fine, but I am curious why it didn't work like it should.
FYI:
Here is my file structure:
C:/wamp/www
bin
pear
...
sites
thebaseballwanderer.local
...
Here is the relevent section of the original script provided by WAMP
<h1><?php echo $langues[$langue]['txt_projet']; ?></h1>
<div class="content">
<?php
// Affichage de la liste des dossiers non énumérés plus haut ( = projets ).
$list_ignore = array ('.','..','exemples','phpmyadmin','sqlitemanager', 'sites');
$handle=opendir(".");
$msg = $langues[$langue]['txt_no_projet'];
while ($file = readdir($handle)) {
if (is_dir($file) && !in_array($file,$list_ignore)) {
$msg = '';
echo '<a class="ditem" href="'.$file.'"><img src="dossier.gif" alt="image dossier" /> '.$file.'</a>';
}
}
closedir($handle);
echo $msg;
?>
</div>
Here is my modified version<h1>Sites</h1>
<div class="content">
<?php
$handle = opendir("sites");
while ($file = readdir($handle)) {
if (/*is_dir($file) && */!in_array($file, array('.','..'))) {
echo '<a class="ditem" href="http://'.preg_replace('/.com|.net|.org/','.local',$file).'"><img src="dossier.gif" alt="image dossier" /> '.$file.'</a>';
}
}
?>
</div>