Skip to content

Commit

Permalink
Adding minified version of RESTler 2 php files to restler_minified
Browse files Browse the repository at this point in the history
…folder for use on production server.
  • Loading branch information
Arul- committed Aug 25, 2011
1 parent ce53f94 commit 3aade21
Show file tree
Hide file tree
Showing 31 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions restler_minified/amfformat/Zend/Amf/Constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
final class Zend_Amf_Constants { const AMF0_NUMBER = 0x00; const AMF0_BOOLEAN = 0x01; const AMF0_STRING = 0x02; const AMF0_OBJECT = 0x03; const AMF0_MOVIECLIP = 0x04; const AMF0_NULL = 0x05; const AMF0_UNDEFINED = 0x06; const AMF0_REFERENCE = 0x07; const AMF0_MIXEDARRAY = 0x08; const AMF0_OBJECTTERM = 0x09; const AMF0_ARRAY = 0x0a; const AMF0_DATE = 0x0b; const AMF0_LONGSTRING = 0x0c; const AMF0_UNSUPPORTED = 0x0e; const AMF0_XML = 0x0f; const AMF0_TYPEDOBJECT = 0x10; const AMF0_AMF3 = 0x11; const AMF0_OBJECT_ENCODING = 0x00; const AMF3_UNDEFINED = 0x00; const AMF3_NULL = 0x01; const AMF3_BOOLEAN_FALSE = 0x02; const AMF3_BOOLEAN_TRUE = 0x03; const AMF3_INTEGER = 0x04; const AMF3_NUMBER = 0x05; const AMF3_STRING = 0x06; const AMF3_XML = 0x07; const AMF3_DATE = 0x08; const AMF3_ARRAY = 0x09; const AMF3_OBJECT = 0x0A; const AMF3_XMLSTRING = 0x0B; const AMF3_BYTEARRAY = 0x0C; const AMF3_OBJECT_ENCODING = 0x03; const ET_PROPLIST = 0x00; const ET_EXTERNAL = 0x01; const ET_DYNAMIC = 0x02; const ET_PROXY = 0x03; const FMS_OBJECT_ENCODING = 0x01; const UNKNOWN_CONTENT_LENGTH = -1; const URL_APPEND_HEADER = 'AppendToGatewayUrl'; const RESULT_METHOD = '/onResult'; const STATUS_METHOD = '/onStatus'; const CREDENTIALS_HEADER = 'Credentials'; const PERSISTENT_HEADER = 'RequestPersistentHeader'; const DESCRIBE_HEADER = 'DescribeService'; const GUEST_ROLE = 'anonymous'; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once 'Zend/Amf/Constants.php'; require_once 'Zend/Amf/Parse/Deserializer.php'; require_once 'Zend/Amf/Parse/TypeLoader.php'; class Zend_Amf_Parse_Amf3_Deserializer extends Zend_Amf_Parse_Deserializer { protected $_objectCount; protected $_referenceObjects = array(); protected $_referenceStrings = array(); protected $_referenceDefinitions = array(); public function readTypeMarker($typeMarker = null) { if(null === $typeMarker) { $typeMarker = $this->_stream->readByte(); } switch($typeMarker) { case Zend_Amf_Constants::AMF3_UNDEFINED: return null; case Zend_Amf_Constants::AMF3_NULL: return null; case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE: return false; case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE: return true; case Zend_Amf_Constants::AMF3_INTEGER: return $this->readInteger(); case Zend_Amf_Constants::AMF3_NUMBER: return $this->_stream->readDouble(); case Zend_Amf_Constants::AMF3_STRING: return $this->readString(); case Zend_Amf_Constants::AMF3_DATE: return $this->readDate(); case Zend_Amf_Constants::AMF3_ARRAY: return $this->readArray(); case Zend_Amf_Constants::AMF3_OBJECT: return $this->readObject(); case Zend_Amf_Constants::AMF3_XML: case Zend_Amf_Constants::AMF3_XMLSTRING: return $this->readXmlString(); case Zend_Amf_Constants::AMF3_BYTEARRAY: return $this->readString(); default: require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unsupported type marker: ' . $typeMarker); } } public function readInteger() { $count = 1; $intReference = $this->_stream->readByte(); $result = 0; while ((($intReference & 0x80) != 0) && $count < 4) { $result <<= 7; $result |= ($intReference & 0x7f); $intReference = $this->_stream->readByte(); $count++; } if ($count < 4) { $result <<= 7; $result |= $intReference; } else { $result <<= 8; $result |= $intReference; if (($result & 0x10000000) != 0) { $result |= ~0xFFFFFFF; } } return $result; } public function readString() { $stringReference = $this->readInteger(); if (($stringReference & 0x01) == 0) { $stringReference = $stringReference >> 1; if ($stringReference >= count($this->_referenceStrings)) { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Undefined string reference: ' . $stringReference); } return $this->_referenceStrings[$stringReference]; } $length = $stringReference >> 1; if ($length) { $string = $this->_stream->readBytes($length); $this->_referenceStrings[] = $string; } else { $string = ""; } return $string; } public function readDate() { $dateReference = $this->readInteger(); if (($dateReference & 0x01) == 0) { $dateReference = $dateReference >> 1; if ($dateReference>=count($this->_referenceObjects)) { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Undefined date reference: ' . $dateReference); } return $this->_referenceObjects[$dateReference]; } $timestamp = floor($this->_stream->readDouble() / 1000); require_once 'Zend/Date.php'; $dateTime = new Zend_Date((int) $timestamp); $this->_referenceObjects[] = $dateTime; return $dateTime; } public function readArray() { $arrayReference = $this->readInteger(); if (($arrayReference & 0x01)==0){ $arrayReference = $arrayReference >> 1; if ($arrayReference>=count($this->_referenceObjects)) { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unknow array reference: ' . $arrayReference); } return $this->_referenceObjects[$arrayReference]; } $data = array(); $this->_referenceObjects[] =& $data; $key = $this->readString(); while ($key != '') { $data[$key] = $this->readTypeMarker(); $key = $this->readString(); } $arrayReference = $arrayReference >>1; for ($i=0; $i < $arrayReference; $i++) { $data[] = $this->readTypeMarker(); } return $data; } public function readObject() { $traitsInfo = $this->readInteger(); $storedObject = ($traitsInfo & 0x01)==0; $traitsInfo = $traitsInfo >> 1; if ($storedObject) { $ref = $traitsInfo; if (!isset($this->_referenceObjects[$ref])) { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unknown Object reference: ' . $ref); } $returnObject = $this->_referenceObjects[$ref]; } else { $storedClass = ($traitsInfo & 0x01) == 0; $traitsInfo = $traitsInfo >> 1; if ($storedClass) { $ref = $traitsInfo; if (!isset($this->_referenceDefinitions[$ref])) { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unknows Definition reference: '. $ref); } $className = $this->_referenceDefinitions[$ref]['className']; $encoding = $this->_referenceDefinitions[$ref]['encoding']; $propertyNames = $this->_referenceDefinitions[$ref]['propertyNames']; } else { $className = $this->readString(); $encoding = $traitsInfo & 0x03; $propertyNames = array(); $traitsInfo = $traitsInfo >> 2; } if (!$className) { $returnObject = new stdClass(); } else { if ($loader = Zend_Amf_Parse_TypeLoader::loadType($className)) { $returnObject = new $loader(); } else { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Typed object not found: '. $className . ' '); } } $this->_referenceObjects[] = $returnObject; $properties = array(); switch ($encoding) { case (Zend_Amf_Constants::ET_EXTERNAL): if (!$storedClass) { $this->_referenceDefinitions[] = array( 'className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames, ); } $returnObject->externalizedData = $this->readTypeMarker(); break; case (Zend_Amf_Constants::ET_DYNAMIC): if (!$storedClass) { $this->_referenceDefinitions[] = array( 'className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames, ); } do { $property = $this->readString(); if ($property != "") { $propertyNames[] = $property; $properties[$property] = $this->readTypeMarker(); } } while ($property !=""); break; default: if (!$storedClass) { $count = $traitsInfo; for($i=0; $i< $count; $i++) { $propertyNames[] = $this->readString(); } $this->_referenceDefinitions[] = array( 'className' => $className, 'encoding' => $encoding, 'propertyNames' => $propertyNames, ); } foreach ($propertyNames as $property) { $properties[$property] = $this->readTypeMarker(); } break; } foreach($properties as $key=>$value) { if($key) { $returnObject->$key = $value; } } } if($returnObject instanceof Zend_Amf_Value_Messaging_ArrayCollection) { if(isset($returnObject->externalizedData)) { $returnObject = $returnObject->externalizedData; } else { $returnObject = get_object_vars($returnObject); } } return $returnObject; } public function readXmlString() { $xmlReference = $this->readInteger(); $length = $xmlReference >> 1; $string = $this->_stream->readBytes($length); return simplexml_load_string($string); } }
2 changes: 2 additions & 0 deletions restler_minified/amfformat/Zend/Amf/Parse/Amf3/Serializer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once 'Zend/Amf/Constants.php'; require_once 'Zend/Amf/Parse/Serializer.php'; require_once 'Zend/Amf/Parse/TypeLoader.php'; class Zend_Amf_Parse_Amf3_Serializer extends Zend_Amf_Parse_Serializer { protected $_referenceObjects = array(); protected $_referenceStrings = array(); protected $_referenceDefinitions = array(); public function writeTypeMarker($data, $markerType=null) { if (null !== $markerType) { $this->_stream->writeByte($markerType); switch ($markerType) { case Zend_Amf_Constants::AMF3_NULL: break; case Zend_Amf_Constants::AMF3_BOOLEAN_FALSE: break; case Zend_Amf_Constants::AMF3_BOOLEAN_TRUE: break; case Zend_Amf_Constants::AMF3_INTEGER: $this->writeInteger($data); break; case Zend_Amf_Constants::AMF3_NUMBER: $this->_stream->writeDouble($data); break; case Zend_Amf_Constants::AMF3_STRING: $this->writeString($data); break; case Zend_Amf_Constants::AMF3_DATE: $this->writeDate($data); break; case Zend_Amf_Constants::AMF3_ARRAY: $this->writeArray($data); break; case Zend_Amf_Constants::AMF3_OBJECT: $this->writeObject($data); break; case Zend_Amf_Constants::AMF3_BYTEARRAY: $this->writeByteArray($data); break; case Zend_Amf_Constants::AMF3_XMLSTRING; $this->writeXml($data); break; default: require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unknown Type Marker: ' . $markerType); } } else { if(is_resource($data)) { $data = Zend_Amf_Parse_TypeLoader::handleResource($data); } switch (true) { case (null === $data): $markerType = Zend_Amf_Constants::AMF3_NULL; break; case (is_bool($data)): if ($data){ $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_TRUE; } else { $markerType = Zend_Amf_Constants::AMF3_BOOLEAN_FALSE; } break; case (is_int($data)): if (($data > 0xFFFFFFF) || ($data < -268435456)) { $markerType = Zend_Amf_Constants::AMF3_NUMBER; } else { $markerType = Zend_Amf_Constants::AMF3_INTEGER; } break; case (is_float($data)): $markerType = Zend_Amf_Constants::AMF3_NUMBER; break; case (is_string($data)): $markerType = Zend_Amf_Constants::AMF3_STRING; break; case (is_array($data)): $markerType = Zend_Amf_Constants::AMF3_ARRAY; break; case (is_object($data)): if (($data instanceof DateTime) || ($data instanceof Zend_Date)) { $markerType = Zend_Amf_Constants::AMF3_DATE; } else if ($data instanceof Zend_Amf_Value_ByteArray) { $markerType = Zend_Amf_Constants::AMF3_BYTEARRAY; } else if (($data instanceof DOMDocument) || ($data instanceof SimpleXMLElement)) { $markerType = Zend_Amf_Constants::AMF3_XMLSTRING; } else { $markerType = Zend_Amf_Constants::AMF3_OBJECT; } break; default: require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unsupported data type: ' . gettype($data)); } $this->writeTypeMarker($data, $markerType); } } public function writeInteger($int) { if (($int & 0xffffff80) == 0) { $this->_stream->writeByte($int & 0x7f); return $this; } if (($int & 0xffffc000) == 0 ) { $this->_stream->writeByte(($int >> 7 ) | 0x80); $this->_stream->writeByte($int & 0x7f); return $this; } if (($int & 0xffe00000) == 0) { $this->_stream->writeByte(($int >> 14 ) | 0x80); $this->_stream->writeByte(($int >> 7 ) | 0x80); $this->_stream->writeByte($int & 0x7f); return $this; } $this->_stream->writeByte(($int >> 22 ) | 0x80); $this->_stream->writeByte(($int >> 15 ) | 0x80); $this->_stream->writeByte(($int >> 8 ) | 0x80); $this->_stream->writeByte($int & 0xff); return $this; } protected function writeBinaryString($string){ $ref = strlen($string) << 1 | 0x01; $this->writeInteger($ref); $this->_stream->writeBytes($string); return $this; } public function writeString($string) { $len = strlen($string); if(!$len){ $this->writeInteger(0x01); return $this; } $ref = array_search($string, $this->_referenceStrings, true); if($ref === false){ $this->_referenceStrings[] = $string; $this->writeBinaryString($string); } else { $ref <<= 1; $this->writeInteger($ref); } return $this; } public function writeByteArray($data){ if($this->writeObjectReference($data)){ return $this; } if(is_string($data)) { } else if ($data instanceof Zend_Amf_Value_ByteArray) { $data = $data->getData(); } else { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Invalid ByteArray specified; must be a string or Zend_Amf_Value_ByteArray'); } $this->writeBinaryString($data); return $this; } public function writeXml($xml) { if($this->writeObjectReference($xml)){ return $this; } if(is_string($xml)) { } else if ($xml instanceof DOMDocument) { $xml = $xml->saveXml(); } else if ($xml instanceof SimpleXMLElement) { $xml = $xml->asXML(); } else { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Invalid xml specified; must be a DOMDocument or SimpleXMLElement'); } $this->writeBinaryString($xml); return $this; } public function writeDate($date) { if($this->writeObjectReference($date)){ return $this; } if ($date instanceof DateTime) { $dateString = $date->format('U') * 1000; } elseif ($date instanceof Zend_Date) { $dateString = $date->toString('U') * 1000; } else { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Invalid date specified; must be a string DateTime or Zend_Date object'); } $this->writeInteger(0x01); $this->_stream->writeDouble($dateString); return $this; } public function writeArray(array $array) { $this->_referenceObjects[] = $array; $numeric = array(); $string = array(); foreach ($array as $key => $value) { if (is_int($key)) { $numeric[] = $value; } else { $string[$key] = $value; } } $length = count($numeric); $id = ($length << 1) | 0x01; $this->writeInteger($id); foreach($string as $key => $value) { $this->writeString($key) ->writeTypeMarker($value); } $this->writeString(''); foreach($numeric as $value) { $this->writeTypeMarker($value); } return $this; } protected function writeObjectReference($object) { $ref = array_search($object, $this->_referenceObjects,true); if($ref !== false){ $ref <<= 1; $this->writeInteger($ref); return true; } $this->_referenceObjects[] = $object; return false; } public function writeObject($object) { if($this->writeObjectReference($object)){ return $this; } $className = ''; switch (true) { case ($className = Zend_Amf_Parse_TypeLoader::getMappedClassName(get_class($object))): break; case isset($object->_explicitType): $className = $object->_explicitType; break; case method_exists($object, 'getASClassName'): $className = $object->getASClassName(); break; case ($object instanceof stdClass): $className = ''; break; default: $className = get_class($object); break; } $writeTraits = true; if(array_key_exists($className, $this->_referenceDefinitions)){ $traitsInfo = $this->_referenceDefinitions[$className]['id']; $encoding = $this->_referenceDefinitions[$className]['encoding']; $propertyNames = $this->_referenceDefinitions[$className]['propertyNames']; $traitsInfo = ($traitsInfo << 2) | 0x01; $writeTraits = false; } else { $propertyNames = array(); if($className == ''){ $encoding = Zend_Amf_Constants::ET_DYNAMIC; } else { $encoding = Zend_Amf_Constants::ET_PROPLIST; foreach($object as $key => $value) { if( $key[0] != "_") { $propertyNames[] = $key; } } } $this->_referenceDefinitions[$className] = array( 'id' => count($this->_referenceDefinitions), 'encoding' => $encoding, 'propertyNames' => $propertyNames, ); $traitsInfo = Zend_Amf_Constants::AMF3_OBJECT_ENCODING; $traitsInfo |= $encoding << 2; $traitsInfo |= (count($propertyNames) << 4); } $this->writeInteger($traitsInfo); if($writeTraits){ $this->writeString($className); foreach ($propertyNames as $value) { $this->writeString($value); } } try { switch($encoding) { case Zend_Amf_Constants::ET_PROPLIST: foreach ($propertyNames as $key) { $this->writeTypeMarker($object->$key); } break; case Zend_Amf_Constants::ET_DYNAMIC: foreach ($propertyNames as $key) { $this->writeTypeMarker($object->$key); } foreach($object as $key => $value){ if(!in_array($key,$propertyNames) && $key[0] != "_"){ $this->writeString($key); $this->writeTypeMarker($value); } } $this->writeString(''); break; case Zend_Amf_Constants::ET_EXTERNAL: require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('External Object Encoding not implemented'); break; default: require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unknown Object Encoding type: ' . $encoding); } } catch (Exception $e) { require_once 'Zend/Amf/Exception.php'; throw new Zend_Amf_Exception('Unable to writeObject output: ' . $e->getMessage(), 0, $e); } return $this; } }
2 changes: 2 additions & 0 deletions restler_minified/amfformat/Zend/Amf/Parse/Deserializer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
abstract class Zend_Amf_Parse_Deserializer { protected $_stream; public function __construct(Zend_Amf_Parse_InputStream $stream) { $this->_stream = $stream; } public abstract function readTypeMarker($markerType = null); }
2 changes: 2 additions & 0 deletions restler_minified/amfformat/Zend/Amf/Parse/InputStream.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once 'Zend/Amf/Util/BinaryStream.php'; class Zend_Amf_Parse_InputStream extends Zend_Amf_Util_BinaryStream { }
2 changes: 2 additions & 0 deletions restler_minified/amfformat/Zend/Amf/Parse/OutputStream.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require_once 'Zend/Amf/Util/BinaryStream.php'; class Zend_Amf_Parse_OutputStream extends Zend_Amf_Util_BinaryStream { public function __construct() { parent::__construct(''); } }
2 changes: 2 additions & 0 deletions restler_minified/amfformat/Zend/Amf/Parse/Serializer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
abstract class Zend_Amf_Parse_Serializer { protected $_stream; public function __construct(Zend_Amf_Parse_OutputStream $stream) { $this->_stream = $stream; } public abstract function writeTypeMarker($content, $markerType=null); }
Loading

0 comments on commit 3aade21

Please sign in to comment.