

<< Prev 5 |
Perl Dynamic XML directory Content Generator_by SUP@
 |
 |
#!/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 "<html><body>";
print "<h1>Loading data...\n";
print "</h1></body><html>";
# open xml file to write
open(FIL,">../pub/database.xml");
# lock the file
flock(FIL,2);
# XML intro
print FIL "<?xml version= 1 ?>\n";
# xml category
print FIL "<categoryName>\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 "<pic$t name=\"$nfile\"></pic$t>\n";
}
# loop
}
closedir(HOMEDIR);
# finish off xml file with end category and close the file
print FIL "</pics>\n";
flock(FIL,8);
close(FIL);
# --
# By : SUP@ mtlelite@hotmail.com
Posted by: SUP@ | website
http://noPortfolioYet.com
|
 |
 |
 |
Using loadVars to send data to a perl script
 |
 |
/*Ok, so, the point of this tutorial is to allow people to use an easier
method to send data to a perl script. The other Perl/CGI tutorial didn't
work for me, so I decided to write a new tutorial for people with picky servers.*/
//Step One:
/*Open a new project in KoolMoves or Flash MX, draw an input (or dynamic in KM) text box.
Give the text box the variable name (label in KM) of text1.
Draw a button.*/
//Step Two:
//Edit the buttons Action Script to match mine:
On(Release) {
myVarData = new loadVars();
myVarData.user = text1.text;
myVarData.sendAndLoad("http://www.yourserver/cgi-bin/loadvars.cgi", myVarData, [,"POST"]);
gotoAndPlay("frame2");
}
//Step three:
/*Create a new Key Frame and label it "frame2".
In frame2, create a new dynamic text box and label it "text2".
Edit that frames action script to match mine:*/
myVarData.onLoad(success) {
if(success) {
text2.text = myVarData.user;
}
else {
text2.text = "Data didn't load, bummer.";
}
}
stop();
//Step Four:
Set up the Perl Code:
#!/usr/bin/perl -wT
use CGI qw(:standard);
#get flash variable (myVarData.user)
$user = param('user');
#print header
print header;
print start_html();
#convert myVarData.user to a message
$usermessage = "Welcome: $user";
#send message to flash
print "&user=$usermessage";
#send a useless variable to make km happy
print "&end=end";
print end_html;
//Step Five:
/*Upload the perl code(loadvars.cgi) to your cgi-bin,
and change the permissions to 755.*/
//Conclusion:
/*This exact code works great for me, but the other tutorial didn't.
I think it's because I'm using KoolMoves(because it's low cost) or
it's because my server requires the -wT in the first line of the
perl code(it caused a download when I used the other tutorials
code.)
Good luck and happy coding,
-Aaron*/
Posted by: Aaron Meier | website
http//none.com
|
 |
 |
 |
<< Prev 5 |