PHP Loader

  • blackhart
  • Graduate
  • Graduate
  • blackhart
  • Posts: 111
  • Loc: Hartbeat

Post 3+ Months Ago

Hi, I'm using PHP to read a directory & create a XML file that would be readable by a flash program that rotates JPG. I didn't make the code but i tried to modify it but it doesn't work.

the rotator can be found here

this is my code
Code: [ Select ]

<?php

/*
This is a sample file that reads through a directory, filters the mp3//jpg/flv 
files and builds a playlist from it. After looking through this file, you'll 
probably 'get the idea' and'll be able to setup your own directory. This 
example uses the mp3player.
*/



// search for mp3 files. set this to '.flv' or '.jpg' for the other scripts 
$filter = ".jpg";
// path to the directory you want to scan
$directory = "pics";



// read through the directory and filter files to an array
@$d = dir($directory);
if ($d) { 
    while($entry=$d->read()) { 
        $ps = strpos(strtolower($entry), $filter);
        if (!($ps === false)) { 
            $items[] = $entry; 
        } 
    }
    $d->close();
    sort($items);
}



// third, the playlist is built in an xspf format
// we'll first add an xml header and the opening tags .. 
header("content-type:text/xml;charset=utf-8");

echo "<?xml version='1.0' encoding='UTF-8' ?>\n";
echo "<jpgrotator>\n";
echo " <parameters>\n";
echo "   <rotatetime>5</rotatetime>\n";
echo "   <randomplay>true</randomplay>\n";
echo "   <shownavigation>false</shownavigation>\n";
echo "   <transition>fade</transition>\n";
echo " </parameters>\n";
echo " <photos>\n";


// .. then we loop through the mysql array ..
for($i=0; $i<sizeof($items); $i++) {
    echo "   <photo path=".'http://domain/pics/'.$items[$i]." />\n";
}
 
// .. and last we add the closing tags
echo "    </photos>\n";
echo "</jpgrotator>\n";

?>
  1. <?php
  2. /*
  3. This is a sample file that reads through a directory, filters the mp3//jpg/flv 
  4. files and builds a playlist from it. After looking through this file, you'll 
  5. probably 'get the idea' and'll be able to setup your own directory. This 
  6. example uses the mp3player.
  7. */
  8. // search for mp3 files. set this to '.flv' or '.jpg' for the other scripts 
  9. $filter = ".jpg";
  10. // path to the directory you want to scan
  11. $directory = "pics";
  12. // read through the directory and filter files to an array
  13. @$d = dir($directory);
  14. if ($d) { 
  15.     while($entry=$d->read()) { 
  16.         $ps = strpos(strtolower($entry), $filter);
  17.         if (!($ps === false)) { 
  18.             $items[] = $entry; 
  19.         } 
  20.     }
  21.     $d->close();
  22.     sort($items);
  23. }
  24. // third, the playlist is built in an xspf format
  25. // we'll first add an xml header and the opening tags .. 
  26. header("content-type:text/xml;charset=utf-8");
  27. echo "<?xml version='1.0' encoding='UTF-8' ?>\n";
  28. echo "<jpgrotator>\n";
  29. echo " <parameters>\n";
  30. echo "   <rotatetime>5</rotatetime>\n";
  31. echo "   <randomplay>true</randomplay>\n";
  32. echo "   <shownavigation>false</shownavigation>\n";
  33. echo "   <transition>fade</transition>\n";
  34. echo " </parameters>\n";
  35. echo " <photos>\n";
  36. // .. then we loop through the mysql array ..
  37. for($i=0; $i<sizeof($items); $i++) {
  38.     echo "   <photo path=".'http://domain/pics/'.$items[$i]." />\n";
  39. }
  40.  
  41. // .. and last we add the closing tags
  42. echo "    </photos>\n";
  43. echo "</jpgrotator>\n";
  44. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

does it creates the xml correctly?
oh, nvm i`ll try it by myself :D
  • blackhart
  • Graduate
  • Graduate
  • blackhart
  • Posts: 111
  • Loc: Hartbeat

Post 3+ Months Ago

I'm not sure... i kinda forgot most of the codeing knowldge i had... :(
  • blackhart
  • Graduate
  • Graduate
  • blackhart
  • Posts: 111
  • Loc: Hartbeat

Post 3+ Months Ago

um bump please
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

i tested it, and i got an error ... so i changed
Code: [ Select ]
echo "   <photo path=".'http://domain/pics/'.$items[$i]." />\n";

with


echo "   <photo path=".'"http://domain/pics/'.$items[$i].'" />\n';
  1. echo "   <photo path=".'http://domain/pics/'.$items[$i]." />\n";
  2. with
  3. echo "   <photo path=".'"http://domain/pics/'.$items[$i].'" />\n';

and the xml was created ok. Didnt look more over the rest of the code
  • blackhart
  • Graduate
  • Graduate
  • blackhart
  • Posts: 111
  • Loc: Hartbeat

Post 3+ Months Ago

Thanks that worked,
hey um how did you test it out of curriosity? this way i could just figure it out on my own :)
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

uhmmm,
i have installed apache+php+mysql for windows on my computer, so it acts like a web server with php support.
So in the default directory which apache takes for web, in my case c:\appserver\www\ i created a file called files.php and copy pasted your code in there, then all i did was to type in the browser:
http://localhost:8080/files.php
(:8080 because i have IIS running on port 80, which is default, so i changed apache to run on port 8080)
  • recep
  • Beginner
  • Beginner
  • recep
  • Posts: 40
  • Loc: www.loanus.info

Post 3+ Months Ago

Hmm, nice rotator, can we find any demo for it?
  • Fabinator
  • Proficient
  • Proficient
  • Fabinator
  • Posts: 467

Post 3+ Months Ago

not very much of a chance, you bumped a year old topic..

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.