1

(9 replies, posted in TiltViewer-Pro)

Hello, here a little PHP script that reads the content of the actual directory and save the xml file gallery.xml with all the needed code. Whith this all you have to do is upload your images into the directory.

<?php
$dir_nom = '.'; // list of actual directory 
$dir = opendir($dir_nom); // opens directory
$fichier= array(); // declaration of table who contents file names

while($element = readdir($dir)) {
    if($element != '.' && $element != '..') {
        if (!is_dir($dir_nom.'/'.$element)) {$fichier[] = $element;}
        else {$dossier[] = $element;}
    }
}

closedir($dir);

$fp = fopen("gallery.xml",a);//Opens xml file 
//fwrite($fp,"<tiltviewergallery>\n    <photos>\n");// write first lines of xml file
if(!empty($fichier)){
    rsort($fichier);// ... becomes sort() if you want
    foreach($fichier as $lien) {
    if (strlen(strstr($lien,".jpg"))>0) {//writes file if it is an image.. else go the the next one
         fwrite($fp,"$lien\n");
         //fwrite($fp,"        <photo imageurl='imgs/$lien' linkurl=''>\n<title>Photo $lien</title>\n<description>album photo</description>\n</photo>\n");
     }
    }
//fwrite($fp,"</photos>\n </tiltviewergallery>\n";//writes 2 last lines of xml file
fclose($fp);
 }
?>