AMFPHP issue referencing ByteArray

http://genius-cm.com/ccmb-hyderabad-dissertation/ ccmb hyderabad dissertation Recently I made some test in AMFPHP sending an retrieving ByteArray to be stored in a mysql blob field.

watermelon pomegranate juice viagra But suddenly I encounter a problem when I was trying to return an array of ByteArrays and I could not find out the reason flash continued to show me this error:

theology homework help

http://loovharidus.ee/dissertation-write-for-payment-2-weeks/ sociology topics for research paper The php file which was generating this error was:

1
2
3
4
5
6
7
8
9
10
11
class Service
{
public function getArray( )
{
$GLOBALS['amfphp']['encoding'] = 'amf3';
$a = new ByteArray("\x00\x10this is a string");
$b = new ByteArray("\x00\x16this is another string");
$c = $a;
return array( $a, $b, $c );
}
}

http://ducasco.gr/content-writing-services-kerala/ content writing services kerala While the Actionscript test class was:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package
{
    import flash.display.Sprite;
    import flash.net.NetConnection;
    import flash.net.ObjectEncoding;
    import flash.net.Responder;
    import flash.utils.ByteArray;

    public class test extends Sprite
    {
        private var nc: NetConnection;
        private var rsp: Responder;

        public function test()
        {
            rsp = new Responder( onResult, null );
            nc = new NetConnection();
            nc.objectEncoding = ObjectEncoding.AMF3;
            nc.connect( "http://localhost/amfphp/trunk/gateway.php" );
            nc.call( "test.bytearray.Service.getArray", rsp );
        }

        private function onResult( e: * ): void
        {
            if ( e is Array )
            {
                for each ( var b: ByteArray in( e as Array ) )
                {
                    trace( 'reading bytearray...' );
                    b.position = 0;
                    trace( b.readUTF() );
                }
            }
        }
    }
}

http://www.forgiveengland.com/writing-help-u-of-t/ writing help u of t After some investigation I found that the error was into the AMFSerializer.php file in the writeAmf3ByteArray method which doesn’t reference correctly the bytearray objects.

http://profesyonelgayrimenkul.com/doctor-education-thesis/ doctor education thesis Thus I made a little modification and after that I succeeded to retrieve correctly the bytearray list ( with the 3rd element as reference of the first one ).

http://mudanzaspt.com/?ghostwriting-service-page ghostwriting service page Here you can download the patch file, if you want to test the modification ( at your own risk 🙂 ). The patch has been created using the last svn version of amfphp and you can apply the patch with the following command:

1
patch -p0 -i bytearray.patch

AMFPHP and mbstring

paper on marketing These days I was working on a flex 2/amfphp project and I discovered a very strange issue accidentally.
With PHP 5.2.4 installed both on local and remote server, the local amfphp works and the remote gave errors.

http://mayneislandmusic.ca/distribution-assistant-cover-letter/ distribution assistant cover letter Connecting to the service browser I was receiving the error “Channel.Ping.Failed” error and investingating a bit more in the fault message I discovered that the source error was:

http://www.seothalesmultimedia.com/essay-on-gender-pay-gap/ essay on gender pay gap The class {Amf3Broker} could not be found under the class path {/var/htdocs/amfphp/services/amfphp/Amf3Broker.php}

http://samassistance.altervista.org/?professional-writing-ou professional writing ou and the Amf3Broker php class does not exists anywhere in amfphp! But in the Actions.php file on line 78 I found this:

1
2
3
4
5
6
7
if(!$handled)
{
$uriclasspath = "amfphp/Amf3Broker.php";
$classpath = $baseClassPath . "amfphp/Amf3Broker.php";
$classname = "Amf3Broker";
$methodname = "handleMessage";
}

http://www.mainframechina.com/phd-thesis-in-electronics-and-communication/ Phd Thesis In Electronics And Communication That’s the strange thing because the $handled variable should be true ’cause usually the first request sent by flash is a dissertation services uk library $messageType = “flex.messaging.messages.CommandMessage”. So I continued in my investigation logging all the messages that php was receiving.
So at the end I discovered that amfphp didn’t deserialize the amf data correctly! All the packet were corrupted (that’s why $messageType wasn’t handled), all the strings were not correctly parsed.
Finally I discovered the reason. It’s because mbstring.
The only difference between the remote server and the local server is the php.ini setting about mbstring overload and the others mbstring settings.
The remote server has mbstring.func_overload = 2, that means all the strings functions are affected and that’s why the amfphp methods were returing corrupted data.
In fact I just changed this method into AMFDeserializer.php:

1
2
3
4
5
6
function readBuffer($len)
{
$data = substr($this->raw_data,$this->current_byte,$len);
$this->current_byte += $len;
return $data;
}

order resume online oriflame into:

1
2
3
4
5
6
7
8
9
10
function readBuffer($len)
{
$data = "";
for($i = 0; $i < $len; $i++)
{
$data .= $this->raw_data{$i + $this->current_byte};
}
$this->current_byte += $len;
return $data;
}

disadvantages of shopping online essay and the original error disappeared! Obviously I got other errors later, that’s because there are many other string functions in amfphp.. but at least I found the cause.

In fact, removing the mbstring.func_overload in the php.ini everything worked again!

AMFPHP 1.9 changes and future plans

Recently Patrick released a new testing version of AMFPHP which supports the Flex2 AMF3 object encoding.

Some changes:

http://www.falydelaferiaalrocio.com/business-plan-writer-edmonton/ business plan writer edmonton $this->methodTable is DEAD. All methods in /services are now considered remotely accessible, unless you set them to protected or private (PHP5) or start the method name with an (_)
– Returning a http://www.pcy0515.com/writing-self-assessment-essay/ writing self assessment essay mysql_query will now return either an Array or an ArrayCollection depending on the setting in gateway.php
– browser now brings up the brand spanking new Flex 2-based service browser

This is a testing version since it has still a lot of limitations and it has been tested only on PHP5. I see the post today and I haven’t tested yet…
You can read here for a detailed list of changes

Moreover Patrick plans to add to amfphp the Flex Data Services (read what they are). In this post he got a brief explanation about flash player/FDS communication and ask for developers to help him with the developement of FDS in amfphp (you might need a copy of charles).