This is a discussion on PHP and Flash within the PHP Language forums, part of the PHP Programming Forums category; Hi everyone, I hope someone can shed some light on this for me! I've just migrated a clients website ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi everyone,
I hope someone can shed some light on this for me! I've just migrated a clients website over to our server. The site's done completely in Flash, but uses a little PHP include to pull various images from a folder and display them in the Flash movie. Ok, this works fine on the old host, but I can't get it to work for the life of me on my server. I've included the PHP script below. Any feedback would be very much appreciated as I'm pulling my hair out a bit now! Thanks in advance, Tom snip --------- <?php function getFileStructure($doc, $curNode, $inDir){ //echo ("get file structure "); if ($currentDirectory = opendir($inDir)){ while ($dirElement = readdir($currentDirectory)){ $pathToElement = $inDir . "/" . $dirElement; if (is_file($pathToElement)){ $dotposition = strpos($dirElement, "."); $fileName = substr($dirElement, 0, $dotposition); $extension = substr($dirElement, 1 + $dotposition); if ($extension == "jpg" or $extension == "JPG"){ $fileNode = addFileNode($doc, $curNode, $fileName, $extension); } } else if($dirElement != "." && $dirElement != ".."){ $catNode = addCategoryNode($doc, $curNode, $dirElement, $pathToElement); } } closedir($currentDirectory); } return $curNode; } function addFileNode($doc, $parentNode, $fileName, $extension){ //echo ("add file node "); $fileNode = $parentNode->append_child($doc->create_element('FILE')); $fileNode->set_attribute('name', $fileName); $fileNode->set_attribute('extension', $extension); } function addCategoryNode($doc, $parentNode, $catName, $pathToElement){ //echo ("add cat node "); $catNode = $parentNode->append_child($doc->create_element('CATEGORY')); $catNode->set_attribute('name', $catName); getFileStructure($doc, $catNode, $pathToElement); } $rootDirectory = './images/'; $doc = domxml_new_doc('1.0'); $comment = $doc->create_comment('This XML document describes the files to be used for a web site'); $doc->append_child($comment); $root = $doc->append_child($doc->create_element('NAVIGATION')); getFileStructure($doc, $root, $rootDirectory); //echo htmlentities($doc->dump_mem(true)); $xmlstring = $doc->dump_mem(true); echo $xmlstring; ?> |
|
|||
|
Hello,
on 01/04/2005 12:19 PM Tom Jordan said the following: > Hi everyone, > > I hope someone can shed some light on this for me! > > I've just migrated a clients website over to our server. The site's > done completely in Flash, but uses a little PHP include to pull > various images from a folder and display them in the Flash movie. > > Ok, this works fine on the old host, but I can't get it to work for > the life of me on my server. I've included the PHP script below. Any > feedback would be very much appreciated as I'm pulling my hair out a > bit now! You may want to use PHP Ming extension that lets you generate Flash movies only with PHP code. Here you may find an example of how to build a Image slideshow in Flash using PHP with Ming: http://www.phpclasses.org/flashslideshow -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html |
|
|||
|
Tom Jordan wrote:
> I've just migrated a clients website over to our server. The site's > done completely in Flash, I don't know Flash, never used it. > but uses a little PHP include to pull > various images from a folder Maybe I can help here :) > and display them in the Flash movie. > > Ok, this works fine on the old host, but I can't get it to work for > the life of me on my server. What are the versions of PHP in both servers? What are the differences between their php.ini's? See my comments below (## lines). <snip> > <?php > function getFileStructure($doc, $curNode, $inDir){ > //echo ("get file structure "); > if ($currentDirectory = opendir($inDir)){ > while ($dirElement = readdir($currentDirectory)){ > $pathToElement = $inDir . "/" . $dirElement; > if (is_file($pathToElement)){ > $dotposition = strpos($dirElement, "."); > $fileName = substr($dirElement, 0, $dotposition); > $extension = substr($dirElement, 1 + $dotposition); > if ($extension == "jpg" or $extension == "JPG"){ > $fileNode = addFileNode($doc, $curNode, $fileName, $extension); > } > } else if($dirElement != "." && $dirElement != ".."){ > $catNode = addCategoryNode($doc, $curNode, $dirElement, $pathToElement); > } > } > closedir($currentDirectory); > } > return $curNode; ## $curNode never changes (as far as I can see) in the code above. ## You're calling functions where it is a parameter, but those function ## do not declare that specific parameter (or any other) as ## pass by reference, so they get a copy of $curNode and any changes ## they make to it are lost when the function return. > } > > function addFileNode($doc, $parentNode, $fileName, $extension){ ## maybe ## function addFileNode($doc, &$parentNode, $fileName, $extension){ ## with the ---------------- '&' here to pass by reference <snip> > } > > function addCategoryNode($doc, $parentNode, $catName, $pathToElement){ <snip> > } > > > $rootDirectory = './images/'; > $doc = domxml_new_doc('1.0'); > $comment = $doc->create_comment('This XML document describes the files > to be used for a web site'); > $doc->append_child($comment); > $root = $doc->append_child($doc->create_element('NAVIGATION')); > getFileStructure($doc, $root, $rootDirectory); ## You're disregarding the return value of getFileStructure() ## This line does absolutely nothing. > //echo htmlentities($doc->dump_mem(true)); > $xmlstring = $doc->dump_mem(true); > echo $xmlstring; > > ?> -- Mail to my "From:" address is readable by all at http://www.dodgeit.com/ == ** ## !! ------------------------------------------------ !! ## ** == TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>) may bypass my spam filter. If it does, I may reply from another address! |