#!/usr/bin/perl
# -- Perl Dynamic XML directory Content Generator_by SUP@ --
# --
# This script is designed to make a dynamic XML file to be used with flash
# out of a directory that holds jpg files. I use this so my client may simply
# upload files into a ftp directory and the flash page automatically gets
# updated. This is the first time i give code to anyone on the net.
# hope you enjoy it. You must have a little knowledge of perl to make this
# work for you. I commented as much as I could.
# --
# By : SUP@ mtlelite@hotmail.com
# --
print "content-type: text/html\n\n";
# show Load data ...
print "
";
print "Loading data...\n";
print "
";
# open xml file to write
open(FIL,">../pub/database.xml");
# lock the file
flock(FIL,2);
# XML intro
print FIL "\n";
# xml category
print FIL "\n";
# create index var
local $t;
$t=0;
# open image directory to create xml from
opendir(HOMEDIR, "../images/") ||
die ("Unable to open directory");
# loop thru array of directory
while ($filename = readdir(HOMEDIR))
{
#parce the . .. things from directory array and for jpgs only
if($filename ne "." && $filename ne ".." && substr($filename,length($filename)-4,4) eq ".jpg")
{
#increment index
$t++;
my $nfile;
# create and print the jpg xml item into xml file
$nfile=substr($filename,0,length($filename)-4);
print FIL "\n";
}
# loop
}
closedir(HOMEDIR);
# finish off xml file with end category and close the file
print FIL "\n";
flock(FIL,8);
close(FIL);
# --
# By : SUP@ mtlelite@hotmail.com