|
comp.lang.php - PHP programming language discussions
|
|
If you were Registered and logged in, you could reply and use other advanced thread options
|
Posted by Tom Jordan on January 4, 2005, 7:19 am
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;
?>
|
|
Posted by Tony Reed on January 4, 2005, 2:02 pm
On 4 Jan 2005 06:19:57 -0800
tom@jb-solutions.co.uk (Tom Jordan) wrote:
: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.
A "little PHP?" Is that like being a "little bit pregnant?"
Anyway, without seeing the errors, or even knowing what version of PHP
you're using, I would say that perhaps the dom/xml stuff isn't enabled
on your server.
--
Tony Reed
|
|
Posted by Manuel Lemos on January 4, 2005, 8:10 pm
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
|
|
Posted by Pedro Graca on January 4, 2005, 11:17 pm
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/
== ** ## !! ------------------------------------------------ !! ## ** ==
may bypass my spam filter. If it does, I may reply from another address!
|
This Thread
If you were Registered and logged in, you could reply and use other advanced thread options
Related Posts
Latest Posts
|
|
$fileNode->set_attribute('name', $fileName);
$fileNode->set_attribute('extension', $extension);