コード例 #1
0
ファイル: view.php プロジェクト: actcms/nowphp
 /**
  * 提供基于flash的AMF3格式的数据返回
  * @static
  * @author 欧远宁
  * @param array $data    返回的数据
  */
 public static function amf($data)
 {
     if (!extension_loaded('amf')) {
         throw new err('need amf ext');
     }
     header('Content-Type: application/x-amf');
     echo substr(amf_encode($data, AMF_AMF3 | AMF_BIG_ENDIAN | AMFC_ARRAY | AMFR_ARRAY), 1);
 }
コード例 #2
0
ファイル: helpers.php プロジェクト: sneakyimp/amfext
function encodeAndDecode($input)
{
    $encoded = amf_encode($input);
    var_dump(bin2hex($encoded));
    $decoded = amf_decode($encoded);
    if ($input === $decoded) {
        var_dump($input);
        echo "OK\n\n";
    } else {
        var_dump($input);
        echo "Encode/decode created\n";
        var_dump($decoded);
        echo "FAILED\n\n";
    }
}
コード例 #3
0
ファイル: server.php プロジェクト: tingyujing/js
<?php

require_once __DIR__ . '/vendor/autoload.php';
$data = file_get_contents("php://input");
header('Content-Type: application/x-amf');
try {
    $deserialized = amf_decode($data);
    http_response_code(200);
    echo amf_encode($deserialized, AMF_CLASS_MAPPING);
} catch (Exception $e) {
    http_response_code(500);
    var_dump($e);
    die;
    die('Invalid AMF packet');
}
class XXX
{
}
class YYY
{
}
コード例 #4
0
ファイル: amf.php プロジェクト: BGCX067/fake-as3-svn-to-git
 /**
  * undocumented function
  *
  * @return void
  *
  **/
 function __encodeHeader($value)
 {
     $result = amf_encode($value, 1);
     return $result;
 }
コード例 #5
0
 /**
  * serialize is the run method of the class.  When serialize is called
  * the AMFObject passed in is read and converted into the amf binary
  * representing the PHP data represented.
  * 
  * @param object $d the AMFObject to serialize
  */
 function serialize(&$amfout)
 {
     $encodeCallback = array(&$this, "encodeCallback");
     $this->writeInt(0);
     //  write the version ???
     $count = $amfout->numOutgoingHeader();
     $this->writeInt($count);
     // write header count
     for ($i = 0; $i < $count; $i++) {
         //write headers
         $header =& $amfout->getOutgoingHeaderAt($i);
         $this->writeUTF($header->name);
         $this->writeByte(0);
         $tempBuf = $this->outBuffer;
         $this->outBuffer = "";
         if ($this->native) {
             $this->outBuffer .= amf_encode($header->value, $this->encodeFlags, $encodeCallback);
         } else {
             $this->writeData($header->value);
         }
         $tempBuf2 = $this->outBuffer;
         $this->outBuffer = $tempBuf;
         $this->writeLong(strlen($tempBuf2));
         $this->outBuffer .= $tempBuf2;
     }
     $count = $amfout->numBody();
     $this->writeInt($count);
     // write the body  count
     for ($i = 0; $i < $count; $i++) {
         //write body
         $this->amf0StoredObjects = array();
         $this->storedStrings = array();
         $this->storedObjects = array();
         $this->encounteredStrings = 0;
         $this->storedDefinitions = 0;
         $body =& $amfout->getBodyAt($i);
         $this->currentBody =& $body;
         $this->writeUTF($body->responseURI);
         // write the responseURI header
         $this->writeUTF($body->responseTarget);
         //  write null, haven't found another use for this
         $tempBuf = $this->outBuffer;
         $this->outBuffer = "";
         if ($this->native) {
             $this->outBuffer .= amf_encode($body->getResults(), $this->encodeFlags, $encodeCallback);
         } else {
             $this->writeData($body->getResults());
         }
         $tempBuf2 = $this->outBuffer;
         $this->outBuffer = $tempBuf;
         $this->writeLong(strlen($tempBuf2));
         $this->outBuffer .= $tempBuf2;
     }
     return $this->outBuffer;
 }
コード例 #6
0
ファイル: server.php プロジェクト: infomaniac-amf/php
<?php

require_once __DIR__ . '/vendor/autoload.php';
$data = file_get_contents("php://input");
header('Content-Type: application/x-amf');
try {
    $deserialized = amf_decode($data);
    http_response_code(200);
    echo amf_encode($deserialized);
} catch (Exception $e) {
    http_response_code(500);
    var_dump($e);
    die;
    die('Invalid AMF packet');
}
コード例 #7
0
ファイル: amf.php プロジェクト: BGCX067/fake-as3-svn-to-git
 function __encode($value)
 {
     if (function_exists('amf_encode')) {
         return amf_encode($value, 1);
     }
     if (is_object($value)) {
         return 'doh, encoding not done. get AMFEXT';
     }
     return $value;
 }