mnieves
08-11-2008, 02:35 PM
i need to add filesize and hide extension filter to this code.
thanks in advance.
<?php
$str = "<root>";
function readfromhere($path=".")
{
global $str;
$currentPath=($path == '.' ? './Shared/' : $path.'/');
//echo "";
//var_dump($currentPath);
//echo "";
if ($handle = opendir($currentPath)) {
while (false !== ($file = readdir($handle))) {
//echo "";
//var_dump($file);
//echo "\n";
//var_dump(is_dir($currentPath.$file));
//echo "";
if (is_dir($currentPath.$file) && $file != "." && $file != "..") {
$str.='<node type="folder" name="'.$file.'">';
readfromhere($currentPath.$file);
$str.='</node>';
} else if ($file != "." && $file != "..") {
$str.='<node type="file" name="'.$file.'" path="'.preg_replace('/\.\/+/i','',$currentPath).$file.'">
</node>';
}
}
closedir($handle);
}
return $str;
}
readfromhere();
$str.="</root>";
header('Content-Type: text/xml');
echo $str;
?>
thanks in advance.
<?php
$str = "<root>";
function readfromhere($path=".")
{
global $str;
$currentPath=($path == '.' ? './Shared/' : $path.'/');
//echo "";
//var_dump($currentPath);
//echo "";
if ($handle = opendir($currentPath)) {
while (false !== ($file = readdir($handle))) {
//echo "";
//var_dump($file);
//echo "\n";
//var_dump(is_dir($currentPath.$file));
//echo "";
if (is_dir($currentPath.$file) && $file != "." && $file != "..") {
$str.='<node type="folder" name="'.$file.'">';
readfromhere($currentPath.$file);
$str.='</node>';
} else if ($file != "." && $file != "..") {
$str.='<node type="file" name="'.$file.'" path="'.preg_replace('/\.\/+/i','',$currentPath).$file.'">
</node>';
}
}
closedir($handle);
}
return $str;
}
readfromhere();
$str.="</root>";
header('Content-Type: text/xml');
echo $str;
?>