Coder Social home page Coder Social logo

php-amf3's People

Contributors

neoxic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-amf3's Issues

shtool doesn't have executable permission after running phpize

Hi-

I am running userland app for android with php 8.1 installed on a tablet. i installed php-dev.
I run phpize and it says shtool doesn't have permissioins. So i gave it permissions
like sudo chmod 600 shtool and sudo chmod +x shtool but i get error msg and I can't do ./configure. Any ideas?
thanks,
j.mcnamara

unresolved symbols when building dll

HI-

Please see console output below.

I'm trying to use https://github.com/php/php-sdk-binary-tools and https://ourcodeworld.com/articles/read/804/how-to-compile-a-php-extension-dll-file-in-windows-with-visual-studio to build the code into a dll. I got as far as below with it and it doesn't work. I notice in the files 2 references - zend_standard_class_def and zend_string_init in the source files. It is threw an error. Is that anything that is possible to fix or is it doomed. I tried to build in cygwin but didnt get anywhere, so I am using the tools mentioned above.

You are the only game in town for this amf3. All the other links are dead ends. I'd like to work with apache royale.

thanks for helping me.
roboloki

amf3-decode.obj : error LNK2019: unresolved external symbol executor_globals_offset referenced in function decodeObject amf3-encode.obj : error LNK2001: unresolved external symbol executor_globals_offset amf3-encode.obj : error LNK2019: unresolved external symbol zend_standard_class_def referenced in function encodeObject amf3.obj : error LNK2019: unresolved external symbol zend_string_init_interned referenced in function zm_startup_amf3 C:\php-sdk\phpmaster\vc15\x64\php-src-PHP-7.4.26\x64\Release_TS\php_amf3.dll : fatal error LNK1120: 3 unresolved externals NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe"' : return code '0x460'

make whith php7 error

/file/php-ext/php-amf3-master/amf3_encode.c:12:40: fatal error: ext/standard/php_smart_str.h: No such file or directory

AMFPHP

How to change serializer.php and Deserialiszer.php in AMFPHP in order to use amf3_encode and amf3_decode ?
I try lot of stuff but none is working :(
Someone can help?

Is this extension compatible with PHP 5.6?

Hello Neoxic,

I have one old project built on amf-php and PHP 5.6. Can I replace encode and decode functions of amf-php with php-amf3?

Thanks for reading this!
Arckid

Memory Issues

As the data grows big the memory consumption becomes alot.
Is there anyway to decrease the memory consumption?

Encoding non-dense arrays

I'm having an issue with the way non-dense PHP arrays are encoded into the associative portion of the array type (0x09). What happens is that they are decoded in ActionScript as Array instances with dynamic properties, which are not interpreted correctly by functions like JSON.stringify(). For example, if I encode an object like this in PHP:

$hash = array('a' => 'apple', 'b' => 'banana', 'c' => 'cantaloupe');

When I decode it with ActionScript, I get the following:

var hash:Object = byteArray.readObject();
trace(hash['a']);    // "apple" (so far so good)
trace(JSON.stringify(hash));    // [ ] (looks like an empty array)

Additionally, any ActionScript code that assumes the contents of an Array instance can be iterated with integer keys (which is usually a good assumption), will find this object to be empty. Similar to my push request, it's a matter of convenience and of how one decides to map PHP arrays onto AMF types. I'm not sure of the best way to solve the problem. My inclination is to encode sparse arrays as anonymous Object types, since this is a better mapping to how PHP arrays behave. It would require some moderate refactoring, since currently the encoder writes the type marker before it's examined whether the array is dense. I'm willing to implement it on my fork and submit another push request, but wanted to get your input first. What do you think?

Array encoding

Hey @neoxic
When serializing an array, you make use of a method encodeHash. This method includes a check to see if the key is a string or a long:

https://github.com/neoxic/php-amf3/blob/master/amf3_encode.c#L104

I think this serializes the following array incorrectly:

array (
  0 => 1,
  1 => 2,
  3 => 
  array (
    0 => 1,
    1 => 2,
    2 => 2,
    4 => 'xxx',
  ),
)

Here's a hex dump of the serialized value:
090103300401033104020333090100040102040203320402033406077878780101

I believe that it should be 0901033004010331040203330901033004010331040203320402033406077878780101

Notice this segment ...3330901 000401 020402033...
That is where the nested array is being written. Now, because encodeHash is checking to see if the key is a long or a string - it's choosing to encode the array key 0 as a long - producing 0, but it should be encoding as a string - producing 033.

I can't see in the spec if its necessary to determine an associative array's key data type and encode it accordingly - I believe that the key can only be encoded as a string.

Did I get something completely wrong? Remember, I'm a n00b to this game :)

在接收数据时候的问题。

有BUG的,在当AS3发送的参数中,有值为0,如:t=0,或者有值为浮点数如t=3.1415,这些值时,PHP会收不到POST过来的数据。
如果有值为大于100的数字如:t=386,这时候amf3_decode方法会自动把这些数字转换掉。。。

error msg AMFSerializable not found

Hi-

I got anonymous object literals working and can receive an array using apache royale code.
When I try to fool with the Serializable object, it give me this error:

interface AMF3Serializable not found. PhP error is looking in my actionscript directory.

I put the header amf3.h in my include_path. Can I please have a hint as to how to fix this?

THANKS,
robo-loki

PHP Warning: Undefined symbol: executor_globals_id

Trying to include the extension on Centos 7, PHP 7.0.7 running as FPM (Non Thread Safe) gives the following error on startup.

PHP Warning: PHP Startup: Unable to load dynamic library /usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/amf3.so: undefined symbol: executor_globals_id in Unknown on line 0.

Here's the catch. Web server maintenance is outsourced so i have very little information. Fingers crossed.

Problem with decoding AMF

So there is this ancient game called "woozworld" (woozworld.com).
I looked into their network traffic and saw that they use AMF to encode their packages. I have tried every decoder out there, but all of them are either deprecated or crash when trying to process the data I throw at them.
It might also be a modified version of amf?

Testdata to see for yourself: https://workupload.com/file/A5fXs7t8MEt

Parse AMF request

I'm trying to parse an "application/x-amf" request using amf3_decode, but it doesn't return anything nor write any warning ($decoded is empty):

if(!isset($GLOBALS['HTTP_RAW_POST_DATA'])){
        $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents('php://input');
}
$decoded = amf3_decode($GLOBALS['HTTP_RAW_POST_DATA']);

Is something wrong with this code? Can you post any example to parse an AMF request on the wiki?

Thanks

Date conversions

Hey @neoxic

I'm seeing that Date objects are left as numbers upon deserialization; would it not be worth converting these to DateTime objects?

Problem deserializing AMF request

I am trying to use your extension in Zend Framework project, but I have a problem.

If I deserialize request data with amfphp I get:
[0] => Amfphp_Core_Amf_Message Object
(
[targetUri] => null
[responseUri] => /1
[data] => Array
(
[0] => stdClass Object
(
[operation] => 5
[correlationId] =>
[body] => stdClass Object
(
)

                                [clientId] => 
                                [destination] => 
                                [messageId] => 600DB250-A2A8-4B2A-98BD-034D5E0A9F99
                                [headers] => stdClass Object
                                    (
                                        [DSMessagingVersion] => 1
                                        [DSId] => nil
                                    )

                                [timestamp] => 0
                                [timeToLive] => 0
                                [_explicitType] => flex.messaging.messages.CommandMessage
                            )

                    )

            )

with Zend_amf I get:
[0] => Zend_Amf_Value_MessageBody Object
(
[_targetUri:protected] => null
[_responseUri:protected] => /1
[_data:protected] => Zend_Amf_Value_Messaging_CommandMessage Object
(
[operation] => 5
[correlationId] =>
[clientId] =>
[destination] =>
[messageId] => 600DB250-A2A8-4B2A-98BD-034D5E0A9F99
[timestamp] => 0
[timeToLive] => 0
[headers] => stdClass Object
(
[DSMessagingVersion] => 1
[DSId] => nil
)

                [body] => stdClass Object
                    (
                    )

            )

    )

If I start using your decompiler in amfphp I get:
[0] => Amfphp_Core_Amf_Message Object
(
[targetUri] => null
[responseUri] => /1
[data] => Array
(
[0] => Array
(
[operation] => 5
[correlationId] =>
[body] => Array
(
)

                                [clientId] => 
                                [destination] => 
                                [messageId] => 600DB250-A2A8-4B2A-98BD-034D5E0A9F99
                                [headers] => Array
                                    (
                                        [DSMessagingVersion] => 1
                                        [DSId] => nil
                                    )

                                [timestamp] => 0
                                [timeToLive] => 0
                                [_class] => flex.messaging.messages.CommandMessage
                            )

                    )

            )

Hex dump of request is:
00030000000100046e756c6c00022f31000000e00a00000001110a81134d666c65782e6d6573736167696e672e6d657373616765732e436f6d6d616e644d657373616765136f7065726174696f6e1b636f7272656c6174696f6e496409626f647911636c69656e7449641764657374696e6174696f6e136d65737361676549640f686561646572731374696d657374616d701574696d65546f4c697665040506010a0b0101010601064936303044423235302d413241382d344232412d393842442d3033344435453041394639390a052544534d6573736167696e6756657273696f6e0401094453496406076e696c0104000400

Message data starts with 0x0a and that I believe means object not array!
How can I get object (StdClass)?

flash NetConnection don't parse amf3_encode data

amf.php

code as3:

var nc:NetConnection = new NetConnection();
NetConnection.defaultObjectEncoding = ObjectEncoding.AMF3;
nc.connect('http://localhost/amf.php');

var responder:Responder = new Responder(onResult, onError);
nc.call('HelloWorld', responder, "good");

function onResult(re:Object):void {
trace(re);  //don't get result
}
function onError(err:Object):void {
for (var i:String in err) {
trace(err[i]);
}
}

flash amf3 vs php amf3

json string:
[[10000,1,[]],[10001,2,{"4":19448,"0":1798}],[10001,1,{"20":22800}],[10001,6,{"1":[[2,0],[2,0],[2,0]]}],[10001,8,{"2":["2",1,14,[15,84,15,1055]]}]]

flash (amf3 encode + base64) string:
CQsBCQcBBM4QBAEJAQEJBwEEzhEEAgoLAQM0BIGXeAMwBI4GAQkHAQTOEQQBCgEFMjAEgbIQAQkHAQTOEQQGCgEDMQkHAQkFAQQCBAAJBQEEAgQACQUBBAIEAAEJBwEEzhEECAoBAzIJCQEGCAQBBA4JCQEEDwRUBA8EiB8B

php (amf3 encode + base64) string:
CQsBCQcBBM4QBAEJAQEJBwEEzhEEAgkBAzQEgZd4AzAEjgYBCQcBBM4RBAEJAQUyMASBshABCQcBBM4RBAYJAQMxCQcBCQUBBAIEAAkFAQQCBAAJBQEEAgQAAQkHAQTOEQQICQEDMgkJAQYIBAEEDgkJAQQPBFQEDwSIHwE=

becase of the data not same, so the flash don't parse php amf3encode data.

this is bug?

encode ClassMaper

If you want to use this extension in Zend_AMF you need encoder class mapper.
I made modifications to your code to add this functionality.

main part is this

static void encodeObject(smart_str *ss, zval *val, int opts, HashTable *sht, HashTable *oht, HashTable *tht, HashTable *cmht TSRMLS_DC) {
    zend_class_entry *ce = Z_TYPE_P(val) == IS_OBJECT ? Z_OBJCE_P(val) : zend_standard_class_def;
    int *oidx, nidx;
        char *str ;
        int len ;
    if (encodeRef(ss, val, oht TSRMLS_CC)) return;
    if (zend_hash_find(tht, (char *)&ce, sizeof(ce), (void **)&oidx) == SUCCESS) encodeU29(ss, (*oidx << 2) | 1);
    else {
        nidx = zend_hash_num_elements(tht);
        if (nidx <= MAPAMF3_MAX_INT) zend_hash_add(tht, (char *)&ce, sizeof(ce), &nidx, sizeof(nidx), NULL);
        smart_str_appendc(ss, 0x0b);
        if (ce == zend_standard_class_def) smart_str_appendc(ss, 0x01); /* anonymous object */

        else {
            str = ce->name ;
            len = ce->name_length ;

            zval **classname;
            if (zend_hash_find(cmht, str, len+1, (void **)&classname) == SUCCESS) {
                str = Z_STRVAL_PP(classname) ;
                len = Z_STRLEN_PP(classname) ;
            }
            encodeStr(ss, str, len, sht TSRMLS_CC); /* typed object */
        }
    }
    encodeHash(ss, HASH_OF(val), opts, 1, sht, oht, tht, cmht TSRMLS_CC);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.