scot
01-11-2005, 01:55 AM
heres the php script giving me problems....
<?php
function getlastdir($dir)
{
$dir = substr($dir, 0, -1);
$dir = substr($dir, strrpos($dir, '/') + 1);
return $dir;
}
function fetchdir($dir, $level = 0)
{
global $len;
global $doc_root;
if ($level == 1)
echo '<groupfolder name="' . getlastdir($dir) . '">';
chdir($doc_root. $dir);
$handle = opendir($doc_root. $dir);
$dir_subdirs=array();
$dir_files=array();
while ($entry = readdir($handle)) {
if ($entry == '.' or $entry == '..' or substr($entry, 0, 3) == "tn_") continue;
if (is_dir($entry)) {
$dir_subdirs[] = $dir . $entry . '/';
} elseif (strtolower(substr ($entry, -4, 4)) == ".jpg") $dir_files[] = $entry;
}
if ($level == 2) {
echo '<folder path="' , substr($dir, $len, strlen($dir)) , '" name="' , getlastdir($dir) , '" amount="' , sizeof($dir_files) , '" />';
}
@sort($dir_subdirs);
for($i = 0; $i < sizeof($dir_subdirs); $i++) {
if ($level < 2)
fetchdir($dir_subdirs[$i], $level + 1);
}
if ($level == 1)
echo '</groupfolder>';
@closedir($handle);
}
$thisdir = dirname($_SERVER['PHP_SELF']);
$len = strlen ($thisdir) + 1;
$doc_root=getenv('DOCUMENT_ROOT');
if(!$doc_root) {
$path=getenv('PATH_TRANSLATED');
$doc_root= substr($path,0,strlen($path)-strlen(getenv('PATH_INFO')));
if(!$doc_root) die('unknown server. ');
}
//
header("Content-type: text/xml");
//
echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<index> '; fetchdir ($thisdir . '/pics/'); echo '</index>
'; ?>
it gives me the below results.......
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<index>
<directory name="Joe Blow" type="directory">
<folder path="pics/Joe Blow/Copy (2) of New Folder/" name="Copy (2) of New Folder" amount="0" />
<folder path="pics/Joe Blow/Copy of New Folder/" name="Copy of New Folder" amount="0" />
<folder path="pics/Joe Blow/New Folder/" name="New Folder" amount="0" />
</directory>
<directory name="Scots Friends" type="directory">
<folder path="pics/Scots Friends/Lake Trout/" name="Lake Trout" amount="28" />
<folder path="pics/Scots Friends/Val Yumm/" name="Val Yumm" amount="84" />
</directory>
</index>
if I take the results in php and put in a file and save a xml ... flash loads the file....... via newxml.load("xmldoc.xml")
but flash wont load in the php file when its called directly
newxml.load("xml.php")
what am I missing ?????
<?php
function getlastdir($dir)
{
$dir = substr($dir, 0, -1);
$dir = substr($dir, strrpos($dir, '/') + 1);
return $dir;
}
function fetchdir($dir, $level = 0)
{
global $len;
global $doc_root;
if ($level == 1)
echo '<groupfolder name="' . getlastdir($dir) . '">';
chdir($doc_root. $dir);
$handle = opendir($doc_root. $dir);
$dir_subdirs=array();
$dir_files=array();
while ($entry = readdir($handle)) {
if ($entry == '.' or $entry == '..' or substr($entry, 0, 3) == "tn_") continue;
if (is_dir($entry)) {
$dir_subdirs[] = $dir . $entry . '/';
} elseif (strtolower(substr ($entry, -4, 4)) == ".jpg") $dir_files[] = $entry;
}
if ($level == 2) {
echo '<folder path="' , substr($dir, $len, strlen($dir)) , '" name="' , getlastdir($dir) , '" amount="' , sizeof($dir_files) , '" />';
}
@sort($dir_subdirs);
for($i = 0; $i < sizeof($dir_subdirs); $i++) {
if ($level < 2)
fetchdir($dir_subdirs[$i], $level + 1);
}
if ($level == 1)
echo '</groupfolder>';
@closedir($handle);
}
$thisdir = dirname($_SERVER['PHP_SELF']);
$len = strlen ($thisdir) + 1;
$doc_root=getenv('DOCUMENT_ROOT');
if(!$doc_root) {
$path=getenv('PATH_TRANSLATED');
$doc_root= substr($path,0,strlen($path)-strlen(getenv('PATH_INFO')));
if(!$doc_root) die('unknown server. ');
}
//
header("Content-type: text/xml");
//
echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<index> '; fetchdir ($thisdir . '/pics/'); echo '</index>
'; ?>
it gives me the below results.......
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<index>
<directory name="Joe Blow" type="directory">
<folder path="pics/Joe Blow/Copy (2) of New Folder/" name="Copy (2) of New Folder" amount="0" />
<folder path="pics/Joe Blow/Copy of New Folder/" name="Copy of New Folder" amount="0" />
<folder path="pics/Joe Blow/New Folder/" name="New Folder" amount="0" />
</directory>
<directory name="Scots Friends" type="directory">
<folder path="pics/Scots Friends/Lake Trout/" name="Lake Trout" amount="28" />
<folder path="pics/Scots Friends/Val Yumm/" name="Val Yumm" amount="84" />
</directory>
</index>
if I take the results in php and put in a file and save a xml ... flash loads the file....... via newxml.load("xmldoc.xml")
but flash wont load in the php file when its called directly
newxml.load("xml.php")
what am I missing ?????