AMF-Perl

 view release on metacpan or  search on metacpan

README.txt  view on Meta::CPAN


Version: 0.15
Date: September 17, 2004.

This is the code and several examples that show the possibility of using Perl to talk to a Macromedia Flash client using AMF (Action Message Format).

To install:

1a. If you have access to Macromedia Flash MX, load the docs/examples/cpu/CpuExample.fla file.  Edit the actions for Layer Name to use the URL of your script.

1b. If you do not have Macromedia authoringh tools, embed the
docs/examples/cpu/CpuExample.swf movie into a web page. 
Use docs/examples/cpu/cpu.html as a template. When the movie starts, enter the URL of your script into the text field.

2. Observe the load of your server when you click Refresh!

Simon Ilyushchenko

doc/examples/cpu/cpu.html  view on Meta::CPAN


<center>
<table width=800 cellspacing=10><tr>
<td align=left width=400 valign=top>
<H2>This is an example of <a href=http://www.simonf.com/amfperl/>AMF::Perl</a> in action.</H2>
<br>
<p>
Download Flash 7 player from <a href="http://www.macromedia.com/shockwave/download/alternates/">here</a> if you don't have it. It even works on Linux!
<p>
These are the 1, 5 and 15 minute load values on this web server. Press Refresh to see the current load.
If you want to use this on your server, but do not have Macromedia authoring tools, you can type your URL instead of the default URL that you see in this Flash movie.
<br>
<a href=cpu.pl>This is the server-side Perl script cpu.pl.</a>
</td>
<td width=400>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" id="CpuExample" width=400 height=400>
<PARAM NAME=movie VALUE="cpu.swf"> 
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>

doc/examples/petmarket/petmarket/api/userservice.pm  view on Meta::CPAN

    };
    
}

my @userFields = ("firstname", "lastname", "homestreet1", "homestreet2", "homecity", "homestate", "homecountry", "homezip", "homephone", "creditcardnumber", "creditcardtype", "creditcardexpiry");

my @shippingFields = ("shippingstreet1", "shippingstreet2", "shippingcity", "shippingcountry", "shippingzip", "shippingphone"); 

my @fields = ("email", "password", @userFields, @shippingFields);

sub authenticate
{
    my ($self, $email, $password) = @_;
    my $ary_ref = $self->dbh->selectall_arrayref("SELECT count(*) FROM user_details where email='$email' AND password='$password'");

    return $ary_ref->[0]->[0] > 0;
}

sub addUser
{
    my ($self, $email, $password) = @_;

doc/examples/petmarket/petmarket/api/userservice.pm  view on Meta::CPAN

    $result->{"password"} = $password;

    return $result;
}


sub getUser
{
  my ($self, $email, $password) = @_;

    return 0 unless $self->authenticate($email, $password);

    my $result = new AMF::Perl::Util::Object;

    my $hash_ref = $self->dbh->selectall_hashref("SELECT * FROM user_details WHERE email='$email'", "email");

    my $rowRef = $hash_ref->{$email};

    foreach my $field (@fields)
    {
        $result->{$field} = $rowRef->{$field};
    }
    $result->{useroid} = $email;
    return $result;
}

sub updateUser
{
    my ($self, $userObject) = @_;

    return 0 unless $self->authenticate($userObject->{"email"}, $userObject->{"password"});

    my $setString = "";

    my @setStringArray = map {"$_='".$userObject->{$_}."'"} @userFields;
    $setString = join ",", @setStringArray;

    $self->dbh->do("UPDATE user_details SET $setString");

    return $userObject;
}



( run in 1.126 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )