|
|
|
|
![]() ![]() |
Apr 4 2005, 10:37 AM
Post
#1
|
|
|
Newbie ![]() Group: Members Posts: 1 Joined: 4-April 05 From: Iceland Member No.: 5,244 |
Need help to include this, i am trying to include this folder
http://www.koddinn.com/shoutbox_v1.2/shoutbox.php to this http://www.koddinn.com/test.php the folder include many files http://www.koddinn.com/shoutbox_v1.2 i want to include all the files in a certain directory. do i use reddir for this, how can i do this CODE echo "<PRE>"; $handle = opendir("."); while($file = readdir($handle)) { if(is_dir($file)) echo "$file/\n"; else echo "$file\n"; } closedir($handle); echo "</PRE>"; do i have to loop to include each file. ?? |
|
|
|
Apr 5 2005, 01:25 AM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 463 Joined: 8-November 04 Member No.: 2,186 |
I don't think you can include a whole folder. I think you can work it out so that your directory list is included like a config file that gets updated when your directory is changed(when files are deleted or created. I would love to help but don't have time right now. If you look on php.net you might be able to something there that might help you out.
round |
|
|
|
Apr 5 2005, 03:17 AM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 874 Joined: 30-July 04 Member No.: 246 |
I would recommend going with round's suggestion. A folder may contain other files that you do not wish to include, such as, for example, .htaccess. Having a configuration file which explicitly specifies which files to include might take a little longer to put together, but would be a much better idea overall.
|
|
|
|
Apr 5 2005, 03:33 AM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 773 Joined: 4-November 04 Member No.: 2,118 |
$dh = opendir("shoutbox_v1.2");
while ($temp=readdir($dh)) { if ($temp!="." && $temp!="..") { include($temp); }} this will include all files in your "shoutbox_v1.2" directory. IF you want to skip certain files, just add them in the IF condition. Right now, the if condition skips "." and ".." because those are not files. You also might want to add $temp!=".htaccess" as well... you can also exclude (or include) files using string functions like eregi and strstr. For example, if you only want to include .php files you only need 1 condition in the if statement. example: if (eregi("\.php",$temp)) will only include php files from the directory "shoutbox_v1.2" another example: if (eregi("\.php",$temp) || eregi("\.html",$temp)) will include all .php files and .html files anyway, modify the if condition to do what you want it to. |
|
|
|
Apr 5 2005, 03:36 AM
Post
#5
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 773 Joined: 4-November 04 Member No.: 2,118 |
no edit button...
you might have to add the directory in front of the $temp variable for your include statement. include ("shoutbox_v1.2/".$temp); this depends on where you call this script. IF it is within the shoutbox_v1.2 directory, you don't need it. If it is in the root (which your original post suggests), you will need it. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th October 2008 - 06:09 PM |