Sorry, but I couldn't think of a Subject that would describe it....
I've got a nice little File Manager set up. (I think I pulled it off of here, actually.) I've changed it a little so you can only view it if you're "logged in".... in other words, if the site's cookie isn't set to "guest". That all works fine, and the FM works great.
What I'm trying to do is force the FM to only list files that start with the username set in the cookie.
Here's the snip that I know needs to be changed... I'm just not sure how to go about it.
$dir = opendir("$currentdir");
$dirarray = array();
$filearray = array();
$dircount = 0;
$filecount = 0;
while ($file_name = readdir($dir)) //Directory Read
{
if(($file_name != ".") && ($file_name != "..") && ($file_name != "index.php"))
{
if(is_dir($file_name))
{
$dirarray[$dircount] = $file_name;
$dircount++;
}
else
{
$filearray[$filecount] = $file_name;
$filecount++;
}
}
}
sort($dirarray);
reset($dirarray);
sort($filearray);
reset($filearray);
$msg = "<p><b>Files in: $currentdir</b></p>";
$msg .= "<a href=\"$PHP_SELF?\">[Click to Refresh]</a>";
$msg .= "<table cellspacing=\"4\" cellpadding\"6\">";
for($a = 0; $a < $dircount; $a++) //Output Dir Listing
{
$msg .= "<tr><td>—</td><td><a href=\"$dirarray[$a]\">$dirarray[$a]</a></td><td><a href=\"$PHP_SELF?function=deldir&dir=$dirarray[$a]\">Delete</a></td></tr>";
}
$msg .= "</table><table cellspacing=\"4\" cellpadding\"6\">";
$msg .= "<tr><td align=\"center\"><b>Filename</b></td><td align=\"center\"><b>Size</b></td><td align=\"center\"><b>Created</b></td><td colspan=\"4\" align=\"center\"><b>Functions</b></td></tr>";
for($b = 0; $b < $filecount; $b++) //Output File Listing
{
$currentfile = $currentdir . "/" . $filearray[$b];
$del = $PHP_SELF . "?function=delfile&file=" . $filearray[$b]; //Delete UI
$size = ByteConverter((double) filesize($currentfile)); //Filesize UI
$time = strftime ("%b %d %Y %H:%M:%S", filectime($currentfile));
$rename = "<a href=\"$PHP_SELF?function=prompt&set=ren&oldname=$filearray[$b]\">Rename</a>";
$copy = "<a href =\"$PHP_SELF?function=prompt&set=copy&oldname=$filearray[$b]\">Copy</a>";
$move = "<a href =\"$PHP_SELF?function=prompt&set=move&oldname=$filearray[$b]\">Move</a>";
$msg .= "<tr><td><a href=\"$filearray[$b]\">$filearray[$b]</a></td><td align=\"right\">$size</td><td align=\"right\">$time</td><td>$rename</td><td>$copy</td><td>$move</td><td><a href=\"$del\">Delete</a></td></tr>";
}
closedir($dir);
clearstatcache();
A little confusing, I know. Maybe somewhere in the "$filearray[$filecount] = $file_name;" line?
If you need more info, just say so.
EDIT: I tried chaging this line:
if(($file_name != ".") && ($file_name != "..") && ($file_name != "index.php") && stristr("$user", $file_name))
....by adding the stristr..... ($user being the username from the cookie)... it doesn't cause errors, but it's not showing me any files at all.