PDA

View Full Version : php / xml issuse......


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 ?????

andehlu
01-11-2005, 02:46 PM
it will work. I always load .php as xml. Check the path and try chmod'ing the php file to 777 to test.

I also suggest str_replace() on the blank spaces in the path attributes in yer xml to underscores or something.

scot
01-11-2005, 03:41 PM
yeah I know it will work... but its not.... I have tried chmod 777 and still no luck .... and str_replace() still doesnt fix the issuse......

andehlu
01-11-2005, 04:20 PM
what does yer actionscript look like?

scot
01-11-2005, 08:21 PM
imageList = new XML();
imageList.ignoreWhite = 1
imageList.onLoad = function() {
if (this.loaded) {
total = this.firstChild.childNodes.length;
trace("dir.xml loaded. Total dirs : "+total);
// xmlNode = this.firstChild;

}
};
//

// this works
//imageList.load("dir.xml");
//
// but not this
imageList.load("dir.php");


I dont think its the AS cause it loads .xml fine ... but not the .php ..... I even tried the latest PHP verision on my server but same issuse.......

CyanBlue
01-11-2005, 08:26 PM
Is there any way you could post the PHP file on the Internet so that I can call it from my computer??? :)

scot
01-11-2005, 08:31 PM
the only difference I have found is in the source of the PHP or XML via a browser .... the php source is on one line and the XML source looks like a XML ... this makes no F***ing sense.......... I hate BUGS ! ! !

andehlu
01-11-2005, 08:37 PM
did u try taking the header call out of the php? nuke this line:

header("Content-type: text/xml");

scot
01-11-2005, 08:57 PM
yeah I nuked that line........... ...

cyan .. . ---> http://www.mtothex.com/help/dir.php if you look at the source of the page at that URL .. its all on one line......

CyanBlue
01-11-2005, 11:29 PM
Okay... I am not following...

I just pasted this code in the new document(FMX)...

imageList = new XML();
imageList.ignoreWhite = 1
imageList.onLoad = function() {
if (this.loaded) {
total = this.firstChild.childNodes.length;
trace("dir.xml loaded. Total dirs : "+total);
xmlNode = this.firstChild;
trace("xmlNode = " + xmlNode);
}
};
imageList.load("http://www.mtothex.com/help/dir.php");

and the output panel says...
dir.xml loaded. Total dirs : 2
xmlNode = <index><groupfolder name="JoeBlow"><folder path="pics/JoeBlow/NewFolder/" name="NewFolder" amount="0" /></groupfolder><groupfolder name="ScotsFriends"><folder path="pics/ScotsFriends/LakeTrout/" name="LakeTrout" amount="28" /><folder path="pics/ScotsFriends/ValYumm/" name="ValYumm" amount="84" /></groupfolder></index>
It looks like it is working to me... Hm...

scot
01-12-2005, 12:42 AM
ARG ... thanks CYAN ... for reminding me to make a new FLA ... yet another FLA became corrupt

CyanBlue
01-12-2005, 03:26 PM
Hm... I DON'T understand if it was the corrupted FLA file case... The file is corrupted, yet you were able to do the Test Movie??? Do you use FMX or FMX 2004??? If it is 2004, it's got to be either a new feature or a bug... :D

scot
01-12-2005, 10:36 PM
its FMX2004 Pro ...... I've had this happen several times ....... working on FLA ... everything is fine and then something doesnt work...... copy code into new FLA and its fine.... I dont know if its cause all My FLA's only Actionscript and nothing else in it ... or what....... Maybe its Windows........ only if I had the cash to put FMX2k4 on my mac .... or if macromedia would come out with a linux ver ... .this windows crap is getting tiresome..... I only use windows for Flash...... ARG ! ! ! !

CyanBlue
01-12-2005, 11:08 PM
That's a big doh... Well... Use FMX... At least it is more stable on Windows and causes less trouble on Mac... ;)

andehlu
01-13-2005, 12:30 AM
i never use windows for anything ever. But thats me. Have u installed the 7.2 patch for mx 2004 pro?

CyanBlue
01-13-2005, 12:36 AM
Um... If you are talking to me... Yeah... I did apply the patch as soon as it came out... and I use Windows all the time even though I don't like it 100%... It's bearable OS when you don't have much money... (Meaning that most of the software that I have runs on Windows...)