Hey, I'm trying to make a function that returns an array of all the files in a directory that end in ".qwiki" The directory I want to search is <!-- m --><a class="postlink" href="http://edandben.snipenut.com/data/">http://edandben.snipenut.com/data/</a><!-- m --> and the php file that will be searching is in <!-- m --><a class="postlink" href="http://edandben.snipenut.com/">http://edandben.snipenut.com/</a><!-- m --> When I try to search /data/ it gives me a whole mess of errors. Could someone help me fix the errors?
what I have so far:function QWListFiles()
{
$dirpath = "/data";
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh))) {
if (!is_dir("$dirpath/$file")) {
$dirlist[] = $file;
};
};
closedir($dh);
return $dirlist;
}the errors:Warning: opendir(<!-- m --><a class="postlink" href="http://edandben.snipenut.com/data/">http://edandben.snipenut.com/data/</a><!-- m -->): failed to open dir: not implemented in /home/edandben/public_html/_wikiLib.php on line 372
Warning: readdir(): supplied argument is not a valid Directory resource in /home/edandben/public_html/_wikiLib.php on line 373
Warning: closedir(): supplied argument is not a valid Directory resource in /home/edandben/public_html/_wikiLib.php on line 378 TIAfrom the <!-- w --><a class="postlink" href="http://www.php.net">www.php.net</a><!-- w --> (<!-- m --><a class="postlink" href="http://uk2.php.net/manual/en/function.opendir.php">http://uk2.php.net/manual/en/function.opendir.php</a><!-- m -->):
As of PHP 4.3.0 path can also be any URL which supports directory listing, however only the file:// URL wrapper supports this in PHP 4.3. As of PHP 5.0.0, support for the ftp:// URL wrapper is included as well.
it looks like you can't open the directory using the http:// URL wrapper...
you need to use the local path (c:\blah\site\data\)
this can be found in the $_SERVER['PATH_TRANSLATED'] parameter...huh? I just use a relative folder "data/". it can open the folder just fine, its just not outputting what I want and I have no idea why.um... it can't open the folder:
Warning: opendir(<!-- m --><a class="postlink" href="http://edandben.snipenut.com/data/">http://edandben.snipenut.com/data/</a><!-- m -->): failed to open dir: not implemented in /home/edandben/public_html/_wikiLib.php on line 372
That is what that error message means.
the other messages are follow-on errors - the directory isn't open, so you can't read from it or close it.oh, i'm sorry I thought this was a different post
I fixed the data thing a while back, all I needed to do was change /data into data/I'll just put that post in here because they are related, you can delete the old one if you want...
OK, I'll let you know what I'm trying to do:
1) I want to search the directory data/ for all the files ending in ".qwiki".
2) Then I want to make an array of all these file names without the ".qwiki".
3) Next I want to search all the files for strings matching either of 2 patterns (via pattern syntax) and put all the matches in an array.
4) then I want to get rid of all, if any, underscores in the values of the array.
5) Then I want to get rid of all repeating values, probably with array_unique.
6) lastly, I want to make an array of the differences between the file list array and the pattern match array.
so yeah, this is what I have so far:<?php
$pageList = array();
$links2 = array();
foreach(QWListFiles() as $list) {
if( strpos($list , ".qwiki" ) && !strpos($list, "QwikiWiki" ) ) {
$location = "data/" . $list;
$page1 = substr( $list, 0, strlen( $list ) - 6 );
$pageList[] = $page1;
preg_match_all( '/(^|[^\w_]+)([A-Z]+[a-z\d]+[A-Z]+\w*)($|[^\w_]+)/', QWGetFileContents( $location ), $out1 );
preg_match_all( '/(^|\W+)_([\w-]+(?:_[\w-]+)*)_($|\W+)/', QWGetFileContents( $location ), $out2 );
$links = array_merge($out1, $out2);
$links2[] = $links;
}
}
$finish = array_diff(array_unique($links2), $pageList);
foreach($finish as $fini) {
foreach($fini as $fin) {
foreach($fin as $fi) {
echo $fi . "<br>";
}
}
}
?> basically, I just want to get this code to do what I said I wanted. it's probably really messy because i'm a supern00b at php, so if you could help me clean it up a bit that 'd be appreciated.
thanks!edit: arggg. double posted, I definately need to close some of these windows...
what I have so far:function QWListFiles()
{
$dirpath = "/data";
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh))) {
if (!is_dir("$dirpath/$file")) {
$dirlist[] = $file;
};
};
closedir($dh);
return $dirlist;
}the errors:Warning: opendir(<!-- m --><a class="postlink" href="http://edandben.snipenut.com/data/">http://edandben.snipenut.com/data/</a><!-- m -->): failed to open dir: not implemented in /home/edandben/public_html/_wikiLib.php on line 372
Warning: readdir(): supplied argument is not a valid Directory resource in /home/edandben/public_html/_wikiLib.php on line 373
Warning: closedir(): supplied argument is not a valid Directory resource in /home/edandben/public_html/_wikiLib.php on line 378 TIAfrom the <!-- w --><a class="postlink" href="http://www.php.net">www.php.net</a><!-- w --> (<!-- m --><a class="postlink" href="http://uk2.php.net/manual/en/function.opendir.php">http://uk2.php.net/manual/en/function.opendir.php</a><!-- m -->):
As of PHP 4.3.0 path can also be any URL which supports directory listing, however only the file:// URL wrapper supports this in PHP 4.3. As of PHP 5.0.0, support for the ftp:// URL wrapper is included as well.
it looks like you can't open the directory using the http:// URL wrapper...
you need to use the local path (c:\blah\site\data\)
this can be found in the $_SERVER['PATH_TRANSLATED'] parameter...huh? I just use a relative folder "data/". it can open the folder just fine, its just not outputting what I want and I have no idea why.um... it can't open the folder:
Warning: opendir(<!-- m --><a class="postlink" href="http://edandben.snipenut.com/data/">http://edandben.snipenut.com/data/</a><!-- m -->): failed to open dir: not implemented in /home/edandben/public_html/_wikiLib.php on line 372
That is what that error message means.
the other messages are follow-on errors - the directory isn't open, so you can't read from it or close it.oh, i'm sorry I thought this was a different post
I fixed the data thing a while back, all I needed to do was change /data into data/I'll just put that post in here because they are related, you can delete the old one if you want...
OK, I'll let you know what I'm trying to do:
1) I want to search the directory data/ for all the files ending in ".qwiki".
2) Then I want to make an array of all these file names without the ".qwiki".
3) Next I want to search all the files for strings matching either of 2 patterns (via pattern syntax) and put all the matches in an array.
4) then I want to get rid of all, if any, underscores in the values of the array.
5) Then I want to get rid of all repeating values, probably with array_unique.
6) lastly, I want to make an array of the differences between the file list array and the pattern match array.
so yeah, this is what I have so far:<?php
$pageList = array();
$links2 = array();
foreach(QWListFiles() as $list) {
if( strpos($list , ".qwiki" ) && !strpos($list, "QwikiWiki" ) ) {
$location = "data/" . $list;
$page1 = substr( $list, 0, strlen( $list ) - 6 );
$pageList[] = $page1;
preg_match_all( '/(^|[^\w_]+)([A-Z]+[a-z\d]+[A-Z]+\w*)($|[^\w_]+)/', QWGetFileContents( $location ), $out1 );
preg_match_all( '/(^|\W+)_([\w-]+(?:_[\w-]+)*)_($|\W+)/', QWGetFileContents( $location ), $out2 );
$links = array_merge($out1, $out2);
$links2[] = $links;
}
}
$finish = array_diff(array_unique($links2), $pageList);
foreach($finish as $fini) {
foreach($fini as $fin) {
foreach($fin as $fi) {
echo $fi . "<br>";
}
}
}
?> basically, I just want to get this code to do what I said I wanted. it's probably really messy because i'm a supern00b at php, so if you could help me clean it up a bit that 'd be appreciated.
thanks!edit: arggg. double posted, I definately need to close some of these windows...