AMF-Perl

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

doc/examples/sql/park.sql
doc/examples/sql/park.pl
doc/examples/sql/parkservices/ParkService.pm
doc/examples/petmarket/README.txt
doc/examples/petmarket/petmarket.pl
doc/examples/petmarket/petmarket.sql
doc/examples/petmarket/petmarket/api/cartservice.pm
doc/examples/petmarket/petmarket/api/catalogservice.pm
doc/examples/petmarket/petmarket/api/dbConn.pm
doc/examples/petmarket/petmarket/api/orderservice.pm
doc/examples/petmarket/petmarket/api/stringresourcesservice.pm
doc/examples/petmarket/petmarket/api/userservice.pm
doc/updates.html
META.yml                                 Module meta-data (added by MakeMaker)

META.yml  view on Meta::CPAN

# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
name:         AMF-Perl
version:      0.15
version_from: lib/AMF/Perl.pm
installdirs:  site
requires:
    DBI:                           0.01
    Encode:                        0.01
    Exception::Class:              0.01

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17

README.txt  view on Meta::CPAN

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/code.html  view on Meta::CPAN

//Get a pointer to a service
remoteService = connection.getService("Foo", this);

//Call a remote method on that service
remoteService.bar();

//or... send arguments to the server:
remoteService.bar(arg1, arg2);

//This callback function will be invoked
function bar_result(value)
{
	//do something with the value
}
</textarea>
&nbsp; <br>
      <h3> Server code, option A - service registration.</h3><br>
Use in simple applications.<br>
<table>
<tr><th>Perl</th><th>Python</th></tr>
    <tr>

doc/code.html  view on Meta::CPAN

<textarea cols=50 rows=20>
	
use AMF::Perl;


#Create the gateway object

my $gateway = AMF::Perl-&gt;new; 

#Set a directory that will contain Perl package.
#Each package will correspond to one service -
#there can be as many as you want!
#You can set only one class path, though.

$gateway-&gt;setBaseClassPath("./basicservices/");

#Let the gateway figure out who will be called.

$gateway-&gt;service();
</textarea>

doc/cpu.pl  view on Meta::CPAN

#!/usr/bin/perl -w
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client 
#talking in ActionScript. See the FLAP project site (http://www.simonf.com/amfperl) 
#for more information.

use strict;

=head1 COMMENT
        
    ActionScript for this service:

    #include "NetServices.as"

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


<center>
<table 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>
This shows various data types passed through AMF to the perl backend and sent back.
The most interesting this is not so much what it does, but how it works. The Perl script utilizes the "service discovery" approach - you simply put Perl modules into a certain directory, and they are automatically registered as services.
<br><br>
This example also shows how to throw exceptions, handled by functionName_onStatus in the Flash client (as opposed to functionName_onResult, which is called normally). Simply include in your Perl code
<pre>
use AMF::Perl qw/amf_throw/;
</pre>

and then call <em>amf_throw()</em> with a string or an arbitrary object as a parameter.
<br><br>
If you call <em>die "Error message"</em>, it will be also caught in the same way and sent as an error to Flash.

doc/examples/basic/basic.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl)
#for more information.

#You have to copy the directory "basicservices" into the same directory as this script.

use strict;
use AMF::Perl;

my $gateway = AMF::Perl->new;
$gateway->setBaseClassPath("./basicservices/");

doc/examples/basic/basicservices/DataEcho.pm  view on Meta::CPAN

package DataEcho;

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)


=head1 NAME
    DataEcho
        
==head1 DESCRIPTION    

doc/examples/basic/basicservices/DataEcho.pm  view on Meta::CPAN

            "description" => "Echoes a Flash Date Object (the returnType needs setting)",
            "access" => "remote", # available values are private, public, remote
            "returns" => "date"
        },
        "echoXML" => {
            "description" => "Echoes a Flash XML Object (the returnType needs setting)",
            "access" => "remote", # available values are private, public, remote
            "returns" => "xml"
        },
        "generateError" => {
            "description" => "Throw an error so that _status, not _result on the client side is called",
            "access" => "remote", # available values are private, public, remote
        },
    };
}

sub echoNormal
{
    my ($self, $data) = @_;
    return $data;
}

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

<body>

<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/cpu/cpu.pl  view on Meta::CPAN

#!/usr/bin/perl -w
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The initial code is based on the AMF-PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client 
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl) 
#for more information.

#You can pass arguments from your Flash code to the perl script.

use strict;

=head1 COMMENT
        
        ActionScript for this service:

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

<body>

<center>
<table 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>
This is an example of a GUI control (Data Grid) that would be non-trivial to implement in straight HTML. Note that by clicking on column headers the values are sorted by that column, and the columns can be resized. Click on a grid row to open the bro...
<br>
The datagrid component is not freely available, unfortunately. You can buy it <a href=http://www.macromedia.com/software/drk/productinfo/all_volumes/>here from Macromedia</a>.
<br><br>
<a href=dataGrid.pl>This is the server-side Perl script dataGrid.pl.</a>
</td>
<td width=600>
&nbsp;&nbsp;&nbsp;
<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="DataGrid" width=550 height=350>
<PARAM NAME=movie VALUE="dataGrid.swf"> 

doc/examples/dataGrid/dataGrid.pl  view on Meta::CPAN

#!/usr/bin/perl -w
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client 
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl) 
#for more information.

#You can pass arguments from your Flash code to the perl script.

use strict;
use lib '/var/www/libperl';

=head1 COMMENT
        

doc/examples/dataGrid/dataGrid.pl  view on Meta::CPAN

    my ($proto)=@_;
    my $self={};
    bless $self, $proto;
    return $self;
}

sub getData
{
    my ($self, $arg1, $arg2) = @_;
    my @array;
    my %hash = ("From" => 'Simon', "Subject" =>'AMF::Perl presentation', "URL" => "http://www.simonf.com");
    push @array, \%hash;
    my %hash1 = ("From" => 'Adrian', "Subject" =>'GUI in Flash', "URL" => "http://www.dnalc.org");
    push @array, \%hash1;
    my %hash2 = ("From" => 'James', "Subject" =>'How to get here from Penn station', "URL" => "http://www.cpan.org");
    push @array, \%hash2;
    return \@array;
    }
    
my $gateway = AMF::Perl->new;
$gateway->registerService("DataGrid",new DataGridModel());

doc/examples/petmarket/petmarket.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl)
#for more information.

use strict;
use AMF::Perl;

my $gateway = AMF::Perl->new;
$gateway->setBaseClassPath(".");
$gateway->debugDir("/tmp");
$gateway->service();

doc/examples/petmarket/petmarket.sql  view on Meta::CPAN

  attr5 varchar(80) default NULL
) TYPE=MyISAM;

--
-- Dumping data for table 'item_details'
--


INSERT INTO item_details VALUES ('EST-3',0.00,12.00,'en-US','fish4.gif','Salt Water fish from Australia','Toothless','Mean','','','');
INSERT INTO item_details VALUES ('EST-15',0.00,12.00,'en-US','cat3.gif','Great for reducing mouse populations','With tail','','','','');
INSERT INTO item_details VALUES ('EST-19',0.00,2.00,'en-US','bird1.gif','Great stress reliever','Adult Male','','','','');
INSERT INTO item_details VALUES ('EST-7',0.00,12.00,'en-US','dog2.gif','Friendly dog from England','Female Puppy','','','','');
INSERT INTO item_details VALUES ('EST-27',0.00,90.00,'en-US','dog4.gif','Great companion dog','Adult Female','','','','');
INSERT INTO item_details VALUES ('EST-26',0.00,92.00,'en-US','dog4.gif','Little yapper','Adult Male','','','','');
INSERT INTO item_details VALUES ('EST-6',0.00,12.00,'en-US','dog2.gif','Friendly dog from England','Male Adult','','','','');
INSERT INTO item_details VALUES ('EST-8',0.00,12.00,'en-US','dog6.gif','Cute dog from France','Male Puppy','','','','');
INSERT INTO item_details VALUES ('EST-28',0.00,90.00,'en-US','dog1.gif','Great family dog','Adult Female','','','','');
INSERT INTO item_details VALUES ('EST-22',0.00,100.00,'en-US','dog5.gif','Great hunting dog','Adult Male','','','','');
INSERT INTO item_details VALUES ('EST-25',0.00,90.00,'en-US','dog5.gif','Great hunting dog','Female Puppy','','','','');
INSERT INTO item_details VALUES ('EST-16',0.00,12.00,'en-US','cat1.gif','Friendly house cat, doubles as a princess','Adult Female','','','','');
INSERT INTO item_details VALUES ('EST-10',0.00,12.00,'en-US','dog5.gif','Great dog for a Fire Station','Spotted Adult Female','','','','');
INSERT INTO item_details VALUES ('EST-2',0.00,10.00,'en-US','fish3.gif','Fresh Water fish from Japan','Small','','','','');
INSERT INTO item_details VALUES ('EST-18',0.00,92.00,'en-US','bird4.gif','Great companion for up to 75 years','Adult Male','','','','');
INSERT INTO item_details VALUES ('EST-17',0.00,12.00,'en-US','cat1.gif','Friendly house cat, doubles as a prince','Adult Male','','','','');
INSERT INTO item_details VALUES ('EST-13',0.00,11.10,'en-US','lizard2.gif','Friendly green friend','Green Adult','','','','');
INSERT INTO item_details VALUES ('EST-4',0.00,12.00,'en-US','fish3.gif','Fresh Water fish from Japan','Spotted','','','','');
INSERT INTO item_details VALUES ('EST-23',0.00,100.00,'en-US','dog5.gif','Great hunting dog','Adult Female','','','','');
INSERT INTO item_details VALUES ('EST-5',0.00,12.00,'en-US','fish3.gif','Fresh Water fish from Japan','Spotless','','','','');
INSERT INTO item_details VALUES ('EST-12',0.00,12.00,'en-US','lizard3.gif','Doubles as a watch dog','Rattleless','','','','');
INSERT INTO item_details VALUES ('EST-21',0.00,1.00,'en-US','fish2.gif','Fresh Water fish from China','Adult Female','','','','');
INSERT INTO item_details VALUES ('EST-1',0.00,10.00,'en-US','fish3.gif','Fresh Water fish from Japan','Large','Cuddly','','','');
INSERT INTO item_details VALUES ('EST-9',0.00,12.00,'en-US','dog5.gif','Great dog for a Fire Station','Spotless Male Puppy','','','','');
INSERT INTO item_details VALUES ('EST-20',0.00,2.00,'en-US','fish2.gif','Fresh Water fish from China','Adult Male','','','','');
INSERT INTO item_details VALUES ('EST-14',0.00,12.00,'en-US','cat3.gif','Great for reducing mouse populations','Tailless','','','','');
INSERT INTO item_details VALUES ('EST-11',0.00,12.00,'en-US','lizard3.gif','More Bark than bite','Venomless','','','','');
INSERT INTO item_details VALUES ('EST-24',0.00,92.00,'en-US','dog5.gif','Great addition to a family','Male Puppy','','','','');

--
-- Table structure for table 'product'
--

CREATE TABLE product (
  productid varchar(10) NOT NULL default '',

doc/examples/petmarket/petmarket.sql  view on Meta::CPAN

) TYPE=MyISAM;

--
-- Dumping data for table 'product_details'
--


INSERT INTO product_details VALUES ('K9-RT-01','en-US','Golden Retriever','dog1.gif','Great family dog');
INSERT INTO product_details VALUES ('K9-DL-01','en-US','Dalmation','dog5.gif','Great dog for a Fire Station');
INSERT INTO product_details VALUES ('FI-SW-01','en-US','Angelfish','fish1.jpg','Salt Water fish from Australia');
INSERT INTO product_details VALUES ('FI-FW-02','en-US','Goldfish','fish2.gif','Fresh Water fish from China');
INSERT INTO product_details VALUES ('K9-BD-01','en-US','Bulldog','dog2.gif','Friendly dog from England');
INSERT INTO product_details VALUES ('K9-PO-02','en-US','Poodle','dog6.gif','Cute dog from France');
INSERT INTO product_details VALUES ('FL-DLH-02','en-US','Persian','cat1.gif','Friendly house cat, doubles as a princess');
INSERT INTO product_details VALUES ('K9-RT-02','en-US','Labrador Retriever','dog5.gif','Great hunting dog');
INSERT INTO product_details VALUES ('AV-CB-01','en-US','Amazon Parrot','bird4.gif','Great companion for up to 75 years');
INSERT INTO product_details VALUES ('AV-SB-02','en-US','Finch','bird1.gif','Great stress reliever');
INSERT INTO product_details VALUES ('FL-DSH-01','en-US','Manx','cat3.gif','Great for reducing mouse populations');
INSERT INTO product_details VALUES ('RP-SN-01','en-US','Rattlesnake','lizard3.gif','Doubles as a watch dog');
INSERT INTO product_details VALUES ('RP-LI-02','en-US','Iguana','lizard2.gif','Friendly green friend');
INSERT INTO product_details VALUES ('FI-SW-02','en-US','Tiger Shark','fish4.gif','Salt Water fish from Australia');
INSERT INTO product_details VALUES ('FI-FW-01','en-US','Koi','fish3.gif','Fresh Water fish from Japan');
INSERT INTO product_details VALUES ('K9-CW-01','en-US','Chihuahua','dog4.gif','Great companion dog');

--
-- Table structure for table 'user_details'
--

CREATE TABLE user_details (
  email varchar(50) default NULL,
  password varchar(50) default NULL,
  firstname varchar(50) default NULL,

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

package petmarket::api::cartservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/amfperl for more information.

use warnings;
no warnings "uninitialized";
use strict;

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

            
    $locations{"STATES_array"} = \@states;
    $locations{"COUNTRIES_array"} = \@countries;
            
    return \%locations;
}

sub getCreditCards 
{
    my ($self) = @_;
    my @cards = ("American Express", "Discover/Novus", "MasterCard", "Visa");
    return \@cards;
}
	
sub getShippingMethods 
{
    my @columns = ("shippingoid", "shippingname", "shippingdescription", "shippingprice", "shippingdays");
    my @names = ("Ground", "2nd Day Air", "Next Day Air", "3 Day Select");
    my @descriptions = (
        "Prompt, dependable, low-cost ground delivery makes Ground an excellent choice for all your routine shipments. Ground reaches every address throughout the 48 contiguous states.",
        "2nd Day Air provides guaranteed on-time delivery to every address throughout the United States (excluding intra-Alaska shipments) and Puerto Rico by the end of the second business day. This service is an economical alternative for time-sensi...
        "Next Day Air features fast, reliable delivery to every address in all 50 states and Puerto Rico. We guarantee delivery by 10:30 a.m., noon, or end of day the next business day depending on destination (noon or 1:30 p.m. on Saturdays).",
        "The ideal mix of economy and guaranteed on-time delivery, 3 Day Select guarantees delivery within three business days to and from every address in the 48 contiguous states."
    );
    my @prices = (13.00, 26.00, 39.00, 18.00);
    my @days = (6, 2, 1, 3);

    my @methods;

    for (my $i = 0; $i < scalar @names; $i++) 
    {
        my @row;
        push @row, $i;

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


    $self->dbh->do("INSERT INTO cart_details SET cartid='$id'");

    return $id;
}

#TODO - where does the item quantity come from?
sub getCartItems
{
    my ($self, $cartid) = @_;
    my @result;
    my $ary_ref = $self->dbh->selectall_arrayref("SELECT d.quantity, a.productid, a.itemid, unitcost, b.descn, attr1, c.name,e.catid FROM item a, item_details b, product_details c, cart_details d, product e WHERE a.itemid=b.itemid AND a.productid= c....
    foreach my $rowRef (@$ary_ref)
    {
        my ($cartQuantity, $productid, $itemid, $unitcost, $descn, $attr, $productname, $catid) = @$rowRef;
        my @row;
        push @row, $itemid;
        push @row, 999;
        push @row, $itemid;
        push @row, $attr;
        push @row, $cartQuantity;
        push @row, $productid;
        push @row, $unitcost;
        push @row, "";
        push @row, $productname;
        push @row, $catid;
        push @row, "888888";
        push @result, \@row;
    }

    my @columnNames = ("ITEMOID", "ITEMQUANTITY", "ITEMID", "ITEMNAME", "QUANTITY", "PRODUCTOID", "LISTPRICE", "DESCRIPTION", "NAME", "CATEGORYOID", "COLOR");

    return AMF::Perl::Util::Object->pseudo_query(\@columnNames, \@result);
}

sub getCartTotal
{
    my ($self, $cartid) = @_;
    my ($count, $total);

    my $ary_ref = $self->dbh->selectall_arrayref("SELECT unitcost, quantity FROM cart_details a, item_details b WHERE a.itemid=b.itemid AND a.cartid='$cartid'");
    foreach my $rowRef (@$ary_ref)
    {
        my ($unitcost, $quantity) = @$rowRef;
        $total += $quantity * $unitcost;
        $count += $quantity;
    }

    my $result = new AMF::Perl::Util::Object;
    $result->{total} = $total;
    $result->{count} = $count;
    return $result;
}

sub addCartItem
{
    my ($self, $cartid, $itemid, $quantity) = @_;
    $self->dbh->do("INSERT INTO cart_details SET cartid='$cartid', itemid='$itemid', quantity=$quantity");
    my $result = $self->getCartTotal($cartid);
    $result->{"itemoid"} = $itemid;
    return $result;
}

sub updateCartItem
{
    my ($self, $cartid, $itemid, $quantity) = @_;
    $self->deleteCartItem($cartid, $itemid);
    return $self->addCartItem($cartid, $itemid, $quantity);
}

sub deleteCartItem
{
    my ($self, $cartid, $itemid) = @_;
    $self->dbh->do("DELETE FROM cart_details WHERE cartid='$cartid' AND itemid='$itemid'");
    my $result = $self->getCartTotal($cartid);
    $result->{"itemoid"} = $itemid;
    return $result;
}

1;

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

package petmarket::api::catalogservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/amfperl for more information.

use warnings;
use strict;

use petmarket::api::dbConn;

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

            "access" => "remote", 
	    "returns" => "AMFObject"
        },
    };
    
}

sub getCategories
{
    my ($self) = @_;
    my @result;
    my $ary_ref = $self->dbh->selectall_arrayref("SELECT catid, name FROM category_details");
    foreach my $rowRef (@$ary_ref)
    {
        my ($catid, $name) = @$rowRef;
        my @row;
        push @row, $catid;
        push @row, $name;
        push @row, lc $name;
        push @row, "888888";
        push @result, \@row;
    }

    my @columnNames = ("CATEGORYOID", "CATEGORYDISPLAYNAME", "CATEGORYNAME", "COLOR");

    return Flash::FLAP::Util::Object->pseudo_query(\@columnNames, \@result);
}


sub getProducts
{
    my ($self, $catid) = @_;
    my @result;
    my $ary_ref = $self->dbh->selectall_arrayref("SELECT catid, a.productid, name, image, descn FROM product a, product_details b WHERE a.productid=b.productid AND catid='$catid'");
    foreach my $rowRef (@$ary_ref)
    {
        my ($catid, $productid, $name, $image, $descn) = @$rowRef;
        my @row;
        push @row, $catid;
        push @row, $productid;
        push @row, $productid;
        push @row, $name;
        push @row, $image;
        push @row, $descn;
        push @result, \@row;
    }

    my @columnNames = ("CATEGORYOID", "PRODUCTOID", "PRODUCTID", "NAME", "IMAGE", "DESCRIPTION");

    return Flash::FLAP::Util::Object->pseudo_query(\@columnNames, \@result);
}


sub getItems
{
    my ($self, $productid) = @_;
    my @result;
    my $ary_ref = $self->dbh->selectall_arrayref("SELECT a.productid, a.itemid, unitcost, b.descn, attr1, c.name FROM item a, item_details b, product_details c WHERE a.itemid=b.itemid AND a.productid=c.productid AND c.productid='$productid'");
    foreach my $rowRef (@$ary_ref)
    {
        my ($productid, $itemid, $unitcost, $descn, $attr, $productname) = @$rowRef;
        my @row;
        push @row, $itemid;
        push @row, $itemid;
        push @row, $attr;
        push @row, 999;
        push @row, $productid;
        push @row, $unitcost;
        push @row, $descn;
        push @row, $productname;
        push @row, $productid;
        push @result, \@row;
    }

    my @columnNames = ("ITEMOID", "ITEMID", "ITEMNAME", "QUANTITY", "PRODUCTIOID", "LISTPRICE", "DESCRIPTION", "NAME", "CATEGORYOID");

    return Flash::FLAP::Util::Object->pseudo_query(\@columnNames, \@result);
}

sub searchProducts
{
    my ($self, $query) = @_;
    my @result;

    my @catids;
    my $ary_ref = $self->dbh->selectall_arrayref("SELECT a.catid  FROM category a, category_details b WHERE a.catid=b.catid AND b.name like '%$query%'");
    foreach my $rowRef (@$ary_ref)
    {
        my ($catid) = @$rowRef;
        push @catids, $catid;
    }

    @catids = map {"'$_'"} @catids;

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

    foreach my $rowRef (@$ary_ref)
    {
        my ($productid, $productName, $catid, $catName) = @$rowRef;
        my @row;
        push @row, $productid;
        push @row, $productName;
        push @row, $catid;
        push @row, "8888";
        push @row, lc $catName;
        push @row, $catName;
        push @result, \@row;
    }

    my @columnNames = ("PRODUCTOID", "NAME", "CATEGORYOID", "COLOR", "CATEGORYNAME", "CATEGORYDISPLAYNAME");

    return Flash::FLAP::Util::Object->pseudo_query(\@columnNames, \@result);
}


1;

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

package petmarket::api::dbConn;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/amfperl for more information.

use warnings;
no warnings "uninitialized";
use strict;

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

package petmarket::api::orderservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/amfperl for more information.

use warnings;
use strict;

use petmarket::api::dbConn;

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

package petmarket::api::stringresourcesservice;


# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/amfperl for more information.

use warnings;
use strict;

my %bundle;

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

    my ($self, $locale) = @_;

    unless (%bundle) 
    {
        my %strings; 

        $strings{"HOME_MODE_TITLE_str"}="Home";
        $strings{"BROWSE_MODE_TITLE_str"}="Browse";
        $strings{"CHECKOUT_MODE_TITLE_str"}="Checkout";
        $strings{"WELCOME_PREFIX_HD_str"}="Welcome to ";
        $strings{"WELCOME_BODY_str"}="Welcome to your online source for pets and pet supplies. Whether you're looking for information or ready to buy, we've created a fun and easy shopping experience. The site is tailored to your interests, so as you...
        $strings{"CHOOSE_ITEM_HINT_str"}="Choose your pet from the list above!";
        $strings{"ADD_ITEM_TO_CART_HINT_str"}="Press the button below or drag this item to your cart!";
        $strings{"ITEM_UNAVAILABLE_HINT_str"}="Unfortunately, we're currently out of stock, please check back soon.";
        $strings{"SEARCH_NO_RESULTS_FOUND_FOR_str"}="no results found for: ";
        $strings{"QTY_AVAILABLE_LBL_str"}="Quantity Available:";
        $strings{"CURRENCY_SYMBOL_str"}="\$";
        $strings{"CURRENCY_DECIMAL_str"}=".";
        $strings{"THOUSANDS_SEPARATOR_str"}="}=";
        $strings{"ITEM_LBL_str"}="Item";
        $strings{"PRICE_LBL_str"}="Price";
        $strings{"QTY_AVAILABLE_LBL_str"}="Qty Available";
        $strings{"QTY_LBL_str"}="Qty";
        $strings{"PRODUCT_LBL_str"}="Product";
        $strings{"ITEMS_IN_CART_LBL_str"}="Items:";
        $strings{"CART_SUBTOTAL_LBL_str"}="Subtotal:";
        $strings{"ADVERT_COPY_DEFAULT_str"}="Keep your pets healthy and happy with\n Pet Market brand pet foods.";
        $strings{"ADVERT_COPY_CONTEXT_str"}="Keep your pet healthy! Try our special formula of pet foods, available in assorted sizes and flavors.";
        $strings{"OK_BTN_LBL_str"}="OK";
        $strings{"EXCEEDS_AVAILABLE_MB_MSG_str"}="The quantity you entered exceeds the number we currently have available. The quantity will be automatically reset to the maximum available at this time.";
        $strings{"EXCEEDS_AVAILABLE_MB_TTL_str"}="Quantity Available Exceeded";
        $strings{"REQUIRED_FIELD_INDICATOR_str"}="*";
        $strings{"ERROR_FIELD_INDICATOR_str"}="<";
        $strings{"NUMBER_SYMBOL_str"}="-";
        $strings{"DATE_SEPARATOR_str"}="/";
        $strings{"ADDRESS_LBL_str"}="Address:";
        $strings{"CITY_LBL_str"}="City:";
        $strings{"STATE_LBL_str"}="State:";
        $strings{"ZIP_LBL_str"}="Zip / Postal Code:";
        $strings{"EMAIL_LBL_str"}="E-mail:";
        $strings{"PHONE_LBL_str"}="Phone:";
        $strings{"CC_NUMBER_LBL_str"}="Credit Card Number:";
        $strings{"CC_EXPIRATION_DATE_LBL_str"}="Expiration Date:";
        $strings{"PROFILE_FLDS_HINT_str"}="If you're a new customer, please provide your email address and a password in order to create your account.  Returning customers, log in using your email address and password.";
        $strings{"PROFILE_FLDS_LOGOUT_1_HINT_str"}="You are currently logged in with the E-mail address: ";
        $strings{"PROFILE_FLDS_LOGOUT_2_HINT_str"}="If this is not correct, you may log in to your existing account or create a new one.";
        $strings{"PROFILE_FLDS_LOGOUT_EDIT_LBL_str"}="Edit";
        $strings{"PASSWORD_LBL_str"}="Password:";
        $strings{"PASSWORD_CONFIRM_LBL_str"}="Confirm Password:";
        $strings{"CREATE_ACCOUNT_BTN_LBL_str"}="Create Account";
        $strings{"LOGIN_BTN_LBL_str"}="Login";
        $strings{"CONTINUE_BTN_LBL_str"}="Continue";
        $strings{"NEW_CUSTOMER_TRUE_RB_LBL_str"}="New Customer";
        $strings{"NEW_CUSTOMER_FALSE_RB_LBL_str"}="Returning Customer";
        $strings{"BILLING_FLDS_HINT_str"}="Please enter your billing address.";
        $strings{"SHIPPING_FLDS_HINT_str"}="Please enter your shipping address.";
        $strings{"USE_THIS_FOR_SHIPPING_CH_LBL_str"}="Use this address for shipping";
        $strings{"USE_BILLING_FOR_SHIPPING_CH_LBL_str"}="Use billing address for shipping";
        $strings{"EDIT_LBL_str"}="Edit";
        $strings{"CHECKOUT_USER_HD_str"}="1) Welcome";
        $strings{"CHECKOUT_BILLING_HD_str"}="2) Customer Details / Billing Address";
        $strings{"CHECKOUT_SHIPPING_HD_str"}="3) Shipping Address";
        $strings{"CHECKOUT_SHIPPING_METHOD_HD_str"}="4) Shipping Options & Promotions";
        $strings{"CHECKOUT_PAYMENT_HD_str"}="5) Payment Method & Confirmation";
        $strings{"SHIPPING_METHODS_FLDS_HINT_str"}="Please select your preferred shipping method.  If you were provided a promotional code, enter it here.";
        $strings{"SHIPPING_METHOD_LBL_str"}="Shipping Method:";
        $strings{"PROMOTION_CODE_LBL_str"}="Promotion Code:";
        $strings{"EST_DELIVERY_DATE_LBL_str"}="Estimated delivery date:";
        $strings{"CHECKOUT_SUBMIT_BTN_LBL_str"}="Place Order";
        $strings{"PAYMENT_METHOD_LBL_str"}="Credit Card Type:";
        $strings{"PAYMENT_METHODS_HINT_str"}="Please review the billing and shipping information you entered above.  Make changes by clicking the Edit button.\n\nComplete your purchase by clicking the Place Order button.";
        $strings{"CHECKOUT_EXIT_BTN_LBL_str"}="Exit Checkout";

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

        $strings{"CHARGE_SUMMARY_PROMOTIONS_LBL_str"}="Promotions:";
        $strings{"CHARGE_SUMMARY_SHIPPING_LBL_str"}="Shipping Charges:";
        $strings{"CHARGE_SUMMARY_TAX_LBL_str"}="Taxes:";
        $strings{"CHARGE_SUMMARY_GRAND_TOTAL_LBL_str"}="Total Charges:";
        $strings{"VALIDATE_EMAIL_ERR_TITLE_str"}="E-mail not valid";
        $strings{"VALIDATE_EMAIL_ERR_MSG_str"}="E-mail entered is not valid.\nPlease try again.";
        $strings{"VALIDATE_PASS_ERR_TITLE_str"}="Password invalid";
        $strings{"VALIDATE_PASS_MISMATCH_ERR_MSG_str"}="Passwords do not match.\nPlease try again.";
        $strings{"VALIDATE_PASS_INVALID_ERR_MSG_str"}="Invalid password.\nPlease try again.";
        $strings{"VALIDATE_CREATE_USER_FAILED_TITLE_str"}="Failed to create user";
        $strings{"VALIDATE_CREATE_USER_FAILED_MSG_str"}="An account using this E-mail address already exists.";
        $strings{"VALIDATE_LOGIN_USER_FAILED_TITLE_str"}="Failed to log in";
        $strings{"VALIDATE_LOGIN_USER_FAILED_MSG_str"}="Unable to log in.\nPlease check the E-mail address and password and try again.";
        $strings{"VALIDATE_FIRST_NAME_ERROR_MSG_str"}="Please type in your first name.";
        $strings{"VALIDATE_FIRST_NAME_ERROR_TITLE_str"}="Invalid first name";
        $strings{"VALIDATE_LAST_NAME_ERROR_MSG_STR"}="Please type in your last name.";
        $strings{"VALIDATE_LAST_NAME_ERROR_TITLE_STR"}="Invalid last name";
        $strings{"VALIDATE_ADDRESS_ERROR_MSG_str"}="Please type in an address.";
        $strings{"VALIDATE_ADDRESS_ERROR_TITLE_str"}="Invalid address";
        $strings{"VALIDATE_CITY_ERROR_MSG_str"}="Please type in a city.";
        $strings{"VALIDATE_CITY_ERROR_TITLE_str"}="Invalid city";
        $strings{"VALIDATE_ZIPCODE_ERROR_MSG_str"}="Please enter a valid 5 digit Zip code.";
        $strings{"VALIDATE_ZIPCODE_ERROR_TITLE_str"}="Invalid Zip code";
        $strings{"VALIDATE_PHONE_ERROR_MSG_str"}="Please enter a valid 10 digit telephone number.";
        $strings{"VALIDATE_PHONE_ERROR_TITLE_str"}="Invalid phone number";
        $strings{"VALIDATE_SELECT_CC_TYPE_ERROR_MSG_str"}="Please select a credit card from the list.";
        $strings{"VALIDATE_SELECT_CC_MO_ERROR_MSG_str"}="Please select a credit card expiry month from the list.";
        $strings{"VALIDATE_SELECT_CC_YR_ERROR_MSG_str"}="Please select a credit card expiry year from the list.";
        $strings{"VALIDATE_CC_EXPIRED_ERROR_MSG_str"}="Please select a credit card expiry date that is not in the past.";
        $strings{"VALIDATE_INVALID_CC_ERROR_MSG_str"}="Invalid credit card number.  Please enter valid credit card number.";
        $strings{"VALIDATE_PAYMENT_ERROR_TITLE_str"}="Payment Method Error";
        $strings{"CREATE_USER_PROGRESS_TITLE_str"}="Creating account";
        $strings{"CREATE_USER_PROGRESS_MSG_str"}="Account creation in progress, please wait.";
        $strings{"LOGIN_USER_PROGRESS_TITLE_str"}="Logging in";
        $strings{"LOGIN_USER_PROGRESS_MSG_str"}="Login in progress, please wait.";
        $strings{"SUBMITTING_ORDER_PROGRESS_TITLE_str"}="Submitting order";
        $strings{"SUBMITTING_USER_PROGRESS_MSG_str"}="Order submission in progress: sending user data.\n\nPlease wait.";
        $strings{"SUBMITTING_ORDER_PROGRESS_MSG_str"}="Order submission in progress: sending order info.\n\nPlease wait.";
        $strings{"CONFIRM_ORDER_TITLE_str"}="Thank You";
        $strings{"CONFIRM_ORDER_MSG_str"}="Thank you for shopping at Pet Market.  If this were a real pet store, your order would be completed.";
        $strings{"AFFILIATE_BTN_LBL_str"}="affiliate program";
        $strings{"LEGAL_NOTICES_BTN_LBL_str"}="legal notices";
        $strings{"ABOUT_US_BTN_LBL_str"}="about us";
        $strings{"HOME_BTN_LBL_str"}="home";
        $strings{"EXP_MONTH_CHOOSE_str"}="Month...";
        $strings{"EXP_YEAR_CHOOSE_str"}="Year...";
        

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

    $strings{"url"} = "http://www.macromedia.com";
    
    return \%strings;
}

sub getLegalStrings()
{
    my ($self) = @_;
    my %strings;
    $strings{"HEAD_str"} = "LEGAL INFORMATION";
    $strings{"BODY_HTML_str"} = "Copyright © 2001-2002 Macromedia, Inc.  All rights reserved.  Macromedia, the Macromedia logo, and Flash are trademarks or registered trademarks of Macromedia, Inc.\n \nMany of the images used in this experience were ...
    $strings{"logoFrameLabel"} = "macr";
    $strings{"url"} = "http://www.macromedia.com";
    
    return \%strings;
}


sub getAffiliateStrings()
{
    my ($self) = @_;

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

package petmarket::api::userservice;

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

#This is server side for the Macromedia's Petmarket example.
#See http://www.simonf.com/amfperl for more information.

use warnings;
use strict;

use petmarket::api::dbConn;

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


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

sub addUser
{
    my ($self, $email, $password) = @_;
	
    $self->dbh->do("INSERT INTO user_details set email='$email', password='$password'");

    my $result = new AMF::Perl::Util::Object;
    $result->{"useroid"} = $email;
    $result->{"email"} = $email;
    $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 = "";

doc/examples/sql/DataGlue.as  view on Meta::CPAN

}

_global.DataGlue.prototype.getLength = function()
{
	return this.dataProvider.getLength();
}

_global.DataGlue.prototype.format = function(formatString, record)
{
	var tokens = formatString.split("#");
	var result = "";
	for (var i = 0; i < tokens.length; i += 2)
	{
		result += tokens[i];
		result += (tokens[i+1] == "") ? "#" : record[tokens[i+1]];
	}	
	return result;
}

_global.DataGlue.getItemAt_FormatString = function(index)
{
	var record = this.dataProvider.getItemAt(index);
	if (record == "in progress" || record==undefined)
		return record;
	return {label: this.format(this.labelString, record), data: (this.dataString == null) ? record : this.format(this.dataString, record)};
}

_global.DataGlue.getItemAt_FormatFunction = function(index)
{	
	var record = this.dataProvider.getItemAt(index);
	if (record == "in progress" || record==undefined)
		return record;
	return this.formatFunction(record);
}

_global.DataGlue.prototype.getItemID = function(index)
{
	return this.dataProvider.getItemID(index);
}

_global.DataGlue.prototype.addItemAt = function(index, value)

doc/examples/sql/park.pl  view on Meta::CPAN

#!/usr/bin/perl -w

# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

#This is a server-side script that responds to an Macromedia Flash client
#talking in ActionScript. See the AMF::Perl project site (http://www.simonf.com/amfperl)
#for more information.

use strict;
use AMF::Perl;

my $gateway = AMF::Perl->new;
$gateway->setBaseClassPath("./parkservices/");
$gateway->debugDir("/tmp");
$gateway->service();

doc/examples/sql/park.sql  view on Meta::CPAN

INSERT INTO tblparks VALUES ('ARCHES NATIONAL PARK','P.O. BOX 907','','','MOAB','UT','84532','801-259-8161','ROCKY MOUNTAIN REGION','Poe, Noel','8:00 AM TO 4:30 PM','04/12/1929','NATIONAL PARK');
INSERT INTO tblparks VALUES ('ARLINGTON HOUSE, THE ROBERT E. LEE MEM','C/O GEORGE WASHINGTON MEMORIAL PARKWAY','TURKEY RUN PARK','','MCLEAN','VA','22101','703-557-3154','National Capital Region','VACANT','9:00 AM TO 5:00 PM','06/29/1955','National Me...
INSERT INTO tblparks VALUES ('ASSATEAGUE ISLAND NATIONAL SEASHORE','ROUTE 611','7206 NATIONAL SEASHORE LANE','','BERLIN','MD','21811','410-641-1441','MID-ATLANTIC REGION','KOENINGS, MARC A.','8:00 AM TO 5:00 PM','08/09/1985','NATIONAL SEASHORE');
INSERT INTO tblparks VALUES ('BADLANDS NATIONAL PARK','P.O. BOX 6','','','INTERIOR','SD','57750','605-433-5361','Rocky Mountain Region','Mortenson, Irvin L.','','01/25/1939','National Park');
INSERT INTO tblparks VALUES ('BANDELIER NATIONAL MONUMENT','HCRI, BOX 1, SUITE 15','','','LOS ALAMOS','NM','87544','505-672-3861','SOUTHWEST REGION','WEAVER, ROY W.','8:00 AM TO 5:00 PM','02/25/1932','NATIONAL MONUMENT');
INSERT INTO tblparks VALUES ('BATTLEGROUND NATIONAL CEMETERY','C/O SUPT, NATL CAP PK-EAST','5210 INDIAN HEAD HGWY','','OXON HILL','MD','20021','301-472-9227','NATIONAL CAPITAL REGION','None','','  /  /19','NATIONAL CEMETERY');
INSERT INTO tblparks VALUES ('BENJAMIN FRANKLIN NATIONAL MEMORIAL','C/O THE FRANKLIN INSTITUTE','20TH ST AND BENJAMIN FRANKLIN PKWY','','PHILADELPHIA','PA','19103','215-448-1000','MID-ATLANTIC REGION','None','','  /  /19','NATIONAL MEMORIAL');
INSERT INTO tblparks VALUES ('BENT\'S OLD FORT NATIONAL HISTORIC SITE','35110 HIGHWAY 194 EAST','','','LA JUNTA','CO','81050-9523','719-384-2596','ROCKY MOUNTAIN REGION','Hill, Donald C.','8:00 AM TO 4:30 PM','03/15/1963','NATIONAL HISTORICAL SITE');...
INSERT INTO tblparks VALUES ('BIG BEND NATIONAL PARK','P.O BOX 129','','','BIG BEND NATIONAL PARK','TX','79834-129','915-477-2251','Southwest Region','JOSE CISNEROS','8:00 AM TO 5:00 PM','06/12/1944','National Park');
INSERT INTO tblparks VALUES ('BIG HOLE NATIONAL BATTLEFIELD','P.O. BOX 237','WISDOM, MT  59761-0237','','DEER LODGE','MT','59761-0237','406-689-3155','Pacific Northwest Region','BUCHEL, SUSAN','8:00 AM TO 5:00 PM','06/23/1910','National Battlefield')...
INSERT INTO tblparks VALUES ('BIG THICKET NATIONAL PRESERVE','3785 MILAM','','','BEAUMONT','TX','77701','409-839-2689','Southwest Region','VACANT','8:00 AM TO 4:30 PM','  /  /19','National Preserve');
INSERT INTO tblparks VALUES ('BIGHORN CANYON NATIONAL RECREATION AREA','P.O. BOX 7458','','','FORT SMITH','MT','59035-7458','406-666-2412','Rocky Mountain Region','COOK, DARRELL J.','8:00 AM TO 5:00 PM','10/15/1966','National Recreation Area');
INSERT INTO tblparks VALUES ('BLACK CANYON OF THE GUNNISON NM','2233 EAST MAIN STREET','','','MONTROSE','CO','81401','303-249-7036','Rocky Mountain Region','Welch, John E.','8:00 AM TO 4:30 PM','03/03/1933','National Monument');
INSERT INTO tblparks VALUES ('BLACKSTONE RIVER VALLEY','NATIONAL HERITAGE CORRIDOR','15 MENDON STREET','P.O. BOX 730','UXBRIDGE','MA','01569','508-278-9400','NORTH ATLANTIC REGION','PEPPER, JAMES R.','8:00 AM TO 5:00 PM','  /  /19','MISCELLANEOUS');
INSERT INTO tblparks VALUES ('BLUESTONE NATIONAL SCENIC RIVER','C/O NEW RIVER GORGE NATIONAL RIVER','P.O. BOX 246','','GLEN JEAN','WV','25846-0246','304-465-0508','MID-ATLANTIC REGION','KENNEDY, JOE L.','8AM TO 4:30PM','10/26/1988',NULL);
INSERT INTO tblparks VALUES ('BOOKER T. WASHINGTON NATIONAL MONUMENT','12130 Booker T. Washington Highway','','','HARDY','VA','24101','703-721-2094','Mid-Atlantic Region','HARRIETT, REBECCA','8:30 AM TO 5:00 PM','04/02/1956','National Monument');
INSERT INTO tblparks VALUES ('BOSTON AFRICAN-AMERICAN NHS','46 JOY STREET','BEACON HILL','','BOSTON','MA','02144','617-742-5415','North Atlantic Region','Heidelberg, Kenneth A.','8:00 AM TO 5:00 PM','  /  /19',NULL);
INSERT INTO tblparks VALUES ('BOSTON NATIONAL HISTORICAL PARK','CHARLESTOWN NAVY YARD','','','BOSTON','MA','02129','617-242-5644','NORTH ATLANTIC REGION','Burchill, John J.','8:00 AM TO 5:00 PM','  /  /19','NATIONAL HISTORICAL PARK');
INSERT INTO tblparks VALUES ('BRYCE CANYON NATIONAL PARK','','','','BRYCE CANYON','UT','84717','801-834-5322','ROCKY MOUNTAIN REGION','Fagergren, Fred J.','8:00 AM TO 5:00 PM','02/25/1928','NATIONAL PARK');
INSERT INTO tblparks VALUES ('BUFFALO NATIONAL RIVER','P.O. BOX 1173','','','HARRISON','AR','72602-1173','501-741-5443','SOUTHWEST REGION','LINAHAN, JOHN D.','8:00 AM TO 5:00 PM','03/01/1972','NATIONAL (WILD/SCENIC) RIVER (WAY)');
INSERT INTO tblparks VALUES ('BUFFALO NATIONAL RIVER LAND ACQ OFFICE','P.O. BOX 1073','','','HARRISON','AR','72602','501-741-7637','SOUTHWEST REGION','Adams, Andrew A.','8:00 AM TO 4:30 PM','  /  /19','LAND RESOURCES OFFICE');

doc/examples/sql/park.sql  view on Meta::CPAN

INSERT INTO tblparks VALUES ('CURECANTI NATIONAL RECREATION AREA','102 ELK CREEK','','','GUNNISON','CO','81230','303-641-2337','ROCKY MOUNTAIN REGION','CHAPMAN, JOHN','8:00 AM TO 4:30 PM','02/11/1965','RECREATION AREA');
INSERT INTO tblparks VALUES ('CUYAHOGA VALLEY NATIONAL RECREATION AREA','15610 VAUGHN ROAD','','','BRECKSVILLE','OH','44141','216-526-5256','MIDWEST REGION','DEBO, JOHN P., JR.','8:00 AM TO 5:00 PM','06/26/1975','NATIONAL RECREATION AREA');
INSERT INTO tblparks VALUES ('DAVID BERGER NATIONAL MEMORIAL','C/O CUYAHOGA VALLEY NATL REC AREA','15610 VAUGHN ROAD','','BRECKSVILLE','OH','44141','216-526-5256','MIDWEST REGION','NONE','','03/05/1980','NATIONAL MEMORIAL');
INSERT INTO tblparks VALUES ('DAYTON AVIATION HERITAGE NHP','P.O. BOX 9280','WRIGHT BROTHERS STATION','','DAYTON','OH','45409','513-225-7705','Midwest Region','GIBSON, WILLIAM','8:00 AM - 5:00PM','10-02-1992','National Historical Site');
INSERT INTO tblparks VALUES ('DE SOTO NATIONAL MEMORIAL','P.O. BOX 15390','','','BRADENTON','FL','34280-5390','813-792-0458','Southeast Region','GOODMAN, BARBARA','8:00 AM TO 5:00 PM','08/05/1949','National Memorial');
INSERT INTO tblparks VALUES ('DEATH VALLEY NATIONAL PARK','','','','DEATH VALLEY','CA','92328','619-786-2331','Western Region','Martin, Richard H.','7:30 AM TO 4:30 PM','02/11/1933','National Park');
INSERT INTO tblparks VALUES ('DELAWARE & LEHIGH COMMISSION','10 EAST CHURCH STREET','ROOM P-208','','BETHLEHEM','PA','18018','610-861-9345','Mid-Atlantic Region','WITMER, DAVID B.','8:00 AM TO 4:45 PM','  /  /19',NULL);
INSERT INTO tblparks VALUES ('DELAWARE NATIONAL SCENIC RIVER','C/O DELAWARE WATER GAP NRA','','','BUSHKILL','PA','18324','717-588-6637','MID-ATLANTIC REGION','None','','11/10/1978','NATIONAL (WILD/SCENIC) RIVER (WAY)');
INSERT INTO tblparks VALUES ('DELAWARE WATER GAP NAT RECREATION AREA','','','','BUSHKILL','PA','18324','717-588-2435','MID-ATLANTIC REGION','RECTOR, ROGER K.','8:00 AM TO 5:00 PM','09/01/1965','NATIONAL RECREATION AREA');
INSERT INTO tblparks VALUES ('DENALI NATIONAL PARK','P.O. BOX 9','','','MCKINLEY PARK','AK','99755','907-683-2294','Alaska Region','VACANT','8:00 AM TO 4:30 PM','02/26/1917','National Park');
INSERT INTO tblparks VALUES ('DENALI NATIONAL PRESERVE','P.O. BOX 9','','','MCKINLEY PARK','AK','99755','907-683-2294','Alaska Region','VACANT','8:00 AM TO 4:30 PM','12/02/1980','National Preserve');
INSERT INTO tblparks VALUES ('DEVILS POSTPILE NATIONAL MONUMENT','C/O SEQUOIA & KINGS CANYON NATL PARKS','','','THREE RIVERS','CA','93271','619-934-2289','WESTERN REGION','Eckhardt, Wymond W.','8:00 AM TO 5:00 PM','07/06/1911','NATIONAL MONUMENT');
INSERT INTO tblparks VALUES ('DEVILS TOWER NATIONAL MONUMENT','P.O. BOX 10','','','DEVILS TOWER','WY','82714-0010','307-467-5283','Rocky Mountain Region','LIGGETT, DEBORAH','8:00 AM TO 4:30 PM','09/24/1906','National Monument');
INSERT INTO tblparks VALUES ('DINOSAUR NATIONAL MONUMENT','4545 HIGHWAY 40','','','DINOSAUR','CO','52146-7519','303-374-2216','Rocky Mountain Region','HUFFMAN, DENNIS K.','8:00 AM TO 4:30 PM','10/04/1915','National Monument');
INSERT INTO tblparks VALUES ('EASTERN FIELD ARCHEOLOGY CENTER','CHARLESTOWN NAVY YARD','BUILDING 28','','BOSTON','MA','02129','617-242-1979','NORTH ATLANTIC REGION','Harrison, Myra F.','7:45 AM TO 5:15 PM','  /  /19','SERVICE/TRAINING/ARCHEOL CENTER'...
INSERT INTO tblparks VALUES ('EDGAR ALLAN POE NATIONAL HISTORIC SITE','C/O INDEPENDENCE NHP','313 WALNUT STREET','','PHILADELPHIA','PA','19106','215-597-7120','MID-ATLANTIC REGION','Aikens, Martha','8:00 AM TO 5:00 PM','  /  /19','NATIONAL HISTORICAL...
INSERT INTO tblparks VALUES ('EDISON NATIONAL HISTORIC SITE','MAINSTREET AND LAKESIDE AVENUE','','','WEST ORANGE','NJ','07052','201-736-0550','NORTH ATLANTIC REGION','GERBAUCKAS, MARYANNE','8:00 AM TO 5:00 PM','12/06/1955','NATIONAL HISTORICAL SITE')...
INSERT INTO tblparks VALUES ('EFFIGY MOUNDS NATIONAL MONUMENT','151 HWY 76','','','HARPERS FERRY','IA','52146-7519','319-873-3491','Midwest Region','GUSTIN, KAREN','8:00 AM TO 5:00 PM','10/25/1949','National Monument');
INSERT INTO tblparks VALUES ('EISENHOWER NATIONAL HISTORIC SITE','97 TANEYTOWN RD','','','GETTYSBURG','PA','17325-2804','717-338-9114','Mid-Atlantic Region','ROACH, JAMES C.','8:00 AM TO 5:00 PM','12/02/1969','National Historical Site');
INSERT INTO tblparks VALUES ('EL MALPAIS NATIONAL MONUMENT','P.O. BOX 939','201 E. ROOSEVELT','','GRANTS','NM','87020','505-285-4641','SOUTHWEST REGION','EURY, DOUGLAS E.','8:00 - 5:00 PM','  /  /19','NATIONAL MONUMENT');
INSERT INTO tblparks VALUES ('EL MORRO NATIONAL MONUMENT','ROUTE 2, P.O. BOX 43','','','RAMAH','NM','87321-9603','505-783-4226','Southwest Region','PELLETIER, MICHELLE C.','8:00 AM TO 5:00 PM','12/08/1906','National Monument');

doc/examples/sql/park.sql  view on Meta::CPAN

INSERT INTO tblparks VALUES ('NATIONAL CAPITAL PARKS-CENTRAL','900 OHIO DRIVE, S.W.','','','WASHINGTON','DC','20242','202-485-9880','NATIONAL CAPITAL REGION','Goldstein, Arnold M.','7:45 AM TO 4:15 PM','08/10/1933','ADMINISTRATIVE OFFICE');
INSERT INTO tblparks VALUES ('NATIONAL PARK SERVICE','U.S. DEPARTMENT OF THE INTERIOR','P.O. BOX 37127','','WASHINGTON','DC','20013-7127','202-208-4621','WASHINGTON OFFICE','KENNEDY, ROGER G.','7:45 AM TO 4:15 PM','08/25/1916','WASHINGTON OFFICE');
INSERT INTO tblparks VALUES ('NATURAL BRIDGES NATIONAL MONUMENT','BOX 1 - NATURAL BRIDGES','','','LAKE POWELL','UT','84533-0101','801-259-5174','Rocky Mountain Region','CHANEY, STEVE','8:00 AM TO 4:30 PM','04/16/1908','National Monument');
INSERT INTO tblparks VALUES ('NAVAJO NATIONAL MONUMENT','HC 71, BOX 3','','','TONALEA','AZ','86044-9704','520-672-2366','Southwest Region','FENDER, ANNA MARIE','8:00 AM TO 5:00 PM','03/20/1909','National Monument');
INSERT INTO tblparks VALUES ('NEW JERSEY COASTAL HERITAGE TRAIL','P.O. BOX 118','','','MAURICETOWN','NJ','08329','609-785-0676','NORTH ATLANTIC','JANET C. WOLF','8:30 TO 5:00','11/30/1987',NULL);
INSERT INTO tblparks VALUES ('NEW RIVER GORGE LAND RESOURCES OFFICE','P.O. BOX 1146','101 KELLY AVENUE','','OAK HILL','WV','25901-1146','304-465-5629','MID-ATLANTIC REGION','Reed, John C.','8:00 AM TO 4:30 PM','  /  /19','LAND RESOURCES OFFICE');
INSERT INTO tblparks VALUES ('NEW RIVER GORGE NATIONAL RIVER','104 MAIN STREET','P.O. BOX 246','','GLEN JEAN','WV','25846-0246','304-465-0508','MID-ATLANTIC REGION','KENNEDY, JOE L.','8:00 AM TO 4:30 PM','11/10/1978','NATIONAL (WILD/SCENIC) RIVER (WA...
INSERT INTO tblparks VALUES ('NEZ PERCE NATIONAL HISTORICAL PARK','P.O. BOX 93','','','SPALDING','ID','83551','208-843-2261','PACIFIC NORTHWEST REGION','WALKER, FRANK','8:00 AM TO 5:00 PM','05/19/1970','NATIONAL HISTORICAL PARK');
INSERT INTO tblparks VALUES ('NINETY SIX NATIONAL HISTORIC SITE','P.O. BOX 496','','','NINETY SIX','SC','29666','803-543-4068','SOUTHEAST REGION','Armstrong, Robert S.','8:00 AM TO 5:00 PM','02/01/1982','NATIONAL HISTORICAL SITE');
INSERT INTO tblparks VALUES ('NIOBRARA/MISSOURI NATIONAL RIVERWAYS','P.O. BOX 591','','','O\'NEILL','NE','68763-0591','402-336-3970','MIDWEST REGION','HILL, WARREN H.','8:00 AM TO 5:00 PM','05/24/1991',NULL);
INSERT INTO tblparks VALUES ('NOATAK NATIONAL PRESERVE','P.O. BOX 1029','','','KOTZEBUE','AK','99752','907-442-3890','Alaska Region','BOB GERHARD','8:00 AM TO 4:30 PM','12/02/1980','National Preserve');
INSERT INTO tblparks VALUES ('NORTH ATLANTIC HISTORIC PRES CENTER','BUILDING 28','CHARLESTOWN NAVY YARD','','BOSTON','MA','02129','617-242-1977','NORTH ATLANTIC REGION','Cliver, E. Blaine','8:00 AM TO 4:30 PM','06/06/1976','SERVICE/TRAINING/ARCHEOL C...
INSERT INTO tblparks VALUES ('NORTH ATLANTIC REGIONAL OFFICE','NATIONAL PARK SERVICE','15 STATE STREET','','BOSTON','MA','02109-3572','617-223-5200','NORTH ATLANTIC REGION','RUST, MARIE (ACTG)','8:00 AM TO 4:30 PM','12/01/1973','REGIONAL OFFICE');
INSERT INTO tblparks VALUES ('NORTH CASCADES NATIONAL PARK','2105 HIGHWAY 20','','','SEDRO WOOLLEY','WA','98284-9314','206-856-5700','PACIFIC NORTHWEST REGION','PALECK, WILLIAM','8:00 AM TO 5:00 PM','10/02/1968','NATIONAL PARK');
INSERT INTO tblparks VALUES ('NORTH COUNTRY NATIONAL SCENIC TRAIL','700 RAYOVAC DRIVE, SUITE 100','','','MADISON','WI','53711','608-264-5610','Midwest Region','Gilbert, Thomas L.','8:00 AM TO 4:30 PM','03/05/1980','National Trail');
INSERT INTO tblparks VALUES ('NORTHWEST ALASKA AREAS','NATIONAL PARK SERVICE','P.O. BOX 1029','','KOTZEBUE','AK','99752','907-442-3890','Alaska Region','BOB GERHARD','8:00 AM TO 5:00 PM','07/27/1982','Group Office');
INSERT INTO tblparks VALUES ('OBED WILD & SCENIC RIVER','P.O. DRAWER 429','','','WARTBURG','TN','37887','615-346-6294','Southeast Region','E. Lee Davis','8:00 AM TO 4:30 PM','  /  /19','National (Wild/Senic River (Way)');
INSERT INTO tblparks VALUES ('OCMULGEE NATIONAL MONUMENT','1207 EMERY HIGHWAY','','','MACON','GA','31201','912-752-8257','SOUTHEAST REGION','JOHN F. BUNDY','8:30 AM TO 5:00 PM','12/23/1936','NATIONAL MONUMENT');
INSERT INTO tblparks VALUES ('OCONALUFTEE JOB CORPS CIV CONS CTR','200 PARK CIRCLE','','','CHEROKEE','NC','28719-9702','704-497-5411','SOUTHEAST REGION','ROBINSON, DELMAR P.','8:00 AM TO 4:30 PM','10/15/1965','JOB CORPS CENTER');
INSERT INTO tblparks VALUES ('OLD POST OFFICE OBSERVATION TOWER','NATIONAL CAPITAL PARKS - CENTRAL','900 OHIO DRIVE, SW','','WASHINGTON','DC','20242','202-523-5691','NATIONAL CAPITAL REGION','Dodson, Robert','8:00 AM TO 5:00 PM','02/22/1984','MISCELL...
INSERT INTO tblparks VALUES ('OLYMPIC NATIONAL PARK','600 EAST PARK AVENUE','','','PORT ANGELES','WA','98362','206-452-4501','Pacific Northwest Region','MORRIS, DAVID K.','8:00 AM TO 4:30 PM','06/29/1938','National Park');

doc/examples/sql/park.sql  view on Meta::CPAN

INSERT INTO tblparks VALUES ('WILSON\'S CREEK NATIONAL BATTLEFIELD','6424 W. Farm Road 182','','','REPUBLIC','MO','65738-2662','417-732-2662','Midwest Region','BERG, MALCOLM J.','8:30 AM TO 5:00 PM','09/22/1972','National Battlefield');
INSERT INTO tblparks VALUES ('WIND CAVE NATIONAL PARK','RR #1, BOX 190 - WCNP','','','HOT SPRINGS','SD','57747-9430','605-745-4600','Rocky Mountain Region','Jimmy Taylor','8:00 AM TO 4:30 PM','01/09/1903','National Park');
INSERT INTO tblparks VALUES ('WOLF TRAP FARM PARK','FOR THE PERFORMING ARTS','1551 TRAP ROAD','','VIENNA','VA','22182-1643','703-255-1800','National Capital Region','WILT, RICHARD A.','8:30 AM TO 5:00 PM','  /  /19','Site for the Performing Arts');
INSERT INTO tblparks VALUES ('WOMEN\'S RIGHTS NATIONAL HISTORICAL PARK','136 FALL STREET','','','SENECA FALLS','NY','13148','315-568-2991','NORTH ATLANTIC REGION','CANZANELLI, LINDA','9:00 AM TO 5:00 PM','12/28/1980','NATIONAL HISTORICAL PARK');
INSERT INTO tblparks VALUES ('WRANGELL-ST ELIAS NATIONAL PARK','P.O. BOX 439','','','COPPER CENTER','AK','99573-','907-822-5234','Alaska Region','JON JARVIS','8:00 AM TO 5:00 PM','12/02/1980','National Park');
INSERT INTO tblparks VALUES ('WUPATKI NATIONAL MONUMENT','TUBA STAR ROUTE N HWY 89','','','FLAGSTAFF','AZ','86001','520-556-7040','Southwest Region','Henderson, Sam','8:00 AM TO 5:00 PM','12/09/1924','National Monument');
INSERT INTO tblparks VALUES ('YELLOWSTONE NATIONAL PARK','P.O. BOX 168','','','YELLOWSTONE NATIONAL PARK','WY','82190','307-344-7381','Rocky Mountain Region','Barbee, Robert D.','8:00 AM TO 4:30 PM','03-01-1872','National Park');
INSERT INTO tblparks VALUES ('YORKTOWN NATIONAL CEMETERY','C/O COLONIAL NATIONAL HISTORICAL PARK','P.O. BOX 210','','YORKTOWN','VA','23690','804-898-3400','MID-ATLANTIC REGION','None','8:00 AM TO 5:00 PM','07/03/1930','NATIONAL CEMETERY');
INSERT INTO tblparks VALUES ('YOSEMITE NATIONAL PARK','P.O. BOX 577','','','YOSEMITE NATIONAL PARK','CA','95389','209-372-0200','Western Region','Finley, Michael','8:00 AM TO 5:00 PM','10-01-1890','National Park');
INSERT INTO tblparks VALUES ('YUCCA HOUSE NATIONAL MONUMENT','P.O. BOX 8','','','MESA VERDE NATIONAL PARK','CO','81330','303-529-4465','ROCKY MOUNTAIN REGION','Heyder, Robert C.','8:00 AM TO 5:00 PM','12/12/1919','NATIONAL MONUMENT');
INSERT INTO tblparks VALUES ('YUKON-CHARLEY RIVERS NATIONAL PRESERVE','P.O. BOX 74718','','','FAIRBANKS','AK','99707','907-456-0593','Alaska Region','Paul, Guraedy','8:00 AM TO 5:00 PM','12/02/1980','National Preserve');
INSERT INTO tblparks VALUES ('ZION NATIONAL PARK','','','','SPRINGDALE','UT','84767-1099','801-772-3256','ROCKY MOUNTAIN REGION','Falvey, Donald','8:00 AM TO 5:00 PM','11/19/1919','NATIONAL PARK');
INSERT INTO tblparks VALUES ('ZUNI-CIBOLA NATIONAL HISTORICAL PARK','C/O EL MORROW NM','','','RAMAH','NM','87321','','SOUTHWEST REGION','(VACANT)','','10/31/1988','NATIONAL HISTORICAL PARK');
INSERT INTO tblparks VALUES ('ABRAHAM LINCOLN BIRTHPLACE NHS','2995 LINCOLN FARM ROAD','','','HODGENVILLE','KY','42748-','502-358-3874','Southeast Region','LINK, CAROLYN E.','8:00 AM TO 4:45 PM','07/17/1919',NULL);
INSERT INTO tblparks VALUES ('ACADIA NATIONAL PARK','P.O. BOX 177','','','BAR HARBOR','ME','04609-','207-288-5456','North Atlantic Region','HAERTEL, PAUL','8:00 AM TO 4:30 PM','02/26/1919',NULL);

doc/index.html  view on Meta::CPAN

      <a href="http://www.macromedia.com/software/flashremoting/">Flash
Remoting</a> is a way for Flash movies running in a web browser to
request structured data from the web server. The following data types
are supported - strings, numbers, dates, arrays, dictionaries/hashes,
objects, recordsets. Flash clients talk with the server using the AMF
protocol, which is proprietary to Macromedia. However, it's not that
hard to decode. <br>
      <br>
Using AMF::Perl, it is possible to send arbitrary
data between client and server using very few lines of code. There is no
need to pack complicated data structures into CGI form parameteres or
XML strings. The coding time can be spent on better things - data
preparation and graphical presentation, not data delivery.<br>
      <br>
      <h3>Long version</h3>
<p>HTML forms are ugly. HTML itself is not well suited for presenting
data. Everybody knows that but still uses them. However, the Rich
Internet Client is back and it gets adopted more and         more. In
part this has to do with Macromedia's eforts. <br>
      <br>
<p>Macromedia Flash has matured enough to <br>
a) allow developers to build rich, visually attractive user interfaces
and <br>
b) receive data from the server in a convenient way.<br>
      <p>But if you believe in the idea of more and more programmers
taking a shot at developing clients in Flash, you must also see the need

doc/index.html  view on Meta::CPAN

available for ColdFusion, JRun, .NET, J2EE. </p>
      <p>The Macromedia development tools are neither free nor
open-source. The server costs go into thousands. (There are
fully-fuctional trial versions available, though.)<br>
However, by using Perl to implement the server-side part of the
gateway, that part of the solution becomes free.<br>
      </p>
      <p> <a href="http://www.macromedia.com/software/flashremoting/">Flash
Remoting</a> protocol (AMF) is similar to SOAP, but the protocol
complexities are hidden from the developer. On the client side you call
a local function, and your call is passed to the corresponding function
on the server. Another function, a callback, is invoked by the framework
when the data is received. On the server side you provide a handler
with a certain name that registers certain functions, available to be
used by the client. Everything on the server side is within the syntax
of the server language. The client side uses ActionScript. <a
 href="code.html">This is what the code looks like.</a><br>
To build/export .swf files with Flash Remoting, you need to install
Flash Remoting MX Components for free at:<br>
http://www.macromedia.com/software/flashremoting/downloads/components/
<br>

doc/index.html  view on Meta::CPAN

used in the ActionScript.
      </p>
      <p>We think that it is very important for the Open Source
community to make this technology available in Perl and (why not?) in
Python as well. We set out to decode the protocol, but soon discovered
that <a href="http://amfphp.sourceforge.net/">PHP folks</a> beat us by a
month, so we simply rewrote their code in Perl.</p>
<p>We would like to hear the community feedback - the amount of time we
will put into this project will be proportional to the need for it.<br>
      <br>
<p>Please respond if you are interested either in using AMF::Perl or in
contributing to it.<br>
      <br>
      <br>
      </td>
			<td style="vertical-align: top;width: 400px">
<h2>Examples</h2>
<ul>
<li><a href="examples/cpu/cpu.html">CPU Usage</a>
	<br><br>
<li><a href=examples/dataGrid/dataGrid.html>Data grid</a> that gets its data from the server as an array of objects.

lib/AMF/Perl.pm  view on Meta::CPAN


=head1 NAME

AMF::Perl - Flash Remoting in Perl
Translated from PHP Remoting v. 0.5b from the -PHP project.

Main gateway class.  This is always the file you call from flash remoting-enabled server scripts.

=head1 SYNOPSIS

This code should be present in your AMF::Perl gateway script, the one called by the Flash client.
    
To enable the client to call method bar() under service Foo,
make sure MyCLass has a method called bar() and register an instance of your class.

        my $object = new MyClass();
        my $gateway = AMF::Perl->new;
        $gateway->registerService("Foo",$object);
        $gateway->service();

Or, if you have many services to register, create a package corresponding to each service
and put them into a separate directory. Then register this directory name. 

In the example below directory "services" may contain Foo.pm, Bar.pm etc.
Therefore, services Foo and Bar are available. However, these packages must have a function
called methodTable returning the names and descriptions of all possible methods to invoke.
See the documentation and examples for details.

	my $gateway = AMF::Perl->new;
	$gateway->setBaseClassPath('./services');
	$gateway->service();

lib/AMF/Perl.pm  view on Meta::CPAN


The web page for the package is at:
http://www.simonf.com/flap

=head1 AUTHOR

Vsevolod (Simon) Ilyushchenko, simonf@simonf.com

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
The code is based on the -PHP project (http://amfphp.sourceforge.net/)

ORIGINAL PHP Remoting CONTRIBUTORS
    Musicman - original design
    Justin - gateway architecture, class structure, datatype io additions
    John Cowen - datatype io additions, class structure
    Klaasjan Tukker - modifications, check routines, and register-framework

lib/AMF/Perl.pm  view on Meta::CPAN

use AMF::Perl::Util::Object;

# constructor
sub new
{
    my ($proto) = @_;
	my $class = ref($proto) || $proto;
    my $self = {};
    bless $self, $class;
    $self->{exec} = new AMF::Perl::App::Executive();
	$self->{"response"} = "/onResult";
    $self->{debug}=0;
    return $self;
}

sub debug
{
    my $self = shift;
    if (@_) {$self->{debug} = shift;}
    return $self->{debug};
}

lib/AMF/Perl.pm  view on Meta::CPAN

    # loop over all of the body elements
    for (my $i=0; $i<$bodycount; $i++)
    {
        my $body = $amfin->getBodyAt($i);
        # set the packagePath of the executive to be our method's uri
        #Simon - unused for now
        $self->{exec}->setTarget( $body->{"target"} );
        #/Simon
        # execute the method and pass it the arguments
        
       	my ($results, $returnType);

        # try
        eval
        {
           $results =  $self->{exec}->doMethodCall( $body->{"value"} );
           # get the return type
           $returnType = $self->{exec}->getReturnType();
        };

        
        if ( $@ )
        {
            $results = UNIVERSAL::isa( $@, 'AMFException' ) ?  $@->error : constructException($@);
            $self->{"response"} = "/onStatus";
            $returnType = "AMFObject"; 
        } 

        # save the result in our amfout object
        $amfout->addBody($body->{"response"}.$self->{"response"}, "null", $results, $returnType);
    }
    
    # create a new output stream
    my $outstream = new AMF::Perl::IO::OutputStream ();

    # create a new serializer
    my $serializer = new AMF::Perl::IO::Serializer ($outstream, $self->{encoding});
    
    # serialize the data
    $serializer->serialize($amfout);

    if(0)
    {
        # save the raw data to a file for debugging
        $self->_saveRawDataToFile ($self->debugDir."/results.amf", $outstream->flush());
    }

    # send the correct header
    my $response = $outstream->flush();

	#Necessary on Windows to prevent conversion of 0a to 0d0a.
	binmode STDOUT;

	$self->output($response);

	return $self;
}

sub output
{
	my ($self, $response) = @_;

    my $resLength = length $response;

    if($ENV{MOD_PERL})
    {
        my $MP2 = ($mod_perl::VERSION >= 1.99);
        my $r = Apache->request();
		#$r->header_out("Content-Length", $resLength);
        #$r->send_http_header("application/x-amf");
        $r->content_type("application/x-amf");
        $r->headers_out->{'Content-Length'} = $resLength;
        $r->send_http_header unless $MP2;
        $r->print($response);

    }
	else
	{
		print <<EOF;
Content-Type: application/x-amf
Content-Length: $resLength

$response
EOF
	}
}

sub debugDir
{
    my ($self, $dir) = @_;
    $self->{debugDir} = $dir if $dir;
    return $self->{debugDir};
}

lib/AMF/Perl.pm  view on Meta::CPAN

    my ($self, $package, $servicepackage) = @_;
    $self->{exec}->registerService($package, $servicepackage);
}


sub constructException
{
    my ($description) = @_;
    my $stack = Devel::StackTrace->new();

    my %result;
    $description = "An error occurred" unless $description;
    $result{"description"} = $description;
    $result{"exceptionStack"} = $stack->as_string;
    my @frames = $stack->frames;
    $result{"details"} = $frames[1]->filename();
    $result{"line"} = $frames[1]->line();
    $result{"level"} = "Error";
    $result{"code"} = "1";
    return \%result;
}


sub amf_throw
{
    my ($description) = @_;

    AMFException->throw( error => constructException($description) );
}

lib/AMF/Perl.pm  view on Meta::CPAN

    # open the file for writing
    if (!open(HANDLE, "> $filepath"))
    {
        die "Could not open file $filepath: $!\n";
    }
    # write to the file
    if (!print HANDLE $data)
    {
        die "Could not print to file $filepath: $!\n";
    }
    # close the file resource
    close HANDLE;
}

sub _appendRawDataToFile 
{
    my ($self, $filepath, $data) = @_;
    # open the file for writing
    if (!open (HANDLE, ">>$filepath"))
    {
        die "Could not open file $filepath: $!\n";
    }
    # write to the file
    if (!print HANDLE $data)
    {
        die "Could not print to file $filepath: $!\n";
    }
    # close the file resource
    close HANDLE;
}


# get contents of a file into a string
sub _loadRawDataFromFile
{
    my ($self, $filepath)=@_;
    # open a handle to the file
    open (HANDLE, $filepath);

lib/AMF/Perl/App/Executive.pm  view on Meta::CPAN

package AMF::Perl::App::Executive;
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http:#amfphp.sourceforge.net/)

=head1 NAME 

AMF::Perl::App::Executive

=head1 DESCRIPTION    

Executive package figures out whether to call an explicitly
registered package or to look one up in a registered directory.
Then it executes the desired method in the package.

=head1 CHANGES

=head2 Wed Apr 14 11:06:28 EDT 2004

=item Added return type determination for registered methods.

=head2 Sun Mar 23 13:27:00 EST 2003

lib/AMF/Perl/App/Executive.pm  view on Meta::CPAN

        else
        {
            $self->{_returnType} = "unknown";
        }
        # set to see if the access was set and the method as remote permissions.
        if ( (exists($methodrecord{'access'})) && (lc ($methodrecord{'access'}) eq "remote"))
        {
            # finally check to see if the method existed
            if ($self->{_classConstruct}->can($method))
            {
                # execute the method and return it's results to the gateway
                return $self->{_classConstruct}->$method(@$a);
            }
            else
            {
                # print STDERR  with error
                print STDERR  "Method " . $calledMethod . " does not exist in class ".$self->{_classConstruct}.".\n";
            }
        }
        else
        {

lib/AMF/Perl/IO/Deserializer.pm  view on Meta::CPAN

package AMF::Perl::IO::Deserializer;
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)

=head1 NAME

AMF::Perl::IO::Deserializer

=head1 DESCRIPTION    

lib/AMF/Perl/IO/Deserializer.pm  view on Meta::CPAN

    # return the data
    return \@ret;    
}

sub readCustomClass
{
    my ($self)=@_;
    # grab the explicit type -- I'm not really convinced on this one but it works,
    # the only example i've seen is the NetDebugConfig object
    my $typeIdentifier = $self->{inputStream}->readUTF();
    # the rest of the bytes are an object without the 0x03 header
    my $value = $self->readObject();
    # save that type because we may need it if we can find a way to add debugging features
    $value->{"_explicitType"} = $typeIdentifier;
    # return the object
    return $value;        
}

sub readNumber
{
    my ($self)=@_;
    # grab the binary representation of the number
    return $self->{inputStream}->readDouble();	
}

# read the next byte and return it's boolean value
sub readBoolean
{
    my ($self)=@_;
    # grab the int value of the next byte
    my $int = $self->{inputStream}->readByte();
    # if it's a 0x01 return true else return false

lib/AMF/Perl/IO/InputStream.pm  view on Meta::CPAN

package AMF::Perl::IO::InputStream;
# Copyright (c) 2003 by Vsevolod (Simon) Ilyushchenko. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# The code is based on the -PHP project (http://amfphp.sourceforge.net/)


=head1 NAME

    AMF::Perl::IO::InputStream

=head1 DESCRIPTION    

lib/AMF/Perl/IO/InputStream.pm  view on Meta::CPAN


# returns a single byte value.
sub readByte
{
    my ($self)=@_;
	# boundary check
	die "Malformed AMF data, cannot readByte\n"
		if $self->{current_byte} > $self->{content_length} - 1;
    # return the next byte
	my $nextByte = $self->{raw_data}->[$self->{current_byte}];
	my $result;
	$result = ord($nextByte) if $nextByte;
    $self->{current_byte} += 1;
    return $result;
}

# returns the value of 2 bytes
sub readInt
{
    my ($self)=@_;

	# boundary check
	die "Malformed AMF data, cannot readInt\n"
		if $self->{current_byte} > $self->{content_length} - 2;

    # read the next 2 bytes, shift and add
	my $thisByte = $self->{raw_data}->[$self->{current_byte}];
	my $nextByte = $self->{raw_data}->[$self->{current_byte}+1];

    my $thisNum = defined($thisByte) ? ord($thisByte) : 0;
    my $nextNum = defined($nextByte) ? ord($nextByte) : 0;

    my $result = (($thisNum) << 8) | $nextNum;

    $self->{current_byte} += 2;
    return $result;
}

# returns the value of 4 bytes
sub readLong
{
    my ($self)=@_;
 
	# boundary check
	die "Malformed AMF data, cannot readLong\n"
		if $self->{current_byte} > $self->{content_length} - 4;

    my $byte1 = $self->{current_byte};
    my $byte2 = $self->{current_byte}+1;
    my $byte3 = $self->{current_byte}+2;
    my $byte4 = $self->{current_byte}+3;
    # read the next 4 bytes, shift and add
    my $result = ((ord($self->{raw_data}->[$byte1]) << 24) | 
                    (ord($self->{raw_data}->[$byte2]) << 16) |
                    (ord($self->{raw_data}->[$byte3]) << 8) |
                        ord($self->{raw_data}->[$byte4]));
    $self->{current_byte} = $self->{current_byte} + 4;
    return $result;
}

sub readDouble
{
    my ($self)=@_;
	# boundary check
	die "Malformed AMF data, cannot readDouble\n"
		if $self->{current_byte} > $self->{content_length} - 8;
    # container to store the reversed bytes
    my $invertedBytes = "";

lib/AMF/Perl/IO/InputStream.pm  view on Meta::CPAN

		if $self->{current_byte} > $self->{content_length} - $length;
    # grab the string
    my @slice = @{$self->{raw_data}}[$self->{current_byte}.. $self->{current_byte}+$length-1];
    my $val = join "", @slice;
    # move the seek head to the end of the string
    $self->{current_byte} += $length;
    # return the string
    return $val;
}

# returns a UTF string with a LONG representing the length
sub readLongUTF
{
    my ($self) = @_;
    # get the length of the string (1st 4 bytes)
    my $length = $self->readLong();
	# boundary check
	die "Malformed AMF data, cannot readLongUTF\n"
		if $self->{current_byte} > $self->{content_length} - $length;
    # grab the string
    my @slice = @{$self->{raw_data}}[$self->{current_byte} .. $self->{current_byte}+$length-1];



( run in 1.336 second using v1.01-cache-2.11-cpan-49f99fa48dc )