<?php
function getFileList($dir) {
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while($file = readdir($dh)) {
if (preg_match( '/^(\.|\.\.)$/', $file)) {
// If the user needs to see "..", then the "echo" and "not_dir" lines should go above this conditional.
continue;
}
$not_dir = strcmp('dir', filetype($dir . '/' . $file));
// jaxtree.js makes a reference to an attribute "parent_id"; what is that supposed to be?
echo "\t<record> <path>$dir/</path><title>$file</title><is_dir>" . !$not_dir . "</is_dir></record>\n";
if (0 == $not_dir) {
getFileList($dir . '/' . $file);
}
}
closedir($dh);
}
}
}
function fileWrite($path, $contents) {
if (!is_writable($path)) die("Unable to write file $path to disk, path is not writable.");
$file = fopen($path, 'w') or die("Unable to write file $path to disk, unable to open the file.");
fwrite($file, $contents);
fclose($file);
return true;
}
/*
ALREADY WRITTEN IN REFOLDER.PHP
function fileRead($path) {
$file = fopen($path, 'r');
$string = fread($file, 5);
fclose($file);
return $string;
}
*/
?>