ted_chou12 Posted December 14, 2006 Share Posted December 14, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/30619-problem-with-listing-root-directories-un~solved/ Share on other sites More sharing options...
ted_chou12 Posted December 14, 2006 Author Share Posted December 14, 2006 sorry for posting it twice... some error with the browser.. Quote Link to comment https://forums.phpfreaks.com/topic/30619-problem-with-listing-root-directories-un~solved/#findComment-141007 Share on other sites More sharing options...
trq Posted December 14, 2006 Share Posted December 14, 2006 Sorry, you'll need to be alot more speecific with your question. For starters, theres only 1 such thing as a root directory. Quote Link to comment https://forums.phpfreaks.com/topic/30619-problem-with-listing-root-directories-un~solved/#findComment-141020 Share on other sites More sharing options...
ted_chou12 Posted December 14, 2006 Author Share Posted December 14, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/30619-problem-with-listing-root-directories-un~solved/#findComment-141025 Share on other sites More sharing options...
ted_chou12 Posted December 14, 2006 Author Share Posted December 14, 2006 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 helpThankyou Quote Link to comment https://forums.phpfreaks.com/topic/30619-problem-with-listing-root-directories-un~solved/#findComment-141099 Share on other sites More sharing options...
HuggieBear Posted December 14, 2006 Share Posted December 14, 2006 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]<?phpphpinfo(32);?>[/code]Look for the value called [b]_SERVER["SCRIPT_FILENAME"][/b] this will give you the full path to the varinfo.phpIt 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] RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/30619-problem-with-listing-root-directories-un~solved/#findComment-141110 Share on other sites More sharing options...
ted_chou12 Posted December 14, 2006 Author Share Posted December 14, 2006 thankyou, i will have a try on it :) Quote Link to comment https://forums.phpfreaks.com/topic/30619-problem-with-listing-root-directories-un~solved/#findComment-141120 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.