Jump to content

Recommended Posts

Hello, I am trying to get the list directory code to show some root directories, however, i am having trouble in doing so, below is my code:
[code]
<?php
$namearray = array("forum"); // File names you want to exclude
$extarray = array("xml","jpg","php","css","bmp","png","html");  //extension you want to exclude
$files = array();
if ($handle = opendir("test/")) {//this is where the directory is optimized, and i want it to show a root directory called test.
  while (false !== ($file = readdir($handle))) {
    if($file != "." && $file != ".."){
      if (filetype($file) == "file" || filetype($file) == "dir"){
      $filearray = explode(".", $file);
      $files[$filearray[0]] = $filearray[1];
      }
    }
  }
closedir($handle);
}

foreach($files as $name => $ext){
 if(in_array($name, $namearray, false) || in_array($ext, $extarray, false)){
 } else {
foreach(@file("$name.txt") as $v){list($topic,$category,$number,$datetime,$name,$username,$message) = explode("#",$v);}
 $counteraa = file_get_contents("topic$number-counter.php");
 $repliesaa = file_get_contents("topic$number-replies.php");
 $lastposteraa = file_get_contents("topic$number-lastposter.php");
 echo "<tr><td valign=center align=center>$number</td><td valign=center align=center><img src=\"\" height=20 width=20></td><td align=left valign=center><a href=\"../viewtopic.php?id=homework/topic$number\"><font color=\"#A0522D\"><b>$topic</b></font></a></td><td align=center>$counteraa</td><td align=center>$repliesaa</td><td align=center>$lastposteraa</td></tr>"."\n";}
}
?>
[/code]
however, it just wont link to the root directory, can anyone suggest me what to do please?
Thanks
okay, this is how the folder looks like:
/listdirectory.php
/test/file.txt(these are what i wish to appear)
therefore I want to point the "listdirectory.php" to the test directory in order to list all the files in the test directory. However, I am having trouble doing so.
Do you understand it better?
can anyone help me please? what i want is just pointing the listdirectory php to a different directory, if you dont understand you can reply to this, i will make my point as understandable as possible, but please do response as i am in need of help
Thankyou
OK, the chances are you need to know the full path, that's probably the only issue.  The likelihood of your [color=green]test[/color] directory being in the root are extremely minimal!

Put this file in the [color=green]test[/color] directory, call it varinfo.php and run it...

[code]<?php
phpinfo(32);
?>[/code]

Look for the value called [b]_SERVER["SCRIPT_FILENAME"][/b] this will give you the full path to the varinfo.php

It should look something like this: [color=brown]/home/domains/yourdomain/test/varinfo.php[/color]

Chop off the file name and then place the path to the file into this line in your code, so change this...
[code=php:0]if ($handle = opendir("test/")[/code]
to this...
[code=php:0]if ($handle = opendir("/home/domains/yourdomain/test/")[/code]

Regards
Huggie

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.