= $max_depth) { error_log("Reached max depth $max_depth in $dir_name."); return false; } $subdirectories = array(); $files = array(); // Is the directory $dir_name a readable directory? If it is, then follow it otherwise skip it with no error if (is_dir($dir_name) && is_readable($dir_name)) { $d = dir($dir_name); // This funny semantic is explained in http://us2.php.net/manual/en/class.dir.php we want to keep going // if we find a directory called false or FALSE or similar. while (false !== ($f = $d->read())) { // skip . and .. if (('.' == $f) || ('..' == $f)) { continue; } if (is_dir("$dir_name/$f")) { array_push($subdirectories,"$dir_name/$f"); } else { array_push($files,"$dir_name/$f"); }; }; $d->close(); foreach ($subdirectories as $subdirectory) { $files = array_merge($files,pc_process_dir($subdirectory,$max_depth,$depth+1)); } }; return $files; }; // this function extracts the titles, if any, from string s. function title_extractor($s) { // print ("In the title extractor, there are ".count($s)." lines
\n"); // print ("First test using a simple match: "); // $n = preg_match("@title\>(.*)$@is", $s, $matches ); // print_r(htmlspecialchars($matches[1])); $pattern = '@'.'\<'.'title'.'\>(.*)'.'\<'.'\/title\>@iXs'; // print ("
More debugging - the pattern is ". htmlspecialchars($pattern). '
' ); // trailing i means case insensitive. The trailing X means signal any useless \ as an error // instead of ignoring it. The trailing s means make . match any character including newline - // but that also means work over several lines if ( preg_match($pattern, $s, $matches) > 0 ) { // print ("debugging! There was a match to the title directive "); print_r(htmlspecialchars($matches[1])); return $matches[1]; } else { // print ("Debugging-no match for the title directive"); return false; }; // print ('
' ); // return $matches ; } // This is from noreply at cvillemedia dot com 21-Sep-2006 11:28 // This function will implement the functionality of file_get_contents() on PHP<4.3.0: // but my PHP (5.1.4-1 on Fedora Core 5) doesn't have it - why? // Because my desktop is at PHP 5.1.4-1 but my server is 'way out of date function my_file_get_contents ($file) { // Wrapper for file_get_contents() with PHP<4.3.0 backwards-compatibility: // © 2006 The Charlottesville Media Group, http://www.cvillemedia.com // Free for unresricted use while this notice remains unchanged. if(function_exists("file_get_contents"))return file_get_contents($file); $ifile = fopen($file,"r"); $contents = false; if($ifile) while (!feof($ifile)) $contents .= fgets($ifile); fclose($ifile); return $contents; } ?> .
$Id: AllFiles.php,v 1.2 2006/10/05 08:00:04 cvsuser Exp $

This is the AllFiles.php script.


"."some test text\nwhich extends over\nthree lines"."<"."/title".">"; print ("A test title: ". htmlspecialchars($s). '
' ); title_extractor($s); ?>
$title $file last modified at ".strftime('%c',filemtime($file))."
\n"; } } ?>

End of PHP script

$Log: AllFiles.php,v $
Revision 1.2  2006/10/05 08:00:04  cvsuser
Fixed a lot of the problems - the script now really does find the titles
of all of the files.

It ought to filter out the files with ,v in the extension

Revision 1.1.1.2  2006/10/02 04:43:03  cvsuser
this is a test

Revision 1.1.1.1  2006/10/01 23:36:23  cvsuser
Initial checkin to CVS

Revision 1.2  2006/09/26 19:57:12  jeffs
Fixed - I hope - the RCS logging at the end of the file