Jump to content


Photo

directory listing problem


  • Please log in to reply
5 replies to this topic

#1 sheepz

sheepz
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 March 2006 - 07:00 AM

i want to have a script that will work just like "directory browsing" i found this script on this site, i'm not sure where i found it, but it does work. the problem that i do have is when i change the $path = "/scripts/"; the folders with in that folder wont open. it gives me a "page cannot be found" but if i use $path = "./"; it works fine, the folders within that folder would open just like "directory browsing" the reason i need this to be /scripts/ is because i dont want the users to be able to access the wwwroot folder and it's contents. is there something wrong with the script that when i change the $path it wont open subfolders? if i use the "./" root folder it opens subfolders fine.


<html>
<head>
<title> Directory List</title>
</head>
<body>
<h2> Directory listing </h2>


<?
$path = "./";
$dir = opendir($path);
echo "<ul>\n";

while($file = readdir($dir))
    {
    if ($file != "." && $file != ".." && $file != ".php")
        {
        echo "<li><a href = \"" .$file. "\" target = \" _blank\"> ".$file." </a></li> \n";
        }
    }
echo "</ul>\n";
closedir($dir);
?>
</body>
</html>


#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 30 March 2006 - 09:40 AM

try using scripts/ instead of /scripts/ because /scripts/ points to the root of the hdd then /scripts which im guessing your looking to search a directory within the foleder your already in which is called scripts?
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 sheepz

sheepz
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 March 2006 - 04:20 PM

[!--quoteo(post=359961:date=Mar 30 2006, 01:40 AM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 30 2006, 01:40 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
try using scripts/ instead of /scripts/ because /scripts/ points to the root of the hdd then /scripts which im guessing your looking to search a directory within the foleder your already in which is called scripts?
[/quote]


the folder i want people to access is "c:\inetpub\wwwroot\scripts" when i put the folder path to "./" it will get me to the root directory of wwwRoot, and all the subfolders open correctly. When i put the folder path to "/wwwroot/scripts/" all the files work fine but the subfolder do not open correctly. i tried putting the path to "scripts/" but still no luck, when i click on the subfolders i get a "page cannot be displayed.

thanks for the reply! =)

#4 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 30 March 2006 - 04:37 PM

<html>
<head>
<title> Directory List</title>
</head>
<body>
<h2> Directory listing </h2>


<?
$path = "../mail/";
$dir = opendir($path);
echo "<ul>\n";

while($file = readdir($dir))
{
if ($file != "." && $file != ".." && $file != ".php")
{
echo "<li><a href = \"" .$path.$file. "\" target = \" _blank\"> ".$file." </a></li> \n";
}
}
echo "</ul>\n";
closedir($dir);
?>
</body>
</html>


Use that i added $path before the filename :) You could check to see if it's a dir and if so then change the link to ?path=$file and then it can search inside other folders instead of treating them as normal files :)
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#5 sheepz

sheepz
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 30 March 2006 - 11:54 PM

you are awsome, it works exactly the way i want it to! thx a bunch!

#6 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 20 May 2006 - 06:39 AM

[!--quoteo(post=360205:date=Mar 31 2006, 07:54 AM:name=sheepz)--][div class=\'quotetop\']QUOTE(sheepz @ Mar 31 2006, 07:54 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
you are awsome, it works exactly the way i want it to! thx a bunch!
[/quote]

Is there a way to remove the file extension when it's displayed?

Maybe using [!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]basename()[!--colorc--][/span][!--/colorc--]?

Thanks!

Joe

[url=http://darkswordsguide.com][/url]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users