Jump to content

[SOLVED] File Manager


mattal999

Recommended Posts

Hi,

 

I need to make a file manager for a certain users folder, which is in a directory tree as follows:

 

MAIN > INDEX.PHP

           SITES > ALL USERS (one folder per user)

 

I have this code so far too, which works a treat for showing all the files and folders:

 

<?php

$hits = 0;
$projectsListIgnore = array ('.','..');

if(isset($_GET['dir'])) {
$dir = "Sites/" . $_COOKIE['UnaMe'] . "/" . $_GET['dir'];
} else {
$dir = "Sites/" . $_COOKIE['UnaMe'] . "/";
}
$dir2 = str_replace("Sites/" . $_COOKIE['UnaMe'] . "/", "", $dir);
$handle=opendir($dir);
while ($file = readdir($handle)) 
{
if (is_dir($dir . $file) && !in_array($file,$projectsListIgnore)) 
{
if ($file == "WYSIWYG") { $hits = $hits + 1; }
if ($file == "Sites") { $hits = $hits + 1; }	
if ($file == "CSS") { $hits = $hits + 1; }
if ($file == "Images") { $hits = $hits + 1; }
$projectContents .= '<li><img src="Images/folder.png" border="0"> <a href="list.php?dir='.$dir2 . $file.'/">'.$file.'</a></li>
';
}
}
closedir($handle);
$handle=opendir($dir);
while ($file = readdir($handle)) 
{
if (is_dir($dir . $file) && in_array($file,$projectsListIgnore)) 
{		
$upContents .= '<li><img src="Images/up.png" border="0"> <a href="list.php?dir='.$dir2 . $file.'/">'.$file.'</a></li>
';
}
}
closedir($handle);
$handle2=opendir($dir);
while ($file = readdir($handle2)) 
{
if(!is_dir($dir . $file)) 
{		
if ($file == "u03iso0eop.txt") { $hits = $hits + 1; }
if ($file == "edit.php") { $hits = $hits + 1; }
if ($file == "list.php") { $hits = $hits + 1; }
if ($file == "editsave.php") { $hits = $hits + 1; }
$filesContents .= '<li><img src="Images/edit.png" border="0"> <a href="edit.php?file='.$dir . $file.'&last='.$dir.'&filename='.$file.'">'.$file.'</a> - <a href="'.$dir . $file . '">View</a></li>
';
}
}
closedir($handle2);

if($hits >= "8") { header("Location: list.php"); }

?>

 

I want to disallow access to the "sites" folder and less, so the user can only access:

 

MAIN(DISALLOW)> INDEX.PHP(DISALLOW)

                          SITES(DISALLOW) > ALL USERS(JUST THEIR FOLDER, NO LESS) (one folder per user)

 

I tried checking for 8 files and folders in the MAIN folder, which works a treat, but the sites folder is a different matter, the folders are made for every user when they register.

 

Thank you and i hope you can understand my question

Link to comment
https://forums.phpfreaks.com/topic/107005-solved-file-manager/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.