Home Tutorials Forums Articles Blogs Movies Library Employment Press
Home » Actionscripts library »  Server-side scripts

Next 5

advanced detection of over 250 language - country codes, php

<html> <!-- upload this script as "yourtld.php" and a flash movie "hostname.swf" -->
<head>
<title>ccTLD suffix detection - 2004 by www.advance-media.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#000000">
<?php
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);	// returns the host name, including the ccTLD country code Top Level Domain. Detecting over 250 language/country/region/island codes by today.
if (is_numeric(substr($host, -1))){ // if last char is numeric than track the host ip number as not identifiable
        $cctld=$idsld="not";
}else{
        $elem=explode( ".", $host); // split the host into an array
        $howm=count($elem);
        $cctld=$elem[$howm-1];// the ccTLD suffix is the last element
        if ($elem[$howm-2]=="edu" or $elem[$howm-2]=="ac" or $elem[$howm-2]=="org" or $elem[$howm-2]=="mil" or $elem[$howm-2]=="gov" or $elem[$howm-2]=="eu" or $elem[$howm-2]=="nato" or $elem[$howm-2]=="un"){
                $idsld=$elem[$howm-2];
                // filter, analyse of common sub domains, identify country codes Second Level Domain SLD or 2LD. Like academic ac.uk and ac.jp or edu.pl and edu.au,  bj.cn would be Beijing China and qc.ca Quebec Canada
                // only the second level domains listed in the if statement are detected, edit as you like
        }else{
                $idsld="not";
        }
}
?>
<table width="100%" height="100%" border="0"> <!-- html table to center the film -->
<tr>
<td align="center" valign="middle">
<!-- embed the flash movie -->
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
WIDTH="500" HEIGHT="450">
<PARAM NAME=movie VALUE="hostname.swf<?php /* send $cctld and $idsld to flash */ echo ("?cctld=$cctld&idsld=$idsld"); ?>"> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000>
<EMBED src="hostname.swf<?php /* and here */ echo ("?cctld=$cctld&idsld=$idsld"); ?>" menu=false quality=high bgcolor=#000000  WIDTH="500" HEIGHT="450"
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
</td>
</tr>
</table>
</body>
</html>

<!--
// Here is the action script of the flash movie called "hostname.swf" to be created
// placed it on frame 10
if (_root.idsld == undefined) { // loop until the variables are retreived
        gotoAndPlay(9);
}
// on frame 11
if (_root.cctld == "not" or _root.cctld == "com" or _root.cctld == "net") { // if not identifiable or international like .com or .net
        sys_all = System.capabilities.serverString; // than further language details are available in flash MX 6,7
        la = System.capabilities.language;
        // la= player plug in language
        pos = sys_all.indexOf("&L=")+3;
        syla = sys_all.substr(pos);
        pos = syla.indexOf("&");// this line and the next if statement is needed by the flash 7 player, the serverString got extended, the L=language is not the last variable element any more.
        if (pos != -1) {
                syla = syla.substr(0, pos);// syla = operating system language which might be different from the la= player plug in language
        }
        // create dynamic text fields showing the variables la, syla, cctld, idsld, now you can make a sophisticated language decision
        // actual country code list, suffix ccTLD on the net
        // info System.capabilities http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary710.html
}
-->

Posted by: Folko Langner | website http://www.advance-media.com
AMFPHPRemoteGateway
/*
Copyright (c) 2006 www.ericfeminella.com.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
                                                                INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ignore
*/

package com.ericfeminella.net
{
        import flash.net.NetConnection;
        import flash.net.ObjectEncoding;
        import flash.net.Responder;
        import mx.rpc.IResponder;
        
        /**
        * AMFPHPRemoteGateway serves as a generic implementation for creating
        * AMFPHP gateway connections in which methods can are invoked on remote
        * PHP objects. AMFPHPRemoteGateway supports both mxml and ActionScript
        * implementations.
        *
        * <p>The following is an example of how to implement AMFPHPRemoteGateway
        * in mxml to invoke a method on a remote PHP object utilizing AMFPHP.</p>
        *
        * <p> The mxml below imports AMFPHPRemoteGateway via the 'service'
        * namespace. An instance of AMFPHPRemoteGateway is instantiated with
        * an id 'gateway'. The 'gatewayURI' method is passed the URI of the
        * AMFPHP root directory 'http://dev.ericfeminella.com/amfphp/gateway.php'
        * A remote PHP class 'remoteServiceClass' is passed to the 'remoteServiceClass'
        * method. Finally a result method is passed to the 'resultResponder' method
        * as well as a fault method passed to 'faultResponder'</p>
        *
        * <pre>
        * xmlns:service="com.ericfeminella.net.*"
        *
        * <service:AMFPHPRemoteGateway id="gateway"
        *          gatewayURI="http://dev.ericfeminella.com/amfphp/gateway.php"
        *          remoteServiceClass="data.business.EmailDelegate"
        *          resultResponder="{this.result}"
        *          faultResponder="{this.fault}" />
        * </pre>
        *
        * <p> The following is an example of how to invoke a 'send' method on a
        * remote PHP class 'EmailDelegate' via AMFPHPRemoteGateway in ActionScript
        * is as follows:</p>
        *
        * <pre>
        * this.gateway.invoke("send",
                              *                     "[email protected]",
                              *                     "AMFPHP Test",
                              *                     "Your Name",
                              *                     "[email protected]",
                              *                     "Your message")
        * </pre>
        */
        public class AMFPHPRemoteGateway extends NetConnection
        {
                protected var remoteClass:String;
                protected var result:Function;
                protected var fault:Function;
                
                /**
                * Instantiates a new instance of RemoteGateway and sets
                * objectEncoding to AMF3
                *
                * <a href="http://www.osflash.org/amf3/index" />
                */
                public function AMFPHPRemoteGateway()
                {
                        this.objectEncoding = ObjectEncoding.AMF3;
                }
                
                /**
                * Sets the root uri in which AMFPHP service gateway.php resides
                * gatewayURI="http://dev.ericfeminella.com/amfphp/gateway.php"
                *
                * @param AMFPHP service gateway.php URI
                */
                public function set gatewayURI(gatewayURI:String):void
                {
                        this.connect(gatewayURI);
                }
                
                /**
                * Sets the class in which specified methods will be invoked
                * You must include the fully qualified classpath.
                *
                * <p>For example, if EamilDelegate.php resides in a package
                * data.business, you must set remoteServiceClass to the exact
                * same path</p>
                *
                * <p>The 'remoteServiceClass' instance class can be changed at
                * runtime therefor a single instance of AMFPHPRemoteGateway can
                * be used to call methods on different objects</p>
                *
                * <code>remoteServiceClass="data.business.EmailDelegate"</code>
                *
                * @param The remote class to invoke
                */
                public function set remoteServiceClass(remoteClass:String):void
                {
                        this.remoteClass = remoteClass;
                }
                
                /**
                * Invokes a method on a remote PHP class as specifed in remoteServiceClass
                *
                * <p>For instance, if you set remoteServiceClass="data.business.EmailDelegate",
                * and pass 'send' as the method parameter, you are essentially calling
                * the following on the server:</p>
                *
                * <pre>
                * EmailDelegate.send(args);
                * </pre>
                *
                * @param The method to invoke on the remote object
                * @param An arbitrary length of arguments passed to the remote method
                */
                public function invoke(method:String, ...args):void
                {
                        var responder:Responder = new Responder(this.resultProxy, this.faultProxy)
                        var remoteClass:String = this.remoteClass + "." + method;
                        
                        super.call.apply(null, [remoteClass, responder].concat(args));
                }
                
                /**
                * Sets the IResponder result method which will be invoked
                * upon an ResultEvent
                *
                * @param An IResponder result method callback
                */
                public function set resultResponder(result:Function):void
                {
                        this.result = result;
                }
                
                /**
                * Sets the IResponder fault method which will be invoked
                * upon an FaultEvent
                *
                * @param An IResponder fault method callback
                */
                public function set faultResponder(fault:Function):void
                {
                        this.fault = fault;
                }
                
                /**
                * Serves as a proxy between NetConnection Responder result and
                * mx.rpc.IResponder result
                */
                protected function resultProxy(data:Object):void
                {
                        this.result(data);
                }
                
                /**
                * Serves as a proxy between NetConnection Responder fault and
                * mx.rpc.IResponder fault
                */
                protected function faultProxy(info:Object):void
                {
                        this.fault(info);
                }
        }
}

Posted by: Eric Feminella | website http://www.ericfeminella.com/blog
basics to send a flash film in a (html) email generated by php
<?php
// this script provides all the basics to send a flash film in a (html)
//email generated by php hook this script to your newsletter database table
//of recipients or use it as middleware for a (flash)form to mail
// in outlook the ActiveX control must be allowed (which is the
//most usual security zone setting -> tools -> options -> security), no problem with NS
// 2004 by www.advance-media.com
$to = "YOU<info@your_server.com>";
$from = "www.ADVANCE-MEDIA.com<[email protected]>";
$subject = "FLASH - html - email";
$file = "http://www.advance-media.com/prev_next.swf"; // absolute path to the flash film to be included in the email
$html_content = '
<html>
<head>
<title>www.advance-media.com FLASH - html - email</title>
</head>
<body bgcolor="#ffffff">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
WIDTH="230" HEIGHT="245">
<PARAM NAME=movie VALUE="'.$file.'"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="'.$file.'" quality=high bgcolor=#FFFFFF  WIDTH="230" HEIGHT="245" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
</body>
</html>
';
$header = "From: ".$from."\n";// eventually your servers requires a "\r\n" instead of the "\n" (carriage return + newline) in the header
$header.= "MIME-Version: 1.0\n";// otherwise no need to edit the header but you'll find more info at www.php.net -> mail
$header.= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$header.= "Content-Transfer-Encoding: 7bit\n";

if(mail($to, $subject, $html_content, $header)) {
        echo ("MAIL SEND OKAY!");
}else{
        echo ("MAIL ERROR!");
}
?>

Posted by: Folko Langner | website http://www.advance-media.com
CLOCK AND DATE SET BY SEVER (GMT) TIMESTAMP, PHP
/*
GMTtimer, DIGITAL FLASH CLOCK AND DATE SET BY PHP HOST SEVER GMT TIMESTAMP,
2004 by www.advance-media.com

The GMTtimer displays (GMT) Greenwich Mean Time or so-called (UTC)
Coordinated Universal Time or world time, the timer can be set to your local time zone (php part).
Flash's Date (object) is set by the current GMT php host server timestamp in
milliseconds since the Unix Epoch (0:00:00 January 1, 1970 GMT).
No manipulation or predating any more by resetting the local client sided system
clock or date,which usually synchronizes Flash's Date (object).
Show different content at an exact and server fixed point of time!

PREVIEW, TEST and DOWNLOAD AS ZIP (FLA movie + PHP) click to
GMTtimer's homepage: http://www.GMTtimer.advance-media.com
*/

<html> <!-- // upload this script as "GMTtimer.php" and a flash movie "GMTtimer.swf" -->
<head>
<title>GMTtimer, 2004 by www.advance-media.com</title>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META name="PUBLISHER" content="WWW.ADVANCE-MEDIA.COM">
<META http-equiv="PRAGMA" content="no-cache"> <!-- // PRAGMA, EXPIRES refresh content -->
<META http-equiv="EXPIRES" content="0">
</head>
<body bgcolor="#000000" onload="frame ()">
<table width="100%" height="100%" border="0"> <!-- // table to center the flash movie horizontally and vertically -->
<tr>
<td align="center" valign="middle">
<?php
$timestamp = explode(" ",microtime());
$timestamp = round(($timestamp[1] + $timestamp[0])*1000); // GMT server timestamp in milliseconds
//$timestamp += 1000*60*60*9; // set a (your local) time zone offset? here GMT +9 hours in milliseconds are added
?>
<!-- // embed the flash movie and send the timestamp variable -->
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"	WIDTH="69%" HEIGHT="69%">
<PARAM NAME=movie VALUE="GMTtimer.swf?timestamp=<?php /* if your server does not support the php microtime(); call, try out the GMT seconds timestamp here: echo time()*1000; */ echo $timestamp; ?>">
<PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#000000>
<EMBED src="GMTtimer.swf?timestamp=<?php /* and here */ echo $timestamp; ?>" menu=false quality=high bgcolor=#000000  WIDTH="69%" HEIGHT="69%"
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
</td>
</tr>
</table>
</body>
</html>

<!-- // create the flash movie named "GMTtimer.swf"  and a dynamic text field showing the variables output from frame 9 to 12
// action on frame 1:
GMTtimer = new Date();
weekday = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
month = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
//timestamp = "1115989993666"; // test timestamp
function fillup(digit) {
        // fills up single digits with 0
        if (digit<10) {
                digit = "0"+digit;
        }
        return (digit);
}

// action on frame 10:
// error test on frame 10, usually the php timestamp variable should be retrieved by now...
isNaN(timestamp) or timestamp == undefined ? gotoAndPlay(9) : timestamp=parseInt(timestamp);
// ... if the server timestamp is not retrieved yet or not numeric than loop back to frame 9
// else parse the retrieved timestamp string to a number, no error loop ...
// also here from frame 9 to 10 you can insert a new  movieClip symbol on a new layer. After a second of blank frames in its begin
// write _root.output = "PHP ERROR TRY http://www.GMTtimer.advance-media.com"; stop(); as ERROR prompt.

// action on frame 11:
// synchronizes Flash's date object with the server GMT milliseconds timestamp + the current milliseconds elapsed since the movie's begin
GMTtimer.setTime(timestamp+getTimer());
// read out this GMT, UTC timestamp
output = weekday[GMTtimer.getUTCDay()];
output += ", "+month[GMTtimer.getUTCMonth()];
output += " "+GMTtimer.getUTCDate();
output += ", "+GMTtimer.getUTCFullYear();
output += "  "+fillup(GMTtimer.getUTCHours());
//  blinking colons pulsed by milliseconds, the colons are visible for the first 2/3rds of each second
GMTtimer.getUTCMilliseconds()>666 ? blink=" " : blink=":";
output += blink+fillup(GMTtimer.getUTCMinutes());
output += blink+fillup(GMTtimer.getUTCSeconds());

// action on frame 12:
gotoAndPlay(11);
// loop eternally? -->

Posted by: Folko Langner | website http://www.advance-media.com
Consuming eBay Price Watcher by Flash Remoting MX for .NET
// WSDL: http://www.xmethods.net/sd/2001/EBayWatcherService.wsdl

// Include remoting components

#include "NetServices.as"
#include "NetDebug.as"

// "Only once" codes

if (inited == null) {
        inited = true;
        
        // Create gateway
        
        NetServices.setDefaultGatewayUrl
        ("http://localhost/eBayPriceWatcher/gateway.aspx");
        
        // Create gateway connection object
        
        gatewayConnection = NetServices.createGatewayConnection();
        eBayWS = gatewayConnection.getService
        ("http://www.xmethods.net/sd/2001/EBayWatcherService.wsdl", this);
        
        // 2511817428 is an item number taken from eBay.Com and its auction will
        // be no longer available after 4th March. So, in order to test, you have to
        // get another item and its number from eBay.Com.
        
        eBayWS.getCurrentPrice("2511817428");
}

// Get the current bid on the item

function getCurrentPrice_Result(result) {
        trace(result);
}

// Report the errors for debugging

function getCurrentPrice_Status(result) {
        trace("Error: " + result.details);
}

Posted by: Mustafa Basgun | website http://www.basgun.com

Next 5

Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.