Hello,
I have been working with this php code for a few hours and... cannot get one or two things to work. I was hoping some PHP genius here could correct and output something I can use.
First of all, the directory thing does NOT work properly. When I select that directory it ONLY shows the files within that have extensions, NOT the directories. I ONLY want to show directories in my final. So I either need a regex that gets rid of the extensions, or I need something that loads the correct directory. I also need this to load TWO columns, one for pics and one for vids, when i place two seperate PHP codes inside of tables on my index.php, it shows the same output in both codes, this could be because of the missing 'closedir'. I did not include that because it don`t work right anyway.
The goal of this code is to create a directory system where all I have to do is upload a directory with a certain file name and the code automatically lists it. The date part also works well so that it appears that the site was updated on whatever date, based on the /last modification/ date of a folder or file.
Please if you make any contributions note where they need to be inserted into the existing code, I am new at this and really don`t fully understand the syntax yet.
If anyone needs any further info or otherwise please just ask, i`ll be watching this topic today.
Thanks!
The code:
<?php
define('MAX_FILES', 365);
$dp = opendir('/home/virtual/site16/fst/var/www/html/members/vids');
if ($dp) {
while( $item = readdir($dp) )
{
if ( $item hahahaha '.' || $item hahahaha '..' ) // replace the hahahaah that GFY creates with :
continue;
if ($mtime = @filemtime($item))
$all_files[$mtime][] = $item;
}
krsort($all_files);
foreach($all_files as $time=>$files)
{
for($i=0; $i < count($files); $i++)
{
$file = $files[$i];
$date = date("m.d.y", $time);
if (++$count > MAX_FILES)
break;
else
printf('<font face="Trebuchet MS"
size=2 color=#000000> <font face=tahoma
size=1>[%s]</font> <a href="%s"
class=hyperlink>%s</a></font><br>',
$date, $file, $file); // Where it says %s is where the name of the output file resides.
}
}
closedir($dp);
} else {
print("Could not open directory.\n");
}
?>